Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2030 - in development/laboratory/planet/components/processing/controller: etc etc/test src/main/net/dpml/processing/controller src/test src/test/net src/test/net/dpml src/test/net/dpml/processing src/test/net/dpml/processing/controller 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: r2030 - in development/laboratory/planet/components/processing/controller: etc etc/test src/main/net/dpml/processing/controller src/test src/test/net src/test/net/dpml src/test/net/dpml/processing src/test/net/dpml/processing/controller src/test/net/dpml/processing/controller/test
  • Date: Fri, 11 Mar 2005 11:18:42 -0500

Author: niclas AT hedhman.org
Date: Fri Mar 11 11:18:40 2005
New Revision: 2030

Added:
development/laboratory/planet/components/processing/controller/etc/
development/laboratory/planet/components/processing/controller/etc/test/

development/laboratory/planet/components/processing/controller/etc/test/nested.block
(contents, props changed)
development/laboratory/planet/components/processing/controller/src/test/

development/laboratory/planet/components/processing/controller/src/test/net/

development/laboratory/planet/components/processing/controller/src/test/net/dpml/

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/ExceptionStep.java
(contents, props changed)

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

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/LastExceptionStep.java
(contents, props changed)

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/NestedControllerTest.java
(contents, props changed)

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/Start.java
(contents, props changed)

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/Step.java
(contents, props changed)

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/Tracking.java
(contents, props changed)

development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/TrackingImpl.java
(contents, props changed)
Modified:

development/laboratory/planet/components/processing/controller/src/main/net/dpml/processing/controller/NestedController.java
Log:
Adding testcase.

Added:
development/laboratory/planet/components/processing/controller/etc/test/nested.block
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/processing/controller/etc/test/nested.block
Fri Mar 11 11:18:40 2005
@@ -0,0 +1,76 @@
+<?xml version="1.0" ?>
+
+<container name="outer" >
+
+ <container name="inner" >
+
+ <classloader>
+ <classpath>
+ <fileset dir="${project.dir}/../">
+ <include name="classes/"/>
+ <include name="test-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>
+
+</container>
\ No newline at end of file

Modified:
development/laboratory/planet/components/processing/controller/src/main/net/dpml/processing/controller/NestedController.java
==============================================================================
---
development/laboratory/planet/components/processing/controller/src/main/net/dpml/processing/controller/NestedController.java
(original)
+++
development/laboratory/planet/components/processing/controller/src/main/net/dpml/processing/controller/NestedController.java
Fri Mar 11 11:18:40 2005
@@ -181,7 +181,7 @@
* @exception ContextException is declared but can only happen if the
container
* is malfunctioning, or the xinfo of the component has been
corrupted.
*/
- public NestedController( ServiceManager man, Parameters params, Context
ctx )
+ public NestedController( Context ctx, ServiceManager man, Parameters
params )
throws ServiceException, ModelException, ContextException
{
m_name = (String) ctx.get( "urn:metro:name" );

Added:
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/ExceptionStep.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/ExceptionStep.java
Fri Mar 11 11:18:40 2005
@@ -0,0 +1,75 @@
+/*
+ * 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 ExceptionStep
+ implements ProcessActivity
+{
+ private Tracking m_tracks;
+ private String m_name;
+ private ProcessActivity m_outcome;
+
+ /**
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ *
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome"
+ * @metro.dependency type="net.dpml.processing.controller.test.Tracking"
+ * key="global-tracking"
+ */
+ public ExceptionStep( Context ctx, ServiceManager man )
+ throws ServiceException, ContextException
+ {
+ m_tracks = (Tracking) man.lookup( "global-tracking" );
+ m_outcome = (ProcessActivity) man.lookup( "outcome" );
+ m_name = (String) ctx.get( "urn:metro:name" );
+ }
+
+ public ProcessActivity process()
+ throws Exception
+ {
+ m_tracks.beenToLocation( m_name );
+ return m_outcome;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "irrelevant";
+ }
+}

Added:
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/ExitPointTest.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/ExitPointTest.java
Fri Mar 11 11:18:40 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 );
+ }
+}
\ No newline at end of file

Added:
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/LastExceptionStep.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/LastExceptionStep.java
Fri Mar 11 11:18:40 2005
@@ -0,0 +1,75 @@
+/*
+ * 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 LastExceptionStep
+ implements ProcessActivity
+{
+ private Tracking m_tracks;
+ private String m_name;
+ private ProcessActivity m_outcome;
+
+ /**
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ *
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome"
+ * @metro.dependency type="net.dpml.processing.controller.test.Tracking"
+ * key="global-tracking"
+ */
+ public LastExceptionStep( Context ctx, ServiceManager man )
+ throws ServiceException, ContextException
+ {
+ m_tracks = (Tracking) man.lookup( "global-tracking" );
+ m_outcome = (ProcessActivity) man.lookup( "outcome" );
+ m_name = (String) ctx.get( "urn:metro:name" );
+ }
+
+ public ProcessActivity process()
+ throws Exception
+ {
+ m_tracks.beenToLocation( m_name );
+ return m_outcome;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "irrelevant";
+ }
+}

