Skip to Content.
Sympa Menu

notify-dpml - r874 - in trunk/main: . metro/model/src/test/net/dpml/metro/info/test metro/model/src/test/net/dpml/metro/model/test

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: r874 - in trunk/main: . metro/model/src/test/net/dpml/metro/info/test metro/model/src/test/net/dpml/metro/model/test
  • Date: Sun, 8 Jan 2006 06:52:02 +0100

Author: mcconnell
Date: 2006-01-08 06:51:57 +0100 (Sun, 08 Jan 2006)
New Revision: 874

Modified:
trunk/main/build.xml

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

trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractEncodingTestCase.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/ContextDescriptorTestCase.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/model/src/test/net/dpml/metro/model/test/ValidationExceptionTestCase.java
Log:
checkstyle cleanup in metro/model

Modified: trunk/main/build.xml
===================================================================
--- trunk/main/build.xml 2006-01-07 19:07:33 UTC (rev 873)
+++ trunk/main/build.xml 2006-01-08 05:51:57 UTC (rev 874)
@@ -267,6 +267,25 @@
</junitreport>
</target>

+ <target name="checkstyle" depends="prepare">
+ <property name="checkstyle.dir"
location="${basedir}/target/reports/checkstyle"/>
+ <property name="checkstyle.data"
location="${checkstyle.dir}/checkstyle.xml"/>
+ <x:plugin
uri="artifact:plugin:dpml/depot/dpml-depot-checkstyle#SNAPSHOT">
+ <task class="net.dpml.tools.checkstyle.CheckstyleTask"
name="checkstyle"/>
+ </x:plugin>
+ <mkdir dir="${checkstyle.dir}"/>
+ <checkstyle>
+ <formatter type="xml" toFile="${checkstyle.data}"/>
+ <fileset dir=".">
+ <include name="**/target/build/test/**/*.java"/>
+ </fileset>
+ </checkstyle>
+ <xslt style="${dpml.prefs}/dpml/tools/xsls/checkstyle-frames.xsl"
+ in="${checkstyle.data}"
+ out="${checkstyle.dir}/checkstyle_report.html">
+ </xslt>
+ </target>
+
</project>



Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractDescriptorTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractDescriptorTestCase.java
2006-01-07 19:07:33 UTC (rev 873)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractDescriptorTestCase.java
2006-01-08 05:51:57 UTC (rev 874)
@@ -24,23 +24,40 @@
import java.io.ObjectOutputStream;
import java.util.Properties;

-import junit.framework.TestCase;
-
import net.dpml.metro.info.Descriptor;

/**
- * AbstractDescriptorTestCase does XYZ
+ * AbstractDescriptorTestCase.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
public abstract class AbstractDescriptorTestCase extends
AbstractEncodingTestCase
{
+ /**
+ * Key.
+ */
protected static final String VALID_KEY = "key";
+
+ /**
+ * Value.
+ */
protected static final String VALID_VALUE = "value";
+
+ /**
+ * Bad key.
+ */
protected static final String INVALID_KEY = "bad-key";
+
+ /**
+ * Default value.
+ */
protected static final String DEFAULT_VALUE = "default";

+ /**
+ * Return a populated properties object.
+ * @return a properties instance
+ */
protected Properties getProperties()
{
Properties props = new Properties();
@@ -49,8 +66,16 @@
return props;
}

+ /**
+ * Abstract operation implemented by derived types.
+ * @return the descriptor to test
+ */
protected abstract Descriptor getDescriptor();

+ /**
+ * Validate the supplied descriptor.
+ * @param desc the descriptor to validate
+ */
protected void checkDescriptor( Descriptor desc )
{
assertEquals( VALID_VALUE, desc.getAttribute( VALID_KEY ) );
@@ -80,8 +105,11 @@
assertTrue( !hasInvalid );
}

