Author: rahul
Date: Fri Jun 15 14:43:38 2007
New Revision: 547799
URL: http://svn.apache.org/viewvc?view=rev&rev=547799
Log:
Provide a SCXMLListener abstract adapter class
SCXML-46
Thanks to Michael Heuer <heuermh AT acm DOT org>.
Added Michael to the list of contributors.
Added:
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/AbstractSCXMLListener.java
(with props)
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/AbstractSCXMLListenerTest.java
(with props)
Modified:
jakarta/commons/proper/scxml/trunk/pom.xml
jakarta/commons/proper/scxml/trunk/project.xml
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java
Modified: jakarta/commons/proper/scxml/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/pom.xml?view=diff&rev=547799&r1=547798&r2=547799
==============================================================================
--- jakarta/commons/proper/scxml/trunk/pom.xml (original)
+++ jakarta/commons/proper/scxml/trunk/pom.xml Fri Jun 15 14:43:38 2007
@@ -78,6 +78,9 @@
<contributor>
<name>Nestor Urquiza</name>
</contributor>
+ <contributor>
+ <name>Michael Heuer</name>
+ </contributor>
</contributors>
<dependencies>
Modified: jakarta/commons/proper/scxml/trunk/project.xml
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/project.xml?view=diff&rev=547799&r1=547798&r2=547799
==============================================================================
--- jakarta/commons/proper/scxml/trunk/project.xml (original)
+++ jakarta/commons/proper/scxml/trunk/project.xml Fri Jun 15 14:43:38 2007
@@ -113,6 +113,9 @@
<contributor>
<name>Nestor Urquiza</name>
</contributor>
+ <contributor>
+ <name>Michael Heuer</name>
+ </contributor>
</contributors>
<dependencies>
Added:
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/AbstractSCXMLListener.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/AbstractSCXMLListener.java?view=auto&rev=547799
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/AbstractSCXMLListener.java
(added)
+++
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/AbstractSCXMLListener.java
Fri Jun 15 14:43:38 2007
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.env;
+
+import org.apache.commons.scxml.SCXMLListener;
+import org.apache.commons.scxml.model.Transition;
+import org.apache.commons.scxml.model.TransitionTarget;
+
+/**
+ * An abstract adapter class for the <code>SXCMLListener</code> interface.
+ * This class exists as a convenience for creating listener objects, and as
+ * such all the methods in this class are empty.
+ */
+public abstract class AbstractSCXMLListener implements SCXMLListener {
+
+ /**
+ * @see SCXMLListener#onEntry(TransitionTarget)
+ */
+ public void onEntry(final TransitionTarget state) {
+ // empty
+ }
+
+ /**
+ * @see SCXMLListener#onExit(TransitionTarget)
+ */
+ public void onExit(final TransitionTarget state) {
+ // empty
+ }
+
+ /**
+* @see SCXMLListener#onTransition(TransitionTarget,TransitionTarget,Transition)
+ */
+ public void onTransition(final TransitionTarget from,
+ final TransitionTarget to, final Transition transition) {
+ // empty
+ }
+
+}
+
Propchange:
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/AbstractSCXMLListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/commons/proper/scxml/trunk/src/main/java/org/apache/commons/scxml/env/AbstractSCXMLListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Added:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/AbstractSCXMLListenerTest.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/AbstractSCXMLListenerTest.java?view=auto&rev=547799
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/AbstractSCXMLListenerTest.java
(added)
+++
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/AbstractSCXMLListenerTest.java
Fri Jun 15 14:43:38 2007
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.env;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import junit.textui.TestRunner;
+
+import org.apache.commons.scxml.SCXMLListener;
+import org.apache.commons.scxml.model.State;
+import org.apache.commons.scxml.model.Transition;
+import org.apache.commons.scxml.model.TransitionTarget;
+
+/**
+ * Unit tests [EMAIL PROTECTED]
org.apache.commons.scxml.AbstractSCXMLListener}.
+ */
+public class AbstractSCXMLListenerTest extends TestCase {
+ /**
+ * Construct a new instance of AbstractSCXMLListenerTest with the
specified name
+ */
+ public AbstractSCXMLListenerTest(String name) {
+ super(name);
+ }
+
+ // Test data
+ private TransitionTarget to;
+ private TransitionTarget from;
+ private Transition transition;
+ private boolean heardOnEntry;
+ private boolean heardOnExit;
+ private boolean heardOnTransition;
+
+ /**
+ * Set up instance variables required by this test case.
+ */
+ public void setUp() {
+ to = new State();
+ from = new State();
+ transition = new Transition();
+ heardOnEntry = false;
+ heardOnExit = false;
+ heardOnTransition = false;
+ }
+
+ /**
+ * Tear down instance variables required by this test case.
+ */
+ public void tearDown() {
+ to = null;
+ from = null;
+ transition = null;
+ }
+
+ public void testAbstractSCXMLListener0() {
+ SCXMLListener listener0 = new AbstractSCXMLListener() {
+ /**
+ * @see SCXMLListener#onEntry(TransitionTarget)
+ */
+ public void onEntry(TransitionTarget state) {
+ heardOnEntry = true;
+ }
+
+ /**
+ * @see SCXMLListener#onExit(TransitionTarget)
+ */
+ public void onExit(TransitionTarget state) {
+ heardOnExit = true;
+ }
+
+ /**
+ * @see
SCXMLListener#onTransition(TransitionTarget,TransitionTarget,Transition)
+ */
+ public void onTransition(TransitionTarget from,
TransitionTarget to,
+ Transition transition) {
+ heardOnTransition = true;
+ }
+ };
+
+ assertFalse("heardOnEntry == false", heardOnEntry);
+ assertFalse("heardOnExit == false", heardOnExit);
+ assertFalse("heardOnTransition == false", heardOnTransition);
+ listener0.onEntry(to);
+ listener0.onExit(to);
+ listener0.onTransition(from, to, transition);
+ assertTrue("heardOnEntry", heardOnEntry);
+ assertTrue("heardOnExit", heardOnExit);
+ assertTrue("heardOnExit", heardOnTransition);
+ }
+
+ public void testAbstractSCXMLListener1() {
+ SCXMLListener listener1 = new AbstractSCXMLListener() {
+ /**
+ * @see SCXMLListener#onEntry(TransitionTarget)
+ */
+ public void onEntry(TransitionTarget state) {
+ heardOnEntry = true;
+ }
+
+ /**
+ * @see SCXMLListener#onExit(TransitionTarget)
+ */
+ public void onExit(TransitionTarget state) {
+ heardOnExit = true;
+ }
+ };
+
+ assertFalse("heardOnEntry == false", heardOnEntry);
+ assertFalse("heardOnExit == false", heardOnExit);
+ assertFalse("heardOnTransition == false", heardOnTransition);
+ listener1.onEntry(to);
+ listener1.onExit(to);
+ listener1.onTransition(from, to, transition);
+ assertTrue("heardOnEntry", heardOnEntry);
+ assertTrue("heardOnExit", heardOnExit);
+ assertFalse("heardOnTransition == false", heardOnTransition);
+ }
+
+ public void testAbstractSCXMLListener2() {
+ SCXMLListener listener2 = new AbstractSCXMLListener() {
+ /**
+ * @see SCXMLListener#onEntry(TransitionTarget)
+ */
+ public void onEntry(TransitionTarget state) {
+ heardOnEntry = true;
+ }
+ };
+
+ assertFalse("heardOnEntry == false", heardOnEntry);
+ assertFalse("heardOnExit == false", heardOnExit);
+ assertFalse("heardOnTransition == false", heardOnTransition);
+ listener2.onEntry(to);
+ listener2.onExit(to);
+ listener2.onTransition(from, to, transition);
+ assertTrue("heardOnEntry", heardOnEntry);
+ assertFalse("heardOnExit == false", heardOnExit);
+ assertFalse("heardOnTransition == false", heardOnTransition);
+ }
+
+ public void testAbstractSCXMLListener3() {
+ SCXMLListener listener3 = new AbstractSCXMLListener() {
+ // empty
+ };
+
+ assertFalse("heardOnEntry == false", heardOnEntry);
+ assertFalse("heardOnExit == false", heardOnExit);
+ assertFalse("heardOnTransition == false", heardOnTransition);
+ listener3.onEntry(to);
+ listener3.onExit(to);
+ listener3.onTransition(from, to, transition);
+ assertFalse("heardOnEntry == false", heardOnEntry);
+ assertFalse("heardOnExit == false", heardOnExit);
+ assertFalse("heardOnTransition == false", heardOnTransition);
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite(AbstractSCXMLListenerTest.class);
+ suite.setName("AbstractSCXMLListener Tests");
+ return suite;
+ }
+
+ public static void main(String args[]) {
+ TestRunner.run(suite());
+ }
+}
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/AbstractSCXMLListenerTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/AbstractSCXMLListenerTest.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified:
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java?view=diff&rev=547799&r1=547798&r2=547799
==============================================================================
---
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java
(original)
+++
jakarta/commons/proper/scxml/trunk/src/test/java/org/apache/commons/scxml/env/EnvTestSuite.java
Fri Jun 15 14:43:38 2007
@@ -48,6 +48,7 @@
public static Test suite() {
TestSuite suite = new TestSuite();
suite.setName("Commons-SCXML Environments Tests");
+ suite.addTest(AbstractSCXMLListenerTest.suite());
suite.addTest(LogUtilsTest.suite());
suite.addTest(SimpleContextTest.suite());
suite.addTest(StopWatchTest.suite());
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]