Skip to Content.
Sympa Menu

notify-dpml - r1233 - in trunk/main: metro/builder/src/main/net/dpml/metro/builder metro/model/src/main/net/dpml/metro/info metro/model/src/test/net/dpml/metro/info/test metro/runtime/src/main/net/dpml/metro/runtime metro/tools/src/main/net/dpml/metro/tools station/builder/src/main/net/dpml/station/builder transit/core/src/main/net/dpml/lang

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: r1233 - in trunk/main: metro/builder/src/main/net/dpml/metro/builder metro/model/src/main/net/dpml/metro/info metro/model/src/test/net/dpml/metro/info/test metro/runtime/src/main/net/dpml/metro/runtime metro/tools/src/main/net/dpml/metro/tools station/builder/src/main/net/dpml/station/builder transit/core/src/main/net/dpml/lang
  • Date: Mon, 20 Mar 2006 14:04:41 +0100

Author: mcconnell
Date: 2006-03-20 14:04:26 +0100 (Mon, 20 Mar 2006)
New Revision: 1233

Added:

trunk/main/metro/model/src/test/net/dpml/metro/info/test/CollectionPolicyTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/LifestylePolicyTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/PriorityTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/ServiceDescriptorTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/ThreadSafePolicyTestCase.java
Modified:

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentConstants.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeDecoder.java
trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptor.java
trunk/main/metro/model/src/main/net/dpml/metro/info/ThreadSafePolicy.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/CategoryDescriptorTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/EntryDescriptorTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/PartReferenceTestCase.java
trunk/main/metro/model/src/test/net/dpml/metro/info/test/TypeTestCase.java

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java

trunk/main/station/builder/src/main/net/dpml/station/builder/RegistryBuilder.java
trunk/main/transit/core/src/main/net/dpml/lang/Version.java
Log:
Move Version.getVersion( String ) to Version.parse( String ) which makes the
operation style consitent with the Enum class failily. Also added a number
of additional testcases.

Modified:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentConstants.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentConstants.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentConstants.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -31,8 +31,11 @@
static final URI CONTROLLER_URI = createURI( "@CONTROLLER-URI@" );
static final URI BUILDER_URI = createURI( "@BUILDER-URI@" );

+ private boolean m_checkstyleIsPainful;
+
ComponentConstants()
{
+ m_checkstyleIsPainful = true;
}

private static URI createURI( String spec )

Modified:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeDecoder.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeDecoder.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeDecoder.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -159,7 +159,7 @@
return new InfoDescriptor(
name,
classname,
- Version.getVersion( version ),
+ Version.parse( version ),
LifestylePolicy.parse( lifestyle ),
CollectionPolicy.parse( collection ),
ThreadSafePolicy.parse( threadsafe ),
@@ -182,7 +182,7 @@
Element child = children[i];
String classname = ElementHelper.getAttribute( child,
"class" );
String version = ElementHelper.getAttribute( child,
"version", "1.0.0" );
- services[i] = new ServiceDescriptor( classname,
Version.getVersion( version ) );
+ services[i] = new ServiceDescriptor( classname,
Version.parse( version ) );
}
return services;
}

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
2006-03-20 11:08:08 UTC (rev 1232)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -158,7 +158,7 @@

