01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18:
19: package org.apache.jmeter.protocol.http.config;
20:
21: import org.apache.jmeter.config.Arguments;
22: import org.apache.jmeter.junit.JMeterTestCase;
23: import org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase;
24: import org.apache.jmeter.protocol.http.sampler.HTTPNullSampler;
25: import org.apache.jmeter.testelement.property.JMeterProperty;
26: import org.apache.jmeter.testelement.property.NullProperty;
27: import org.apache.jmeter.testelement.property.TestElementProperty;
28:
29: /**
30: * @author Michael Stover
31: * @version $Revision: 493796 $
32: */
33: public class UrlConfigTest extends JMeterTestCase {
34: HTTPSamplerBase config;
35:
36: HTTPSamplerBase defaultConfig;
37:
38: HTTPSamplerBase partialConfig;
39:
40: public UrlConfigTest(String name) {
41: super (name);
42: }
43:
44: protected void setUp() {
45: Arguments args = new Arguments();
46: args.addArgument("username", "mstover");
47: args.addArgument("password", "pass");
48: args.addArgument("action", "login");
49: config = new HTTPNullSampler();
50: config.setName("Full Config");
51: config.setProperty(HTTPSamplerBase.DOMAIN, "www.lazer.com");
52: config.setProperty(HTTPSamplerBase.PATH, "login.jsp");
53: config
54: .setProperty(HTTPSamplerBase.METHOD,
55: HTTPSamplerBase.POST);
56: config.setProperty(new TestElementProperty(
57: HTTPSamplerBase.ARGUMENTS, args));
58: defaultConfig = new HTTPNullSampler();
59: defaultConfig.setName("default");
60: defaultConfig.setProperty(HTTPSamplerBase.DOMAIN,
61: "www.xerox.com");
62: defaultConfig.setProperty(HTTPSamplerBase.PATH, "default.html");
63: partialConfig = new HTTPNullSampler();
64: partialConfig.setProperty(HTTPSamplerBase.PATH, "main.jsp");
65: partialConfig.setProperty(HTTPSamplerBase.METHOD,
66: HTTPSamplerBase.GET);
67: }
68:
69: public void testSimpleConfig() {
70: assertTrue(config.getName().equals("Full Config"));
71: assertEquals(config.getDomain(), "www.lazer.com");
72: }
73:
74: public void testOverRide() {
75: JMeterProperty jmp = partialConfig
76: .getProperty(HTTPSamplerBase.DOMAIN);
77: assertTrue(jmp instanceof NullProperty);
78: assertTrue(new NullProperty(HTTPSamplerBase.DOMAIN).equals(jmp));
79: partialConfig.addTestElement(defaultConfig);
80: assertEquals(partialConfig
81: .getPropertyAsString(HTTPSamplerBase.DOMAIN),
82: "www.xerox.com");
83: assertEquals(partialConfig
84: .getPropertyAsString(HTTPSamplerBase.PATH), "main.jsp");
85: }
86: }
|