Index: java/xml/xslist/TestSourceGenerator.java =================================================================== --- java/xml/xslist/TestSourceGenerator.java (Revision 0) +++ java/xml/xslist/TestSourceGenerator.java (Revision 0) @@ -0,0 +1,29 @@ +package xml.xslist; + +import junit.framework.TestCase; + +import org.exolab.castor.builder.SourceGenerator; +import org.xml.sax.InputSource; + +public class TestSourceGenerator extends TestCase { + + public void testGeneration() throws Exception { + SourceGenerator generator = new SourceGenerator(); + String xmlSchema = getClass().getResource("test.xsd").toExternalForm(); + InputSource inputSource = new InputSource(xmlSchema); + generator.setDestDir("./codegen/src/test/java"); + generator.setSuppressNonFatalWarnings(true); + + // uncomment the next line to set a binding file for source generation +// generator.setBinding(new InputSource(getClass().getResource("binding.xml").toExternalForm())); + + // uncomment the next lines to set custom properties for source generation +// Properties properties = new Properties(); +// properties.load(getClass().getResource("builder.properties").openStream()); +// generator.setDefaultProperties(properties); + + generator.generateSource(inputSource, getClass().getPackage().getName() + ".generated"); + } + +} + Eigenschafts„nderungen: java\xml\xslist\TestSourceGenerator.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Index: java/xml/xslist/TestTemplate.java =================================================================== --- java/xml/xslist/TestTemplate.java (Revision 0) +++ java/xml/xslist/TestTemplate.java (Revision 0) @@ -0,0 +1,137 @@ +package xml.xslist; + +import java.io.StringWriter; + +import junit.framework.TestCase; + +import org.exolab.castor.xml.Marshaller; +import org.exolab.castor.xml.Unmarshaller; +import org.xml.sax.InputSource; + +import xml.xslist.generated.Root; +import xml.xslist.generated.RootList; +import xml.xslist.generated.RootShortList; + +public final class TestTemplate extends TestCase { + + private static final String SAMPLE_FILE = "input.xml"; + + public TestTemplate() { + super(); + } + + public TestTemplate(final String name) { + super(name); + } + + /** + * Test method. + * + * @throws Exception + * For any exception thrown. + */ + public void testUnmarshalEntity() throws Exception { + Unmarshaller unmarshaller = new Unmarshaller(Root.class); + + Root rootList = (Root) unmarshaller.unmarshal(new InputSource(getClass() + .getResource(SAMPLE_FILE).toExternalForm())); + + assertNotNull(rootList); + assertNotNull(rootList.getMember()); + + String[] members = rootList.getMember(); + assertTrue(members.length > 0); + assertTrue(members.length == 2); + + assertEquals("blah1", members[0]); + assertEquals("blah2", members[1]); + + StringWriter out = new StringWriter(); + Marshaller marshaller = new Marshaller(out); + + marshaller.marshal(rootList); + + System.out.println(out.toString()); + } + + /** + * Test method. + * + * @throws Exception + * For any exception thrown. + */ + public void testUnmarshalRootShortList() throws Exception { + Unmarshaller unmarshaller = new Unmarshaller(RootShortList.class); + + RootShortList rootShortList = (RootShortList) unmarshaller + .unmarshal(new InputSource(getClass().getResource( + "input-list-short.xml").toExternalForm())); + assertNotNull(rootShortList); + assertNotNull(rootShortList.getMember()); + + short[] members = rootShortList.getMember(); + assertTrue(members.length > 0); + assertTrue(members.length == 2); + + assertEquals(4, members[0]); + assertEquals(2, members[1]); + + StringWriter out = new StringWriter(); + Marshaller marshaller = new Marshaller(out); + + marshaller.marshal(rootShortList); + + System.out.println(out.toString()); + + } + + /** + * Test method. + * + * @throws Exception + * For any exception thrown. + */ + public void testUnmarshalRootList() throws Exception { + Unmarshaller unmarshaller = new Unmarshaller(RootList.class); + + RootList rootList = (RootList) unmarshaller.unmarshal(new InputSource( + getClass().getResource("input-list.xml").toExternalForm())); + assertNotNull(rootList); + + + assertNotNull(rootList); + assertNotNull(rootList.getMember()); + + String[] members = rootList.getMember(); + assertTrue(members.length > 0); + assertTrue(members.length == 2); + + assertEquals("blah1", members[0]); + assertEquals("blah2", members[1]); + + StringWriter out = new StringWriter(); + Marshaller marshaller = new Marshaller(out); + + marshaller.marshal(rootList); + + System.out.println(out.toString()); + } + + // /** + // * Test method. + // * @throws Exception For any exception thrown. + // */ + // public void testMarshalEntity() throws Exception { + // + // StringWriter out = new StringWriter(); + // Marshaller marshaller = new Marshaller (out); + // + // Root root = new Root(); + // root.addMember("blah1"); + // root.addMember("blah2"); + // marshaller.marshal(root); + // + // System.out.println(out.toString()); + // } + +} Eigenschafts„nderungen: java\xml\xslist\TestTemplate.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:keywords + Id Name: svn:eol-style + native Index: resources/xml/xslist/input-list-short.xml =================================================================== --- resources/xml/xslist/input-list-short.xml (Revision 0) +++ resources/xml/xslist/input-list-short.xml (Revision 0) @@ -0,0 +1,4 @@ + + + 4 2 + \ Kein Zeilenvorschub am Ende der Datei Eigenschafts„nderungen: resources\xml\xslist\input-list-short.xml ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:keywords + Id Name: svn:eol-style + native Index: resources/xml/xslist/input-list.xml =================================================================== --- resources/xml/xslist/input-list.xml (Revision 0) +++ resources/xml/xslist/input-list.xml (Revision 0) @@ -0,0 +1,4 @@ + + + blah1 blah2 + \ Kein Zeilenvorschub am Ende der Datei Eigenschafts„nderungen: resources\xml\xslist\input-list.xml ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:keywords + Id Name: svn:eol-style + native Index: resources/xml/xslist/test.xsd =================================================================== --- resources/xml/xslist/test.xsd (Revision 0) +++ resources/xml/xslist/test.xsd (Revision 0) @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Eigenschafts„nderungen: resources\xml\xslist\test.xsd ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:keywords + Id Name: svn:eol-style + native Index: resources/xml/xslist/input.xml =================================================================== --- resources/xml/xslist/input.xml (Revision 0) +++ resources/xml/xslist/input.xml (Revision 0) @@ -0,0 +1,5 @@ + + + blah1 + blah2 + \ Kein Zeilenvorschub am Ende der Datei Eigenschafts„nderungen: resources\xml\xslist\input.xml ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:keywords + Id Name: svn:eol-style + native