if( null == version )
{
- m_version = Version.getVersion( "0.0.0" );
+ m_version = Version.parse( "0" );
}
else
{

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptor.java
===================================================================
---
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptor.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/main/net/dpml/metro/info/ServiceDescriptor.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Stephen J. McConnell.
+ * Copyright 2005-2006 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.
@@ -36,36 +36,36 @@
*/
static final long serialVersionUID = 1L;

- /**
- * The name of service class.
- */
+ /**
+ * The name of service class.
+ */
private final String m_classname;

- /**
- * The version of service class.
- */
+ /**
+ * The version of service class.
+ */
private final Version m_version;

- /**
- * Construct a service with specified type. The type argument will be
- * parsed for a classname and version in the form [classname]#[version].
- * If not version is present a default 1.0.0 version will be assigned.
- *
- * @param spec the service specification
- * @exception NullPointerException if the spec is null
- */
+ /**
+ * Construct a service with specified type. The type argument will be
+ * parsed for a classname and version in the form [classname]#[version].
+ * If not version is present a default 1.0.0 version will be assigned.
+ *
+ * @param spec the service specification
+ * @exception NullPointerException if the spec is null
+ */
public ServiceDescriptor( final String spec ) throws NullPointerException
{
this( parseClassname( spec ), parseVersion( spec ) );
}

- /**
- * Construct a service with specified name, version.
- *
- * @param classname the name of the service
- * @param version the version of service
- * @exception NullPointerException if the classname or version is null
- */
+ /**
+ * Construct a service with specified name, version.
+ *
+ * @param classname the name of the service
+ * @param version the version of service
+ * @exception NullPointerException if the classname or version is null
+ */
public ServiceDescriptor( final String classname, final Version version )
throws NullPointerException
{
@@ -82,7 +82,7 @@

if( null == version )
{
- m_version = Version.getVersion( "" );
+ m_version = Version.parse( "1" );
}
else
{
@@ -90,11 +90,11 @@
}
}

- /**
- * Return classname of service specification.
- *
- * @return the classname of the service specification
- */
+ /**
+ * Return classname of service specification.
+ *
+ * @return the classname of the service specification
+ */
public String getClassname()
{
return m_classname;
@@ -110,13 +110,13 @@
return m_version;
}

- /**
- * Determine if specified service will match this service.
- * To match a service has to have same name and must comply with version.
- *
- * @param other the other ServiceInfo
- * @return true if matches, false otherwise
- */
+ /**
+ * Determine if specified service will match this service.
+ * To match a service has to have same name and must comply with version.
+ *
+ * @param other the other ServiceInfo
+ * @return true if matches, false otherwise
+ */
public boolean matches( final ServiceDescriptor other )
{
if( !m_classname.equals( other.m_classname ) )
@@ -139,12 +139,12 @@
return getClassname() + ":" + getVersion();
}

- /**
- * Compare this object with another for equality.
- * @param other the object to compare this object with
- * @return TRUE if the supplied object is a reference, service, or
service
- * descriptor that matches this objct in terms of classname and version
- */
+ /**
+ * Compare this object with another for equality.
+ * @param other the object to compare this object with
+ * @return TRUE if the supplied object is a reference, service, or service
+ * descriptor that matches this objct in terms of classname and version
+ */
public boolean equals( Object other )
{
if( !( other instanceof ServiceDescriptor ) )
@@ -163,45 +163,45 @@
}
}

- /**
- * Returns the cashcode.
- * @return the hascode value
- */
+ /**
+ * Returns the cashcode.
+ * @return the hascode value
+ */
public int hashCode()
{
return getClassname().hashCode() ^ getVersion().hashCode();
}

- private static final String parseClassname( final String type )
+ private static final String parseClassname( final String spec )
throws NullPointerException
{
- if( type == null )
+ if( spec == null )
{
- throw new NullPointerException( "type" );
+ throw new NullPointerException( "spec" );
}

- int index = type.indexOf( "#" );
+ int index = spec.indexOf( "#" );
if( index == -1 )
{
- return type;
+ return spec;
}
else
{
- return type.substring( 0, index );
+ return spec.substring( 0, index );
}
}

- private static final Version parseVersion( final String type )
+ private static final Version parseVersion( final String spec )
{
- int index = type.indexOf( "#" );
+ int index = spec.indexOf( "#" );
if( index == -1 )
{
- return Version.getVersion( "1" );
+ return Version.parse( "1" );
}
else
{
- String value = type.substring( index + 1 );
- return Version.getVersion( value );
+ String value = spec.substring( index + 1 );
+ return Version.parse( value );
}
}
}

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/ThreadSafePolicy.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/ThreadSafePolicy.java
2006-03-20 11:08:08 UTC (rev 1232)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/ThreadSafePolicy.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -93,9 +93,13 @@
{
return FALSE;
}
- else
+ else if( value.equalsIgnoreCase( "unknown" ) )
{
return UNKNOWN;
}
+ else
+ {
+ throw new IllegalArgumentException( value );
+ }
}
}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/CategoryDescriptorTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/CategoryDescriptorTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/CategoryDescriptorTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -41,8 +41,35 @@
{
return new CategoryDescriptor( m_name, m_priority, getProperties() );
}
+
+ /**
+ * Test the category name accessor.
+ */
+ public void testName()
+ {
+ CategoryDescriptor category = getCategoryDescriptor();
+ assertEquals( m_name, category.getName() );
+ }