- public void testSerialization()
- throws Exception
+ /**
+ * Test serialization of the object retutrned from getDescriptor().
+ * @exception Exception if an error occurs
+ */
+ public void testSerialization() throws Exception
{
Descriptor desc = getDescriptor();
checkDescriptor( desc );

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractEncodingTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractEncodingTestCase.java
2006-01-07 19:07:33 UTC (rev 873)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/AbstractEncodingTestCase.java
2006-01-08 05:51:57 UTC (rev 874)
@@ -23,24 +23,16 @@
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
import java.beans.Encoder;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.beans.ExceptionListener;
import java.beans.Expression;
-import java.beans.PersistenceDelegate;
import java.beans.DefaultPersistenceDelegate;
import java.net.URI;

import junit.framework.TestCase;

-import net.dpml.metro.info.PartReference;
-
-import net.dpml.metro.data.ValueDirective;
-
/**
* EntryDescriptorTestCase does XYZ
*
@@ -49,6 +41,13 @@
*/
public abstract class AbstractEncodingTestCase extends TestCase
{
+ /**
+ * Test encoding of an object.
+ * @param object the object to encode
+ * @param filename path relative to the target/test directory
+ * @return the result of decoding an encoded representation of object
+ * @exception Exception if an error occurs
+ */
public Object executeEncodingTest( Object object, String filename )
throws Exception
{
String base = System.getProperty( "project.test.dir" );
@@ -78,13 +77,22 @@
return result;
}

+ /**
+ * URIPersistenceDelegate.
+ */
public static class URIPersistenceDelegate extends
DefaultPersistenceDelegate
{
+ /**
+ * Return an expression used to create a uri.
+ * @param old the old instance
+ * @param encoder an encoder
+ * @return the expression
+ */
public Expression instantiate( Object old, Encoder encoder )
{
URI uri = (URI) old;
String spec = uri.toString();
- Object[] args = new Object[]{ spec };
+ Object[] args = new Object[]{spec};
return new Expression( old, old.getClass(), "new", args );
}
}

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-01-07 19:07:33 UTC (rev 873)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/CategoryDescriptorTestCase.java
2006-01-08 05:51:57 UTC (rev 874)
@@ -18,26 +18,12 @@

package net.dpml.metro.info.test;

-import java.beans.Encoder;
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.PersistenceDelegate;
-import java.beans.DefaultPersistenceDelegate;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedInputStream;
-import java.io.File;
-
import net.dpml.metro.info.Descriptor;
import net.dpml.metro.info.CategoryDescriptor;
import net.dpml.metro.info.Priority;

-
/**
- * CategoryTestCase does XYZ
+ * CategoryDescriptorTestCase.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
@@ -47,17 +33,28 @@
private final String m_name = "name";
private final Priority m_priority = Priority.WARN;

+ /**
+ * Return the category descriptor to test.
+ * @return the descriptor
+ */
protected CategoryDescriptor getCategoryDescriptor()
{
return new CategoryDescriptor( m_name, m_priority, getProperties() );
}

+ /**
+ * Return the category descriptor to test.
+ * @return the descriptor
+ */
protected Descriptor getDescriptor()
{
return getCategoryDescriptor();
}

-
+ /**
+ * Validate the category descriptor.
+ * @param desc the descriptor to validate
+ */
protected void checkDescriptor( Descriptor desc )
{
super.checkDescriptor( desc );
@@ -65,7 +62,11 @@
assertEquals( "name", m_name, cat.getName() );
assertEquals( "priority", m_priority, cat.getDefaultPriority() );
}
-
+
+ /**
+ * Test encoding/decoding of the category descriptor.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
CategoryDescriptor descriptor = getCategoryDescriptor();

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/ContextDescriptorTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/ContextDescriptorTestCase.java
2006-01-07 19:07:33 UTC (rev 873)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/ContextDescriptorTestCase.java
2006-01-08 05:51:57 UTC (rev 874)
@@ -18,28 +18,11 @@

package net.dpml.metro.info.test;

-import java.beans.Encoder;
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.PersistenceDelegate;
-import java.beans.DefaultPersistenceDelegate;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedInputStream;
-import java.io.File;
-
-import net.dpml.metro.info.Descriptor;
import net.dpml.metro.info.ContextDescriptor;
-
import net.dpml.metro.info.EntryDescriptor;

-import junit.framework.TestCase;
-
/**
- * ContextDescriptorTestCase does XYZ
+ * ContextDescriptorTestCase.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
@@ -48,11 +31,19 @@
{
private EntryDescriptor[] m_entries;

+ /**
+ * Return the descriptor to test.
+ * @return the descriptor
+ */
protected ContextDescriptor getDescriptor()
{
return new ContextDescriptor( m_entries );
}

+ /**
+ * Validate the descriptor.
+ * @param desc the descriptor to validate
+ */
protected void checkDescriptor( ContextDescriptor desc )
{
ContextDescriptor ctxd = (ContextDescriptor) desc;
@@ -68,6 +59,9 @@
}
}

+ /**
+ * Test join.
+ */
public void testJoin()
{
ContextDescriptor desc = (ContextDescriptor) getDescriptor();
@@ -99,6 +93,9 @@
}
}

