Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java')
-rw-r--r--jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java56
1 files changed, 42 insertions, 14 deletions
diff --git a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java
index 79b4038400..49cb229254 100644
--- a/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java
+++ b/jetty-xml/src/test/java/org/eclipse/jetty/xml/XmlConfigurationTest.java
@@ -13,20 +13,24 @@
package org.eclipse.jetty.xml;
-import static junit.framework.Assert.assertEquals;
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.*;
-
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
+import org.junit.Assert;
import org.junit.Test;
+import static junit.framework.Assert.assertEquals;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
+
public class XmlConfigurationTest
{
protected String _configure="org/eclipse/jetty/xml/configure.xml";
-
+
private static final String STRING_ARRAY_XML = "<Array type=\"String\"><Item type=\"String\">String1</Item><Item type=\"String\">String2</Item></Array>";
private static final String INT_ARRAY_XML = "<Array type=\"int\"><Item type=\"int\">1</Item><Item type=\"int\">2</Item></Array>";
@@ -37,7 +41,7 @@ public class XmlConfigurationTest
XmlConfiguration configuration = new XmlConfiguration(url);
configuration.configure();
}
-
+
@Test
public void testPassedObject() throws Exception
{
@@ -53,7 +57,7 @@ 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"));
@@ -76,7 +80,7 @@ public class XmlConfigurationTest
assertEquals( "SystemProperty", System.getProperty("user.dir")+"/stuff",tc.get("SystemProperty"));
assertEquals( "Env", System.getenv("HOME"),tc.get("Env"));
-
+
assertEquals( "Property", "xxx", tc.get("Property"));
@@ -104,12 +108,12 @@ public class XmlConfigurationTest
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
{
@@ -124,7 +128,7 @@ 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"));
@@ -173,13 +177,13 @@ public class XmlConfigurationTest
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
{
@@ -314,4 +318,28 @@ public class XmlConfigurationTest
xmlConfiguration.configure(tc);
assertThat("tc.getSet() has two entries as specified in the xml",tc.getSet().size(),is(2));
}
+
+ @Test
+ public void testMap() throws Exception
+ {
+ XmlConfiguration xmlConfiguration = new XmlConfiguration("" +
+ "<Configure class=\"org.eclipse.jetty.xml.TestConfiguration\">" +
+ " <Set name=\"map\">" +
+ " <Map>" +
+ " <Entry>" +
+ " <Item>key1</Item>" +
+ " <Item>value1</Item>" +
+ " </Entry>" +
+ " <Entry>" +
+ " <Item>key2</Item>" +
+ " <Item>value2</Item>" +
+ " </Entry>" +
+ " </Map>" +
+ " </Set>" +
+ "</Configure>");
+ TestConfiguration tc = new TestConfiguration();
+ Assert.assertNull("tc.map is null as it's not configured yet", tc.map);
+ xmlConfiguration.configure(tc);
+ Assert.assertEquals("tc.map is has two entries as specified in the XML", 2, tc.map.size());
+ }
}

Back to the top