Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2093 - in development/planet/users/niclas/processing: . api/src/main/net/dpml/processing controller/etc/test controller/src/main/net/dpml/processing/controller controller/src/test test test/src test/src/main test/src/main/net test/src/main/net/dpml test/src/main/net/dpml/processing test/src/main/net/dpml/processing/controller test/src/main/net/dpml/processing/controller/test test/src/test test/src/test/net test/src/test/net/dpml test/src/test/net/dpml/processing test/src/test/net/dpml/processing/controller test/src/test/net/dpml/processing/controller/test

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT hedhman.org
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2093 - in development/planet/users/niclas/processing: . api/src/main/net/dpml/processing controller/etc/test controller/src/main/net/dpml/processing/controller controller/src/test test test/src test/src/main test/src/main/net test/src/main/net/dpml test/src/main/net/dpml/processing test/src/main/net/dpml/processing/controller test/src/main/net/dpml/processing/controller/test test/src/test test/src/test/net test/src/test/net/dpml test/src/test/net/dpml/processing test/src/test/net/dpml/processing/controller test/src/test/net/dpml/processing/controller/test
  • Date: Sat, 19 Mar 2005 19:09:02 -0500

Author: niclas AT hedhman.org
Date: Sat Mar 19 19:09:01 2005
New Revision: 2093

Added:
development/planet/users/niclas/processing/test/
development/planet/users/niclas/processing/test/build.xml (contents,
props changed)
development/planet/users/niclas/processing/test/src/
development/planet/users/niclas/processing/test/src/main/
development/planet/users/niclas/processing/test/src/main/net/
development/planet/users/niclas/processing/test/src/main/net/dpml/

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/ExceptionGenerator.java
(contents, props changed)

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/ExceptionStep.java
(contents, props changed)

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/LastExceptionStep.java
(contents, props changed)

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/Start.java
(contents, props changed)

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/Step.java
(contents, props changed)

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/Tracking.java
(contents, props changed)

development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/TrackingImpl.java
(contents, props changed)
development/planet/users/niclas/processing/test/src/test/
development/planet/users/niclas/processing/test/src/test/net/
development/planet/users/niclas/processing/test/src/test/net/dpml/

development/planet/users/niclas/processing/test/src/test/net/dpml/processing/

development/planet/users/niclas/processing/test/src/test/net/dpml/processing/controller/

development/planet/users/niclas/processing/test/src/test/net/dpml/processing/controller/test/

development/planet/users/niclas/processing/test/src/test/net/dpml/processing/controller/test/ExitPointTest.java
(contents, props changed)

development/planet/users/niclas/processing/test/src/test/net/dpml/processing/controller/test/NestedControllerTest.java
(contents, props changed)
Removed:
development/planet/users/niclas/processing/controller/src/test/
Modified:

development/planet/users/niclas/processing/api/src/main/net/dpml/processing/ProcessActivity.java
development/planet/users/niclas/processing/controller/etc/test/nested.block

development/planet/users/niclas/processing/controller/src/main/net/dpml/processing/controller/ExitPoint.java

development/planet/users/niclas/processing/controller/src/main/net/dpml/processing/controller/NestedController.java
development/planet/users/niclas/processing/index.xml
Log:
Processing nested and tested.

Modified:
development/planet/users/niclas/processing/api/src/main/net/dpml/processing/ProcessActivity.java
==============================================================================
---
development/planet/users/niclas/processing/api/src/main/net/dpml/processing/ProcessActivity.java
(original)
+++
development/planet/users/niclas/processing/api/src/main/net/dpml/processing/ProcessActivity.java
Sat Mar 19 19:09:01 2005
@@ -109,4 +109,13 @@
* outcomes.
*/
String getDescription( Locale locale );
+
+ /** Marks whether this ProcessActivity is an <i>exit point</i> or not.
+ * <p>
+ * This method should normally return false for all
<code>ProcessActivity</code>
+ * implementations.
+ * </p>
+ * @return true if this ProcessActivity is an <i>exit point</i>
+ */
+ boolean isExitPoint();
}
\ No newline at end of file

