Skip to Content.
Sympa Menu

notify-dpml - r876 - trunk/main/metro/state/impl/src/test/net/dpml/state/test

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r876 - trunk/main/metro/state/impl/src/test/net/dpml/state/test
  • Date: Sun, 8 Jan 2006 14:03:04 +0100

Author: mcconnell
Date: 2006-01-08 14:03:00 +0100 (Sun, 08 Jan 2006)
New Revision: 876

Modified:

trunk/main/metro/state/impl/src/test/net/dpml/state/test/AbstractEncodingTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultOperationTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTransitionTestCase.java

trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTriggerTestCase.java
Log:
complete cleanup of metro/state/impl

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/AbstractEncodingTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/AbstractEncodingTestCase.java
2006-01-08 07:10:35 UTC (rev 875)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/AbstractEncodingTestCase.java
2006-01-08 13:03:00 UTC (rev 876)
@@ -23,31 +23,32 @@
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.beans.Encoder;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.beans.ExceptionListener;
import java.beans.Expression;
-import java.beans.PersistenceDelegate;
import java.beans.DefaultPersistenceDelegate;
import java.net.URI;

import junit.framework.TestCase;

-import net.dpml.state.State;
-import net.dpml.state.impl.DefaultState;
-
/**
- * EntryDescriptorTestCase does XYZ
+ * AbstractEncodingTestCase.
*
* @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
* @version $Id: EntryDescriptorTestCase.java 2387 2005-04-23 19:12:58Z
mcconnell AT dpml.net $
*/
public abstract class AbstractEncodingTestCase extends TestCase
{
+ /**
+ * Utility operation to validate encoding and decoding of a supplied
object.
+ * @param object the enject to encode and decode
+ * @param filename a file path relative to the test directory to which
+ * interim encoded data will be written to
+ * @return the object resulting from the decode of the interim file
+ * @exception Exception if an error occurs
+ */
public Object executeEncodingTest( Object object, String filename )
throws Exception
{
String base = System.getProperty( "project.test.dir" );
@@ -77,13 +78,22 @@
return result;
}

+ /**
+ * Utility persistence delegate used to handle uri encoding.
+ */
public static class URIPersistenceDelegate extends
DefaultPersistenceDelegate
{
+ /**
+ * Create an expression instance for a supplied uri.
+ * @param old the old uri
+ * @param encoder the encoder
+ * @return the expression
+ */
public Expression instantiate( Object old, Encoder encoder )
{
URI uri = (URI) old;
String spec = uri.toString();
- Object[] args = new Object[]{ spec };
+ Object[] args = new Object[]{spec};
return new Expression( old, old.getClass(), "new", args );
}
}

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultOperationTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultOperationTestCase.java
2006-01-08 07:10:35 UTC (rev 875)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultOperationTestCase.java
2006-01-08 13:03:00 UTC (rev 876)
@@ -18,21 +18,11 @@

package net.dpml.state.test;

-import java.io.File;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.List;
+import net.dpml.state.Operation;
+import net.dpml.state.impl.DefaultOperation;

-import junit.framework.TestCase;
-
-import net.dpml.state.*;
-import net.dpml.state.impl.*;
-
/**
- * State testcase.
+ * DefaultOperationTestCase.
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
@@ -41,17 +31,29 @@
private String m_name;
private Operation m_operation;

+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
public void setUp() throws Exception
{
m_name = "test";
m_operation = new DefaultOperation( m_name );
}

+ /**
+ * Test name accessor.
+ * @exception Exception if an error occurs
+ */
public void testName() throws Exception
{
assertEquals( "name", m_name, m_operation.getName() );
}

+ /**
+ * Test that the constructor throws an NPE if supplied with a null name.
+ * @exception Exception if an error occurs
+ */
public void testNullName() throws Exception
{
try
@@ -65,6 +67,10 @@
}
}

+ /**
+ * Test encoding/decoding of an operation instance.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
Operation operation = (Operation) executeEncodingTest( m_operation,
"simple-operation-encoded.xml" );

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
2006-01-08 07:10:35 UTC (rev 875)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateMachineTestCase.java
2006-01-08 13:03:00 UTC (rev 876)
@@ -21,25 +21,30 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.BufferedInputStream;
-import java.net.URI;
import java.util.ArrayList;
import java.util.List;

-import junit.framework.TestCase;
+import net.dpml.state.State;
+import net.dpml.state.Transition;
+import net.dpml.state.Operation;
+import net.dpml.state.Trigger;
+import net.dpml.state.Action;
+import net.dpml.state.impl.DefaultStateMachine;

-import net.dpml.state.*;
-import net.dpml.state.impl.*;
-
/**
- * State testcase.
+ * Default state machine test-case.
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
public class DefaultStateMachineTestCase extends AbstractEncodingTestCase
{
- State m_state;
- DefaultStateMachine m_machine;
+ private State m_state;
+ private DefaultStateMachine m_machine;

+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
public void setUp() throws Exception
{
String testPath = System.getProperty( "project.test.dir" );
@@ -63,16 +68,28 @@
}
}

+ /**
+ * List the state graph.
+ * @exception Exception if an error occurs
+ */
public void testAudit() throws Exception
{
audit( m_state );
}