/**
+ * Test the category priority accessor.
+ */
+ public void testPriority()
+ {
+ CategoryDescriptor category = getCategoryDescriptor();
+ assertEquals( m_priority, category.getDefaultPriority() );
+ }
+
+ /**
+ * Test the category properties accessor.
+ */
+ public void testProperties()
+ {
+ CategoryDescriptor category = getCategoryDescriptor();
+ assertEquals( getProperties() , category.getProperties() );
+ }
+
+ /**
* Return the category descriptor to test.
* @return the descriptor
*/
@@ -50,7 +77,7 @@
{
return getCategoryDescriptor();
}
-
+
/**
* Validate the category descriptor.
* @param desc the descriptor to validate

Added:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/CollectionPolicyTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/CollectionPolicyTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/CollectionPolicyTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004 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.metro.info.test;
+
+import net.dpml.metro.info.CollectionPolicy;
+
+import junit.framework.TestCase;
+
+/**
+ * CategoryDescriptorTestCase.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class CollectionPolicyTestCase extends TestCase
+{
+ /**
+ * Test weak policy.
+ * @exception Exception if an error occurs
+ */
+ public void testWeakCollectionPolicy() throws Exception
+ {
+ CollectionPolicy policy = CollectionPolicy.parse( "weak" );
+ assertEquals( "name", "weak", policy.getName() );
+ }
+
+ /**
+ * Test soft policy.
+ * @exception Exception if an error occurs
+ */
+ public void testSoftCollectionPolicy() throws Exception
+ {
+ CollectionPolicy policy = CollectionPolicy.parse( "soft" );
+ assertEquals( "name", "soft", policy.getName() );
+ }
+
+ /**
+ * Test hard policy.
+ * @exception Exception if an error occurs
+ */
+ public void testHardCollectionPolicy() throws Exception
+ {
+ CollectionPolicy policy = CollectionPolicy.parse( "hard" );
+ assertEquals( "name", "hard", policy.getName() );
+ }
+
+ /**
+ * Test bad policy.
+ * @exception Exception if an error occurs
+ */
+ public void testBadCollectionPolicy() throws Exception
+ {
+ try
+ {
+ CollectionPolicy policy = CollectionPolicy.parse( "???" );
+ fail( "Bad priority parse argument succeeded." );
+ }
+ catch( IllegalArgumentException e )
+ {
+ // success
+ }
+ }
+}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/EntryDescriptorTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/EntryDescriptorTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/EntryDescriptorTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -90,6 +90,62 @@
}

