KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > protocol > http > sampler > PackageTest


1 // $Header: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/protocol/http/sampler/PackageTest.java,v 1.3 2004/02/12 00:29:49 sebb Exp $
2
/*
3  * Copyright 2003-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * 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.util.HTTPArgument;
31
32 /**
33  * @author ano ano
34  * @version $Revision: 1.3 $ last updated $Date: 2004/02/12 00:29:49 $
35  */

36 public class PackageTest extends TestCase
37 {
38     public PackageTest(String JavaDoc arg0)
39     {
40         super(arg0);
41     }
42
43     public void testConfiguring() throws Exception JavaDoc
44     {
45         HTTPSampler sampler =
46             (HTTPSampler) new HttpTestSampleGui().createTestElement();
47         sampler.addArgument("arg1", "val1");
48         ConfigTestElement config =
49             (ConfigTestElement) new HttpDefaultsGui().createTestElement();
50         (
51             (Arguments) config
52                 .getProperty(HTTPSampler.ARGUMENTS)
53                 .getObjectValue())
54                 .addArgument(
55             new HTTPArgument("config1", "configValue"));
56         config.setRunningVersion(true);
57         sampler.setRunningVersion(true);
58         sampler.setRunningVersion(true);
59         sampler.addTestElement(config);
60         assertEquals(
61             "config1=configValue",
62             sampler.getArguments().getArgument(1).toString());
63         sampler.recoverRunningVersion();
64         config.recoverRunningVersion();
65         assertEquals(1, sampler.getArguments().getArgumentCount());
66         sampler.addTestElement(config);
67         assertEquals(
68             "config1=configValue",
69             sampler.getArguments().getArgument(1).toString());
70     }
71 }
72
Popular Tags