KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > testelement > PackageTest


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/testelement/PackageTest.java,v 1.4 2004/02/21 21:27:59 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  */

23 package org.apache.jmeter.testelement;
24
25 import junit.framework.TestCase;
26
27 import org.apache.jmeter.config.Arguments;
28 import org.apache.jmeter.config.ConfigTestElement;
29 import org.apache.jmeter.config.LoginConfig;
30 import org.apache.jmeter.testelement.property.NullProperty;
31 import org.apache.jmeter.testelement.property.StringProperty;
32 import org.apache.jmeter.testelement.property.TestElementProperty;
33
34 /**
35  *
36  * @author unattributed
37  * @version $Revision: 1.4 $ $Date: 2004/02/21 21:27:59 $
38  */

39 public class PackageTest extends TestCase
40 {
41     public PackageTest(String JavaDoc arg0)
42     {
43         super(arg0);
44     }
45     
46     public void testRecovery() throws Exception JavaDoc
47     {
48         ConfigTestElement config = new ConfigTestElement();
49         config.addProperty(new StringProperty("name","config"));
50         config.setRunningVersion(true);
51         LoginConfig loginConfig = new LoginConfig();
52         loginConfig.setUsername("user1");
53         loginConfig.setPassword("pass1");
54         assertTrue(config.getProperty("login") instanceof NullProperty);
55         // This test should work whether or not all Nulls are equal
56
assertEquals(new NullProperty("login"),config.getProperty("login"));
57         config.addProperty(new TestElementProperty("login",loginConfig));
58         assertEquals(
59             loginConfig.toString(),
60             config.getPropertyAsString("login"));
61         config.recoverRunningVersion();
62         assertTrue(config.getProperty("login") instanceof NullProperty);
63         assertEquals(new NullProperty("login"),config.getProperty("login"));
64     }
65     
66     public void testArguments() throws Exception JavaDoc
67     {
68         Arguments args = new Arguments();
69         args.addArgument("arg1","val1","=");
70         TestElementProperty prop = new TestElementProperty("args",args);
71         ConfigTestElement te = new ConfigTestElement();
72         te.addProperty(prop);
73         te.setRunningVersion(true);
74         Arguments config = new Arguments();
75         config.addArgument("config1","configValue","=");
76         TestElementProperty configProp = new TestElementProperty("args",config);
77         ConfigTestElement te2 = new ConfigTestElement();
78         te2.addProperty(configProp);
79         te.addTestElement(te2);
80         assertEquals(2,args.getArgumentCount());
81         assertEquals("config1=configValue",args.getArgument(1).toString());
82         te.recoverRunningVersion();
83         te.addTestElement(te2);
84         assertEquals(2,args.getArgumentCount());
85         assertEquals("config1=configValue",args.getArgument(1).toString());
86         
87     }
88
89 }
90
Popular Tags