Skip to content

Instantly share code, notes, and snippets.

@digulla
Created September 1, 2011 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save digulla/1186034 to your computer and use it in GitHub Desktop.
Save digulla/1186034 to your computer and use it in GitHub Desktop.
Demo for SimpleXml line number problem
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