+ /**
+ * Test state machine validation function.
+ * @exception Exception if an error occurs
+ */
public void testValidation() throws Exception
{
DefaultStateMachine.validate( m_state );
}

+ /**
+ * Test state machine initialization and termination internal state
integrity.
+ * @exception Exception if an error occurs
+ */
public void testExecution() throws Exception
{
// check that the termination action is null
@@ -153,9 +170,12 @@

m_machine.terminate( null );
assertEquals( "terminated-state-name", "terminated",
m_machine.getState().getName() );
-
}

+ /**
+ * Test illegal attempt to initialize a disposed state machine.
+ * @exception Exception if an error occurs
+ */
public void testInitializationInDisposed() throws Exception
{
m_machine.dispose();
@@ -170,6 +190,10 @@
}
}

+ /**
+ * Test illegal attempt to terminate a disposed state machine.
+ * @exception Exception if an error occurs
+ */
public void testTerminationInDisposed() throws Exception
{
m_machine.dispose();
@@ -184,6 +208,10 @@
}
}

+ /**
+ * Test encoding of a state graph.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
Object state = executeEncodingTest( m_state, "state-encoded.xml" );
@@ -214,7 +242,7 @@
Trigger trigger = triggers[i];
System.out.println(
pad + "# trigger "
- + "(" + (i+1) + "): ["
+ + "(" + ( i+1 ) + "): ["
+ trigger.toString()
+ "]" );
}
@@ -224,7 +252,7 @@
Transition transition = transitions[i];
System.out.println(
pad + "# transition "
- + "(" + (i+1) + "): ["
+ + "(" + ( i+1 ) + "): ["
+ transition.getName()
+ "] --> [" + transition.getTargetName()
+ "]" );
@@ -235,7 +263,7 @@
Operation operation = operations[i];
System.out.println(
pad + "# operation "
- + "(" + (i+1) + "): ["
+ + "(" + ( i+1 ) + "): ["
+ operation.getName()
+ "]" );
}

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
2006-01-08 07:10:35 UTC (rev 875)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultStateTestCase.java
2006-01-08 13:03:00 UTC (rev 876)
@@ -18,21 +18,16 @@

package net.dpml.state.test;

-import java.io.File;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.List;
+import net.dpml.state.State;
+import net.dpml.state.Transition;
+import net.dpml.state.Operation;
+import net.dpml.state.Trigger;
+import net.dpml.state.impl.DefaultOperation;
+import net.dpml.state.impl.DefaultTransition;
+import net.dpml.state.impl.DefaultState;

-import junit.framework.TestCase;
-
-import net.dpml.state.*;
-import net.dpml.state.impl.*;
-
/**
- * State testcase.
+ * Default state test-case.
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
@@ -45,6 +40,10 @@
private Trigger[] m_triggers;
private State m_state;

+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
public void setUp() throws Exception
{
m_name = "test";
@@ -73,37 +72,65 @@
m_name, m_triggers, m_transitions, m_operations, m_states );
}

+ /**
+ * Test name accessor.
+ * @exception Exception if an error occurs
+ */
public void testState() throws Exception
{
assertEquals( "name", m_name, m_state.getName() );
}

+ /**
+ * Test triggers accessor.
+ * @exception Exception if an error occurs
+ */
public void testTriggers() throws Exception
{
assertEquals( "triggers", m_triggers, m_state.getTriggers() );
}

+ /**
+ * Test transitions accessor.
+ * @exception Exception if an error occurs
+ */
public void testTransitions() throws Exception
{
assertEquals( "transitions", m_transitions, m_state.getTransitions()
);
}

+ /**
+ * Test operations accessor.
+ * @exception Exception if an error occurs
+ */
public void testOperations() throws Exception
{
assertEquals( "operations", m_operations, m_state.getOperations() );
}

+ /**
+ * Test states accessor.
+ * @exception Exception if an error occurs
+ */
public void testStates() throws Exception
{
assertEquals( "states", m_states, m_state.getStates() );
}

