KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > junit > protocol > http > config > UrlConfigTest


1 // $Header: /home/cvs/jakarta-jmeter/src/protocol/http/org/apache/jmeter/junit/protocol/http/config/UrlConfigTest.java,v 1.7 2004/02/21 21:28:36 sebb Exp $
2
/*
3  * Copyright 2001-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 package org.apache.jmeter.junit.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.HTTPSampler;
24 import org.apache.jmeter.testelement.property.JMeterProperty;
25 import org.apache.jmeter.testelement.property.NullProperty;
26 import org.apache.jmeter.testelement.property.TestElementProperty;
27
28 /**
29  * @author Michael Stover
30  * @version $Revision: 1.7 $
31  */

32 public class UrlConfigTest extends JMeterTestCase
33 {
34     HTTPSampler config;
35     HTTPSampler defaultConfig;
36     HTTPSampler partialConfig;
37
38     public UrlConfigTest(String JavaDoc name)
39     {
40         super(name);
41     }
42
43     protected void setUp()
44     {
45         Arguments args = new Arguments();
46         args.addArgument("username", "mstover");
47         args.addArgument("password", "pass");
48         args.addArgument("action", "login");
49         config = new HTTPSampler();
50         config.setName("Full Config");
51         config.setProperty(HTTPSampler.DOMAIN, "www.lazer.com");
52         config.setProperty(HTTPSampler.PATH, "login.jsp");
53         config.setProperty(HTTPSampler.METHOD, HTTPSampler.POST);
54         config.setProperty(
55             new TestElementProperty(HTTPSampler.ARGUMENTS, args));
56         defaultConfig = new HTTPSampler();
57         defaultConfig.setName("default");
58         defaultConfig.setProperty(HTTPSampler.DOMAIN, "www.xerox.com");
59         defaultConfig.setProperty(HTTPSampler.PATH, "default.html");
60         partialConfig = new HTTPSampler();
61         partialConfig.setProperty(HTTPSampler.PATH, "main.jsp");
62         partialConfig.setProperty(HTTPSampler.METHOD, HTTPSampler.GET);
63     }
64
65     public void testSimpleConfig()
66     {
67         assertTrue(config.getName().equals("Full Config"));
68         assertEquals(config.getDomain(), "www.lazer.com");
69     }
70
71     public void testOverRide()
72     {
73         JMeterProperty jmp =partialConfig.getProperty(HTTPSampler.DOMAIN);
74         assertTrue(jmp instanceof NullProperty);
75         assertTrue(new NullProperty(HTTPSampler.DOMAIN).equals(jmp));
76         partialConfig.addTestElement(defaultConfig);
77         assertEquals(
78             partialConfig.getPropertyAsString(HTTPSampler.DOMAIN),
79             "www.xerox.com");
80         assertEquals(
81             partialConfig.getPropertyAsString(HTTPSampler.PATH),
82             "main.jsp");
83     }
84 }
Popular Tags