Commits

kolb0128  committed 6fd3ba7

Added stub XmlDtoContentHandler and test cases.

  • Participants
  • Parent commits be35f40

Comments (0)

Files changed (3)

File common-serialize/src/main/java/org/grouplens/common/dto/XmlDtoContentHandler.java

+package org.grouplens.common.dto;
+
+import java.io.Reader;
+import java.io.Writer;
+
+public class XmlDtoContentHandler implements DtoContentHandler {
+	
+	public XmlDtoContentHandler() {
+		this(false);
+	}
+	
+	public XmlDtoContentHandler(boolean ignoreExclude) {
+		
+	}
+
+	@Override
+	public <T extends Dto> String toString(DtoContainer<T> dto) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public <T extends Dto> void toString(DtoContainer<T> dto, Writer writer) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public <T extends Dto> void fromString(String content,
+			DtoContainer<T> result) {
+		// TODO Auto-generated method stub
+		
+	}
+
+	@Override
+	public <T extends Dto> void fromString(Reader content,
+			DtoContainer<T> container) {
+		// TODO Auto-generated method stub
+		
+	}
+
+}

File common-serialize/src/test/java/org/grouplens/common/dto/DtoToXmlConverterTest.java

+/*
+ * GroupLens Common Utilities
+ * Copyright © 2011 Regents of the University of Minnesota
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the
+ *    distribution.
+ *
+ *  * Neither the name of the University of Minnesota nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software has been partly funded by NSF grant IIS 08-08692.
+ */
+package org.grouplens.common.dto;
+
+import org.grouplens.common.dto.HierarchyDto.SubclassDto;
+import org.junit.Test;
+
+public class DtoToXmlConverterTest extends DtoMarshallerTest {
+
+	@Override
+	protected DtoContentHandler createMarshaller(boolean ignoreExclude) throws Exception {
+		return new XmlDtoContentHandler(ignoreExclude);
+	}
+
+	@Test
+	public void testExport_HappyPath() throws Exception {
+		// test all content types, nested values
+		String xml = 
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+			"<test>\n" +
+			"\t<float>4.3242</float>\n" +
+			"\t<boolean>true</boolean>\n" + 
+			"\t<byte>23</byte>\n" +
+			"\t<char>b</char>\n" +
+			"\t<double>2.32</double>\n" +
+			"\t<long>123415123512351235</long>\n" +
+			"\t<integer>234234</integer>\n" +
+			"\t<short>45</short>\n" +
+			"\t<dto>\n" +
+			"\t\t<import>hasdf</import>\n" +
+			"\t</dto>\n" +
+			"\t<strings>\n" +
+			"\t\t<string>hello</string>\n" +
+			"\t\t<string>world</string>\n" +
+			"\t</strings>\n" +
+			"\t<dtos>\n" +
+			"\t\t<nestedTest>\n" +
+			"\t\t\t<import>hello</import>\n" +
+			"\t\t</nestedTest>\n" +
+			"\t\t<nestedTest>\n" +
+			"\t\t\t<export>blah</export>\n" +
+			"\t\t</nestedTest>\n" +
+			"\t\t<nestedTest>\n" +
+			"\t\t</nestedTest>\n" +
+			"\t</dtos>" +
+			"</test>";
+
+		TestDto dto = new TestDto();
+		dto.floatField = 4.3242f;
+		dto.doubleField = 2.32;
+		dto.longField = 123415123512351235L;
+		dto.intField = 234234;
+		dto.shortField = 45;
+		dto.byteField = 23;
+		dto.boolField = true;
+		dto.charField = 'b';
+		dto.strings = new String[] {"hello", "world"};
+
+		dto.dto = new NestedTestDto();
+		dto.dto.importField = "hasdf";
+
+
+		NestedTestDto a1 = new NestedTestDto();
+		a1.importField = "hello";
+		NestedTestDto a2 = new NestedTestDto();
+		a2.export = "blah";
+		NestedTestDto a3 = new NestedTestDto();
+		dto.dtos = new NestedTestDto[] {a1, a2, a3};
+
+		// we ignore @Excludes for this test
+		runExportTest_Success(xml, true, dto);
+	}
+
+	//TODO Fix this to avoid renaming all lists (nested lists won't work)
+	@Test
+	public void testExport_RenamePlural() throws Exception {
+		String xml = 
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+			"<configurations>\n" +
+			"\t<configuration>\n" +
+			"\t\t<newName>\n" +
+			"\t\t\t<string>hello</string>\n" +
+			"\t\t\t<string>world</string>\n" +
+			"\t\t</newName>\n" +
+			"\t\t<multiple>value</multiple>\n" +
+			"\t\t<instantiums>\n" +
+			"\t\t\t<string>instance1</string>\n" +
+			"\t\t\t<string>instance2</string>\n" +
+			"\t\t</instantiums>\n" +
+			"\t</configuration>\n" +
+			"\t<configuration>\n" +
+			"\t\t<newName>\n" +
+			"\t\t\t<string>hello</string>\n" +
+			"\t\t\t<string>world</string>\n" +
+			"\t\t</newName>\n" +
+			"\t\t<multiple>value</multiple>\n" +
+			"\t\t<instantiums>\n" +
+			"\t\t\t<string>instance1</string>\n" +
+			"\t\t\t<string>instance2</string>\n" +
+			"\t\t</instantiums>\n" +
+			"\t</configuration>\n" +
+			"</configurations>";
+
+		ConfiguredTestDto dto = new ConfiguredTestDto();
+		dto.renamedProperties = new String[] {"hello", "world"};
+		dto.instances = new String[] {"instance1", "instance2"};
+		dto.single = "value";
+
+		ConfiguredTestDto dto2 = new ConfiguredTestDto();
+		dto2.renamedProperties = new String[] {"hello", "world"};
+		dto2.instances = new String[] {"instance1", "instance2"};
+		dto2.single = "value";
+
+		runExportTest_Success(xml, false, dto, dto2);
+	}
+
+	@Test
+	public void testExport_ClassHierarchy_Success() throws Exception {
+		String xml = 
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+			"<subclass>\n" +
+			"\t<inner>hello</inner>\n" +
+			"\t<outer>world</outer>\n" +
+			"</subclass>";
+
+		SubclassDto dto = new SubclassDto();
+		dto.inner = "hello";
+		dto.outer = "world";
+
+		runExportTest_Success(xml, false, dto);
+	}
+
+	@Test
+	public void testExport_BlankProperty() throws Exception {
+		// test that 0-length arrays and empty strings are formed correctly
+		String xml =
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+			"<test>\n" +
+			"\t<dtos>\n" +
+			"\t</dtos>\n" +
+			"\t<string></string>\n" +
+			"</test>";
+
+		TestDto dto = new TestDto();
+		dto.string = "";
+		dto.dtos = new NestedTestDto[0];
+		runExportTest_Success(xml, false, dto);
+	}
+
+	@Test
+	public void testExport_NonExportable_Ignored() throws Exception {
+		// make sure non-exportable prop is excluded from output
+		TestDto dto = new TestDto();
+		dto.boolField = true;
+		dto.charField = 'a';
+		String xml =
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+			"<test></test>";
+		runExportTest_Success(xml, false, dto);
+	}
+
+	@Test
+	public void testExport_AllowedNonExportable_Included() throws Exception {
+		// make sure non-exportable prop is included when configg'ed to do so
+		TestDto dto = new TestDto();
+		dto.boolField = true;
+		dto.charField = 'a';
+		String xml = 
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+			"<test>\n" +
+			"\t<boolean>true</boolean>\n" +
+			"\t<char>a</char>\n" +
+			"</test>";		
+
+		runExportTest_Success(xml, true, dto);
+	}
+
+	@Test
+	public void testExport_NullArrayElement() throws Exception {
+		// make sure null array elements are included
+		TestDto dto = new TestDto();
+		dto.strings = new String[] {"hello", null, "world"};
+		String xml =
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+			"<test>\n" +
+			"\t<strings>\n" +
+			"\t\t<string>hello</string>\n" +
+			"\t\t<null/>\n" +
+			"\t\t<string>world</string>\n" +
+			"\t</strings>" +
+			"</test>";
+		runExportTest_Success(xml, false, dto);
+	}
+
+	@Test
+	public void testExport_EscapedStrings() throws Exception {
+		// make sure exported strings are not trimmed
+		TestDto dto = new TestDto();
+		dto.strings = new String[] {"  hello   "};
+		dto.string = "    world\n\n";
+		String xml = 
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+			"<test>\n" +
+			"\t<string>    world\\n\\n</string>\n" +
+			"\t<strings>\n" +
+			"\t\t<string>  hello   </string>\n" +
+			"\t</strings>\n" +
+			"</test>";
+		runExportTest_Success(xml, false, dto);
+	}
+
+	@Test
+	public void testExportEmptyDto() throws Exception {
+		TestDto dto = new TestDto();
+		String xml = 
+			"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
+			"<test/>";
+		runExportTest_Success(xml, false, dto);
+	}
+}