+ /**
+ * Setup the testcase.
+ */
public void setUp()
{
m_entries = new EntryDescriptor[]{
@@ -106,6 +103,10 @@
};
}

+ /**
+ * Test context descriptor encoding.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
ContextDescriptor context = getDescriptor();

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-01-07 19:07:33 UTC (rev 873)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/EntryDescriptorTestCase.java
2006-01-08 05:51:57 UTC (rev 874)
@@ -26,13 +26,9 @@
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.beans.Encoder;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.PersistenceDelegate;
-import java.beans.DefaultPersistenceDelegate;

import junit.framework.TestCase;

@@ -46,41 +42,50 @@
*/
public class EntryDescriptorTestCase extends TestCase
{
- private static final String m_key = "key";
- private static final String m_type = EntryDescriptor.class.getName();
- private static final boolean m_optional = true;
- private static final boolean m_volatile = true;
+ private static final String KEY = "key";
+ private static final String TYPE = EntryDescriptor.class.getName();
+ private static final boolean OPTIONAL = true;
+ private static final boolean VOLATILE = true;

+ /**
+ * Test an entry descriptor.
+ */
public void testEntryDescriptor()
{
- EntryDescriptor entry = new EntryDescriptor( m_key, m_type,
m_optional, m_volatile );
- checkEntry( entry, m_key, m_type, m_optional, m_volatile );
+ EntryDescriptor entry = new EntryDescriptor( KEY, TYPE, OPTIONAL,
VOLATILE );
+ checkEntry( entry, KEY, TYPE, OPTIONAL, VOLATILE );

- entry = new EntryDescriptor( m_key, m_type );
- checkEntry( entry, m_key, m_type, false, false );
+ entry = new EntryDescriptor( KEY, TYPE );
+ checkEntry( entry, KEY, TYPE, false, false );

- entry = new EntryDescriptor(m_key, m_type, m_optional );
- checkEntry( entry, m_key, m_type, m_optional, false );
+ entry = new EntryDescriptor( KEY, TYPE, OPTIONAL );
+ checkEntry( entry, KEY, TYPE, OPTIONAL, false );
}

+ /**
+ * Test that the constructor throws an NPE when supplied with a null key.
+ */
public void testNullKey()
{
try
{
- new EntryDescriptor( null, m_type );
- fail("Did not throw expected NullPointerException ");
+ new EntryDescriptor( null, TYPE );
+ fail( "Did not throw expected NullPointerException " );
}
- catch( NullPointerException npe)
+ catch( NullPointerException npe )
{
// Success!!
}
}

+ /**
+ * Test that the constructor throws an NPE when supplied with a null type.
+ */
public void testNullType()
{
try
{
- new EntryDescriptor( m_key, null );
+ new EntryDescriptor( KEY, null );
fail( "Did not throw expected NullPointerException" );
}
catch ( NullPointerException npe )
@@ -89,7 +94,16 @@
}
}

- private void checkEntry( EntryDescriptor desc, String key, String type,
boolean isOptional, boolean isVolatile )
+ /**
+ * Validate the entry descriptor.
+ * @param desc the entry descriptor to validate
+ * @param key the entry key
+ * @param type the entry type
+ * @param isOptional the optional flag
+ * @param isVolatile the volotile flag
+ */
+ private void checkEntry(
+ EntryDescriptor desc, String key, String type, boolean isOptional,
boolean isVolatile )
{
assertNotNull( desc );
assertEquals( key, desc.getKey() );
@@ -99,30 +113,36 @@
assertEquals( isVolatile, desc.isVolatile() );
}

