Skip to Content.
Sympa Menu

notify-dpml - r887 - in trunk/main/transit/core/src/test/net/dpml/transit: . info 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: r887 - in trunk/main/transit/core/src/test/net/dpml/transit: . info test
  • Date: Mon, 9 Jan 2006 00:19:27 +0100

Author: mcconnell
Date: 2006-01-09 00:19:24 +0100 (Mon, 09 Jan 2006)
New Revision: 887

Modified:

trunk/main/transit/core/src/test/net/dpml/transit/PropertiesPluginTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/test/AbstractEncodingTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/test/ArtifactTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
trunk/main/transit/core/src/test/net/dpml/transit/test/LinkTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/test/MimeHandlerTestCase.java
trunk/main/transit/core/src/test/net/dpml/transit/test/OfflineTestCase.java
trunk/main/transit/core/src/test/net/dpml/transit/test/OnlineTestCase.java

trunk/main/transit/core/src/test/net/dpml/transit/test/PropertyResolverTestCase.java
Log:
resolve all transit checkstyle issues

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/PropertiesPluginTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/PropertiesPluginTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/PropertiesPluginTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -19,15 +19,11 @@
package net.dpml.transit;

import java.io.InputStream;
-
import java.net.URI;
-
import java.util.Properties;

import junit.framework.TestCase;

-import net.dpml.transit.Artifact;
-
/**
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
* @version $Id: PropertiesPluginTestCase.java 2445 2005-04-28 23:44:22Z
niclas AT hedhman.org $

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/AbstractTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -27,12 +27,9 @@
import java.io.FileOutputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.beans.Encoder;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.beans.ExceptionListener;
-import java.beans.Expression;
import java.util.Properties;

import junit.framework.TestCase;

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/CacheDirectiveTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -18,8 +18,6 @@

package net.dpml.transit.info;

-import java.util.Arrays;
-
/**
* Testing the CodeBaseDirective class.
*

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/CodeBaseDirectiveTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -28,10 +28,28 @@
*/
public class CodeBaseDirectiveTestCase extends AbstractTestCase
{
- protected String m_codebase;
- protected ValueDirective[] m_values;
+ private String m_codebase;
+ private ValueDirective[] m_values;

/**
+ * Return the test codebase value.
+ * @return the codebase spec
+ */
+ protected String getCodebaseValue()
+ {
+ return m_codebase;
+ }
+
+ /**
+ * Return the test value directives.
+ * @return the value directive array
+ */
+ protected ValueDirective[] getValueDirectives()
+ {
+ return m_values;
+ }
+
+ /**
* Test case setup.
* @exception Exception if an error occurs during setup.
*/

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/ContentDirectiveTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -18,8 +18,6 @@

package net.dpml.transit.info;

-import java.net.URI;
-
/**
* Testing the CodeBaseDirective class.
*
@@ -37,8 +35,10 @@
*/
public void testID() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
ContentDirective directive =
- new ContentDirective( m_id, m_title, m_codebase, m_values );
+ new ContentDirective( m_id, m_title, codebase, values );

assertEquals( "id", m_id, directive.getID() );
}
@@ -49,8 +49,10 @@
*/
public void testTitle() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
ContentDirective directive =
- new ContentDirective( m_id, m_title, m_codebase, m_values );
+ new ContentDirective( m_id, m_title, codebase, values );

assertEquals( "title", m_title, directive.getTitle() );
}
@@ -61,10 +63,12 @@
*/
public void testNullID() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
try
{
ContentDirective directive =
- new ContentDirective( null, m_title, m_codebase, m_values );
+ new ContentDirective( null, m_title, codebase, values );
fail( "NPE expected" );
}
catch( NullPointerException e )
@@ -79,8 +83,10 @@
*/
public void testNullTitle() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
ContentDirective directive =
- new ContentDirective( m_id, null, m_codebase, m_values );
+ new ContentDirective( m_id, null, codebase, values );
assertEquals( "title", m_id, directive.getTitle() );
}