File common-serialize/src/test/java/org/grouplens/common/dto/XmlToDtoConverterTest.java

+/*
+ * GroupLens Common Utilities
+ * Copyright © 2011 Regents of the University of Minnesota
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ *  * Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ *  * Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the
+ *    distribution.
+ *
+ *  * Neither the name of the University of Minnesota nor the names of
+ *    its contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * This software has been partly funded by NSF grant IIS 08-08692.
+ */
+package org.grouplens.common.dto;
+
+import org.grouplens.common.dto.HierarchyDto.SubclassDto;
+import org.junit.Test;
+
+public class XmlToDtoConverterTest extends DtoUnmarshallerTest {
+	
+	@Test
+	public void testImport_HappyPath() throws Exception {
+		// test all allowed types, arrays, and nested dtos
+		// we also test non-importable properties because simple 
+		// importing is a subset of those operations
+		String xml = 		
+		"<test>\n" +
+		"\t<float>4.3242</float>\n" +
+		"\t<boolean>true</boolean>\n" + 
+		"\t<byte>23</byte>\n" +
+		"\t<char>b</char>\n" +
+		"\t<double>2.32</double>\n" +
+		"\t<long>123415123512351235</long>\n" +
+		"\t<integer>234234</integer>\n" +
+		"\t<short>45</short>\n" +
+		"\t<dto>\n" +
+		"\t\t<import>hasdf</import>\n" +
+		"\t</dto>\n" +
+		"\t<strings>\n" +
+		"\t\t<string>hello</string>\n" +
+		"\t\t<string>world</string>\n" +
+		"\t</strings>\n" +
+		"\t<dtos>\n" +
+		"\t\t<nestedTest>\n" +
+		"\t\t\t<import>hello</import>\n" +
+		"\t\t</nestedTest>\n" +
+		"\t\t<nestedTest>\n" +
+		"\t\t\t<export>blah</export>\n" +
+		"\t\t</nestedTest>\n" +
+		"\t\t<nestedTest>\n" +
+		"\t\t</nestedTest>\n" +
+		"\t</dtos>" +
+		"</test>";
+
+		TestDto dto = new TestDto();
+		dto.floatField = 4.3242f;
+		dto.doubleField = 2.32;
+		dto.longField = 123415123512351235L;
+		dto.intField = 234234;
+		dto.shortField = 45;
+		dto.byteField = 23;
+		dto.boolField = true;
+		dto.charField = 'b';
+		dto.strings = new String[] {"hello", "world"};
+
+		dto.dto = new NestedTestDto();
+		dto.dto.importField = "hasdf";
+
+
+		NestedTestDto a1 = new NestedTestDto();
+		a1.importField = "hello";
+		NestedTestDto a2 = new NestedTestDto();
+		a2.export = "blah";
+		NestedTestDto a3 = new NestedTestDto();
+		dto.dtos = new NestedTestDto[] {a1, a2, a3};
+
+		// we've included excluded properties, so we must make sure to ignore them
+		runImportTest_Success(xml, true, dto);
+	}
+
+	@Test
+	public void testExport_RenamePlural() throws Exception {
+		String xml = 			
+			"<configurations>\n" +
+			"\t<configuration>\n" +
+			"\t\t<newName>\n" +
+			"\t\t\t<string>hello</string>\n" +
+			"\t\t\t<string>world</string>\n" +
+			"\t\t</newName>\n" +
+			"\t\t<multiple>value</multiple>\n" +
+			"\t\t<instantiums>\n" +
+			"\t\t\t<string>instance1</string>\n" +
+			"\t\t\t<string>instance2</string>\n" +
+			"\t\t</instantiums>\n" +
+			"\t</configuration>\n" +
+			"\t<configuration>\n" +
+			"\t\t<newName>\n" +
+			"\t\t\t<string>hello</string>\n" +
+			"\t\t\t<string>world</string>\n" +
+			"\t\t</newName>\n" +
+			"\t\t<multiple>value</multiple>\n" +
+			"\t\t<instantiums>\n" +
+			"\t\t\t<string>instance1</string>\n" +
+			"\t\t\t<string>instance2</string>\n" +
+			"\t\t</instantiums>\n" +
+			"\t</configuration>\n" +
+			"</configurations>";
+
+		ConfiguredTestDto dto = new ConfiguredTestDto();
+		dto.renamedProperties = new String[] {"hello", "world"};
+		dto.instances = new String[] {"instance1", "instance2"};
+		dto.single = "value";
+
+		runImportTest_Success(xml, false, dto, dto);
+	}
+
+	@Test
+	public void testExport_EscapedStrings() throws Exception {
+		// make sure exported strings are not trimmed
+		String xml = 			
+			"<test>\n" +
+			"\t<string>    world\\n\\n</string>\n" +
+			"\t<strings>\n" +
+			"\t\t<string>  hello   </string>\n" +
+			"\t</strings>\n" +
+			"</test>";
+
+		TestDto dto = new TestDto();
+		dto.strings = new String[] {"  hello   "};
+		dto.string = "    world\n\n";
+
+		runImportTest_Success(xml, false, dto);
+	}
+
+	@Test
+	public void testImport_BlankElement_Success() throws Exception {
+		// test that blank elements are treated as null on an import
+		String xml = 			
+			"<test>\n" +
+			"\t<string></string>\n" +
+			"\t<char></char>\n" +
+			"\t<dto>\n" +
+			"\t</dto>\n" +
+			"\t<strings>\n" +
+			"\t</strings>\n" +
+			"\t<dtos>\n" +
+			"\t\t<nestedTest>\n" +
+			"\t\t</nestedTest>\n" +
+			"\t</dtos>" +
+			"</test>";
+
+		TestDto expected = new TestDto();
+		// numeric values default to 0
+		expected.charField = '\0';
+		// string is the empty string
+		expected.string = "";
+
+		// object types are blank objects (but not null)
+		expected.dto = new NestedTestDto();
+
+		// arrays are 0 length
+		expected.strings = new String[0];
+		// empty element in an array is still counted
+		expected.dtos = new NestedTestDto[] {new NestedTestDto()};
+		runImportTest_Success(xml, true, expected);
+	}
+
+	@Test
+	public void testImport_NullValue_Success() throws Exception {
+		// test that the null value is handled correctly
+		String xml = 			
+			"<test>\n" +
+			"\t<float>null</float>\n" +
+			"\t<strings>\n" +
+			"\t\t<string>hello</string>\n" +
+			"\t\t<null/>\n" +
+			"\t</strings>\n" +
+			"</test>";
+
+		TestDto expected = new TestDto();
+		expected.strings = new String[] {"hello", null};
+
+		runImportTest_Success(xml, false, expected);
+	}
+
+	@Test
+	public void testImport_AllowedNonImportableProperty_Success() throws Exception {
+		// test successful import of property not flagged with @Importable, when it's allowed
+		String xml = 			
+			"<test>\n " +
+			"\t<byte>3</byte>\n" + //byte isn't importabale in TestDto
+			"</test>";
+
+		TestDto expected = new TestDto();
+		expected.byteField = 3;
+
+		runImportTest_Success(xml, true, expected);
+	}
+
+	@Test
+	public void testImport_ClassHierarchy_Success() throws Exception {
+		String xml = 			
+			"<subclass>\n" +
+			"\t<inner>hello</inner>\n" +
+			"\t<outer>world</outer>\n" +
+			"</subclass>";
+
+		SubclassDto dto = new SubclassDto();
+		dto.inner = "hello";
+		dto.outer = "world";
+
+		runImportTest_Success(xml, false, dto);
+	}
+
+	@Test
+	public void testImport_EmptyRoot_Success() throws Exception {
+		// ensure {"test": {}} is an empty Dto
+		TestDto expected = new TestDto();
+		String xml = "<test/>";
+		runImportTest_Success(xml, false, expected);
+	}
+
+	@Test
+	public void testImport_InvalidBasicType_Fail() throws Exception {
+		// ensure that a bad property type causes a parse exception
+
+		// primitives with bad content (not numeric or out of range, or fp for ints)
+		String xml = 			
+			"<test>\n" +
+			"\t<float>asdf</float>\n" +
+			"</test>";		
+		runImport_Fail(xml, TestDto.class, false);
+
+		xml = 			
+			"<test>\n" +
+			"\t<double>asdf</double>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, false);
+
+		xml = 			
+			"<test>\n" +
+			"\t<long>asdf</long>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, false);
+
+		xml = 			
+			"<test>\n" +
+			"\t<byte>"+Integer.MAX_VALUE+"</byte>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, true);
+
+		xml = 			
+			"<test>\n" +
+			"\t<short>"+Integer.MAX_VALUE+"</short>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, true);
+
+		xml = 			
+			"<test>\n" +
+			"\t<byte>"+Integer.MAX_VALUE+"</byte>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, true);		
+
+		xml = 			
+			"<test>\n" +
+			"\t<integer>34 34</integer>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, false);
+
+		xml = 			
+			"<test>\n" +
+			"\t<integer>4.543</integer>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, false);
+
+		// numeric content that is quoted
+		xml = 			
+			"<test>\n" +
+			"\t<float>\"4.543\"</float>\n" +
+			"</test>";		
+		runImport_Fail(xml, TestDto.class, false);
+
+		// char with a string of len > 1
+		xml = 			
+			"<test>\n" +
+			"\t<char>aa</char>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, false);
+
+		xml = 			
+			"<test>\n " +
+			"\t<boolean>asdf</boolean>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, false);
+	}
+
+	@Test
+	public void testImport_InvalidComplexType_Fail() throws Exception {
+		// ensure that a bad data type, when a nested dto is expected, will fail
+		String xml = 			
+			"<test>\n" +
+			"\t<dto>45</dto>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, false);
+
+		// array checking
+		xml = 			
+			"<test>\n" +
+			"\t<strings>hello world</strings>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, false);
+	}
+
+	@Test
+	public void testImport_IncorrectRoot_Fail() throws Exception {
+		// ensure that a bad root tag fails
+		runImport_Fail("<wrong></wrong>", TestDto.class, false);
+
+		// no 'root'
+		runImport_Fail("<></>", TestDto.class, false);
+
+		// multi root
+		runImport_Fail("<test></test>\n<test></test>", TestDto.class, false);
+	}
+
+	@Test
+	public void testImport_BadlyFormedXml_Fail() throws Exception {
+		// should include: incorrect closing tag
+		String xml = 			
+			"<test><test>";
+		runImport_Fail(xml,  TestDto.class, false);
+
+		//no closing tag
+		xml =			
+			"<test>";
+		runImport_Fail(xml, TestDto.class, false);
+
+		//no closing tag on member element
+		xml = 			
+			"<test>\n" +
+			"\t<strings>\n" +
+			"</test>";
+		runImport_Fail(xml, TestDto.class, false);
+
+		// missing closing tag on array elements
+		xml =			
+			"<test>\n" +
+			"\t<strings>\n" +
+			"\t\t<string>hello\n" +
+			"\t\t<string>world\n" +
+			"\t</strings>\n" +
+			"</test>";			
+		runImport_Fail(xml, TestDto.class, false);
+
+		//extra closing tag on array element
+		xml =			
+			"<test>\n" +
+			"\t<strings>\n" +
+			"\t\t<string>hello</string></string>\n" +
+			"\t\t<string>world\n" +
+			"\t</strings>\n" +
+			"</test>";			
+		runImport_Fail(xml, TestDto.class, false);
+
+		//missing closing tag on member element
+		xml = 			
+			"<test>\n" +
+			"\t<float>4.5\n" +
+			"<double>4.5</double>\n" +
+			"</test>";		
+		runImport_Fail(xml, TestDto.class, false);
+
+		//extra closing tag on member element
+		xml = 			
+			"<test>\n" +
+			"\t<float>4.5</float></float>\n" +
+			"<double>4.5</double>\n" +
+			"</test>";	
+		runImport_Fail(xml, TestDto.class, false);
+
+		// extra closing tag at end
+		xml = 		
+			"<test>\n" +
+			"\t<float>4.5</float>\n" +
+			"<double>4.5</double>\n" +
+			"</test>\n" +
+			"</test>";	
+		runImport_Fail(xml, TestDto.class, false);
+
+		// and also completely badly formatted data
+		xml = 			
+			"<asdwed>\n" +
+			"<j23\n" +
+			"<23></23>";
+		runImport_Fail(xml, TestDto.class, false);
+
+		// duplicate fields
+		xml = 
+			"<test>\n" +
+			"\t<float>4.5</float>\n" +
+			"<double>4.5</double>\n" +
+			"<double>7.9</double>\n" +
+			"</test>\n";
+		runImport_Fail(xml, TestDto.class, false);
+	}
+
+	@Override
+	protected DtoContentHandler createUnmarshaller(boolean ignoreExclude) throws Exception {
+		return new XmlDtoContentHandler(ignoreExclude);
+	}
+}