+ /**
+ * Test entry serialization.
+ * @exception IOException if an I/O error occurs
+ * @exception ClassNotFoundException if a class is not found
+ */
public void testSerialization() throws IOException,
ClassNotFoundException
{
- EntryDescriptor entry = new EntryDescriptor( m_key, m_type,
m_optional, m_volatile );
- checkEntry( entry, m_key, m_type, m_optional, m_volatile );
+ EntryDescriptor entry = new EntryDescriptor( KEY, TYPE, OPTIONAL,
VOLATILE );
+ checkEntry( entry, KEY, TYPE, OPTIONAL, VOLATILE );

File file = new File( "test.out" );
ObjectOutputStream oos = new ObjectOutputStream( new
FileOutputStream( file ) );
oos.writeObject( entry );
oos.close();
-
ObjectInputStream ois = new ObjectInputStream( new FileInputStream(
file ) );
EntryDescriptor serialized = (EntryDescriptor) ois.readObject();
ois.close();
file.delete();
-
- checkEntry( serialized, m_key, m_type, m_optional, m_volatile );
-
+ checkEntry( serialized, KEY, TYPE, OPTIONAL, VOLATILE );
assertEquals( entry, serialized );
assertEquals( entry.hashCode(), serialized.hashCode() );
}

+ /**
+ * Test entry encoding.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
- EntryDescriptor entry = new EntryDescriptor( m_key, m_type,
m_optional, m_volatile );
+ EntryDescriptor entry = new EntryDescriptor( KEY, TYPE, OPTIONAL,
VOLATILE );
String base = System.getProperty( "project.test.dir" );
File test = new File( base );
File destination = new File( test, "info.xml" );
@@ -141,7 +161,6 @@
);
encoder.writeObject( entry );
encoder.close();
-
FileInputStream input = new FileInputStream( destination );
XMLDecoder decoder = new XMLDecoder( new BufferedInputStream( input
) );
EntryDescriptor result = (EntryDescriptor) decoder.readObject();

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-01-07 19:07:33 UTC (rev 873)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
2006-01-08 05:51:57 UTC (rev 874)
@@ -18,19 +18,6 @@

package net.dpml.metro.info.test;

-import java.beans.Encoder;
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.PersistenceDelegate;
-import java.beans.DefaultPersistenceDelegate;
-import java.io.FileOutputStream;
-import java.io.FileInputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedInputStream;
-import java.io.File;
-
import net.dpml.metro.info.Descriptor;
import net.dpml.metro.info.InfoDescriptor;
import net.dpml.metro.info.CollectionPolicy;
@@ -39,7 +26,7 @@
import net.dpml.part.Version;

/**
- * InfoDescriptorTestCase does XYZ
+ * InfoDescriptorTestCase.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
@@ -48,60 +35,94 @@
{
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.getVersion( "1.2.3" );
private final LifestylePolicy m_lifestyle = LifestylePolicy.SINGLETON;
private final CollectionPolicy m_collection = CollectionPolicy.WEAK;
private final boolean m_threadsafe = false;

private InfoDescriptor m_info;

+ /**
+ * Setup the testcase.
+ * @exception Exception if an error occurs in setup
+ */
public void setUp() throws Exception
{
m_info = getInfoDescriptor();
}

+ /**
+ * Test the name.
+ */
public void testName()
{
assertEquals( m_name, m_info.getName() );
}

+ /**
+ * Test the classname.
+ */
public void testClassName()
{
assertEquals( m_classname, m_info.getClassname() );
}

+ /**
+ * Test the version.
+ */
public void testVersion()
{
assertEquals( m_version, m_info.getVersion() );
}

+ /**
+ * Test the lifestyle policy.
+ */
public void testLifestyle()
{
assertEquals( m_lifestyle, m_info.getLifestyle() );
}

+ /**
+ * Test the thread safe policy.
+ */
public void testThreadsafeCapable()
{
assertEquals( m_threadsafe, m_info.isThreadsafe() );
}

+ /**
+ * Test the collection policy.
+ */
public void testCollectionPolicy()
{
assertEquals( m_collection, m_info.getCollectionPolicy() );
}

+ /**
+ * Return the info descriptor to test.
+ * @return the info descriptor
+ */
protected Descriptor getDescriptor()
{
return getInfoDescriptor();
}

+ /**
+ * Return the info descriptor to test.
+ * @return the info descriptor
+ */
protected InfoDescriptor getInfoDescriptor()
{
return new InfoDescriptor(
m_name, m_classname, m_version, m_lifestyle, m_collection,
- m_threadsafe, getProperties());
+ m_threadsafe, getProperties() );
}