@@ -90,8 +96,10 @@
*/
public void testSerialization() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
ContentDirective directive =
- new ContentDirective( m_id, m_title, m_codebase, m_values );
+ new ContentDirective( m_id, m_title, codebase, values );
doSerializationTest( directive );
}

@@ -101,8 +109,10 @@
*/
public void testEncoding() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
ContentDirective directive =
- new ContentDirective( m_id, m_title, m_codebase, m_values );
+ new ContentDirective( m_id, m_title, codebase, values );
ContentDirective result =
(ContentDirective) doEncodingTest( directive,
"content-handler-directive.xml" );
assertEquals( "encoded", directive, result );

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/HostDirectiveTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -18,8 +18,6 @@

package net.dpml.transit.info;

-import java.util.Arrays;
-
/**
* Testing the CodeBaseDirective class.
*

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/LayoutDirectiveTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -18,8 +18,6 @@

package net.dpml.transit.info;

-import java.net.URI;
-
/**
* Testing the CodeBaseDirective class.
*
@@ -37,8 +35,10 @@
*/
public void testID() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
LayoutDirective directive =
- new LayoutDirective( m_id, m_title, m_codebase, m_values );
+ new LayoutDirective( m_id, m_title, codebase, values );

assertEquals( "id", m_id, directive.getID() );
}
@@ -49,8 +49,10 @@
*/
public void testTitle() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
LayoutDirective directive =
- new LayoutDirective( m_id, m_title, m_codebase, m_values );
+ new LayoutDirective( m_id, m_title, codebase, values );

assertEquals( "title", m_title, directive.getTitle() );
}
@@ -61,10 +63,12 @@
*/
public void testNullID() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
try
{
LayoutDirective directive =
- new LayoutDirective( null, m_title, m_codebase, m_values );
+ new LayoutDirective( null, m_title, codebase, values );
fail( "NPE expected" );
}
catch( NullPointerException e )
@@ -79,8 +83,10 @@
*/
public void testNullTitle() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
LayoutDirective directive =
- new LayoutDirective( m_id, null, m_codebase, m_values );
+ new LayoutDirective( m_id, null, codebase, values );
assertEquals( "title", m_id, directive.getTitle() );
}

@@ -90,8 +96,10 @@
*/
public void testSerialization() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
LayoutDirective directive =
- new LayoutDirective( m_id, m_title, m_codebase, m_values );
+ new LayoutDirective( m_id, m_title, codebase, values );
doSerializationTest( directive );
}