+ /**
+ * Test states encoding/decoding.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
State state = (State) executeEncodingTest( m_state,
"simple-state-encoded.xml" );
assertEquals( "origin-equals-encoded", m_state, state );
}

+ /**
+ * Test terminal falg accessor.
+ * @exception Exception if an error occurs
+ */
public void testTerminalState() throws Exception
{
State state = new DefaultState( "terminal" );

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTransitionTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTransitionTestCase.java
2006-01-08 07:10:35 UTC (rev 875)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTransitionTestCase.java
2006-01-08 13:03:00 UTC (rev 876)
@@ -18,21 +18,13 @@

package net.dpml.state.test;

-import java.io.File;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.List;
+import net.dpml.state.Operation;
+import net.dpml.state.Transition;
+import net.dpml.state.impl.DefaultTransition;
+import net.dpml.state.impl.DefaultOperation;

-import junit.framework.TestCase;
-
-import net.dpml.state.*;
-import net.dpml.state.impl.*;
-
/**
- * State testcase.
+ * Default transition test-case.
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
@@ -43,6 +35,10 @@
private String m_target;
private Transition m_transition;

+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
public void setUp() throws Exception
{
m_name = "test";
@@ -51,27 +47,47 @@
m_transition = new DefaultTransition( m_name, m_target, m_operation
);
}

+ /**
+ * Test name accessor.
+ * @exception Exception if an error occurs
+ */
public void testName() throws Exception
{
assertEquals( "name", m_name, m_transition.getName() );
}

+ /**
+ * Test target name accessor.
+ * @exception Exception if an error occurs
+ */
public void testTargetName() throws Exception
{
assertEquals( "target", m_target, m_transition.getTargetName() );
}

+ /**
+ * Test operation accessor.
+ * @exception Exception if an error occurs
+ */
public void testOperation() throws Exception
{
assertEquals( "operation", m_operation, m_transition.getOperation()
);
}

+ /**
+ * Test transition encoding.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
Transition transition = (Transition) executeEncodingTest(
m_transition, "simple-transition-encoded.xml" );
assertEquals( "original-equals-encoded", m_transition, transition );
}

+ /**
+ * Test null constructor arguments.
+ * @exception Exception if an error occurs
+ */
public void testNulls() throws Exception
{
try
@@ -83,6 +99,14 @@
{
// ok
}
+ }
+
+ /**
+ * Test null name constructor arguments.
+ * @exception Exception if an error occurs
+ */
+ public void testNullName() throws Exception
+ {
try
{
new DefaultTransition( null, m_target, m_operation );
@@ -92,6 +116,14 @@
{
// ok
}
+ }
+
+ /**
+ * Test null target constructor arguments.
+ * @exception Exception if an error occurs
+ */
+ public void testNullTarget() throws Exception
+ {
try
{
new DefaultTransition( m_name, null, m_operation );
@@ -101,6 +133,14 @@
{
// ok
}
+ }
+
+ /**
+ * Test allowable null operation constructor arguments.
+ * @exception Exception if an error occurs
+ */
+ public void testNullOperation() throws Exception
+ {
try
{
new DefaultTransition( m_name, m_target, null );

Modified:
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTriggerTestCase.java
===================================================================
---
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTriggerTestCase.java
2006-01-08 07:10:35 UTC (rev 875)
+++
trunk/main/metro/state/impl/src/test/net/dpml/state/test/DefaultTriggerTestCase.java
2006-01-08 13:03:00 UTC (rev 876)
@@ -18,23 +18,14 @@

package net.dpml.state.test;

-import java.io.File;
-import java.io.FileInputStream;
-import java.io.BufferedInputStream;
-import java.net.URI;
-import java.util.Arrays;
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import net.dpml.state.*;
+import net.dpml.state.Action;
import net.dpml.state.Trigger;
import net.dpml.state.Trigger.TriggerEvent;
-import net.dpml.state.impl.*;
+import net.dpml.state.impl.DefaultOperation;
+import net.dpml.state.impl.DefaultTrigger;

/**
- * State testcase.
+ * Default trigger test-case.
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
*/
@@ -44,6 +35,10 @@
private Action m_action;
private Trigger m_trigger;

+ /**
+ * Testcase setup.
+ * @exception Exception if a setup error occurs
+ */
public void setUp() throws Exception
{
m_event = Trigger.INITIALIZATION;
@@ -51,22 +46,38 @@
m_trigger = new DefaultTrigger( m_event, m_action );
}

+ /**
+ * Test event accessor.
+ * @exception Exception if an error occurs
+ */
public void testEvent() throws Exception
{
assertEquals( "event", m_event, m_trigger.getEvent() );
}

+ /**
+ * Test action accessor.
+ * @exception Exception if an error occurs
+ */
public void testAction() throws Exception
{
assertEquals( "action", m_action, m_trigger.getAction() );
}

+ /**
+ * Test trigger encoding/decoding.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
Trigger trigger = (Trigger) executeEncodingTest( m_trigger,
"simple-trigger-encoded.xml" );
assertEquals( "original-equals-encoded", m_trigger, trigger );
}

+ /**
+ * Test that the constructor throws an NPE if supplied with null
arguments.
+ * @exception Exception if an error occurs
+ */
public void testNulls() throws Exception
{
try
@@ -78,6 +89,14 @@
{
// ok
}
+ }
+
+ /**
+ * Test that the constructor throws an NPE if supplied with a null name.
+ * @exception Exception if an error occurs
+ */
+ public void testNullName() throws Exception
+ {
try
{
new DefaultTrigger( null, m_action );
@@ -87,6 +106,14 @@
{
// ok
}
+ }
+
+ /**
+ * Test that the constructor throws an NPE if supplied with a null target.
+ * @exception Exception if an error occurs
+ */
+ public void testNullTrigger() throws Exception
+ {
try
{
new DefaultTrigger( m_event, null );




  • r876 - trunk/main/metro/state/impl/src/test/net/dpml/state/test, mcconnell at BerliOS, 01/08/2006

Archive powered by MHonArc 2.6.24.

Top of Page