Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2606 - in development/main/test: . unit/simple unit/simple/src unit/simple/src/main unit/simple/src/main/net unit/simple/src/main/net/dpml unit/simple/src/main/net/dpml/test unit/simple/src/main/net/dpml/test/acme

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2606 - in development/main/test: . unit/simple unit/simple/src unit/simple/src/main unit/simple/src/main/net unit/simple/src/main/net/dpml unit/simple/src/main/net/dpml/test unit/simple/src/main/net/dpml/test/acme
  • Date: Thu, 19 May 2005 00:37:41 +0000

Author: mcconnell AT dpml.net
Date: Thu May 19 00:37:32 2005
New Revision: 2606

Added:
development/main/test/unit/simple/ (props changed)
development/main/test/unit/simple/build.xml
development/main/test/unit/simple/src/
development/main/test/unit/simple/src/main/
development/main/test/unit/simple/src/main/net/
development/main/test/unit/simple/src/main/net/dpml/
development/main/test/unit/simple/src/main/net/dpml/test/
development/main/test/unit/simple/src/main/net/dpml/test/acme/

development/main/test/unit/simple/src/main/net/dpml/test/acme/SimpleTestCase.java
Modified:
development/main/test/index.xml
Log:
add simple testcase

Modified: development/main/test/index.xml
==============================================================================
--- development/main/test/index.xml (original)
+++ development/main/test/index.xml Thu May 19 00:37:32 2005
@@ -42,4 +42,22 @@
</plugins>
</project>

+ <project basedir="unit/simple">
+ <info>
+ <group>dpml/test</group>
+ <name>dpml-test-unit-acme</name>
+ <types>
+ <type>test</type>
+ </types>
+ </info>
+ <dependencies>
+ <include key="dpml-test-acme"/>
+ <include key="dpml-composition-unit"/>
+ <include key="ant-junit"/>
+ </dependencies>
+ <plugins>
+ <include key="dpml-composition-builder" runtime="false"/>
+ </plugins>
+ </project>
+
</index>

Added: development/main/test/unit/simple/build.xml
==============================================================================
--- (empty file)
+++ development/main/test/unit/simple/build.xml Thu May 19 00:37:32 2005
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<project name="dpml-test-unit-acme" 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">
+
+ <!--
+ Simple component test part.
+ This is a simple component with no dependencies. It is used
+ primarily to validate context entry construction. It includes
+ an example of a of a non-trivial custom context entry under the
+ 'dimension' key. In this example the context entry is an instance
+ of the class Dimension which is created with two int arguments.
+ The DefaultWidget component class accesses this via the Context
+ constructor value and uses it to calculate a size.
+ -->
+
+ <component dest="target/test/acme-simple.part"
+ xmlns="plugin:dpml/composition/dpml-composition-builder"
+ type="net.dpml.test.acme.WidgetComponent"
+ name="widget">
+ <context>
+ <value key="name" value="urn:model:name"/>
+ <value key="partition" value="urn:model:partition"/>
+ <value key="uri" value="urn:model:uri"/>
+ <value key="workingDirectory">
+ <param class="java.io.File" value="urn:system:work.dir"/>
+ <param value="acme/workspace"/>
+ </value>
+ <value key="dimension" class="net.dpml.test.acme.DimensionValue">
+ <param class="int" value="12"/>
+ <param class="int" value="100"/>
+ </value>
+ </context>
+ </component>
+
+ </target>
+
+</project>