@@ -101,8 +109,10 @@
*/
public void testEncoding() throws Exception
{
+ String codebase = getCodebaseValue();
+ ValueDirective[] values = getValueDirectives();
LayoutDirective directive =
- new LayoutDirective( m_id, m_title, m_codebase, m_values );
+ new LayoutDirective( m_id, m_title, codebase, values );
LayoutDirective result =
(LayoutDirective) doEncodingTest( directive,
"content-handler-directive.xml" );
assertEquals( "encoded", directive, result );

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/ProxyDirectiveTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -18,8 +18,6 @@

package net.dpml.transit.info;

-import java.util.Arrays;
-
/**
* Testing the CodeBaseDirective class.
*
@@ -40,9 +38,9 @@
public void setUp() throws Exception
{
m_host = "http://localhost:1234";;
- m_excludes = new String[]{ "http://www.gotham-city.net"; };
+ m_excludes = new String[]{"http://www.gotham-city.net"};
m_username = "batman";
- m_password = new char[]{'r','o','b','i','n'};
+ m_password = new char[]{'r', 'o', 'b', 'i', 'n'};
}

/**
@@ -109,7 +107,7 @@
public void testNullHost() throws Exception
{
String host = null;
- String[] excludes = new String[]{ "http://www.osm.net"; };
+ String[] excludes = new String[]{"http://www.osm.net"};
String username = "me";
char[] password = new char[0];
try
@@ -130,7 +128,7 @@
public void testClassicSerialization() throws Exception
{
String host = "http://localhost:1234";;
- String[] excludes = new String[]{ "http://www.osm.net"; };
+ String[] excludes = new String[]{"http://www.osm.net"};
String username = "me";
char[] password = new char[0];
ProxyDirective directive = new ProxyDirective( host, excludes,
username, password );
@@ -144,7 +142,7 @@
public void testClassicEncoding() throws Exception
{
String host = "http://localhost:1234";;
- String[] excludes = new String[]{ "http://www.osm.net"; };
+ String[] excludes = new String[]{"http://www.osm.net"};
String username = "me";
char[] password = new char[0];
ProxyDirective directive = new ProxyDirective( host, excludes,
username, password );

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/TransitDirectiveTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -18,8 +18,6 @@

package net.dpml.transit.info;

-import java.util.Arrays;
-
/**
* Testing the CodeBaseDirective class.
*
@@ -40,8 +38,8 @@
{
m_proxy =
new ProxyDirective(
- "http://localhost:1234";, new String[]{
"http://www.gotham-city.net"; },
- "batman", new char[]{'r','o','b','i','n'} );
+ "http://localhost:1234";, new
String[]{"http://www.gotham-city.net"},
+ "batman", new char[]{'r', 'o', 'b', 'i', 'n'} );
m_cache =
new CacheDirective(
"${dpml.data}/cache", "classic", "${dpml.share}/local",
"modern",

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/info/ValueDirectiveTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -21,7 +21,6 @@
import java.io.File;

import net.dpml.transit.Construct;
-import net.dpml.transit.ValueException;

/**
* Testing the ValueDirective class.

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/test/AbstractEncodingTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/test/AbstractEncodingTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/test/AbstractEncodingTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -23,15 +23,11 @@
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;

@@ -95,7 +91,7 @@
{
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/transit/core/src/test/net/dpml/transit/test/ArtifactTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/test/ArtifactTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/test/ArtifactTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -133,7 +133,7 @@
*/
public void testFullSpec() throws Exception
{
- Artifact artifact = Artifact.createArtifact(
"artifact:jar:group/sub-group/name#version");
+ Artifact artifact = Artifact.createArtifact(
"artifact:jar:group/sub-group/name#version" );
verify( artifact, "group/sub-group", "name", "jar", "version" );
}

@@ -179,7 +179,7 @@
*/
public void testNullVersion() throws Exception
{
- Artifact artifact = Artifact.createArtifact(
"artifact:jar:group/sub-group/name");
+ Artifact artifact = Artifact.createArtifact(
"artifact:jar:group/sub-group/name" );
verify( artifact, "group/sub-group", "name", "jar", null );
}

@@ -241,7 +241,7 @@
*/
public void testZeroLengthVersion() throws Exception
{
- Artifact artifact = Artifact.createArtifact(
"artifact:jar:group/sub-group/name#");
+ Artifact artifact = Artifact.createArtifact(
"artifact:jar:group/sub-group/name#" );
verify( artifact, "group/sub-group", "name", "jar", null );
}


Modified:
trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/test/ConstructTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -27,7 +27,6 @@

import net.dpml.transit.Value;
import net.dpml.transit.Construct;
-import net.dpml.transit.info.ValueDirective;

/**
* Construct testcase.
@@ -182,7 +181,7 @@

Value number = new Construct( "int", "${number}" );
Value logical = new Construct( "boolean", "${logical}" );
- Value construct = new Construct( Context2.class.getName(), new
Value[]{ number, logical } );
+ Value construct = new Construct( Context2.class.getName(), new
Value[]{number, logical} );
Object value = construct.resolve( map );

assertEquals( "isa-context", value.getClass(), Context2.class );
@@ -207,7 +206,7 @@
{
Value number = new Construct( "int", "${number}" );
Value logical = new Construct( "boolean", "${logical}" );
- Value construct = new Construct( Context2.class.getName(), new
Value[]{ number, logical } );
+ Value construct = new Construct( Context2.class.getName(), new
Value[]{number, logical} );
Value result = (Value) executeEncodingTest( construct,
"construct.xml" );
assertEquals( "encoding", construct, result );
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/test/LinkTestCase.java
===================================================================
--- trunk/main/transit/core/src/test/net/dpml/transit/test/LinkTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++ trunk/main/transit/core/src/test/net/dpml/transit/test/LinkTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -22,9 +22,6 @@
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
-import java.util.prefs.Preferences;
-import java.util.logging.Logger;
-import java.util.logging.Level;

import junit.framework.TestCase;

@@ -38,19 +35,21 @@
import net.dpml.transit.info.ContentDirective;
import net.dpml.transit.monitor.LoggingAdapter;
import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.model.HostModel;
import net.dpml.transit.Transit;
import net.dpml.transit.DefaultTransitModel;

/**
- *
+ * LinkTestCase.
* @author <a href="http://www.dpml.net/";>The Digital Product Meta
Library</a>
* @version $Id$
*/
public class LinkTestCase extends TestCase
{
- static Transit TRANSIT = setupTransit();
+ static final Transit TRANSIT = setupTransit();

+ /**
+ * Static Transit setup.
+ */
private static Transit setupTransit()
{
System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
@@ -78,6 +77,10 @@
}
}

+ /**
+ * Test-case setup.
+ * @exception Exception if an error occurs
+ */
public void setUp() throws Exception
{
if( null == TRANSIT )
@@ -87,7 +90,7 @@
}

/**
- * Constructor
+ * Creation of a new link testcase.
* @param name the test name
*/
public LinkTestCase( String name )
@@ -95,32 +98,41 @@
super( name );
}