Modified:
development/planet/users/niclas/processing/controller/etc/test/nested.block
==============================================================================
---
development/planet/users/niclas/processing/controller/etc/test/nested.block
(original)
+++
development/planet/users/niclas/processing/controller/etc/test/nested.block
Sat Mar 19 19:09:01 2005
@@ -6,66 +6,13 @@

<classloader>
<classpath>
+ <fileset dir=".">
+ <include name="../test-classes/" />
+ <include name="../classes/" />
+ </fileset>
</classpath>
</classloader>

- <component name="tracking"
class="net.dpml.processing.controller.test.TrackingImpl" />
-
- <component name="nested"
class="net.dpml.processing.controller.NestedController" >
- <dependencies>
- <dependency key="initial-activity" source="start" />
- <dependency key="exception-path" source="exception" />
- <dependency key="recover-point" source="step3" />
- </dependencies>
- </component>
-
- <component name="start"
class="net.dpml.processing.controller.test.Start" >
- <dependencies>
- <dependency key="outcome1" source="step1" />
- <dependency key="outcome2" source="step2" />
- <dependency key="outcome3" source="step3" />
- </dependencies>
- </component>
-
- <component name="step1" class="net.dpml.processing.controller.test.Step"
>
- <dependencies>
- <dependency key="outcome" source="step3" />
- </dependencies>
- </component>
-
- <component name="step2" class="net.dpml.processing.controller.test.Step"
>
- <dependencies>
- <dependency key="outcome" source="step3" />
- </dependencies>
- </component>
-
- <component name="step3" class="net.dpml.processing.controller.test.Step"
>
- <dependencies>
- <dependency key="outcome" source="exit" />
- </dependencies>
- </component>
-
- <component name="exit" class="net.dpml.processing.controller.ExitPoint"
/>
-
- <component name="exception"
class="net.dpml.processing.controller.test.ExceptionStep" >
- <dependencies>
- <dependency key="oneMore" source="onemore" />
- </dependencies>
- </component>
-
- <component name="notused"
class="net.dpml.processing.controller.test.ExceptionStep" >
- <dependencies>
- <dependency key="oneMore" source="onemore" />
- </dependencies>
- </component>
-
- <component name="onemore"
class="net.dpml.processing.controller.test.LastExceptionStep" >
- <dependencies>
- <dependency key="exit" source="exitException" />
- </dependencies>
- </component>
-
- <component name="exitException"
class="net.dpml.processing.controller.ExitPoint" />

</container>


Modified:
development/planet/users/niclas/processing/controller/src/main/net/dpml/processing/controller/ExitPoint.java
==============================================================================
---
development/planet/users/niclas/processing/controller/src/main/net/dpml/processing/controller/ExitPoint.java
(original)
+++
development/planet/users/niclas/processing/controller/src/main/net/dpml/processing/controller/ExitPoint.java
Sat Mar 19 19:09:01 2005
@@ -128,4 +128,20 @@
return bundle.getString( "description" );
}

+ /** Marks whether this ProcessActivity is an <i>exit point</i> or not.
+ * <p>
+ * This method should normally return false for all
<code>ProcessActivity</code>
+ * implementations.
+ * </p>
+ * @return true if this ProcessActivity is an <i>exit point</i>
+ */
+ public boolean isExitPoint()
+ {
+ return true;
+ }
+
+ public String toString()
+ {
+ return "ExitPoint[" + m_name + "]";
+ }
}

Modified:
development/planet/users/niclas/processing/controller/src/main/net/dpml/processing/controller/NestedController.java
==============================================================================
---
development/planet/users/niclas/processing/controller/src/main/net/dpml/processing/controller/NestedController.java
(original)
+++
development/planet/users/niclas/processing/controller/src/main/net/dpml/processing/controller/NestedController.java
Sat Mar 19 19:09:01 2005
@@ -29,6 +29,8 @@
import net.dpml.context.Context;
import net.dpml.context.ContextException;

+import net.dpml.logging.Logger;
+
import net.dpml.parameters.Parameters;

import net.dpml.processing.ProcessActivity;
@@ -159,6 +161,7 @@
private ProcessActivity m_recoverPoint;
private ContainmentModel m_grandparentContainer;
private String m_name;
+ private Logger m_logger;