Added:
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/NestedControllerTest.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/NestedControllerTest.java
Fri Mar 11 11:18:40 2005
@@ -0,0 +1,71 @@
+/*
+ * 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.composition.model.ComponentModel;
+import net.dpml.composition.model.ContainmentModel;
+
+import net.dpml.metro.unit.CompositionTestCase;
+
+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
+ {
+ System.out.println( System.getProperty( "project.dir" ) );
+ System.setProperty( "metro.processing.outcome", "1" );
+ createContainmentModel( "nested.block" );
+ String path = "/outer/inner/nested";
+ m_nested = (ComponentModel) getRoot().getModel( path );
+ path = "/outer/inner/tracking";
+ ComponentModel tracking = (ComponentModel) getRoot().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" );
+ NestedController instance = (NestedController) m_nested.resolve();
+ ProcessActivity activity = instance.process();
+ assertNull( "return value", activity );
+
+ String[] visited = m_tracking.getLocations();
+ System.out.println( "Visited" );
+ for( int i = 0; i < visited.length ; i++ )
+ {
+ System.out.println( visited[ i ] );
+ }
+ System.out.println( "Visited" );
+ }
+
+}
\ No newline at end of file

Added:
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/Start.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/Start.java
Fri Mar 11 11:18:40 2005
@@ -0,0 +1,80 @@
+/*
+ * 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 ProcessActivity m_outcome;
+
+ /**
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ *
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome1"
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome2"
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome3"
+ * @metro.dependency type="net.dpml.processing.controller.test.Tracking"
+ * key="global-tracking"
+ */
+ public Start( Context ctx, ServiceManager man )
+ throws ServiceException, ContextException
+ {
+ m_tracks = (Tracking) man.lookup( "global-tracking" );
+ String number = System.getProperty( "metro.processing.test.outcome"
);
+ m_outcome = (ProcessActivity) man.lookup( "outcome" + number.trim()
);
+ m_name = (String) ctx.get( "urn:metro:name" );
+ }
+
+ public ProcessActivity process()
+ throws Exception
+ {
+ m_tracks.beenToLocation( m_name );
+ return m_outcome;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "irrelevant";
+ }
+}

Added:
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/Step.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/Step.java
Fri Mar 11 11:18:40 2005
@@ -0,0 +1,75 @@
+/*
+ * 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 Step
+ implements ProcessActivity
+{
+ private Tracking m_tracks;
+ private String m_name;
+ private ProcessActivity m_outcome;
+
+ /**
+ * @metro.entry key="urn:metro:name"
+ * type="java.lang.String"
+ *
+ * @metro.dependency
type="net.dpml.processing.controller.ProcessActivity"
+ * key="outcome"
+ * @metro.dependency type="net.dpml.processing.controller.test.Tracking"
+ * key="global-tracking"
+ */
+ public Step( Context ctx, ServiceManager man )
+ throws ServiceException, ContextException
+ {
+ m_tracks = (Tracking) man.lookup( "global-tracking" );
+ m_outcome = (ProcessActivity) man.lookup( "outcome" );
+ m_name = (String) ctx.get( "urn:metro:name" );
+ }
+
+ public ProcessActivity process()
+ throws Exception
+ {
+ m_tracks.beenToLocation( m_name );
+ return m_outcome;
+ }
+
+ public String getName()
+ {
+ return m_name;
+ }
+
+ public String getDescription( Locale locale )
+ {
+ return "irrelevant";
+ }
+}

Added:
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/Tracking.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/Tracking.java
Fri Mar 11 11:18:40 2005
@@ -0,0 +1,29 @@
+/*
+ * 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;
+
+/**
+ * @metro.service type="net.dpml.processing.controller.test.Tracking"
+ */
+public interface Tracking
+{
+ void beenToLocation( String identifier );
+
+ String[] getLocations();
+}

Added:
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/TrackingImpl.java
==============================================================================
--- (empty file)
+++
development/laboratory/planet/components/processing/controller/src/test/net/dpml/processing/controller/test/TrackingImpl.java
Fri Mar 11 11:18:40 2005
@@ -0,0 +1,46 @@
+/*
+ * 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;
+
+/**
+ * @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( String identifier )
+ {
+ m_destinations.add( identifier );
+ }
+
+ public String[] getLocations()
+ {
+ return (String[]) m_destinations.toArray();
+ }
+}
\ No newline at end of file



  • svn commit: r2030 - in development/laboratory/planet/components/processing/controller: etc etc/test src/main/net/dpml/processing/controller src/test src/test/net src/test/net/dpml src/test/net/dpml/processing src/test/net/dpml/processing/controller src/test/net/dpml/processing/controller/test, niclas, 03/10/2005

Archive powered by MHonArc 2.6.24.

Top of Page