- public void testDefaultValue()
- throws Exception
+ /**
+ * Test default target value.
+ * @exception Exception if an error occurs
+ */
+ public void testDefaultValue() throws Exception
{
URL url = new URL( "link:blob:transit/test/aaa/bbb" );
- Class[] args = new Class[] { Link.class };
+ Class[] args = new Class[]{Link.class};
Link link = (Link) url.getContent( args );
URI defUri = URI.create( "artifact:bla:abc/def#142" );
URI uri = link.getTargetURI( defUri );
assertEquals( "default", defUri, uri );
}

- public void testContentUri()
- throws Exception
+ /**
+ * Test content value.
+ * @exception Exception if an error occurs
+ */
+ public void testContentUri() throws Exception
{
URI orig = URI.create( "link:blob:transit/test/aaa/bbb" );
URL url = orig.toURL();
- Class[] args = new Class[] { URI.class };
+ Class[] args = new Class[]{URI.class};
URI found = (URI) url.getContent( args );
assertEquals( "default", orig, found );
}

- public void testSetValue()
- throws Exception
+ /**
+ * Test value assignment.
+ * @exception Exception if an error occurs
+ */
+ public void testSetValue() throws Exception
{
URL url = new URL( "link:blob:transit/test/aaa/ccc" );
- Class[] args = new Class[] { Link.class };
+ Class[] args = new Class[]{Link.class};
Link link = (Link) url.getContent( args );
URI newUri = URI.create( "artifact:testfile:dpml/test/abc#1.0.1" );
link.setTargetURI( newUri );
@@ -133,11 +145,14 @@
assertEquals( "setting", newUri, uri );
}

- public void testResetValue()
- throws Exception
+ /**
+ * Test value reset.
+ * @exception Exception if an error occurs
+ */
+ public void testResetValue() throws Exception
{
URL url = new URL( "link:blob:transit/test/example" );
- Class[] args = new Class[] { Link.class };
+ Class[] args = new Class[]{Link.class};
Link link = (Link) url.getContent( args );
URI newUri = URI.create( "artifact:testfile:dpml/test/abc#1.0" );
link.setTargetURI( newUri );
@@ -145,11 +160,14 @@
link.setTargetURI( newerUri );
}

