You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ni...@apache.org on 2007/10/18 20:39:49 UTC

svn commit: r586063 [3/3] - in /mina/sandbox/niklas/mina-sm: ./ src/main/java/org/apache/mina/sm/ src/main/java/org/apache/mina/sm/annotation/ src/main/java/org/apache/mina/sm/context/ src/main/java/org/apache/mina/sm/event/ src/main/java/org/apache/mi...

Modified: mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineTest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineTest.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineTest.java (original)
+++ mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateMachineTest.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
 /*
- *   @(#) $Id$
- *
- *   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.
+ *  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.mina.sm;
@@ -28,135 +29,117 @@
 /**
  * Tests {@link StateMachine}.
  *
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
  * @version $Rev$, $Date$
  */
-public class StateMachineTest extends TestCase
-{
+public class StateMachineTest extends TestCase {
+
+    public void testBreakAndContinue() throws Exception {
+        State s1 = new State("s1");
+        s1.addTransition(new BreakAndContinueTransition("foo"));
+        s1.addTransition(new SuccessTransition("foo"));
 
-    public void testBreakAndContinue() throws Exception
-    {
-        State s1 = new State( "s1" );
-        s1.addTransition( new BreakAndContinueTransition( "foo" ) );
-        s1.addTransition( new SuccessTransition( "foo" ) );
-        
         StateContext context = new DefaultStateContext();
-        StateMachine sm = new StateMachine( new State[] { s1 }, "s1" );
-        sm.handle( new Event( "foo", context ) );
-        assertEquals( true, context.getAttribute( "success" ));
+        StateMachine sm = new StateMachine(new State[] { s1 }, "s1");
+        sm.handle(new Event("foo", context));
+        assertEquals(true, context.getAttribute("success"));
     }
     
-    public void testBreakAndGotoNow() throws Exception
-    {
-        State s1 = new State( "s1" );
-        State s2 = new State( "s2" );
-        s1.addTransition( new BreakAndGotoNowTransition( "foo", "s2" ) );
-        s2.addTransition( new SuccessTransition( "foo" ) );
-        
+    public void testBreakAndGotoNow() throws Exception {
+        State s1 = new State("s1");
+        State s2 = new State("s2");
+        s1.addTransition(new BreakAndGotoNowTransition("foo", "s2"));
+        s2.addTransition(new SuccessTransition("foo"));
+
         StateContext context = new DefaultStateContext();
-        StateMachine sm = new StateMachine( new State[] { s1, s2 }, "s1" );
-        sm.handle( new Event( "foo", context ) );
-        assertEquals( true, context.getAttribute( "success" ));
+        StateMachine sm = new StateMachine(new State[] { s1, s2 }, "s1");
+        sm.handle(new Event("foo", context));
+        assertEquals(true, context.getAttribute("success"));
     }
     
-    public void testBreakAndGotoNext() throws Exception
-    {
-        State s1 = new State( "s1" );
-        State s2 = new State( "s2" );
-        s1.addTransition( new BreakAndGotoNextTransition( "foo", "s2" ) );
-        s2.addTransition( new SuccessTransition( "foo" ) );
-        
+    public void testBreakAndGotoNext() throws Exception {
+        State s1 = new State("s1");
+        State s2 = new State("s2");
+        s1.addTransition(new BreakAndGotoNextTransition("foo", "s2"));
+        s2.addTransition(new SuccessTransition("foo"));
+
         StateContext context = new DefaultStateContext();
-        StateMachine sm = new StateMachine( new State[] { s1, s2 }, "s1" );
-        sm.handle( new Event( "foo", context ) );
-        assertSame( s2, context.getCurrentState() );
-        sm.handle( new Event( "foo", context ) );
-        assertEquals( true, context.getAttribute( "success" ));
+        StateMachine sm = new StateMachine(new State[] { s1, s2 }, "s1");
+        sm.handle(new Event("foo", context));
+        assertSame(s2, context.getCurrentState());
+        sm.handle(new Event("foo", context));
+        assertEquals(true, context.getAttribute("success"));
     }
-    
-    private static class SuccessTransition extends AbstractTransition
-    {
-        public SuccessTransition( Object eventId )
-        {
-            super( eventId );
-        }
-        
-        public SuccessTransition( Object eventId, State nextState )
-        {
-            super( eventId, nextState );
+
+    private static class SuccessTransition extends AbstractTransition {
+        public SuccessTransition(Object eventId) {
+            super(eventId);
+        }
+
+        public SuccessTransition(Object eventId, State nextState) {
+            super(eventId, nextState);
         }
 
         @Override
-        protected boolean doExecute( Event event )
-        {
-            event.getContext().setAttribute( "success", true );
+        protected boolean doExecute(Event event) {
+            event.getContext().setAttribute("success", true);
             return true;
         }
     }
     
-    private static class BreakAndContinueTransition extends AbstractTransition
-    {
-        public BreakAndContinueTransition( Object eventId )
-        {
-            super( eventId );
-        }
-        
-        public BreakAndContinueTransition( Object eventId, State nextState )
-        {
-            super( eventId, nextState );
+    private static class BreakAndContinueTransition extends AbstractTransition {
+        public BreakAndContinueTransition(Object eventId) {
+            super(eventId);
+        }
+
+        public BreakAndContinueTransition(Object eventId, State nextState) {
+            super(eventId, nextState);
         }
 
         @Override
-        protected boolean doExecute( Event event )
-        {
+        protected boolean doExecute(Event event) {
             StateControl.breakAndContinue();
             return true;
         }
     }
     
-    private static class BreakAndGotoNowTransition extends AbstractTransition
-    {
+    private static class BreakAndGotoNowTransition extends AbstractTransition {
         private final String stateId;
-        public BreakAndGotoNowTransition( Object eventId, String stateId )
-        {
-            super( eventId );
+
+        public BreakAndGotoNowTransition(Object eventId, String stateId) {
+            super(eventId);
             this.stateId = stateId;
         }
-        
-        public BreakAndGotoNowTransition( Object eventId, State nextState, String stateId )
-        {
-            super( eventId, nextState );
+
+        public BreakAndGotoNowTransition(Object eventId, State nextState, String stateId) {
+            super(eventId, nextState);
             this.stateId = stateId;
         }
 
         @Override
-        protected boolean doExecute( Event event )
-        {
-            StateControl.breakAndGotoNow( stateId );
+        protected boolean doExecute(Event event) {
+            StateControl.breakAndGotoNow(stateId);
             return true;
         }
     }
-    
-    private static class BreakAndGotoNextTransition extends AbstractTransition
-    {
+
+    private static class BreakAndGotoNextTransition extends AbstractTransition {
         private final String stateId;
-        public BreakAndGotoNextTransition( Object eventId, String stateId )
-        {
-            super( eventId );
+
+        public BreakAndGotoNextTransition(Object eventId, String stateId) {
+            super(eventId);
             this.stateId = stateId;
         }
-        
-        public BreakAndGotoNextTransition( Object eventId, State nextState, String stateId )
-        {
-            super( eventId, nextState );
+
+        public BreakAndGotoNextTransition(Object eventId, State nextState, String stateId) {
+            super(eventId, nextState);
             this.stateId = stateId;
         }
 
         @Override
-        protected boolean doExecute( Event event )
-        {
-            StateControl.breakAndGotoNext( stateId );
+        protected boolean doExecute(Event event) {
+            StateControl.breakAndGotoNext(stateId);
             return true;
         }
-    }    
+    }
 }

Modified: mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateTest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateTest.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateTest.java (original)
+++ mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/StateTest.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
 /*
- *   @(#) $Id$
- *
- *   Copyright 2004 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.
+ *  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.mina.sm;
@@ -25,70 +26,61 @@
 /**
  * Tests {@link FsmState}.
  *
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
  * @version $Rev$, $Date$
  */
-public class StateTest extends RMockTestCase
-{
+public class StateTest extends RMockTestCase {
     State state;
     Transition transition1;
     Transition transition2;
     Transition transition3;
     
-    protected void setUp() throws Exception
-    {
-        state = new State( "test" );
-        transition1 = ( Transition ) mock( Transition.class );
-        transition2 = ( Transition ) mock( Transition.class );
-        transition3 = ( Transition ) mock( Transition.class );
+    protected void setUp() throws Exception {
+        state = new State("test");
+        transition1 = (Transition) mock(Transition.class);
+        transition2 = (Transition) mock(Transition.class);
+        transition3 = (Transition) mock(Transition.class);
     }
 
-    public void testAddFirstTransition() throws Exception
-    {
-        assertTrue( state.getTransitions().isEmpty() );
-        state.addTransition( transition1 );
-        assertFalse( state.getTransitions().isEmpty() );
-        assertEquals( 1, state.getTransitions().size() );
-        assertSame( transition1, state.getTransitions().get( 0 ) );
+    public void testAddFirstTransition() throws Exception {
+        assertTrue(state.getTransitions().isEmpty());
+        state.addTransition(transition1);
+        assertFalse(state.getTransitions().isEmpty());
+        assertEquals(1, state.getTransitions().size());
+        assertSame(transition1, state.getTransitions().get(0));
     }
-    
-    public void testUnweightedTransitions() throws Exception
-    {
-        assertTrue( state.getTransitions().isEmpty() );
-        state.addTransition( transition1 );
-        state.addTransition( transition2 );
-        state.addTransition( transition3 );
-        assertEquals( 3, state.getTransitions().size() );
-        assertSame( transition1, state.getTransitions().get( 0 ) );
-        assertSame( transition2, state.getTransitions().get( 1 ) );
-        assertSame( transition3, state.getTransitions().get( 2 ) );
+
+    public void testUnweightedTransitions() throws Exception {
+        assertTrue(state.getTransitions().isEmpty());
+        state.addTransition(transition1);
+        state.addTransition(transition2);
+        state.addTransition(transition3);
+        assertEquals(3, state.getTransitions().size());
+        assertSame(transition1, state.getTransitions().get(0));
+        assertSame(transition2, state.getTransitions().get(1));
+        assertSame(transition3, state.getTransitions().get(2));
     }
     
-    public void testWeightedTransitions() throws Exception
-    {
-        assertTrue( state.getTransitions().isEmpty() );
-        state.addTransition( transition1, 10 );
-        state.addTransition( transition2, 5 );
-        state.addTransition( transition3, 7 );
-        assertEquals( 3, state.getTransitions().size() );
-        assertSame( transition2, state.getTransitions().get( 0 ) );
-        assertSame( transition3, state.getTransitions().get( 1 ) );
-        assertSame( transition1, state.getTransitions().get( 2 ) );
+    public void testWeightedTransitions() throws Exception {
+        assertTrue(state.getTransitions().isEmpty());
+        state.addTransition(transition1, 10);
+        state.addTransition(transition2, 5);
+        state.addTransition(transition3, 7);
+        assertEquals(3, state.getTransitions().size());
+        assertSame(transition2, state.getTransitions().get(0));
+        assertSame(transition3, state.getTransitions().get(1));
+        assertSame(transition1, state.getTransitions().get(2));
     }
-    
-    public void testAddTransitionReturnsSelf() throws Exception
-    {
-        assertSame( state, state.addTransition( transition1 ) );
+
+    public void testAddTransitionReturnsSelf() throws Exception {
+        assertSame(state, state.addTransition(transition1));
     }
-    
-    public void testAddNullTransitionThrowsException() throws Exception
-    {
-        try
-        {
-            state.addTransition( null );
-            fail( "null transition added. NullPointerException expected." );
-        }
-        catch (NullPointerException npe) {
+
+    public void testAddNullTransitionThrowsException() throws Exception {
+        try {
+            state.addTransition(null);
+            fail("null transition added. NullPointerException expected.");
+        } catch (NullPointerException npe) {
         }
     }
     

Modified: mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/context/AbstractStateContextLookupTest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/context/AbstractStateContextLookupTest.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/context/AbstractStateContextLookupTest.java (original)
+++ mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/context/AbstractStateContextLookupTest.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
 /*
- *   @(#) $Id$
- *
- *   Copyright 2004 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.
+ *  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.mina.sm.context;
@@ -26,7 +27,7 @@
 /**
  * Tests {@link AbstractStateContextLookup}.
  *
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
  * @version $Rev$, $Date$
  */
 public class AbstractStateContextLookupTest extends TestCase {

Modified: mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/transition/MethodTransitionTest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/transition/MethodTransitionTest.java?rev=586063&r1=586062&r2=586063&view=diff
==============================================================================
--- mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/transition/MethodTransitionTest.java (original)
+++ mina/sandbox/niklas/mina-sm/src/test/java/org/apache/mina/sm/transition/MethodTransitionTest.java Thu Oct 18 11:39:46 2007
@@ -1,19 +1,20 @@
 /*
- *   @(#) $Id$
- *
- *   Copyright 2004 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.
+ *  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.mina.sm.transition;
@@ -30,7 +31,7 @@
 /**
  * Tests {@link MethodTransition}.
  *
- * @author The Apache Directory Project (mina-dev@directory.apache.org)
+ * @author The Apache MINA Project (dev@mina.apache.org)
  * @version $Rev$, $Date$
  */
 public class MethodTransitionTest extends RMockTestCase {