/**
+ * Validate the entry key.
+ */
+ public void testKey()
+ {
+ EntryDescriptor desc = new EntryDescriptor( KEY, TYPE );
+ assertEquals( KEY, desc.getKey() );
+ }
+
+ /**
+ * Validate the entry type.
+ */
+ public void testType()
+ {
+ EntryDescriptor desc = new EntryDescriptor( KEY, TYPE );
+ assertEquals( TYPE, desc.getClassname() );
+ }
+
+ /**
+ * Validate the entry optional flag.
+ */
+ public void testOptional()
+ {
+ EntryDescriptor desc = new EntryDescriptor( KEY, TYPE, true );
+ assertEquals( true, desc.isOptional() );
+ assertEquals( false, desc.isRequired() );
+ }
+
+ /**
+ * Validate the entry required flag.
+ */
+ public void testRequired()
+ {
+ EntryDescriptor desc = new EntryDescriptor( KEY, TYPE, false );
+ assertEquals( false, desc.isOptional() );
+ assertEquals( true, desc.isRequired() );
+ }
+
+ /**
+ * Validate the entry volatile flag.
+ */
+ public void testVolotile()
+ {
+ EntryDescriptor desc = new EntryDescriptor( KEY, TYPE, false, true );
+ assertEquals( true, desc.isVolatile() );
+ }
+
+ /**
+ * Validate the entry volatile flag.
+ */
+ public void testNonVolotile()
+ {
+ EntryDescriptor desc = new EntryDescriptor( KEY, TYPE, false, false
);
+ assertEquals( false, desc.isVolatile() );
+ }
+
+ /**
* Validate the entry descriptor.
* @param desc the entry descriptor to validate
* @param key the entry key

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -36,7 +36,7 @@
{
private final String m_name = "name";
private final String m_classname =
InfoDescriptorTestCase.class.getName();
- private final Version m_version = Version.getVersion( "1.2.3" );
+ private final Version m_version = Version.parse( "1.2.3" );
private final LifestylePolicy m_lifestyle = LifestylePolicy.SINGLETON;
private final CollectionPolicy m_collection = CollectionPolicy.WEAK;
private final ThreadSafePolicy m_threadsafe = ThreadSafePolicy.FALSE;

Added:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/LifestylePolicyTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/LifestylePolicyTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/LifestylePolicyTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2004 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.metro.info.test;
+
+import net.dpml.metro.info.LifestylePolicy;
+
+import junit.framework.TestCase;
+
+/**
+ * LifestylePolicy testcase.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class LifestylePolicyTestCase extends TestCase
+{
+ /**
+ * Test weak policy.
+ * @exception Exception if an error occurs
+ */
+ public void testSingletonLifestylePolicy() throws Exception
+ {
+ LifestylePolicy policy = LifestylePolicy.parse( "singleton" );
+ assertEquals( "name", "singleton", policy.getName() );
+ }
+
+ /**
+ * Test soft policy.
+ * @exception Exception if an error occurs
+ */
+ public void testThreadLifestylePolicy() throws Exception
+ {
+ LifestylePolicy policy = LifestylePolicy.parse( "thread" );
+ assertEquals( "name", "thread", policy.getName() );
+ }
+
+ /**
+ * Test hard policy.
+ * @exception Exception if an error occurs
+ */
+ public void testTransientLifestylePolicy() throws Exception
+ {
+ LifestylePolicy policy = LifestylePolicy.parse( "transient" );
+ assertEquals( "name", "transient", policy.getName() );
+ }
+
+ /**
+ * Test bad policy.
+ * @exception Exception if an error occurs
+ */
+ public void testBadLifestylePolicy() throws Exception
+ {
+ try
+ {
+ LifestylePolicy policy = LifestylePolicy.parse( "???" );
+ fail( "Bad priority parse argument succeeded." );
+ }
+ catch( IllegalArgumentException e )
+ {
+ // success
+ }
+ }
+}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/PartReferenceTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/PartReferenceTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/PartReferenceTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -45,6 +45,22 @@
}

/**
+ * Test key intergrity.
+ */
+ public void testKey()
+ {
+ assertEquals( "key", m_key, m_reference.getKey() );
+ }
+
+ /**
+ * Test directive intergrity.
+ */
+ public void testDirective()
+ {
+ assertEquals( "directive", m_directive, m_reference.getDirective() );
+ }
+
+ /**
* Test part reference encoding/decoding.
* @exception Exception if an error occurs
*/

Added:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/PriorityTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/PriorityTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/PriorityTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2004 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.metro.info.test;
+
+import net.dpml.metro.info.Priority;
+
+import junit.framework.TestCase;
+
+/**
+ * Priority testcase.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class PriorityTestCase extends TestCase
+{
+ /**
+ * Test info priority.
+ * @exception Exception if an error occurs
+ */
+ public void testInfoPriority() throws Exception
+ {
+ String name = "info";
+ Priority policy = Priority.parse( name );
+ assertEquals( "name", name, policy.getName() );
+ }
+
+ /**
+ * Test warn priority.
+ * @exception Exception if an error occurs
+ */
+ public void testWarnPriority() throws Exception
+ {
+ String name = "warn";
+ Priority policy = Priority.parse( name );
+ assertEquals( "name", name, policy.getName() );
+ }
+
+ /**
+ * Test error priority.
+ * @exception Exception if an error occurs
+ */
+ public void testErrorPriority() throws Exception
+ {
+ String name = "error";
+ Priority policy = Priority.parse( name );
+ assertEquals( "name", name, policy.getName() );
+ }
+
+ /**
+ * Test error priority.
+ * @exception Exception if an error occurs
+ */
+ public void testDebugPriority() throws Exception
+ {
+ String name = "debug";
+ Priority policy = Priority.parse( name );
+ assertEquals( "name", name, policy.getName() );
+ }
+
+ /**
+ * Test bad policy.
+ * @exception Exception if an error occurs
+ */
+ public void testBadPolicy() throws Exception
+ {
+ try
+ {
+ Priority policy = Priority.parse( "???" );
+ fail( "Bad priority parse argument succeeded." );
+ }
+ catch( IllegalArgumentException e )
+ {
+ // success
+ }
+ }
+}