Added:
development/main/test/unit/simple/src/main/net/dpml/test/acme/SimpleTestCase.java
==============================================================================
--- (empty file)
+++
development/main/test/unit/simple/src/main/net/dpml/test/acme/SimpleTestCase.java
Thu May 19 00:37:32 2005
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2004 Stephen J. McConnell.
+ * Copyright 1999-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.
+ */
+
+package net.dpml.test.acme;
+
+import java.net.URI;
+import java.util.Hashtable;
+import java.util.Map.Entry;
+
+import junit.framework.TestCase;
+
+import net.dpml.parts.model.Model;
+import net.dpml.parts.control.Controller;
+import net.dpml.parts.control.Manager;
+
+import net.dpml.composition.unit.CompositionHelper;
+
+/**
+ * Test a simple component case.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: AbstractDescriptorTestCase.java 1556 2005-01-22 12:43:42Z
niclas $
+ */
+public class SimpleTestCase extends TestCase
+{
+ private static final String PATH = "acme-simple.part";
+
+ public void tearDown()
+ {
+ System.gc();
+ }
+
+ /**
+ * Test the construction of the widget component and the invocation of
+ * an operation on the widget service interface.
+ */
+ public void testGetValue() throws Exception
+ {
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( PATH );
+ Model model = helper.getCompositionManager().getModel( uri, "widget"
);
+ Widget widget = (Widget) model.getProvider().resolve();
+ widget.doWidgetStuff( "green" );
+ model.getProvider().release( widget );
+ }
+
+ /**
+ * Test the construction of the widget component using the
+ * DimensionComponent as the Dimension provider.
+ */
+ public void testDimensionInWidget() throws Exception
+ {
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( "acme-widget.part" );
+ Model model = helper.getCompositionManager().getModel( uri, "widget"
);
+ Widget widget = (Widget) model.getProvider().resolve();
+ widget.doWidgetStuff( "green" );
+ model.getProvider().release( widget );
+ }
+
+ /**
+ * Test the isolation of the widget.
+ */
+ public void testServiceIsolation() throws Exception
+ {
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( PATH );
+ Model model = helper.getCompositionManager().getModel( uri, "widget"
);
+ Widget widget = (Widget) model.getProvider().resolve();
+ try
+ {
+ WidgetComponent w = (WidgetComponent) widget;
+ fail( "Casting to implementation class!" );
+ }
+ catch( ClassCastException e )
+ {
+ // success
+ }
+ finally
+ {
+ model.getProvider().release( widget );
+ }
+ }
+
+ /**
+ * Test the construction of the widget implementation and invocation
+ * of a non-service public method on the implementation class.
+ */
+ public void testNonProxiedCreation() throws Exception
+ {
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( PATH );
+ Model model = helper.getCompositionManager().getModel( uri, "widget"
);
+ WidgetComponent widget = (WidgetComponent)
model.getProvider().resolve( false );
+ String name = widget.getName();
+ assertEquals( "name", "widget", name );
+ String newName = "freight";
+ widget.setName( newName );
+ assertEquals( "name", newName, widget.getName() );
+ model.getProvider().release( widget );
+ }
+
+ /**
+ * Test the construction of the widget implementation and invocation
+ * of a non-service public method on the implementation class.
+ */
+ public void testIdentifiableManagerCreation() throws Exception
+ {
+ String id = "steve";
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( PATH );
+ Model model = helper.getCompositionManager().getModel( uri, "widget"
);
+ WidgetComponent widget = (WidgetComponent) model.getProvider( id
).resolve( false );
+ model.getProvider( id ).release( widget );
+ }
+
+ /**
+ * Test the construction of an identifiable widget instance. We create
+ * widgets w1 and w2 under unique ids and check that they are in fact
+ * unique. Then we create w3 using the same key as we used for w1 and
+ * check that the instances are the same (which is dependent on the
+ * implementation providing a rational equals implementation).
+ */
+ public void testIdentifiableCreation() throws Exception
+ {
+ CompositionHelper helper = new CompositionHelper();
+ URI uri = helper.toURI( PATH );
+ Model model = helper.getCompositionManager().getModel( uri, "widget"
);
+ Controller controller = model.getController();
+ Widget w1 = (Widget) model.getProvider( "acme-widget-one" ).resolve(
false );
+ Widget w2 = (Widget) model.getProvider( "acme-widget-two" ).resolve(
false );
+ if( w1.equals( w2 ) )
+ {
+ fail( "Widget w1 and w2 are not unique!" );
+ }
+ Widget w3 = (Widget) model.getProvider( "acme-widget-one" ).resolve(
false );
+ if( !w1.equals( w3 ) )
+ {
+ System.out.println( "" + System.identityHashCode( w1 ) );
+ System.out.println( "" + System.identityHashCode( w3 ) );
+ fail( "Widget w1 and w3 are not the same!" );
+ }
+ }
+}



  • svn commit: r2606 - in development/main/test: . unit/simple unit/simple/src unit/simple/src/main unit/simple/src/main/net unit/simple/src/main/net/dpml unit/simple/src/main/net/dpml/test unit/simple/src/main/net/dpml/test/acme, mcconnell, 05/18/2005

Archive powered by MHonArc 2.6.24.

Top of Page