jetty9 - fixed NPE in XML tests.
This commit is contained in:
parent
99e7b9becc
commit
da21e1433b
|
@ -120,7 +120,7 @@ public class XmlConfiguration
|
|||
__parser.redirectEntity("configure_6_0.dtd",config60);
|
||||
__parser.redirectEntity("configure_7_6.dtd",config76);
|
||||
|
||||
|
||||
|
||||
__parser.redirectEntity("http://jetty.mortbay.org/configure.dtd",config76);
|
||||
__parser.redirectEntity("http://jetty.eclipse.org/configure.dtd",config76);
|
||||
__parser.redirectEntity("http://www.eclipse.org/jetty/configure.dtd",config76);
|
||||
|
@ -303,7 +303,7 @@ public class XmlConfiguration
|
|||
|
||||
public void init(URL url, XmlParser.Node config, Map<String, Object> idMap, Map<String, String> properties)
|
||||
{
|
||||
_url=url.toString();
|
||||
_url=url==null?null:url.toString();
|
||||
_config=config;
|
||||
_idMap=idMap;
|
||||
_propertyMap=properties;
|
||||
|
@ -927,7 +927,7 @@ public class XmlConfiguration
|
|||
configure(prop,node,0);
|
||||
return prop;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
|
@ -1097,7 +1097,7 @@ public class XmlConfiguration
|
|||
String defaultValue = node.getAttribute("default");
|
||||
return System.getProperty(name,defaultValue);
|
||||
}
|
||||
|
||||
|
||||
if ("Env".equals(tag))
|
||||
{
|
||||
String name = node.getAttribute("name");
|
||||
|
|
|
@ -13,15 +13,15 @@
|
|||
|
||||
package org.eclipse.jetty.xml;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.net.URL;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class XmlConfigurationTest
|
||||
{
|
||||
protected String _configure="org/eclipse/jetty/xml/configure.xml";
|
||||
|
@ -31,14 +31,14 @@ public class XmlConfigurationTest
|
|||
{
|
||||
URL url = XmlConfigurationTest.class.getClassLoader().getResource("org/eclipse/jetty/xml/mortbay.xml");
|
||||
XmlConfiguration configuration = new XmlConfiguration(url);
|
||||
Object o=configuration.configure();
|
||||
configuration.configure();
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testPassedObject() throws Exception
|
||||
{
|
||||
TestConfiguration.VALUE=77;
|
||||
Map<String,String> properties = new HashMap<String,String>();
|
||||
Map<String,String> properties = new HashMap<>();
|
||||
properties.put("whatever", "xxx");
|
||||
|
||||
URL url = XmlConfigurationTest.class.getClassLoader().getResource(_configure);
|
||||
|
@ -49,30 +49,30 @@ public class XmlConfigurationTest
|
|||
|
||||
assertEquals("Set String","SetValue",tc.testObject);
|
||||
assertEquals("Set Type",2,tc.testInt);
|
||||
|
||||
|
||||
assertEquals(18080, tc.propValue);
|
||||
|
||||
assertEquals("Put","PutValue",tc.get("Test"));
|
||||
assertEquals("Put dft","2",tc.get("TestDft"));
|
||||
assertEquals("Put type",new Integer(2),tc.get("TestInt"));
|
||||
assertEquals("Put type",2,tc.get("TestInt"));
|
||||
|
||||
assertEquals("Trim","PutValue",tc.get("Trim"));
|
||||
assertEquals("Null",null,tc.get("Null"));
|
||||
assertEquals("NullTrim",null,tc.get("NullTrim"));
|
||||
|
||||
assertEquals("ObjectTrim",new Double(1.2345),tc.get("ObjectTrim"));
|
||||
assertEquals("ObjectTrim",1.2345,tc.get("ObjectTrim"));
|
||||
assertEquals("Objects","-1String",tc.get("Objects"));
|
||||
assertEquals( "ObjectsTrim", "-1String",tc.get("ObjectsTrim"));
|
||||
assertEquals( "String", "\n PutValue\n ",tc.get("String"));
|
||||
assertEquals( "NullString", "",tc.get("NullString"));
|
||||
assertEquals( "WhateSpace", "\n ",tc.get("WhiteSpace"));
|
||||
assertEquals( "WhiteSpace", "\n ",tc.get("WhiteSpace"));
|
||||
assertEquals( "ObjectString", "\n 1.2345\n ",tc.get("ObjectString"));
|
||||
assertEquals( "ObjectsString", "-1String",tc.get("ObjectsString"));
|
||||
assertEquals( "ObjectsWhiteString", "-1\n String",tc.get("ObjectsWhiteString"));
|
||||
|
||||
assertEquals( "SystemProperty", System.getProperty("user.dir")+"/stuff",tc.get("SystemProperty"));
|
||||
assertEquals( "Env", System.getenv("HOME"),tc.get("Env"));
|
||||
|
||||
|
||||
assertEquals( "Property", "xxx", tc.get("Property"));
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class XmlConfigurationTest
|
|||
|
||||
assertEquals("oa[0]","Blah",tc.oa[0]);
|
||||
assertEquals("oa[1]","1.2.3.4:5678",tc.oa[1]);
|
||||
assertEquals("oa[2]",new Double(1.2345),tc.oa[2]);
|
||||
assertEquals("oa[2]",1.2345,tc.oa[2]);
|
||||
assertEquals("oa[3]",null,tc.oa[3]);
|
||||
|
||||
assertEquals("ia[0]",1,tc.ia[0]);
|
||||
|
@ -92,25 +92,25 @@ public class XmlConfigurationTest
|
|||
|
||||
TestConfiguration tc2=tc.nested;
|
||||
assertTrue(tc2!=null);
|
||||
assertEquals( "Called(bool)", new Boolean(true),tc2.get("Arg"));
|
||||
assertEquals( "Called(bool)",true,tc2.get("Arg"));
|
||||
|
||||
assertEquals("nested config",null,tc.get("Arg"));
|
||||
assertEquals("nested config",new Boolean(true),tc2.get("Arg"));
|
||||
assertEquals("nested config",true,tc2.get("Arg"));
|
||||
|
||||
assertEquals("nested config","Call1",tc2.testObject);
|
||||
assertEquals("nested config",4,tc2.testInt);
|
||||
assertEquals( "nested call", "http://www.eclipse.com/",tc2.url.toString());
|
||||
|
||||
|
||||
assertEquals("static to field",tc.testField1,77);
|
||||
assertEquals("field to field",tc.testField2,2);
|
||||
assertEquals("literal to static",TestConfiguration.VALUE,42);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNewObject() throws Exception
|
||||
{
|
||||
TestConfiguration.VALUE=71;
|
||||
Map<String,String> properties = new HashMap<String,String>();
|
||||
Map<String,String> properties = new HashMap<>();
|
||||
properties.put("whatever", "xxx");
|
||||
|
||||
URL url = XmlConfigurationTest.class.getClassLoader().getResource(_configure);
|
||||
|
@ -120,23 +120,23 @@ public class XmlConfigurationTest
|
|||
|
||||
assertEquals("Set String","SetValue",tc.testObject);
|
||||
assertEquals("Set Type",2,tc.testInt);
|
||||
|
||||
|
||||
assertEquals(18080, tc.propValue);
|
||||
|
||||
assertEquals("Put","PutValue",tc.get("Test"));
|
||||
assertEquals("Put dft","2",tc.get("TestDft"));
|
||||
assertEquals("Put type",new Integer(2),tc.get("TestInt"));
|
||||
assertEquals("Put type",2,tc.get("TestInt"));
|
||||
|
||||
assertEquals("Trim","PutValue",tc.get("Trim"));
|
||||
assertEquals("Null",null,tc.get("Null"));
|
||||
assertEquals("NullTrim",null,tc.get("NullTrim"));
|
||||
|
||||
assertEquals("ObjectTrim",new Double(1.2345),tc.get("ObjectTrim"));
|
||||
assertEquals("ObjectTrim",1.2345,tc.get("ObjectTrim"));
|
||||
assertEquals("Objects","-1String",tc.get("Objects"));
|
||||
assertEquals( "ObjectsTrim", "-1String",tc.get("ObjectsTrim"));
|
||||
assertEquals( "String", "\n PutValue\n ",tc.get("String"));
|
||||
assertEquals( "NullString", "",tc.get("NullString"));
|
||||
assertEquals( "WhateSpace", "\n ",tc.get("WhiteSpace"));
|
||||
assertEquals( "WhiteSpace", "\n ",tc.get("WhiteSpace"));
|
||||
assertEquals( "ObjectString", "\n 1.2345\n ",tc.get("ObjectString"));
|
||||
assertEquals( "ObjectsString", "-1String",tc.get("ObjectsString"));
|
||||
assertEquals( "ObjectsWhiteString", "-1\n String",tc.get("ObjectsWhiteString"));
|
||||
|
@ -151,7 +151,7 @@ public class XmlConfigurationTest
|
|||
|
||||
assertEquals("oa[0]","Blah",tc.oa[0]);
|
||||
assertEquals("oa[1]","1.2.3.4:5678",tc.oa[1]);
|
||||
assertEquals("oa[2]",new Double(1.2345),tc.oa[2]);
|
||||
assertEquals("oa[2]",1.2345,tc.oa[2]);
|
||||
assertEquals("oa[3]",null,tc.oa[3]);
|
||||
|
||||
assertEquals("ia[0]",1,tc.ia[0]);
|
||||
|
@ -161,21 +161,21 @@ public class XmlConfigurationTest
|
|||
|
||||
TestConfiguration tc2=tc.nested;
|
||||
assertTrue(tc2!=null);
|
||||
assertEquals( "Called(bool)", new Boolean(true),tc2.get("Arg"));
|
||||
assertEquals( "Called(bool)",true,tc2.get("Arg"));
|
||||
|
||||
assertEquals("nested config",null,tc.get("Arg"));
|
||||
assertEquals("nested config",new Boolean(true),tc2.get("Arg"));
|
||||
assertEquals("nested config",true,tc2.get("Arg"));
|
||||
|
||||
assertEquals("nested config","Call1",tc2.testObject);
|
||||
assertEquals("nested config",4,tc2.testInt);
|
||||
assertEquals( "nested call", "http://www.eclipse.com/",tc2.url.toString());
|
||||
|
||||
|
||||
assertEquals("static to field",71,tc.testField1);
|
||||
assertEquals("field to field",2,tc.testField2);
|
||||
assertEquals("literal to static",42,TestConfiguration.VALUE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
public void testStringConfiguration() throws Exception
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue