notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2199 - in development/main/metro/composition/unit: . src/main src/main/net/dpml/composition/testing src/test
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2199 - in development/main/metro/composition/unit: . src/main src/main/net/dpml/composition/testing src/test
- Date: Mon, 04 Apr 2005 04:22:14 -0400
Author: mcconnell AT dpml.net
Date: Mon Apr 4 04:22:12 2005
New Revision: 2199
Added:
development/main/metro/composition/unit/src/main/
- copied from r2198, development/main/metro/composition/unit/src/test/
development/main/metro/composition/unit/src/main/net/dpml/composition/testing/CompositionHelper.java
Removed:
development/main/metro/composition/unit/src/main/net/dpml/composition/testing/CompositionManagerTestCase.java
development/main/metro/composition/unit/src/test/
Modified:
development/main/metro/composition/unit/build.xml
Log:
Complete reshuffle.
Modified: development/main/metro/composition/unit/build.xml
==============================================================================
--- development/main/metro/composition/unit/build.xml (original)
+++ development/main/metro/composition/unit/build.xml Mon Apr 4 04:22:12
2005
@@ -1,30 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
-<project name="dpml-composition-testing-system" default="install" basedir="."
+<project name="dpml-composition-unit" 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="init" depends="standard.init">
<x:filter key="dpml-system-impl" feature="plugin"
token="SYSTEM-PLUGIN-URI"/>
- <x:property key="dpml-composition-testing-acme" feature="uri"
type="part" name="acme.part"/>
- <filter token="ACME-PART-URI" value="${acme.part}"/>
- </target>
-
- <target name="build" depends="standard.build">
-
- <!--
- Setup a component dealing with experimental part handling.
- -->
- <component xmlns="plugin:dpml/composition/dpml-composition-builder"
- name="gizmo"
- class="net.dpml.composition.testing.CompositeGizmo"
- dest="target/test/acme-gizmo.part">
- <parts>
- <component name="widget" uri="${acme.part}"/>
- </parts>
- </component>
-
</target>
</project>
Added:
development/main/metro/composition/unit/src/main/net/dpml/composition/testing/CompositionHelper.java
==============================================================================
--- (empty file)
+++
development/main/metro/composition/unit/src/main/net/dpml/composition/testing/CompositionHelper.java
Mon Apr 4 04:22:12 2005
@@ -0,0 +1,141 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * 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.composition.unit;
+
+import java.io.File;
+import java.io.IOException;
+
+import java.net.URI;
+import java.net.URL;
+
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Map;
+
+import net.dpml.system.SystemCriteria;
+import net.dpml.system.SystemContext;
+import net.dpml.system.SystemContextFactory;
+
+import net.dpml.transit.artifact.Artifact;
+import net.dpml.transit.repository.Repository;
+import net.dpml.transit.repository.StandardLoader;
+
+import net.dpml.automation.model.Model;
+import net.dpml.automation.control.Controller;
+
+import net.dpml.composition.control.CompositionManager;
+
+
+/**
+ * A utility class used for the deployment of components in embedded
scenarios
+ * includuing but not limited to test-cases.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Id: CompositionTestCase.java 363 2004-11-04 15:06:34Z mcconnell
$
+ */
+public class CompositionHelper
+{
+ //------------------------------------------------------------------
+ // state
+ //------------------------------------------------------------------
+
+ private CompositionManager m_manager;
+
+ //------------------------------------------------------------------
+ // constructor
+ //------------------------------------------------------------------
+
+ public CompositionManager( File base )
+ {
+ this( getWorkingTestDirectory() );
+ }
+
+ public CompositionManager( File base )
+ {
+ this( base, new Hashtable() );
+ }
+
+ public CompositionManager( File base, Map map )
+ {
+ SystemContext system = createSystemContext( map, base );
+ m_manager = new CompositionManager( system );
+ }
+
+ //------------------------------------------------------------------
+ // internal
+ //------------------------------------------------------------------
+
+ public CompositionManager getCompositionManager()
+ {
+ return m_manager;
+ }
+
+ /**
+ * Setup the system context.
+ *
+ * @param map a map of supplimentary factory criteria that will be
+ * applied to the system context factory
+ */
+ private SystemContext createSystemContext( Map map, File dir )
+ throws Exception
+ {
+ ClassLoader classloader =
CompositionManagerTestCase.class.getClassLoader();
+ Repository repository = new StandardLoader();
+ SystemContextFactory factory =
+ (SystemContextFactory) repository.getPlugin( classloader,
SYSTEM_PLUGIN_URI, new Object[]{ map } );
+ SystemCriteria criteria = factory.createDefaultSystemCriteria();
+
+ criteria.setWorkingDirectory( dir );
+ criteria.setAnchorDirectory( dir );
+ return factory.createSystemContext( criteria );
+ }
+
+ public static File getTestWorkingDir()
+ {
+ String dir = System.getProperty( "project.test.dir" );
+ if( null == dir )
+ {
+ final String error =
+ "System property 'project.test.dir' is undefined.";
+ throw new IllegalStateException( error );
+ }
+ try
+ {
+ return new File( dir ).getCanonicalFile();
+ }
+ catch( IOException e )
+ {
+ return new File( dir );
+ }
+ }
+
+ private static final URI SYSTEM_PLUGIN_URI = createStaticURI(
"@SYSTEM-PLUGIN-URI@" );
+
+ private static URI createStaticURI( String path )
+ {
+ try
+ {
+ return new URI( path );
+ }
+ catch( Throwable e )
+ {
+ return null;
+ }
+ }
+}
- svn commit: r2199 - in development/main/metro/composition/unit: . src/main src/main/net/dpml/composition/testing src/test, mcconnell, 04/03/2005
Archive powered by MHonArc 2.6.24.