forked from ngallagher/simplexml
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
niallg
committed
Feb 18, 2013
1 parent
cc03e1a
commit bb6b5ec
Showing
2 changed files
with
104 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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
50 changes: 50 additions & 0 deletions
50
src/test/java/org/simpleframework/xml/core/PrimitiveClassTest.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package org.simpleframework.xml.core; | ||
|
||
import java.io.StringWriter; | ||
|
||
import org.simpleframework.xml.ValidationTestCase; | ||
|
||
public class PrimitiveClassTest extends ValidationTestCase { | ||
|
||
private static class Example { | ||
private Class[] classes; | ||
public Example() { | ||
this.classes = new Class[]{ | ||
int.class, | ||
double.class, | ||
float.class, | ||
long.class, | ||
void.class, | ||
byte.class, | ||
short.class, | ||
boolean.class, | ||
char.class | ||
}; | ||
} | ||
} | ||
|
||
|
||
public void testPrimitiveClass() throws Exception { | ||
Example example = new Example(); | ||
Persister persister = new Persister(); | ||
StringWriter writer = new StringWriter(); | ||
|
||
persister.write(example, writer); | ||
|
||
String text = writer.toString(); | ||
System.err.println(text); | ||
|
||
assertElementExists(text, "/example"); | ||
assertElementExists(text, "/example/classes"); | ||
assertElementHasAttribute(text, "/example/classes", "length", "9"); | ||
assertElementHasValue(text, "/example/classes/class[1]", "int"); | ||
assertElementHasValue(text, "/example/classes/class[2]", "double"); | ||
assertElementHasValue(text, "/example/classes/class[3]", "float"); | ||
assertElementHasValue(text, "/example/classes/class[4]", "long"); | ||
assertElementHasValue(text, "/example/classes/class[5]", "void"); | ||
assertElementHasValue(text, "/example/classes/class[6]", "byte"); | ||
assertElementHasValue(text, "/example/classes/class[7]", "short"); | ||
assertElementHasValue(text, "/example/classes/class[8]", "boolean"); | ||
assertElementHasValue(text, "/example/classes/class[9]", "char"); | ||
} | ||
} |