+ /**
+ * Validate an info descriptor.
+ * @param desc the info descriptor to validate
+ */
protected void checkDescriptor( Descriptor desc )
{
super.checkDescriptor( desc );
@@ -114,6 +135,9 @@
assertEquals( m_collection, info.getCollectionPolicy() );
}

+ /**
+ * Test null classname in constructor.
+ */
public void testNullClassnameConstructor()
{
try
@@ -121,7 +145,7 @@
new InfoDescriptor(
m_name, null, m_version, m_lifestyle, m_collection,
m_threadsafe, getProperties() );
- fail("Did not throw a NullPointerException");
+ fail( "Did not throw a NullPointerException" );
}
catch( NullPointerException npe )
{
@@ -129,14 +153,17 @@
}
}

+ /**
+ * Test bad classname in constructor.
+ */
public void testBadClassnameConstructor()
{
try
{
new InfoDescriptor(
m_name, "foo/fake/ClassName", m_version, m_lifestyle,
m_collection,
- m_threadsafe, getProperties());
- fail("Did not throw the proper IllegalArgumentException");
+ m_threadsafe, getProperties() );
+ fail( "Did not throw the proper IllegalArgumentException" );
}
catch( IllegalArgumentException iae )
{
@@ -144,6 +171,9 @@
}
}

+ /**
+ * Test constructors.
+ */
public void testNormalConstructors()
{
new InfoDescriptor(
@@ -157,6 +187,10 @@
m_threadsafe, getProperties() );
}

+ /**
+ * Test encoding/decoding.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
InfoDescriptor info = getInfoDescriptor();

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-01-07 19:07:33 UTC (rev 873)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/PartReferenceTestCase.java
2006-01-08 05:51:57 UTC (rev 874)
@@ -18,24 +18,6 @@

package net.dpml.metro.info.test;

-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.BufferedOutputStream;
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.beans.Encoder;
-import java.beans.XMLDecoder;
-import java.beans.XMLEncoder;
-import java.beans.ExceptionListener;
-import java.beans.Expression;
-import java.beans.PersistenceDelegate;
-import java.beans.DefaultPersistenceDelegate;
-
-import junit.framework.TestCase;
-
import net.dpml.metro.info.PartReference;
import net.dpml.metro.data.ValueDirective;

@@ -52,12 +34,20 @@

private PartReference m_reference;

+ /**
+ * Setup the testcase.
+ * @exception Exception if an error occurs during setup.
+ */
public void setUp() throws Exception
{
m_directive = new ValueDirective( "test" );
m_reference = new PartReference( m_key, m_directive );
}

+ /**
+ * Test part reference encoding/decoding.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
PartReference ref = new PartReference( m_key, m_directive );

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-01-07 19:07:33 UTC (rev 873)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/TypeTestCase.java
2006-01-08 05:51:57 UTC (rev 874)
@@ -27,8 +27,6 @@

import java.util.Properties;

-import junit.framework.TestCase;
-
import net.dpml.metro.info.CategoryDescriptor;
import net.dpml.metro.info.ContextDescriptor;
import net.dpml.metro.info.EntryDescriptor;
@@ -42,7 +40,7 @@
import net.dpml.state.State;

/**
- * TypeTestCase does XYZ
+ * TypeTestCase.
*
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
@@ -58,16 +56,20 @@
private String m_key;
private State m_graph;

+ /**
+ * Testcase setup.
+ */
public void setUp()
{
m_reference = new ServiceDescriptor( TypeTestCase.class.getName() );
m_key = TypeTestCase.class.getName();
m_info = createSimpleInfo( TypeTestCase.class.getName() );
- m_loggers = new CategoryDescriptor[] {
- new CategoryDescriptor("name", Priority.INFO, new Properties())
- };
+ m_loggers =
+ new CategoryDescriptor[]{
+ new CategoryDescriptor( "name", Priority.INFO, new Properties() )
+ };
m_context = new ContextDescriptor( new EntryDescriptor[0] );
- m_services = new ServiceDescriptor[] { m_reference };
+ m_services = new ServiceDescriptor[]{m_reference};
m_parts = new PartReference[0];
m_graph = State.NULL_STATE;
}
@@ -81,8 +83,8 @@
assertEquals( m_graph, type.getStateGraph() );
assertEquals( m_services[0], type.getServiceDescriptor( m_reference
) );
assertEquals( m_services[0], type.getServiceDescriptor(
m_services[0].getClassname() ) );
- checkArray( m_services, type.getServiceDescriptors());
- checkArray( m_parts, type.getPartReferences());
+ checkArray( m_services, type.getServiceDescriptors() );
+ checkArray( m_parts, type.getPartReferences() );
assertTrue( type.isaCategory( m_loggers[0].getName() ) );
assertTrue( !type.isaCategory( "fake name" ) );
}
@@ -96,6 +98,9 @@
}
}

