diff --git a/OutlawEditor/pom.xml b/OutlawEditor/pom.xml index 5c4b7a71..1939c554 100644 --- a/OutlawEditor/pom.xml +++ b/OutlawEditor/pom.xml @@ -84,5 +84,12 @@ ${java.home}/../lib/ant-javafx.jar system + + junit + junit + 4.8.1 + test + jar + diff --git a/OutlawEditor/src/main/resources/jaxb/OutlawSchema/OutlawSchema.xsd b/OutlawEditor/src/main/resources/jaxb/OutlawSchema/OutlawSchema.xsd index 263ff732..1310f295 100644 --- a/OutlawEditor/src/main/resources/jaxb/OutlawSchema/OutlawSchema.xsd +++ b/OutlawEditor/src/main/resources/jaxb/OutlawSchema/OutlawSchema.xsd @@ -1,12 +1,7 @@ - - + elementFormDefault="qualified" targetNamespace="outlaw" xmlns:tns="outlaw" attributeFormDefault="unqualified"> @@ -35,7 +30,7 @@ and open the template in the editor. - + @@ -87,6 +82,55 @@ and open the template in the editor. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -95,5 +139,5 @@ and open the template in the editor. - + diff --git a/OutlawEditor/src/main/resources/testData/blocklytest1.xml b/OutlawEditor/src/main/resources/testData/blocklytest1.xml new file mode 100644 index 00000000..00b3798b --- /dev/null +++ b/OutlawEditor/src/main/resources/testData/blocklytest1.xml @@ -0,0 +1,53 @@ + + + + + + name + description + + var1 + + + 0 + + + + + + + EQ + + + var1 + + + + + 0 + + + + + + + WHILE + + + var1 + + + blah + + + + + + + + + + + + + \ No newline at end of file diff --git a/OutlawEditor/src/main/resources/testData/blocklytest2.xml b/OutlawEditor/src/main/resources/testData/blocklytest2.xml new file mode 100644 index 00000000..e0416d34 --- /dev/null +++ b/OutlawEditor/src/main/resources/testData/blocklytest2.xml @@ -0,0 +1,118 @@ + + + + + + name + description + + + + + + Procedure + + + var1 + + + 0 + + + + + + + + EQ + + + var1 + + + + + 0 + + + + + + + WHILE + + + var1 + + + blah + + + + + + + + + OR + + + TRUE + + + + + + + FALSE + + + + + + + + + x + + + 1 + + + + + + + x + + + + + + + + + x + + + + + y + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/OutlawEditor/src/test/java/org/badvision/outlaweditor/test/TestMythosEditor.java b/OutlawEditor/src/test/java/org/badvision/outlaweditor/test/TestMythosEditor.java new file mode 100644 index 00000000..f5549a66 --- /dev/null +++ b/OutlawEditor/src/test/java/org/badvision/outlaweditor/test/TestMythosEditor.java @@ -0,0 +1,100 @@ +package org.badvision.outlaweditor.test; + +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.StringWriter; +import javax.xml.bind.JAXB; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBElement; +import javax.xml.bind.Marshaller; +import javax.xml.namespace.QName; +import org.badvision.outlaweditor.data.xml.Block; +import org.badvision.outlaweditor.data.xml.GameData; +import org.badvision.outlaweditor.data.xml.Map; +import org.badvision.outlaweditor.data.xml.Map.Scripts; +import org.badvision.outlaweditor.data.xml.Script; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * Various sanity checks of the Mythos script editing feature + * + * @author blurry + */ +public class TestMythosEditor { + + static public final String[] testData = {"testData/blocklytest1.xml", "testData/blocklytest2.xml"}; + static public final String XML_HEADER = "\n"; + + @Test + public void deserializeTest() throws Exception { + for (String path : testData) { + System.out.println("testing " + path); + Block theBlock = getBlock(path); + assertNotNull(theBlock); + } + } + + @Test + public void roundtripTest() throws Exception { + JAXBContext context = JAXBContext.newInstance("org.badvision.outlaweditor.data.xml"); + Marshaller m = context.createMarshaller(); + m.setProperty(Marshaller.JAXB_FRAGMENT, true); + for (String path : testData) { + System.out.println("testing " + path); + Block theBlock = getBlock(path); + StringWriter testWriter = new StringWriter(); + + GameData d = new GameData(); + Map map = new Map(); + d.getMap().add(map); + Script script = new Script(); + script.setName("name"); + script.setDescription("description"); + script.setBlock(theBlock); + map.setScripts(new Scripts()); + map.getScripts().getEnterOrExitOrStepOn().add(new JAXBElement