- public void testGetValue()
- throws Exception
+ /**
+ * Test get value.
+ * @exception Exception if an error occurs
+ */
+ public void testGetValue() throws Exception
{
URL url = new URL( "link:blob:transit/test/aaa/xxx" );
- Class[] args = new Class[] { Link.class };
+ Class[] args = new Class[]{Link.class};
Link link = (Link) url.getContent( args );
URI newUri = URI.create( "artifact:testfile:dpml/test/abc#1.0.1" );
link.setTargetURI( newUri );
@@ -161,11 +179,15 @@
assertTrue( "different content", StreamUtils.compareStreams( in1,
in2 ) );
}

+ /**
+ * Test illegal link artifact.
+ * @exception Exception if an error occurs
+ */
public void testIllegalArtifact()
throws Exception
{
URL url = new URL( "link:blob:transit/test/errors/aaa" );
- Class[] args = new Class[] { Link.class };
+ Class[] args = new Class[]{Link.class};
URI newUri = URI.create( "artifact:abc:does/not/exist" );
try
{

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/test/MimeHandlerTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/test/MimeHandlerTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/test/MimeHandlerTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -24,27 +24,33 @@

import net.dpml.transit.util.MimeTypeHandler;

-public class MimeHandlerTestCase extends TestCase
+/**
+ * MimeHandlerTestCase.
+ */
+public final class MimeHandlerTestCase extends TestCase
{
- static private String[][] TESTS = new String[][]
+ private static final String[][] TESTS = new String[][]
{
- { "plugin", "text/x-dpml-plugin" },
- { "conf", "text/x-dpml-conf" },
- { "jar", "application/x-jar" },
- { "zip", "application/x-zip" },
- { "pdf", "application/pdf" },
- { "png", "image/png" },
- { "jpg", "image/jpg" },
- { "gif", "image/gif" },
- { "link", "application/x-dpml-link" },
- { "part", "application/x-dpml-part" }
+ {"plugin", "text/x-dpml-plugin"},
+ {"conf", "text/x-dpml-conf"},
+ {"jar", "application/x-jar"},
+ {"zip", "application/x-zip"},
+ {"pdf", "application/pdf"},
+ {"png", "image/png"},
+ {"jpg", "image/jpg"},
+ {"gif", "image/gif"},
+ {"link", "application/x-dpml-link"},
+ {"part", "application/x-dpml-part"}
};

- static public Test suite()
+ /**
+ * Return the test suite.
+ * @return the test
+ */
+ public static Test suite()
{
TestSuite tests = new TestSuite();
-
- for( int i = 0 ; i < TESTS.length ; i++ )
+ for( int i = 0; i<TESTS.length; i++ )
{
String lookup = TESTS[i][0];
String expected = TESTS[i][1];
@@ -58,23 +64,30 @@
return tests;
}

- private String m_Lookup;
- private String m_Expected;
+ private String m_lookup;
+ private String m_expected;

private MimeHandlerTestCase( String name, String lookup, String expected
)
{
super( name );
- m_Lookup = lookup;
- m_Expected = expected;
+ m_lookup = lookup;
+ m_expected = expected;
}

+ /**
+ * Test mime type lookup.
+ * @exception Exception if an error occurs
+ */
public void testLookup()
throws Exception
{
- String mime = MimeTypeHandler.getMimeType( m_Lookup );
- assertEquals( m_Lookup, m_Expected, mime );
+ String mime = MimeTypeHandler.getMimeType( m_lookup );
+ assertEquals( m_lookup, m_expected, mime );
}

+ /**
+ * Test mime map size.
+ */
public void testSize()
{
assertEquals( "Map Size", TESTS.length,
MimeTypeHandler.getMimeTypesSize() );

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/test/OfflineTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/test/OfflineTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/test/OfflineTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -26,9 +26,6 @@
import java.io.OutputStream;
import java.net.URL;
import java.net.URLClassLoader;
-import java.util.prefs.Preferences;
-import java.util.logging.Logger;
-import java.util.logging.Level;
import java.util.Date;

import junit.framework.TestCase;
@@ -40,7 +37,6 @@
import net.dpml.transit.info.ContentDirective;
import net.dpml.transit.monitor.LoggingAdapter;
import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.model.HostModel;
import net.dpml.transit.Transit;
import net.dpml.transit.DefaultTransitModel;

@@ -52,7 +48,7 @@
*/
public class OfflineTestCase extends TestCase
{
- static Transit TRANSIT = setupTransit();
+ private static final Transit TRANSIT = setupTransit();

private static Transit setupTransit()
{
@@ -81,59 +77,85 @@
}
}

+ /**
+ * Test case setup.
+ * @exception Exception if an error occurs
+ */
protected void setUp() throws Exception
{
new File( "target/test/cache" ).delete();
}

- public void testDownloadNoVersion()
- throws Exception
+ /**
+ * Test non-version artifact download.
+ * @exception Exception if an error occurs
+ */
+ public void testDownloadNoVersion() throws Exception
{
URL url = new URL( "artifact:testfile:dpml/test/1" );
String content = getContent( url );
assertEquals( "Content not retrieved.", "abc\n", content );
}

- public void testDownloadWithVersion()
- throws Exception
+ /**
+ * Test version artifact download.
+ * @exception Exception if an error occurs
+ */
+ public void testDownloadWithVersion() throws Exception
{
URL url = new URL( "artifact:testfile:dpml/test/abc#1.0.1" );
String content = getContent( url );
assertEquals( "Content not retrieved.", "abc\ndef\n", content );
}

- public void testClassLoader1()
- throws Exception
+ /**
+ * Test classloader construction.
+ * @exception Exception if an error occurs
+ */
+ public void testClassLoader1() throws Exception
{
URL url = new URL( "artifact:jar:dpml/test/dpml-test-testa" );
- ClassLoader classloader = new URLClassLoader( new URL[]{ url } );
+ ClassLoader classloader = new URLClassLoader( new URL[]{url} );
classloader.loadClass( "net.dpml.test.testa.A" );
}

- public void testClassLoader2()
- throws Exception
+ /**
+ * Test classloader construction.
+ * @exception Exception if an error occurs
+ */
+ public void testClassLoader2() throws Exception
{
URL url = new URL( "artifact:jar:dpml/test/dpml-test-testb" );
- ClassLoader classloader = new URLClassLoader( new URL[]{ url } );
+ ClassLoader classloader = new URLClassLoader( new URL[]{url} );
classloader.loadClass( "net.dpml.test.testb.B" );
}

- public void testContentConversionA()
- throws Exception
+ /**
+ * Test content conversion.
+ * @exception Exception if an error occurs
+ */
+ public void testContentConversionA() throws Exception
{
URL url = new URL( "artifact:jar:dpml/test/dpml-test-testa" );
Object content = url.getContent();
assertTrue( "Content type not correct.", content instanceof
InputStream );
}

- public void testContentConversionB()
- throws Exception
+ /**
+ * Test content conversion.
+ * @exception Exception if an error occurs
+ */
+ public void testContentConversionB() throws Exception
{
URL url = new URL( "artifact:png:dpml/test/sample" );
Object content = url.getContent();
assertTrue( "Content type not correct.", content instanceof
java.awt.image.ImageProducer );
}

+ /**
+ * Test non-writable artifact.
+ * @exception Exception if an error occurs
+ */
public void testWriteExistingArtifact()
throws Exception
{
@@ -141,19 +163,24 @@
try
{
OutputStream out = url.openConnection().getOutputStream();
- for( int i = 65 ; i < 91 ; i++ )
+ for( int i = 65; i < 91; i++ )
{
out.write( i );
}
out.write( 10 );
out.close();
fail( "Able to write to an existing artifact." );
- } catch( java.io.IOException e )
+ }
+ catch( java.io.IOException e )
{
// A "Artifact on server" exception should be thrown.
}
}

+ /**
+ * Test writable artifact.
+ * @exception Exception if an error occurs
+ */
public void testWriteNewArtifact()
throws Exception
{
@@ -161,7 +188,7 @@
String spec = "artifact:txt:dpml/test/" + name;
URL url = new URL( spec );
OutputStream out = url.openConnection().getOutputStream();
- for( int i = 65 ; i < 91 ; i++ )
+ for( int i = 65; i<91; i++ )
{
out.write( i );
}
@@ -175,7 +202,9 @@
{
int value = in.read();
if( value == -1 )
+ {
break;
+ }
char ch = (char) value;
result.append( ch );
}
@@ -199,7 +228,8 @@
line = in.readLine();
}
return buf.toString();
- } finally
+ }
+ finally
{
stream.close();
}
@@ -208,29 +238,14 @@
private void delete( File dir )
{
File[] entries = dir.listFiles();
- for( int i = 0; i < entries.length; i++ )
+ for( int i=0; i<entries.length; i++ )
{
- File f = entries[ i ];
+ File f = entries[i];
if( f.isDirectory() )
+ {
delete( f );
+ }
f.delete();
}
}
-
-/* TODO: not used
- private void print( URL url )
- {
- System.out.println( "URL: " + url );
- System.out.println( "Authority: " + url.getAuthority() );
- System.out.println( "File: " + url.getFile() );
- System.out.println( "Host: " + url.getHost() );
- System.out.println( "Path: " + url.getPath() );
- System.out.println( "Port: " + url.getPort() );
- System.out.println( "Protocol: " + url.getProtocol() );
- System.out.println( "Query: " + url.getQuery() );
- System.out.println( "Ref: " + url.getRef() );
- System.out.println( "Userinfo: " + url.getUserInfo() );
- System.out.println( "--------------" );
- }
-*/
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/test/OnlineTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/test/OnlineTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/test/OnlineTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -26,8 +26,6 @@

import java.net.URL;
import java.net.URLClassLoader;
-import java.util.prefs.Preferences;
-import java.util.logging.Logger;

import junit.framework.TestCase;

@@ -38,21 +36,20 @@
import net.dpml.transit.info.ContentDirective;
import net.dpml.transit.monitor.LoggingAdapter;
import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.model.HostModel;
import net.dpml.transit.Transit;
import net.dpml.transit.DefaultTransitModel;

/**
- * URL Handler TestCase for Offline operations.
+ * URL Handler TestCase for online operations.
*
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
* @version $Id: OnlineTestCase.java 2926 2005-06-27 10:53:17Z
mcconnell AT dpml.net $
*/
public class OnlineTestCase extends TestCase
{
- static Transit TRANSIT = setupTransit();
+ private static final Transit TRANSIT = setupTransit();

- private static Transit setupTransit()
+ private static final Transit setupTransit()
{
System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
try
@@ -79,13 +76,21 @@
}
}

+ /**
+ * Test stack jar url.
+ * @exception Exception if an error occurs
+ */
public void testStackedJarUrl() throws Exception
{
URL url = new URL(
"jar:artifact:jar:dpml/test/dpml-test-testb!/net/dpml/test/testb/B.class" );
Object obj = url.getContent();
- System.out.println( obj.getClass() );
+ //System.out.println( obj.getClass() );
}

+ /**
+ * Test non-versioned artifact download.
+ * @exception Exception if an error occurs
+ */
public void testDownloadNoVersion() throws Exception
{
URL url = new URL( "artifact:testfile:dpml/test/1" );
@@ -93,6 +98,10 @@
assertEquals( "Content not retrieved.", "abc\n", content );
}

+ /**
+ * Test versioned artifact download.
+ * @exception Exception if an error occurs
+ */
public void testDownloadWithVersion() throws Exception
{
URL url = new URL( "artifact:testfile:dpml/test/abc#1.0.1" );
@@ -100,24 +109,36 @@
assertEquals( "Content not retrieved.", "abc\ndef\n", content );
}

+ /**
+ * Test classloader creation.
+ * @exception Exception if an error occurs
+ */
public void testClassLoader1() throws Exception
{
URL url = new URL( "artifact:jar:dpml/test/dpml-test-testa" );
- ClassLoader classloader = new URLClassLoader( new URL[]{ url } );
+ ClassLoader classloader = new URLClassLoader( new URL[]{url} );
classloader.loadClass( "net.dpml.test.testa.A" );
}

+ /**
+ * Test classloader creation.
+ * @exception Exception if an error occurs
+ */
public void testClassLoader2() throws Exception
{
URL url = new URL( "artifact:jar:dpml/test/dpml-test-testb" );
- ClassLoader classloader = new URLClassLoader( new URL[]{ url } );
+ ClassLoader classloader = new URLClassLoader( new URL[]{url} );
classloader.loadClass( "net.dpml.test.testb.B" );
}

+ /**
+ * Test internal resource.
+ * @exception Exception if an error occurs
+ */
public void testInternalResource() throws Exception
{
URL url = new URL( "artifact:jar:dpml/test/dpml-test-testb" );
- ClassLoader classloader = new URLClassLoader( new URL[]{ url } );
+ ClassLoader classloader = new URLClassLoader( new URL[]{url} );
Class clazz = classloader.loadClass( "net.dpml.test.testb.B" );
URL resourceUrl = clazz.getResource( "TestB.xinfo" );
String external =
@@ -126,6 +147,10 @@
resourceUrl.openStream();
}

+ /**
+ * Test content conversion.
+ * @exception Exception if an error occurs
+ */
public void testContentConversionA() throws Exception
{
URL url = new URL( "artifact:jar:dpml/test/dpml-test-testa" );
@@ -133,6 +158,10 @@
assertTrue( "Content type not correct.", content instanceof
InputStream );
}

+ /**
+ * Test content conversion.
+ * @exception Exception if an error occurs
+ */
public void testContentConversionB() throws Exception
{
URL url = new URL( "artifact:png:dpml/test/sample" );
@@ -157,7 +186,8 @@
line = in.readLine();
}
return buf.toString();
- } finally
+ }
+ finally
{
stream.close();
}