Added:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/ServiceDescriptorTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/ServiceDescriptorTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/ServiceDescriptorTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2004 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.metro.info.test;
+
+import net.dpml.lang.Version;
+
+import net.dpml.metro.info.ServiceDescriptor;
+
+import junit.framework.TestCase;
+
+/**
+ * Priority testcase.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ServiceDescriptorTestCase extends TestCase
+{
+ /**
+ * Test classname.
+ * @exception Exception if an error occurs
+ */
+ public void testClassname() throws Exception
+ {
+ String classname = "Widget";
+ ServiceDescriptor service = new ServiceDescriptor( classname );
+ assertEquals( "classname", classname, service.getClassname() );
+ }
+
+ /**
+ * Test default version.
+ * @exception Exception if an error occurs
+ */
+ public void testDefaultVersion() throws Exception
+ {
+ String classname = "Widget";
+ Version version = Version.parse( "1" );
+ ServiceDescriptor service = new ServiceDescriptor( classname );
+ assertEquals( "version", version, service.getVersion() );
+ }
+
+ /**
+ * Test explicit version.
+ * @exception Exception if an error occurs
+ */
+ public void testExplicitVersion() throws Exception
+ {
+ String classname = "Widget";
+ Version version = Version.parse( "2.1.3" );
+ String spec = classname + "#" + version;
+ ServiceDescriptor service = new ServiceDescriptor( spec );
+ assertEquals( "version", version, service.getVersion() );
+ }
+}

Added:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/ThreadSafePolicyTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/ThreadSafePolicyTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/ThreadSafePolicyTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2004 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.metro.info.test;
+
+import net.dpml.metro.info.ThreadSafePolicy;
+
+import junit.framework.TestCase;
+
+/**
+ * ThreadSafePolicy testcase.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ThreadSafePolicyTestCase extends TestCase
+{
+ /**
+ * Test weak policy.
+ * @exception Exception if an error occurs
+ */
+ public void testThreadSafePolicy() throws Exception
+ {
+ ThreadSafePolicy policy = ThreadSafePolicy.parse( "true" );
+ assertEquals( "name", "true", policy.getName() );
+ }
+
+ /**
+ * Test soft policy.
+ * @exception Exception if an error occurs
+ */
+ public void testNonThreadThreadSafePolicy() throws Exception
+ {
+ ThreadSafePolicy policy = ThreadSafePolicy.parse( "false" );
+ assertEquals( "name", "false", policy.getName() );
+ }
+
+ /**
+ * Test hard policy.
+ * @exception Exception if an error occurs
+ */
+ public void testUnknownThreadSafePolicy() throws Exception
+ {
+ ThreadSafePolicy policy = ThreadSafePolicy.parse( "unknown" );
+ assertEquals( "name", "unknown", policy.getName() );
+ }
+
+
+ /**
+ * Test pad policy.
+ * @exception Exception if an error occurs
+ */
+ public void testBadPolicy() throws Exception
+ {
+ try
+ {
+ ThreadSafePolicy policy = ThreadSafePolicy.parse( "???" );
+ fail( "Bad thread-safe policy argument succeeded." );
+ }
+ catch( IllegalArgumentException e )
+ {
+ // success
+ }
+ }
+}

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/TypeTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/TypeTestCase.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/TypeTestCase.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -74,7 +74,67 @@
m_parts = new PartReference[0];
m_graph = State.NULL_STATE;
}
+
+ /**
+ * Test categories accessor.
+ */
+ public void testCategories()
+ {
+ Type type =
+ new Type(
+ m_info, m_loggers, m_context, m_services, m_parts, m_graph );
+ checkArray( m_loggers, type.getCategoryDescriptors() );
+ assertTrue( type.isaCategory( m_loggers[0].getName() ) );
+ assertTrue( !type.isaCategory( "fake name" ) );
+ }

