408945 XML Args ignored without DTD

This commit is contained in:
Greg Wilkins 2013-06-03 18:54:48 +10:00
parent 7bb3a7be28
commit 1bbab6d6f2
2 changed files with 30 additions and 3 deletions

View File

@ -741,7 +741,6 @@ public class XmlConfiguration
private Object newObj(Object obj, XmlParser.Node node) throws Exception
{
Class<?> oClass = nodeClass(node);
int size = 0;
int argIndex = node.size();
for (int i = 0; i < node.size(); i++)
{
@ -753,13 +752,12 @@ public class XmlConfiguration
argIndex = i;
break;
}
size++;
}
Map<String, Object> namedArgMap = new HashMap<>();
List<Object> arguments = new LinkedList<>();
for (int i = 0; i < size; i++)
for (int i = 0; i < node.size(); i++)
{
Object o = node.get(i);

View File

@ -25,6 +25,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;
@ -541,6 +542,34 @@ public class XmlConfigurationTest
Assert.assertEquals("nested second parameter not wired correctly","arg2", atc.getNested().getSecond());
Assert.assertEquals("nested third parameter not wired correctly","arg3", atc.getNested().getThird());
}
@Test
public void testArgumentsGetIgnoredMissingDTD() throws Exception
{
XmlConfiguration xmlConfiguration = new XmlConfiguration(new ByteArrayInputStream(("" +
"<Configure class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">" +
" <Arg>arg1</Arg> " +
" <Arg>arg2</Arg> " +
" <Arg>arg3</Arg> " +
" <Set name=\"nested\"> " +
" <New class=\"org.eclipse.jetty.xml.AnnotatedTestConfiguration\">\n" +
" <Arg>arg1</Arg>\n" +
" <Arg>arg2</Arg>\n" +
" <Arg>arg3</Arg>\n" +
" </New>" +
" </Set>" +
"</Configure>").getBytes("ISO-8859-1")));
// XmlConfiguration xmlConfiguration = new XmlConfiguration(url);
AnnotatedTestConfiguration atc = (AnnotatedTestConfiguration)xmlConfiguration.configure();
Assert.assertEquals("first parameter not wired correctly","arg1", atc.getFirst());
Assert.assertEquals("second parameter not wired correctly","arg2", atc.getSecond());
Assert.assertEquals("third parameter not wired correctly","arg3", atc.getThird());
Assert.assertEquals("nested first parameter not wired correctly","arg1", atc.getNested().getFirst());
Assert.assertEquals("nested second parameter not wired correctly","arg2", atc.getNested().getSecond());
Assert.assertEquals("nested third parameter not wired correctly","arg3", atc.getNested().getThird());
}
@Test
public void testNestedConstructorNamedInjectionUnorderedMixed() throws Exception