Author: rahul
Date: Thu Jan 8 16:56:16 2009
New Revision: 732892
URL: http://svn.apache.org/viewvc?rev=732892&view=rev
Log:
Restore some of the bits removed in r732856. Added a simple test for
<transition> serialization.
Modified:
commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java
commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java
Modified:
commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java
URL:
http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java?rev=732892&r1=732891&r2=732892&view=diff
==============================================================================
---
commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java
(original)
+++
commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/ModelUpdater.java
Thu Jan 8 16:56:16 2009
@@ -161,6 +161,9 @@
updateTransition(trn, targets);
}
Invoke inv = s.getInvoke();
+ if (inv != null && !c.isEmpty()) {
+ logAndThrowModelError(ERR_STATE_BAD_CONTENTS, new Object[]
{getStateName(s)});
+ }
if (inv != null) {
String ttype = inv.getTargettype();
if (ttype == null || ttype.trim().length() == 0) {
@@ -342,6 +345,13 @@
+ "null or not a descendant of {0}";
/**
+ * Error message when a state element contains anything other than
+ * an <invoke> or any number of <state> children.
+ */
+ private static final String ERR_STATE_BAD_CONTENTS = "{0} should "
+ + "contain either one <invoke> or any number of <state> children.";
+
+ /**
* Error message when a referenced history state cannot be found.
*/
private static final String ERR_STATE_NO_HIST = "Referenced history state"
Modified:
commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
URL:
http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java?rev=732892&r1=732891&r2=732892&view=diff
==============================================================================
---
commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
(original)
+++
commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLSerializer.java
Thu Jan 8 16:56:16 2009
@@ -299,6 +299,10 @@
b.append(" cond=\"").append(SCXMLHelper.escapeXML(t.getCond())).
append("\"");
}
+ if (!SCXMLHelper.isStringEmpty(t.getNext())) {
+ b.append(" target=\"").append(SCXMLHelper.escapeXML(t.getNext())).
+ append("\"");
+ }
b.append(">\n");
serializeActions(b, t.getActions(), indent + INDENT);
b.append(indent).append("</transition>\n");
Modified:
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java?rev=732892&r1=732891&r2=732892&view=diff
==============================================================================
---
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java
(original)
+++
commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/io/SCXMLSerializerTest.java
Thu Jan 8 16:56:16 2009
@@ -313,6 +313,21 @@
assertEquals(actualValue, returnValue.toString());
}
+ public void testSerializeTransition() {
+ Transition t = new Transition();
+
+ t.setEvent("foo.bar");
+ t.setCond("i == 3");
+ t.setNext("next");
+
+ String actualValue = "<transition event=\"foo.bar\" cond=\"i == 3\"
target=\"next\">\n</transition>\n";
+
+ StringBuffer returnValue = new StringBuffer();
+ SCXMLSerializer.serializeTransition(returnValue, t, "");
+
+ assertEquals(actualValue, returnValue.toString());
+ }
+
public void testSerializeTransitionEscapeXML() {
Transition t = new Transition();