+ /**
+ * Test context accessor.
+ */
+ public void testContextDescriptor()
+ {
+ Type type =
+ new Type(
+ m_info, m_loggers, m_context, m_services, m_parts, m_graph );
+ assertEquals( m_context, type.getContextDescriptor() );
+ }
+
+ /**
+ * Test info accessor.
+ */
+ public void testInfo()
+ {
+ Type type =
+ new Type(
+ m_info, m_loggers, m_context, m_services, m_parts, m_graph );
+ assertEquals( m_info, type.getInfo() );
+ }
+
+ /**
+ * Test state accessor.
+ */
+ public void testState()
+ {
+ Type type =
+ new Type(
+ m_info, m_loggers, m_context, m_services, m_parts, m_graph );
+ assertEquals( m_graph, type.getStateGraph() );
+ }
+
+ /**
+ * Test services accessor.
+ */
+ public void testServices()
+ {
+ ServiceDescriptor[] services = new ServiceDescriptor[2];
+ services[0] = new ServiceDescriptor( "Widget" );
+ services[1] = new ServiceDescriptor( "Gizmo" );
+ Type type =
+ new Type(
+ m_info, m_loggers, m_context, services, m_parts, m_graph );
+ checkArray( services, type.getServiceDescriptors() );
+ }
+
private void checkType( Type type )
{
assertNotNull( type );
@@ -136,7 +196,8 @@

private static InfoDescriptor createSimpleInfo( String classname )
{
- return new InfoDescriptor( null, classname, null, null,
CollectionPolicy.WEAK, ThreadSafePolicy.FALSE, null );
+ return new InfoDescriptor(
+ null, classname, null, null, CollectionPolicy.WEAK,
ThreadSafePolicy.FALSE, null );
}

/**

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultPartsManager.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -168,7 +168,7 @@
*/
public ComponentHandler[] getComponentHandlers( Class clazz )
{
- Service service = new DefaultService( clazz, Version.getVersion(
"-1" ) );
+ Service service = new DefaultService( clazz, Version.parse( "-1" ) );
ArrayList list = new ArrayList();
Component[] components = getComponents();
for( int i=0; i<components.length; i++ )

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
2006-03-20 11:08:08 UTC (rev 1232)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -124,9 +124,10 @@
*/
public void execute()
{
+ log( "building catalog index" );
Project proj = getProject();
File[] types = getTypes();
- log( "Catalog size: " + types.length );
+ log( "Catalog type count: " + types.length );
if( types.length == 0 )
{
return;

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
2006-03-20 11:08:08 UTC (rev 1232)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/ServiceDataType.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -58,7 +58,7 @@
{
throw new NullPointerException( "spec" );
}
- m_version = Version.getVersion( spec );
+ m_version = Version.parse( spec );
}

ServiceDescriptor getServiceDescriptor()

Modified:
trunk/main/station/builder/src/main/net/dpml/station/builder/RegistryBuilder.java
===================================================================
---
trunk/main/station/builder/src/main/net/dpml/station/builder/RegistryBuilder.java
2006-03-20 11:08:08 UTC (rev 1232)
+++
trunk/main/station/builder/src/main/net/dpml/station/builder/RegistryBuilder.java
2006-03-20 13:04:26 UTC (rev 1233)
@@ -54,7 +54,7 @@
* @param uri the uri to the descriptor XML document
* @return the registry descriptor
* @exception DecodingException if a decoding error occurs
- * @exception DecodingException if a IO error occurs
+ * @exception IOException if a IO error occurs
*/
public Object build( URI uri ) throws DecodingException, IOException
{

Modified: trunk/main/transit/core/src/main/net/dpml/lang/Version.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/Version.java 2006-03-20
11:08:08 UTC (rev 1232)
+++ trunk/main/transit/core/src/main/net/dpml/lang/Version.java 2006-03-20
13:04:26 UTC (rev 1233)
@@ -74,7 +74,7 @@
* @throws NullPointerException if the version argument is
<code>null</code>.
* @since 4.1
*/
- public static Version getVersion( final String version )
+ public static Version parse( final String version )
throws NumberFormatException, IllegalArgumentException,
NullPointerException
{
if( version == null )




  • r1233 - in trunk/main: metro/builder/src/main/net/dpml/metro/builder metro/model/src/main/net/dpml/metro/info metro/model/src/test/net/dpml/metro/info/test metro/runtime/src/main/net/dpml/metro/runtime metro/tools/src/main/net/dpml/metro/tools station/builder/src/main/net/dpml/station/builder transit/core/src/main/net/dpml/lang, mcconnell at BerliOS, 03/20/2006

Archive powered by MHonArc 2.6.24.

Top of Page