/**
* @metro.entry key="urn:composition:containment.model"
@@ -181,17 +184,20 @@
* @exception ContextException is declared but can only happen if the
container
* is malfunctioning, or the xinfo of the component has been
corrupted.
*/
- public NestedController( Context ctx, ServiceManager man, Parameters
params )
+ public NestedController( Logger logger, Context ctx, ServiceManager man,
Parameters params )
throws ServiceException, ModelException, ContextException
{
+ m_logger = logger;
m_name = (String) ctx.get( "urn:metro:name" );
String path = (String) ctx.get( "urn:metro:partition" );
int lastSlash = path.lastIndexOf( "/" );
- lastSlash = path.lastIndexOf( "/", lastSlash );
+ lastSlash = path.lastIndexOf( "/", lastSlash - 1 );

try
{
- path = path.substring( lastSlash );
+ path = path.substring( 0, lastSlash );
+ if( "".equals( path ) )
+ path = "/";
} catch( IndexOutOfBoundsException e )
{
throw new ModelException( "This component must be located in a
container of a container." );
@@ -235,12 +241,12 @@
try
{
next = next.process();
- if( next instanceof ExitPoint )
+ if( next.isExitPoint() )
{
- ExitPoint p = (ExitPoint) next;
- String name = p.getName();
-
+ String name = next.getName();
+ System.out.println( "Return to:" + name );
DeploymentModel dp = m_grandparentContainer.getModel(
name );
+ System.out.println( "Return to:" + dp );
if( dp == null )
return null;

@@ -251,7 +257,13 @@
} catch( Exception e )
{
if( m_exceptionPath != null )
+ {
+ String name = null;
+ if( next != null )
+ name = next.getName();
+ m_logger.warn( "Exception in activity: " + name, e );
next = processExceptionPath();
+ }
else
throw e;
}
@@ -266,7 +278,7 @@
while( true )
{
next = next.process();
- if( next instanceof ExitPoint )
+ if( next.isExitPoint() )
return m_recoverPoint;
}
}
@@ -311,4 +323,16 @@
ResourceBundle bundle = ResourceBundle.getBundle( base, locale,
classloader );
return bundle.getString( "description" );
}
+
+ /** Marks whether this ProcessActivity is an <i>exit point</i> or not.
+ * <p>
+ * This method should normally return false for all
<code>ProcessActivity</code>
+ * implementations.
+ * </p>
+ * @return true if this ProcessActivity is an <i>exit point</i>
+ */
+ public boolean isExitPoint()
+ {
+ return false;
+ }
}
\ No newline at end of file

Modified: development/planet/users/niclas/processing/index.xml
==============================================================================
--- development/planet/users/niclas/processing/index.xml (original)
+++ development/planet/users/niclas/processing/index.xml Sat Mar 19
19:09:01 2005
@@ -66,12 +66,47 @@
</plugins>
</project>

- <project basedir="docs" >
+ <project basedir="test" >
+ <info>
+ <name>dpml-processing-test</name>
+ <group>dpml/processing/test</group>
+ <version>1.0</version>
+ </info>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ <dependencies>
+ <include key="dpml-processing-api"/>
+ <include key="dpml-processing-controller"/>
+ <include key="dpml-metro-unit"/>
+ <include key="dpml-transit-main"/>
+ </dependencies>
+ </project>
+
+ <project basedir="nested-test" >
+ <info>
+ <name>dpml-processing-nestedtest</name>
+ <group>dpml/processing/test</group>
+ <version>1.0</version>
+ </info>
+ <plugins>
+ <include key="dpml-meta-tools" />
+ </plugins>
+ <dependencies>
+ <include key="dpml-processing-api"/>
+ <include key="dpml-processing-controller"/>
+ <include key="dpml-processing-test"/>
+ <include key="dpml-metro-unit"/>
+ <include key="dpml-transit-main"/>
+ </dependencies>
+ </project>
+
+ <!-- project basedir="docs" >
<info>
<name>dpml-processing-docs</name>
<group>dpml/processing/docs</group>
<version>1.0</version>
</info>
- </project>
+ </project -->

</index>

Added: development/planet/users/niclas/processing/test/build.xml
==============================================================================
--- (empty file)
+++ development/planet/users/niclas/processing/test/build.xml Sat Mar 19
19:09:01 2005
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Copyright 2005 Niclas Hedhman
+
+ 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.
+-->
+
+<project name="dpml-processing-test" default="install" basedir="."
+ xmlns:transit="antlib:net.dpml.transit"
+ xmlns:x="plugin:dpml/magic/dpml-magic-core"
+>
+
+ <transit:import uri="artifact:template:dpml/magic/standard"/>
+
+ <target name="build" depends="standard.build">
+ <x:block name="main" embed="MAIN">
+ <x:service source="controller"
type="net.dpml.processing.ProcessActivity" />
+
+ <x:component name="tracking"
class="net.dpml.processing.controller.test.TrackingImpl" />
+
+ <x:component name="controller"
class="net.dpml.processing.controller.NestedController" >
+ <x:dependencies>
+ <x:dependency key="initial-activity" source="start" />
+ <x:dependency key="exception-path" source="exception" />
+ <x:dependency key="recover-point" source="step3" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="start"
class="net.dpml.processing.controller.test.Start" >
+ <x:dependencies>
+ <x:dependency key="outcome1" source="step1" />
+ <x:dependency key="outcome2" source="step2" />
+ <x:dependency key="outcome3" source="step3" />
+ <x:dependency key="outcome4" source="step4" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="step1"
class="net.dpml.processing.controller.test.Step" >
+ <x:dependencies>
+ <x:dependency key="outcome" source="step3" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="step2"
class="net.dpml.processing.controller.test.Step" >
+ <x:dependencies>
+ <x:dependency key="outcome" source="step3" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="step3"
class="net.dpml.processing.controller.test.Step" >
+ <x:dependencies>
+ <x:dependency key="outcome" source="main-succeeded" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="main-succeeded"
class="net.dpml.processing.controller.ExitPoint" />
+
+ <x:component name="step4"
class="net.dpml.processing.controller.test.ExceptionGenerator" >
+ <x:dependencies>
+ <x:dependency key="outcome" source="main-succeeded" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="exception"
class="net.dpml.processing.controller.test.ExceptionStep" >
+ <x:dependencies>
+ <x:dependency key="outcome" source="onemore" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="notused"
class="net.dpml.processing.controller.test.ExceptionStep" >
+ <x:dependencies>
+ <x:dependency key="outcome" source="onemore" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="onemore"
class="net.dpml.processing.controller.test.LastExceptionStep" >
+ <x:dependencies>
+ <x:dependency key="outcome" source="exitException" />
+ </x:dependencies>
+ </x:component>
+
+ <x:component name="exitException"
class="net.dpml.processing.controller.ExitPoint" />
+
+ </x:block>
+ </target>
+</project>

Added:
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/ExceptionGenerator.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/ExceptionGenerator.java
Sat Mar 19 19:09:01 2005
@@ -0,0 +1,100 @@
+/*
+ * Copyright 2005, Niclas Hedhman
+ *
+ * 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 net.dpml.processing.controller.test;
+
+import java.util.Locale;
+
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+
+import net.dpml.processing.ProcessActivity;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+
+/**
+ * @metro.component name="exception-generator" lifestyle="singleton"
+ * @metro.service type="net.dpml.processing.ProcessActivity"
+ */
+public class ExceptionGenerator
+ implements ProcessActivity
+{
+ private Tracking m_tracks;
+ private String m_name;
+ private String m_descr;
+ private ProcessActivity m_outcome;
+
+ /**
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ * @metro.entry key="urn:metro:partition"
+ * type="java.lang.String"
+ *
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome"
+ * @metro.dependency type="net.dpml.processing.controller.test.Tracking"
+ * key="tracking"
+ */
+ public ExceptionGenerator( Context ctx, ServiceManager man )
+ throws ServiceException, ContextException
+ {
+ m_tracks = (Tracking) man.lookup( "tracking" );
+ m_outcome = (ProcessActivity) man.lookup( "outcome" );
+ m_name = (String) ctx.get( "urn:metro:name" );
+ String partition = (String) ctx.get( "urn:metro:partition" );
+ m_descr = partition + m_name;
+ }
+
+ public ProcessActivity process()
+ throws Exception
+ {
+ System.out.println( this );
+ m_tracks.beenToLocation( this );
+ if( m_name != null )
+ throw new IllegalArgumentException();
+ return m_outcome;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "irrelevant";
+ }
+
+ /** Marks whether this ProcessActivity is an <i>exit point</i> or not.
+ * <p>
+ * This method should normally return false for all
<code>ProcessActivity</code>
+ * implementations.
+ * </p>
+ * @return true if this ProcessActivity is an <i>exit point</i>
+ */
+ public boolean isExitPoint()
+ {
+ return false;
+ }
+
+ public String toString()
+ {
+ return m_descr;
+ }
+}

Added:
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/ExceptionStep.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/ExceptionStep.java
Sat Mar 19 19:09:01 2005
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005, Niclas Hedhman
+ *
+ * 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 net.dpml.processing.controller.test;
+
+import java.util.Locale;
+
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+
+import net.dpml.processing.ProcessActivity;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+
+/**
+ * @metro.component name="exception-step" lifestyle="singleton"
+ * @metro.service type="net.dpml.processing.ProcessActivity"
+ */
+public class ExceptionStep
+ implements ProcessActivity
+{
+ private Tracking m_tracks;
+ private String m_descr;
+ private String m_name;
+ private ProcessActivity m_outcome;
+
+ /**
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ * @metro.entry key="urn:metro:partition"
+ * type="java.lang.String"
+ *
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome"
+ * @metro.dependency type="net.dpml.processing.controller.test.Tracking"
+ * key="tracking"
+ */
+ public ExceptionStep( Context ctx, ServiceManager man )
+ throws ServiceException, ContextException
+ {
+ m_tracks = (Tracking) man.lookup( "tracking" );
+ m_outcome = (ProcessActivity) man.lookup( "outcome" );
+ m_name = (String) ctx.get( "urn:metro:name" );
+ String partition = (String) ctx.get( "urn:metro:partition" );
+ m_descr = partition + m_name;
+ }
+
+ public ProcessActivity process()
+ throws Exception
+ {
+ System.out.println( this );
+ m_tracks.beenToLocation( this );
+ return m_outcome;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "irrelevant";
+ }
+
+ /** Marks whether this ProcessActivity is an <i>exit point</i> or not.
+ * <p>
+ * This method should normally return false for all
<code>ProcessActivity</code>
+ * implementations.
+ * </p>
+ * @return true if this ProcessActivity is an <i>exit point</i>
+ */
+ public boolean isExitPoint()
+ {
+ return false;
+ }
+
+ public String toString()
+ {
+ return m_descr;
+ }
+}

Added:
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/LastExceptionStep.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/LastExceptionStep.java
Sat Mar 19 19:09:01 2005
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005, Niclas Hedhman
+ *
+ * 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 net.dpml.processing.controller.test;
+
+import java.util.Locale;
+
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+
+import net.dpml.processing.ProcessActivity;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+
+/**
+ * @metro.component name="last-exception-step" lifestyle="singleton"
+ * @metro.service type="net.dpml.processing.ProcessActivity"
+ */
+public class LastExceptionStep
+ implements ProcessActivity
+{
+ private Tracking m_tracks;
+ private String m_name;
+ private String m_descr;
+ private ProcessActivity m_outcome;
+
+ /**
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ * @metro.entry key="urn:metro:partition"
+ * type="java.lang.String"
+ *
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome"
+ * @metro.dependency type="net.dpml.processing.controller.test.Tracking"
+ * key="tracking"
+ */
+ public LastExceptionStep( Context ctx, ServiceManager man )
+ throws ServiceException, ContextException
+ {
+ m_tracks = (Tracking) man.lookup( "tracking" );
+ m_outcome = (ProcessActivity) man.lookup( "outcome" );
+ m_name = (String) ctx.get( "urn:metro:name" );
+ String partition = (String) ctx.get( "urn:metro:partition" );
+ m_descr = partition + m_name;
+ }
+
+ public ProcessActivity process()
+ throws Exception
+ {
+ System.out.println( this );
+ m_tracks.beenToLocation( this );
+ return m_outcome;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "irrelevant";
+ }
+
+ /** Marks whether this ProcessActivity is an <i>exit point</i> or not.
+ * <p>
+ * This method should normally return false for all
<code>ProcessActivity</code>
+ * implementations.
+ * </p>
+ * @return true if this ProcessActivity is an <i>exit point</i>
+ */
+ public boolean isExitPoint()
+ {
+ return false;
+ }
+
+ public String toString()
+ {
+ return m_descr;
+ }
+}

Added:
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/Start.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/Start.java
Sat Mar 19 19:09:01 2005
@@ -0,0 +1,106 @@
+/*
+ * Copyright 2005, Niclas Hedhman
+ *
+ * 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 net.dpml.processing.controller.test;
+
+import java.util.Locale;
+
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+
+import net.dpml.processing.ProcessActivity;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+
+/**
+ * @metro.component name="start" lifestyle="singleton"
+ * @metro.service type="net.dpml.processing.ProcessActivity"
+ */
+public class Start
+ implements ProcessActivity
+{
+ private Tracking m_tracks;
+ private String m_name;
+ private String m_descr;
+ private ServiceManager m_serviceManager;
+
+ /**
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ * @metro.entry key="urn:metro:partition"
+ * type="java.lang.String"
+ *
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome1"
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome2" optional="true"
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome3" optional="true"
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome4" optional="true"
+ * @metro.dependency type="net.dpml.processing.controller.test.Tracking"
+ * key="tracking"
+ */
+ public Start( Context ctx, ServiceManager man )
+ throws ServiceException, ContextException
+ {
+ m_serviceManager = man;
+ m_tracks = (Tracking) man.lookup( "tracking" );
+ m_name = (String) ctx.get( "urn:metro:name" );
+ String partition = (String) ctx.get( "urn:metro:partition" );
+ m_descr = partition + m_name;
+ }
+
+ public ProcessActivity process()
+ throws Exception
+ {
+ String number = System.getProperty( "metro.processing.test.outcome"
);
+ ProcessActivity outcome = (ProcessActivity) m_serviceManager.lookup(
"outcome" + number.trim() );
+ System.out.println( this );
+ m_tracks.beenToLocation( this );
+ return outcome;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "irrelevant";
+ }
+
+ /** Marks whether this ProcessActivity is an <i>exit point</i> or not.
+ * <p>
+ * This method should normally return false for all
<code>ProcessActivity</code>
+ * implementations.
+ * </p>
+ * @return true if this ProcessActivity is an <i>exit point</i>
+ */
+ public boolean isExitPoint()
+ {
+ return false;
+ }
+
+ public String toString()
+ {
+ return m_descr;
+ }
+}

Added:
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/Step.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/Step.java
Sat Mar 19 19:09:01 2005
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2005, Niclas Hedhman
+ *
+ * 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 net.dpml.processing.controller.test;
+
+import java.util.Locale;
+
+import net.dpml.context.Context;
+import net.dpml.context.ContextException;
+
+import net.dpml.processing.ProcessActivity;
+
+import net.dpml.service.ServiceException;
+import net.dpml.service.ServiceManager;
+
+/**
+ * @metro.component name="step" lifestyle="singleton"
+ * @metro.service type="net.dpml.processing.ProcessActivity"
+ */
+public class Step
+ implements ProcessActivity
+{
+ private Tracking m_tracks;
+ private String m_name;
+ private String m_descr;
+ private ProcessActivity m_outcome;
+
+ /**
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ * @metro.entry key="urn:metro:partition"
+ * type="java.lang.String"
+ *
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome"
+ * @metro.dependency type="net.dpml.processing.controller.test.Tracking"
+ * key="tracking"
+ */
+ public Step( Context ctx, ServiceManager man )
+ throws ServiceException, ContextException
+ {
+ m_tracks = (Tracking) man.lookup( "tracking" );
+ m_outcome = (ProcessActivity) man.lookup( "outcome" );
+ m_name = (String) ctx.get( "urn:metro:name" );
+ String partition = (String) ctx.get( "urn:metro:partition" );
+ m_descr = partition + m_name;
+ }
+
+ public ProcessActivity process()
+ throws Exception
+ {
+ System.out.println( this );
+ m_tracks.beenToLocation( this );
+ return m_outcome;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "irrelevant";
+ }
+
+ /** Marks whether this ProcessActivity is an <i>exit point</i> or not.
+ * <p>
+ * This method should normally return false for all
<code>ProcessActivity</code>
+ * implementations.
+ * </p>
+ * @return true if this ProcessActivity is an <i>exit point</i>
+ */
+ public boolean isExitPoint()
+ {
+ return false;
+ }
+
+ public String toString()
+ {
+ return m_descr;
+ }
+}

Added:
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/Tracking.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/Tracking.java
Sat Mar 19 19:09:01 2005
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2005, Niclas Hedhman
+ *
+ * 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 net.dpml.processing.controller.test;
+
+import net.dpml.processing.ProcessActivity;
+
+/**
+ * @metro.service type="net.dpml.processing.controller.test.Tracking"
+ */
+public interface Tracking
+{
+ void beenToLocation( ProcessActivity identifier );
+
+ String[] getLocations();
+}

Added:
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/TrackingImpl.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/processing/test/src/main/net/dpml/processing/controller/test/TrackingImpl.java
Sat Mar 19 19:09:01 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005, Niclas Hedhman
+ *
+ * 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 net.dpml.processing.controller.test;
+
+import java.util.ArrayList;
+
+import net.dpml.processing.ProcessActivity;
+
+/**
+ * @metro.component name="tracking" lifestyle="singleton"
+ * @metro.service type="net.dpml.processing.controller.test.Tracking"
+ */
+public class TrackingImpl
+ implements Tracking
+{
+ private ArrayList m_destinations;
+
+ public TrackingImpl()
+ {
+ m_destinations = new ArrayList();
+ }
+
+ public void beenToLocation( ProcessActivity identifier )
+ {
+ m_destinations.add( identifier.toString() );
+ }
+
+ public String[] getLocations()
+ {
+ String[] result = new String[ m_destinations.size() ];
+ m_destinations.toArray( result );
+ return result;
+ }
+}
\ No newline at end of file

Added:
development/planet/users/niclas/processing/test/src/test/net/dpml/processing/controller/test/ExitPointTest.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/processing/test/src/test/net/dpml/processing/controller/test/ExitPointTest.java
Sat Mar 19 19:09:01 2005
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2005, Niclas Hedhman
+ *
+ * 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 net.dpml.processing.controller.test;
+
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import net.dpml.metro.unit.TestContext;
+import net.dpml.processing.controller.ExitPoint;
+
+public class ExitPointTest extends TestCase
+{
+ private ExitPoint m_comp;
+
+ public ExitPointTest( String name )
+ {
+ super( name );
+ }
+
+ public void setUp()
+ throws Exception
+ {
+ TestContext ctx = new TestContext();
+ m_comp = new ExitPoint( ctx );
+ }
+
+ public void testProcess()
+ throws Exception
+ {
+ assertNull( "process()", m_comp.process() );
+ }
+
+ public void testName()
+ throws Exception
+ {
+ assertEquals( "name", "unit-test", m_comp.getName() );
+ }
+
+ public void testDescriptionDefault()
+ throws Exception
+ {
+ Locale locale = Locale.ENGLISH;
+ String desc = m_comp.getDescription( locale );
+ String expected = "An activity that instructs the NestedController
class to exit the controlling activity and return to its containing
controller.";
+ assertEquals( "description", expected , desc );
+ }
+}

Added:
development/planet/users/niclas/processing/test/src/test/net/dpml/processing/controller/test/NestedControllerTest.java
==============================================================================
--- (empty file)
+++
development/planet/users/niclas/processing/test/src/test/net/dpml/processing/controller/test/NestedControllerTest.java
Sat Mar 19 19:09:01 2005
@@ -0,0 +1,117 @@
+/*
+ * Copyright 2005, Niclas Hedhman
+ *
+ * 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 net.dpml.processing.controller.test;
+
+import java.net.URL;
+import java.net.URLClassLoader;
+
+import java.util.Locale;
+
+import junit.framework.TestCase;
+
+import net.dpml.composition.model.ComponentModel;
+import net.dpml.composition.model.ContainmentModel;
+
+import net.dpml.metro.unit.CompositionTestCase;
+
+import net.dpml.transit.artifact.Handler;
+
+import net.dpml.processing.ProcessActivity;
+
+import net.dpml.processing.controller.NestedController;
+
+public class NestedControllerTest extends CompositionTestCase
+{
+ private ComponentModel m_nested;
+ private Tracking m_tracking;
+
+ public void setUp()
+ throws Exception
+ {
+ ContainmentModel root = createContainmentModel( "../classes" );
+ root.commission();
+ String path = "controller";
+ m_nested = (ComponentModel) root.getModel( path );
+ path = "tracking";
+ ComponentModel tracking = (ComponentModel) root.getModel( path );
+ m_tracking = (Tracking) tracking.resolve();
+ }
+
+
+ public void testSequenceA()
+ throws Exception
+ {
+ // A bit hacky way to pass a parameter to a component, but...
+ System.setProperty( "metro.processing.test.outcome", "1" );
+ ProcessActivity instance = (ProcessActivity) m_nested.resolve();
+ ProcessActivity activity = instance.process();
+ assertNull( "return value: " + activity, activity );
+
+ String[] visited = m_tracking.getLocations();
+ assertEquals( "/main/start", visited[ 0 ] );
+ assertEquals( "/main/step1", visited[ 1 ] );
+ assertEquals( "/main/step3", visited[ 2 ] );
+ }
+
+ public void testSequenceB()
+ throws Exception
+ {
+ // A bit hacky way to pass a parameter to a component, but...
+ System.setProperty( "metro.processing.test.outcome", "2" );
+ ProcessActivity instance = (ProcessActivity) m_nested.resolve();
+ ProcessActivity activity = instance.process();
+ assertNull( "return value", activity );
+
+ String[] visited = m_tracking.getLocations();
+ assertEquals( "/main/start", visited[ 0 ] );
+ assertEquals( "/main/step2", visited[ 1 ] );
+ assertEquals( "/main/step3", visited[ 2 ] );
+ }
+
+ public void testSequenceC()
+ throws Exception
+ {
+ // A bit hacky way to pass a parameter to a component, but...
+ System.setProperty( "metro.processing.test.outcome", "3" );
+ ProcessActivity instance = (ProcessActivity) m_nested.resolve();
+ ProcessActivity activity = instance.process();
+ assertNull( "return value", activity );
+
+ String[] visited = m_tracking.getLocations();
+ assertEquals( "/main/start", visited[ 0 ] );
+ assertEquals( "/main/step3", visited[ 1 ] );
+ }
+
+ public void testSequenceD()
+ throws Exception
+ {
+ // A bit hacky way to pass a parameter to a component, but...
+ System.setProperty( "metro.processing.test.outcome", "4" );
+ ProcessActivity instance = (ProcessActivity) m_nested.resolve();
+ ProcessActivity activity = instance.process();
+ assertNull( "return value", activity );
+
+ String[] visited = m_tracking.getLocations();
+ assertEquals( "/main/start", visited[ 0 ] );
+ assertEquals( "/main/step4", visited[ 1 ] );
+ assertEquals( "/main/exception", visited[ 2 ] );
+ assertEquals( "/main/onemore", visited[ 3 ] );
+ assertEquals( "/main/step3", visited[ 4 ] );
+ }
+}
\ No newline at end of file



  • svn commit: r2093 - in development/planet/users/niclas/processing: . api/src/main/net/dpml/processing controller/etc/test controller/src/main/net/dpml/processing/controller controller/src/test test test/src test/src/main test/src/main/net test/src/main/net/dpml test/src/main/net/dpml/processing test/src/main/net/dpml/processing/controller test/src/main/net/dpml/processing/controller/test test/src/test test/src/test/net test/src/test/net/dpml test/src/test/net/dpml/processing test/src/test/net/dpml/processing/controller test/src/test/net/dpml/processing/controller/test, niclas, 03/19/2005

Archive powered by MHonArc 2.6.24.

Top of Page