1 18 19 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 39 public class PackageTest extends TestCase 40 { 41 public PackageTest(String arg0) 42 { 43 super(arg0); 44 } 45 46 public void testRecovery() throws Exception 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 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 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 |