Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 36349 invoked from network); 19 Nov 2008 21:22:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Nov 2008 21:22:43 -0000 Received: (qmail 67993 invoked by uid 500); 19 Nov 2008 21:22:52 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 67589 invoked by uid 500); 19 Nov 2008 21:22:50 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 67580 invoked by uid 99); 19 Nov 2008 21:22:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Nov 2008 13:22:50 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Nov 2008 21:21:36 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 608D323888E6; Wed, 19 Nov 2008 13:21:51 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r719076 - in /commons/proper/scxml/branches/J6/src: main/java/org/apache/commons/scxml/io/ main/java/org/apache/commons/scxml/model/ main/java/org/apache/commons/scxml/semantics/ test/java/org/apache/commons/scxml/model/ Date: Wed, 19 Nov 2008 21:21:51 -0000 To: commits@commons.apache.org From: rahul@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081119212151.608D323888E6@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rahul Date: Wed Nov 19 13:21:50 2008 New Revision: 719076 URL: http://svn.apache.org/viewvc?rev=719076&view=rev Log: Porting r719073 from trunk. Support executable content in child of as specified in the latest WD: * with the exception of * added a related test case. Added: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-initial-test.xml (with props) Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Action.java commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionTest.java commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionsTest.java commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java?rev=719076&r1=719075&r2=719076&view=diff ============================================================================== --- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java (original) +++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/io/SCXMLParser.java Wed Nov 19 13:21:50 2008 @@ -1010,9 +1010,17 @@ scxmlRules.add(xp + XPF_EXT, new Rule() { public void end(final String namespace, final String name) { Transition t = (Transition) getDigester().peek(1); - State exitState = new State(); - exitState.setFinal(true); - t.getTargets().add(exitState); + TransitionTarget tt = (TransitionTarget) getDigester(). + peek(2); + if (tt instanceof Initial) { + org.apache.commons.logging.Log log = LogFactory. + getLog(SCXMLParser.class); + log.warn("Ignored action in "); + } else { + State exitState = new State(); + exitState.setFinal(true); + t.getTargets().add(exitState); + } } }); scxmlRules.setNamespaceURI(NAMESPACE_SCXML); Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Action.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Action.java?rev=719076&r1=719075&r2=719076&view=diff ============================================================================== --- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Action.java (original) +++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/model/Action.java Wed Nov 19 13:21:50 2008 @@ -111,7 +111,7 @@ TransitionTarget tt = parent.getParent(); if (tt instanceof State || tt instanceof Parallel) { return tt; - } else if (tt instanceof History) { + } else if (tt instanceof History || tt instanceof Initial) { return tt.getParent(); } else { throw new ModelException("Unknown TransitionTarget subclass:" Modified: commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java?rev=719076&r1=719075&r2=719076&view=diff ============================================================================== --- commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java (original) +++ commons/proper/scxml/branches/J6/src/main/java/org/apache/commons/scxml/semantics/SCXMLSemanticsImpl.java Wed Nov 19 13:21:50 2008 @@ -48,6 +48,7 @@ import org.apache.commons.scxml.model.Action; import org.apache.commons.scxml.model.Finalize; import org.apache.commons.scxml.model.History; +import org.apache.commons.scxml.model.Initial; import org.apache.commons.scxml.model.Invoke; import org.apache.commons.scxml.model.ModelException; import org.apache.commons.scxml.model.OnEntry; @@ -249,9 +250,22 @@ TriggerEvent te = new TriggerEvent(tt.getId() + ".entry", TriggerEvent.CHANGE_EVENT); internalEvents.add(te); - //3.2.1 and 3.4 (.done events) + // actions in initial transition (if any) and .done events if (tt instanceof State) { State ts = (State) tt; + Initial ini = ts.getInitial(); + if (ts.isComposite() && ini != null) { + try { + for (Action initialAct : ini.getTransition(). + getActions()) { + initialAct.execute(evtDispatcher, + errRep, scInstance, appLog, internalEvents); + } + } catch (SCXMLExpressionException e) { + errRep.onError(ErrorConstants.EXPRESSION_ERROR, + e.getMessage(), ini); + } + } if (ts.isFinal()) { State parent = (State) ts.getParent(); String prefix = ""; Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionTest.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionTest.java?rev=719076&r1=719075&r2=719076&view=diff ============================================================================== --- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionTest.java (original) +++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionTest.java Wed Nov 19 13:21:50 2008 @@ -71,7 +71,7 @@ TransitionTarget returnValue = action.getParentTransitionTarget(); - assertEquals("off", returnValue.getId()); + assertEquals("on", returnValue.getId()); } public void testGetParentStateIsHistory() throws Exception { @@ -93,21 +93,22 @@ assertEquals("off", returnValue.getId()); } - public void testGetParentStateIsInitial() { + public void testGetParentStateIsInitial() throws Exception { Transition transition = new Transition(); Initial initial = new Initial(); initial.setId("on"); - + + State state = new State(); + state.setId("off"); + + initial.setParent(state); + transition.setParent(initial); action.setParent(transition); - try{ - action.getParentTransitionTarget(); - fail("Unknown TransitionTarget subclass:Initial"); - } - catch( ModelException e ){ - //ignore - } + TransitionTarget returnValue = action.getParentTransitionTarget(); + + assertEquals("off", returnValue.getId()); } } Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionsTest.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionsTest.java?rev=719076&r1=719075&r2=719076&view=diff ============================================================================== --- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionsTest.java (original) +++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ActionsTest.java Wed Nov 19 13:21:50 2008 @@ -54,7 +54,7 @@ } // Test data - private URL actionsSample01, actionsSample02; + private URL actionsSample01, actionsSample02, actionsSample03; private ELEvaluator evaluator; private ELContext ctx; private SCXMLExecutor exec; @@ -67,6 +67,8 @@ getResource("org/apache/commons/scxml/model/actions-state-test.xml"); actionsSample02 = this.getClass().getClassLoader(). getResource("org/apache/commons/scxml/model/actions-parallel-test.xml"); + actionsSample03 = this.getClass().getClassLoader(). + getResource("org/apache/commons/scxml/model/actions-initial-test.xml"); evaluator = new ELEvaluator(); ctx = new ELContext(); } @@ -75,7 +77,7 @@ * Tear down instance variables required by this test case. */ public void tearDown() { - actionsSample01 = actionsSample02 = null; + actionsSample01 = actionsSample02 = actionsSample03 = null; evaluator = null; ctx = null; exec = null; @@ -86,16 +88,20 @@ */ public void testStateActions() { SCXML scxml = SCXMLTestHelper.parse(actionsSample01); - exec = SCXMLTestHelper.getExecutor(scxml, ctx, evaluator); - ELContext ctx = (ELContext) SCXMLTestHelper.lookupContext(exec, - "actionsTest"); - assertEquals((String) ctx.get("foo"), "foobar"); - assertEquals("Missed event transition", - "true", (String) ctx.get("eventsent")); + runTest(scxml); } public void testParallelActions() { SCXML scxml = SCXMLTestHelper.parse(actionsSample02); + runTest(scxml); + } + + public void testInitialActions() { + SCXML scxml = SCXMLTestHelper.parse(actionsSample03); + runTest(scxml); + } + + private void runTest(SCXML scxml) { exec = SCXMLTestHelper.getExecutor(scxml, ctx, evaluator); ELContext ctx = (ELContext) SCXMLTestHelper.lookupContext(exec, "actionsTest"); Modified: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java?rev=719076&r1=719075&r2=719076&view=diff ============================================================================== --- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java (original) +++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/ModelTestSuite.java Wed Nov 19 13:21:50 2008 @@ -54,6 +54,7 @@ suite.addTest(CustomActionTest.suite()); suite.addTest(DatamodelTest.suite()); suite.addTest(HistoryTest.suite()); + suite.addTest(ParallelTest.suite()); suite.addTest(PathTest.suite()); suite.addTest(StateTest.suite()); suite.addTest(StatelessModelTest.suite()); Added: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-initial-test.xml URL: http://svn.apache.org/viewvc/commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-initial-test.xml?rev=719076&view=auto ============================================================================== --- commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-initial-test.xml (added) +++ commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-initial-test.xml Wed Nov 19 13:21:50 2008 @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Propchange: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-initial-test.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: commons/proper/scxml/branches/J6/src/test/java/org/apache/commons/scxml/model/actions-initial-test.xml ------------------------------------------------------------------------------ svn:keywords = Date Author Id Revision HeadURL