Created
September 1, 2011 12:02
-
-
Save digulla/1186034 to your computer and use it in GitHub Desktop.
Demo for SimpleXml line number problem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.sf.simple.test; | |
import static org.junit.Assert.*; | |
import java.io.StringReader; | |
import org.junit.Test; | |
import org.simpleframework.xml.Attribute; | |
import org.simpleframework.xml.Root; | |
import org.simpleframework.xml.Serializer; | |
import org.simpleframework.xml.core.Persister; | |
import org.simpleframework.xml.core.ValueRequiredException; | |
public class LineNumberTest { | |
@Root | |
static class Type { | |
@Attribute | |
String name; | |
} | |
@Test | |
public void testLineNumber() throws Exception { | |
try { | |
Serializer serializer = new Persister(); | |
serializer.read(Type.class, new StringReader( "<root />" ) ); | |
fail( "No exception was thrown" ); | |
} catch( ValueRequiredException e ) { | |
assertEquals( | |
"Unable to satisfy @org.simpleframework.xml.Attribute(required=true, empty=, name=) on field 'name' java.lang.String net.sf.simple.test.LineNumberTest$Type.name for class net.sf.simple.test.LineNumberTest$Type at line 1" | |
, e.getMessage() ); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment