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: /*
20: * Created on Jul 16, 2003
21: */
22: package org.apache.jmeter.protocol.http.sampler;
23:
24: import junit.framework.TestCase;
25:
26: import org.apache.jmeter.config.Arguments;
27: import org.apache.jmeter.config.ConfigTestElement;
28: import org.apache.jmeter.protocol.http.config.gui.HttpDefaultsGui;
29: import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui;
30: import org.apache.jmeter.protocol.http.control.gui.HttpTestSampleGui2;
31: import org.apache.jmeter.protocol.http.util.HTTPArgument;
32:
33: /**
34: * @version $Revision: 493796 $ last updated $Date: 2007-01-07 18:31:05 +0000 (Sun, 07 Jan 2007) $
35: */
36: public class PackageTest extends TestCase {
37: public PackageTest(String arg0) {
38: super (arg0);
39: }
40:
41: public void testConfiguring() throws Exception {
42: HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui()
43: .createTestElement();
44: configure(sampler);
45: }
46:
47: public void testConfiguring2() throws Exception {
48: HTTPSamplerBase sampler = (HTTPSamplerBase) new HttpTestSampleGui2()
49: .createTestElement();
50: configure(sampler);
51: }
52:
53: private void configure(HTTPSamplerBase sampler) throws Exception {
54: sampler.addArgument("arg1", "val1");
55: ConfigTestElement config = (ConfigTestElement) new HttpDefaultsGui()
56: .createTestElement();
57: ((Arguments) config.getProperty(HTTPSamplerBase.ARGUMENTS)
58: .getObjectValue()).addArgument(new HTTPArgument(
59: "config1", "configValue"));
60: config.setRunningVersion(true);
61: sampler.setRunningVersion(true);
62: sampler.setRunningVersion(true);
63: sampler.addTestElement(config);
64: assertEquals("config1=configValue", sampler.getArguments()
65: .getArgument(1).toString());
66: sampler.recoverRunningVersion();
67: config.recoverRunningVersion();
68: assertEquals(1, sampler.getArguments().getArgumentCount());
69: sampler.addTestElement(config);
70: assertEquals("config1=configValue", sampler.getArguments()
71: .getArgument(1).toString());
72: }
73: }
|