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: */
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: 493796 $ $Date: 2007-01-07 18:31:05 +0000 (Sun, 07 Jan 2007) $
38: */
39: public class PackageTest extends TestCase {
40: public PackageTest(String arg0) {
41: super (arg0);
42: }
43:
44: public void testRecovery() throws Exception {
45: ConfigTestElement config = new ConfigTestElement();
46: config.addProperty(new StringProperty("name", "config"));
47: config.setRunningVersion(true);
48: LoginConfig loginConfig = new LoginConfig();
49: loginConfig.setUsername("user1");
50: loginConfig.setPassword("pass1");
51: assertTrue(config.getProperty("login") instanceof NullProperty);
52: // This test should work whether or not all Nulls are equal
53: assertEquals(new NullProperty("login"), config
54: .getProperty("login"));
55: config
56: .addProperty(new TestElementProperty("login",
57: loginConfig));
58: assertEquals(loginConfig.toString(), config
59: .getPropertyAsString("login"));
60: config.recoverRunningVersion();
61: assertTrue(config.getProperty("login") instanceof NullProperty);
62: assertEquals(new NullProperty("login"), config
63: .getProperty("login"));
64: }
65:
66: public void testArguments() throws Exception {
67: Arguments args = new Arguments();
68: args.addArgument("arg1", "val1", "=");
69: TestElementProperty prop = new TestElementProperty("args", args);
70: ConfigTestElement te = new ConfigTestElement();
71: te.addProperty(prop);
72: te.setRunningVersion(true);
73: Arguments config = new Arguments();
74: config.addArgument("config1", "configValue", "=");
75: TestElementProperty configProp = new TestElementProperty(
76: "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)
82: .toString());
83: te.recoverRunningVersion();
84: te.addTestElement(te2);
85: assertEquals(2, args.getArgumentCount());
86: assertEquals("config1=configValue", args.getArgument(1)
87: .toString());
88:
89: }
90:
91: }
|