Modified:
trunk/main/transit/core/src/test/net/dpml/transit/test/PropertyResolverTestCase.java
===================================================================
---
trunk/main/transit/core/src/test/net/dpml/transit/test/PropertyResolverTestCase.java
2006-01-08 22:24:54 UTC (rev 886)
+++
trunk/main/transit/core/src/test/net/dpml/transit/test/PropertyResolverTestCase.java
2006-01-08 23:19:24 UTC (rev 887)
@@ -35,6 +35,9 @@
{
private Properties m_properties;

+ /**
+ * Testcase setup.
+ */
public void setUp()
{
m_properties = new Properties();
@@ -46,11 +49,19 @@
m_properties.put( "some.abc.def.ghi.value", "All that." );
}

+ /**
+ * Testcase constructor.
+ * @param name the testcase name
+ */
public PropertyResolverTestCase( String name )
{
super( name );
}

+ /**
+ * Test simple property resolution.
+ * @exception Exception if an error occurs
+ */
public void testSimple1() throws Exception
{
String src = "${abc}";
@@ -59,6 +70,10 @@
assertEquals( expected, result );
}

+ /**
+ * Test simple property resolution.
+ * @exception Exception if an error occurs
+ */
public void testSimple2() throws Exception
{
String src = "Def = ${abc} is it.";
@@ -67,6 +82,10 @@
assertEquals( expected, result );
}

+ /**
+ * Test simple property resolution.
+ * @exception Exception if an error occurs
+ */
public void testSimple3() throws Exception
{
String src = "def = ${abc} = ${def}";
@@ -75,6 +94,10 @@
assertEquals( expected, result );
}

+ /**
+ * Test complex property resolution.
+ * @exception Exception if an error occurs
+ */
public void testComplex1() throws Exception
{
String src = "${${abc}}";
@@ -83,6 +106,10 @@
assertEquals( expected, result );
}

+ /**
+ * Test complex property resolution.
+ * @exception Exception if an error occurs
+ */
public void testComplex2() throws Exception
{
String src = "${some.${mama}.${papa}.${child}.value}";




  • r887 - in trunk/main/transit/core/src/test/net/dpml/transit: . info test, mcconnell at BerliOS, 01/08/2006

Archive powered by MHonArc 2.6.24.

Top of Page