1 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 32 public class UrlConfigTest extends JMeterTestCase 33 { 34 HTTPSampler config; 35 HTTPSampler defaultConfig; 36 HTTPSampler partialConfig; 37 38 public UrlConfigTest(String 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 |