+ /**
+ * Validate the type.
+ */
public void testType()
{
Type type =
@@ -104,29 +109,28 @@
checkType( type );
}

+ /**
+ * Test serialization.
+ * @exception IOException if an IO error occurs
+ * @exception ClassNotFoundException if a class is not found
+ */
public void testSerialization() throws IOException,
ClassNotFoundException
{
Type type =
new Type(
m_info, m_loggers, m_context, m_services, m_parts, m_graph );
-
checkType( type );
-
File file = new File( "test.out" );
ObjectOutputStream oos = new ObjectOutputStream( new
FileOutputStream( file ) );
oos.writeObject( type );
oos.close();
-
ObjectInputStream ois = new ObjectInputStream( new FileInputStream(
file ) );
Type serialized = (Type) ois.readObject();
ois.close();
file.delete();
-
checkType( serialized );
-
assertEquals( "equality", type, serialized );
assertEquals( "hashcode", type.hashCode(), serialized.hashCode() );
-
}

private static InfoDescriptor createSimpleInfo( String classname )
@@ -134,6 +138,10 @@
return new InfoDescriptor( null, classname, null, null,
CollectionPolicy.WEAK, false, null );
}

+ /**
+ * Test encoding/decoding.
+ * @exception Exception if an error occurs
+ */
public void testEncoding() throws Exception
{
Type type =

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/model/test/ValidationExceptionTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/model/test/ValidationExceptionTestCase.java
2006-01-07 19:07:33 UTC (rev 873)
+++
trunk/main/metro/model/src/test/net/dpml/metro/model/test/ValidationExceptionTestCase.java
2006-01-08 05:51:57 UTC (rev 874)
@@ -34,6 +34,11 @@
*/
public class ValidationExceptionTestCase extends TestCase
{
+ /**
+ * Test that the validation exception Issue constructor throws a NPE
+ * when supplied with a null key.
+ * @exception Exception if an error occurs
+ */
public void testIssueNullKey() throws Exception
{
try
@@ -47,6 +52,11 @@
}
}

+ /**
+ * Test that the validation exception Issue constructor throws a NPE
+ * when suopplied with a null message.
+ * @exception Exception if an error occurs
+ */
public void testIssueNullMessage() throws Exception
{
try
@@ -60,6 +70,10 @@
}
}

+ /**
+ * Test issue key and message accessor.
+ * @exception Exception if an error occurs
+ */
public void testIssueAccessors() throws Exception
{
Issue issue = new Issue( "key", "message" );
@@ -67,6 +81,10 @@
assertEquals( "issue-message", "message", issue.getMessage() );
}

+ /**
+ * Test accessor.
+ * @exception Exception if an error occurs
+ */
public void testExceptionAccessors() throws Exception
{
Issue[] issues = new Issue[3];
@@ -78,6 +96,11 @@
assertEquals( "issues-source", this, exception.getSource() );
}

+ /**
+ * Test that the validation exception constructor throws a NPE
+ * when supplied with a null source.
+ * @exception Exception if an error occurs
+ */
public void testValidationNullSource() throws Exception
{
try
@@ -91,6 +114,11 @@
}
}

+ /**
+ * Test that the validation exception constructor throws a NPE
+ * when supplied with a null issues array.
+ * @exception Exception if an error occurs
+ */
public void testValidationNullIssues() throws Exception
{
try




  • r874 - in trunk/main: . metro/model/src/test/net/dpml/metro/info/test metro/model/src/test/net/dpml/metro/model/test, mcconnell at BerliOS, 01/08/2006

Archive powered by MHonArc 2.6.24.

Top of Page