[ http://issues.apache.org/jira/browse/SCXML-8?page=all ]
     
Rahul Akolkar resolved SCXML-8:
-------------------------------

    Resolution: Fixed

Fixed in r407424, should appear in 05182006 nightlies.


> [scxml] External Digester does not addCustomActions
> ---------------------------------------------------
>
>          Key: SCXML-8
>          URL: http://issues.apache.org/jira/browse/SCXML-8
>      Project: Commons SCXML
>         Type: Bug

>     Versions: 1.0 Alpha
>  Environment: Operating System: other
> Platform: Other
>     Reporter: Fasihullah

>
> I was not sure where to put my test-case. So attaching it here.
> /*
>  * Copyright 2006 The Apache Software Foundation.
>  *
>  * Licensed under the Apache License, Version 2.0 (the "License");
>  * you may not use this file except in compliance with the License.
>  * You may obtain a copy of the License at
>  *
>  *      http://www.apache.org/licenses/LICENSE-2.0
>  *
>  * Unless required by applicable law or agreed to in writing, software
>  * distributed under the License is distributed on an "AS IS" BASIS,
>  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
>  * See the License for the specific language governing permissions and
>  * limitations under the License.
>  */
> package org.apache.commons.scxml.model;
> import java.net.URL;
> import junit.framework.Test;
> import junit.framework.TestCase;
> import junit.framework.TestSuite;
> import org.apache.commons.digester.Digester;
> import org.apache.commons.scxml.Context;
> import org.apache.commons.scxml.Evaluator;
> import org.apache.commons.scxml.SCXMLExecutor;
> import org.apache.commons.scxml.SCXMLTestHelper;
> import org.apache.commons.scxml.env.jexl.JexlContext;
> import org.apache.commons.scxml.env.jexl.JexlEvaluator;
> import org.apache.commons.scxml.io.SCXMLDigester;
> import org.apache.commons.scxml.model.SCXML;
> import org.apache.commons.scxml.model.State;
> public class ExternalCustomActionTest extends TestCase {
>     public ExternalCustomActionTest(String testName) {
>         super(testName);
>     }
>     public static Test suite() {
>         return new TestSuite(ExternalCustomActionTest.class);
>     }
>     public static void main(String args[]) {
>         String[] testCaseName = { ExternalCustomActionTest.class.getName()};
>         junit.textui.TestRunner.main(testCaseName);
>     }
>     private URL externalhello01, custom01;
>     private Digester digester;
>     private SCXMLExecutor exec;
>     /**
>      * Set up instance variables required by this test case.
>      */
>     public void setUp() {
>         externalhello01 = this.getClass().getClassLoader().
>             getResource("org/apache/commons/scxml/external-hello-world.xml");
>         custom01 = this.getClass().getClassLoader().
>             getResource("org/apache/commons/scxml/custom-hello-world.xml");
>     }
>     /**
>      * Tear down instance variables required by this test case.
>      */
>     public void tearDown() {
>       externalhello01 = custom01 = null;
>         digester = null;
>         exec = null;
>     }
>     // Hello World example using the SCXML <log> action
>     public void testHelloWorld() {
>         // (1) Get Digester with "default" rules for parsing SCXML documents
>         digester = SCXMLDigester.newInstance(null, null);
>         // (2) Register the "custom" action(s)
>         SCXMLDigester.addCustomAction(digester,
>             "http://my.custom-actions.domain/CUSTOM";, "hello", Hello.class);
>         // (3) Parse the SCXML document containing the custom action(s)
>         SCXML scxml = null;
>         try {
>             scxml = (SCXML) digester.parse(externalhello01.toString());
>         } catch (Exception e) {
>               e.printStackTrace();
>             fail(e.getMessage());
>         }
>         // (4) Wire up the object model for the SCXMLExecutor
>         SCXMLDigester.updateSCXML(scxml);
>         // (5) Get a SCXMLExecutor
>         Context context = new JexlContext();
>         Evaluator evaluator = new JexlEvaluator();
>         exec = SCXMLTestHelper.getExecutor(scxml, context, evaluator);
>         // (6) Single, final state
>         assertEquals("external-hello", ((State) 
> exec.getCurrentStatus().getStates().
>                 iterator().next()).getId());
>         assertEquals ("external world", context.get("custom"));
>     }
>     // Hello World example using a custom <hello> action
>     public void testCustomActionHelloWorld() {
>         // (1) Get Digester with "default" rules for parsing SCXML documents
>         digester = SCXMLDigester.newInstance(null, null);
>         // (2) Register the "custom" action(s)
>         SCXMLDigester.addCustomAction(digester,
>             "http://my.custom-actions.domain/CUSTOM";, "hello", Hello.class);
>         // (3) Parse the SCXML document containing the custom action(s)
>         SCXML scxml = null;
>         try {
>             scxml = (SCXML) digester.parse(custom01.toString());
>         } catch (Exception e) {
>               e.printStackTrace();
>             fail(e.getMessage());
>         }
>         // (4) Wire up the object model for the SCXMLExecutor
>         SCXMLDigester.updateSCXML(scxml);
>         // (5) Get a SCXMLExecutor
>         Context context = new JexlContext();
>         Evaluator evaluator = new JexlEvaluator();
>         exec = SCXMLTestHelper.getExecutor(scxml, context, evaluator);
>         // (6) Fire events, proceed as usual
>         assertEquals("external-hello", ((State) 
> exec.getCurrentStatus().getStates().
>                 iterator().next()).getId());
>         assertEquals ("external world", context.get("custom"));
>     }
> }
> <?xml version="1.0"?>
> <scxml xmlns="http://www.w3.org/2005/07/SCXML";
>        xmlns:my="http://my.custom-actions.domain/CUSTOM";
>        version="1.0"
>        initialstate="external-hello">
>     <state id="external-hello">
>         <onentry>
>             <my:hello name="external world"/>
>         </onentry>
>     </state>
> </scxml>
> <?xml version="1.0"?>
> <scxml xmlns="http://www.w3.org/2005/07/SCXML";
>        xmlns:my="http://my.custom-actions.domain/CUSTOM";
>        version="1.0"
>        initialstate="custom">
>       <datamodel/>
>     <state id="custom" final="true"
> src="test/org/apache/commons/scxml/external-hello-world.xml"/>
> </scxml>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to