[CVS spice] Added unit tests

mauro-yCVjj/[email protected] 20 Jun 2004 13:38:03 -0000
Newsgroups gmane.comp.java.spice.cvs
Message-ID <[email protected]>
<html>
<head>
<style><!--
  body {background-color:#ffffff;}
  .file {border:1px solid #eeeeee;margin-top:1em;margin-bottom:1em;}
  .pathname {font-family:monospace; float:right;}
  .fileheader {margin-bottom:.5em;}
  .diff {margin:0;}
  .tasklist {padding:4px;border:1px dashed #000000;margin-top:1em;}
  .tasklist ul {margin-top:0;margin-bottom:0;}
  tr.alt {background-color:#eeeeee}
  #added {background-color:#ddffdd;}
  #addedchars {background-color:#99ff99;font-weight:bolder;}
  tr.alt #added {background-color:#ccf7cc;}
  #removed {background-color:#ffdddd;}
  #removedchars {background-color:#ff9999;font-weight:bolder;}
  tr.alt #removed {background-color:#f7cccc;}
  #info {color:#888888;}
  #context {background-color:#eeeeee;}
  td {padding-left:.3em;padding-right:.3em;}
  tr.head {border-bottom-width:1px;border-bottom-style:solid;}
  tr.head td {padding:0;padding-top:.2em;}
  .task {background-color:#ffff00;}
  .comment {padding:4px;border:1px dashed #000000;background-color:#ffffdd}
  .error {color:red;}
  hr {border-width:0px;height:2px;background:black;}
--></style>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="0" rules="cols">
<tr class="head"><td colspan="4">Commit in <b><tt>spice/components/alchemist/src/test/org/codehaus/spice/alchemist</tt></b><span id="info"> on MAIN</span></td></tr>
<tr><td><tt>activity/<a href="#file1"><span id="added">MockAvalonDisposable.java</span></a></tt></td><td align="right" id="added">+24</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file2"><span id="added">MockDNAActive.java</span></a></tt></td><td align="right" id="added">+30</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file3"><span id="added">ActivityAlchemistTestCase.java</span></a></tt></td><td align="right" id="added">+108</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file4"><span id="added">MockAvalonInitializable.java</span></a></tt></td><td align="right" id="added">+24</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>logger/<a href="#file5"><span id="added">MockDNALogEnabled.java</span></a></tt></td><td align="right" id="added">+26</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file6"><span id="added">MockAvalonLogEnabled.java</span></a></tt></td><td align="right" id="added">+25</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file7">LoggerAlchemistTestCase.java</a></tt></td><td align="right" id="added">+67</td><td align="right" id="removed">-4</td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file8">MockLogger.java</a></tt></td><td align="right" id="added">+1</td><td align="right" id="removed">-1</td><td nowrap="nowrap" align="center">1.1 -&gt; 1.2</td></tr>
<tr><td><tt>configuration/<a href="#file9"><span id="added">MockAvalonConfigurable.java</span></a></tt></td><td align="right" id="added">+25</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file10"><span id="added">ConfigurationAlchemistTestCase.java</span></a></tt></td><td align="right" id="added">+126</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file11"><span id="added">MockDNAConfigurable.java</span></a></tt></td><td align="right" id="added">+26</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>instrument/<a href="#file12"><span id="added">MockDNAInstrumentManager.java</span></a></tt></td><td align="right" id="added">+65</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file13"><span id="added">DNAInstrumentManagerTestCase.java</span></a></tt></td><td align="right" id="added">+70</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr class="alt"><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file14"><span id="added">MockAvalonInstrumentManager.java</span></a></tt></td><td align="right" id="added">+65</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/<a href="#file15"><span id="added">InstrumentAlchemistTestCase.java</span></a></tt></td><td align="right" id="added">+25</td><td></td><td nowrap="nowrap" align="right">added 1.1</td></tr>
<tr><td></td><td align="right" id="added">+707</td><td align="right" id="removed">-5</td><td></td></tr>
</table>
<small id="info">13 added + 2 modified, total 15 files</small><br />
<pre class="comment">
Added unit tests
</pre>
<hr /><a name="file1" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/activity<br /></span>
<div class="fileheader" id="added"><big><b>MockAvalonDisposable.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N MockAvalonDisposable.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MockAvalonDisposable.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,24 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.activity;
+
+import org.apache.avalon.framework.activity.Disposable;
+
+
+/**
+ * @author Mauro Talevi
+ */
+public class MockAvalonDisposable implements Disposable {
+    
+    /**
+     * @see Disposable#dispose()
+     */
+    public void dispose(){
+        // no-op
+    }
+}
</pre></div>
<hr /><a name="file2" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/activity<br /></span>
<div class="fileheader" id="added"><big><b>MockDNAActive.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N MockDNAActive.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MockDNAActive.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,30 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.activity;
+
+import org.codehaus.dna.Active;
+
+/**
+ * @author Mauro Talevi
+ */
+public class MockDNAActive implements Active {
+
+    /**
+     * @see Active#initialize()
+     */
+    public void initialize(){
+        // no-op
+    }
+
+    /**
+     * @see Active#dispose()
+     */
+    public void dispose(){
+        // no-op
+    }
+}
</pre></div>
<hr /><a name="file3" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/activity<br /></span>
<div class="fileheader" id="added"><big><b>ActivityAlchemistTestCase.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ActivityAlchemistTestCase.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ActivityAlchemistTestCase.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,108 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.activity;
+
+import org.codehaus.dna.Active;
+import junit.framework.TestCase;
+
+public class ActivityAlchemistTestCase
+    extends TestCase
+{
+
+    public void testIsAvalonInitializable()
+    {
+        MockAvalonInitializable avalonInitializable = new MockAvalonInitializable();
+        MockDNAActive dnaActive = new MockDNAActive();
+        assertTrue("Avalon Initializable", ActivityAlchemist.isAvalonInitializable(avalonInitializable));
+        assertTrue("!Avalon Initializable", !ActivityAlchemist.isAvalonInitializable(dnaActive));
+    }
+
+    public void testToAvalonInitializable()
+    {
+        MockAvalonInitializable avalonInitializable = new MockAvalonInitializable();
+        MockDNAActive dnaActive = new MockDNAActive();
+        assertTrue("Avalon Initializable", 
+                (ActivityAlchemist.toAvalonInitializable(avalonInitializable) 
+                 instanceof org.apache.avalon.framework.activity.Initializable ));
+        try {
+            ActivityAlchemist.toAvalonInitializable( null );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = "Object is not Avalon Initializable";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+        try {
+            ActivityAlchemist.toAvalonInitializable( dnaActive );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = dnaActive.getClass().getName()+ " is not Avalon Initializable";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+    }
+    
+    public void testIsAvalonDisposable()
+    {
+        MockAvalonDisposable avalonDisposable = new MockAvalonDisposable();
+        MockDNAActive dnaActive = new MockDNAActive();
+        assertTrue("Avalon Disposable", ActivityAlchemist.isAvalonDisposable(avalonDisposable));
+        assertTrue("!Avalon Disposable", !ActivityAlchemist.isAvalonDisposable(dnaActive));
+    }
+
+    public void testToAvalonDisposable()
+    {
+        MockAvalonDisposable avalonDisposable = new MockAvalonDisposable();
+        MockDNAActive dnaActive = new MockDNAActive();
+        assertTrue("Avalon Disposable", 
+                (ActivityAlchemist.toAvalonDisposable(avalonDisposable) 
+                 instanceof org.apache.avalon.framework.activity.Disposable ));
+        try {
+            ActivityAlchemist.toAvalonDisposable( null );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = "Object is not Avalon Disposable";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+        try {
+            ActivityAlchemist.toAvalonDisposable( dnaActive );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = dnaActive.getClass().getName()+ " is not Avalon Disposable";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+    }
+    
+    public void testIsDNAActive()
+    {
+        MockAvalonInitializable avalonInitializable = new MockAvalonInitializable();
+        MockDNAActive dnaActive = new MockDNAActive();
+        assertTrue("DNA Initializable", ActivityAlchemist.isDNAActive(dnaActive));
+        assertTrue("!DNA Initializable", !ActivityAlchemist.isDNAActive(avalonInitializable));
+    }
+
+    public void testToDNAActive()
+    {
+        MockAvalonInitializable avalonInitializable = new MockAvalonInitializable();
+        MockDNAActive dnaActive = new MockDNAActive();
+        assertTrue("DNA Active", 
+                (ActivityAlchemist.toDNAActive(dnaActive) instanceof Active ));
+        try {
+            ActivityAlchemist.toDNAActive( null );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = "Object is not DNA Active";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+        try {
+            ActivityAlchemist.toDNAActive( avalonInitializable );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = avalonInitializable.getClass().getName()+ " is not DNA Active";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+    }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file4" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/activity<br /></span>
<div class="fileheader" id="added"><big><b>MockAvalonInitializable.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N MockAvalonInitializable.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MockAvalonInitializable.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,24 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.activity;
+
+import org.apache.avalon.framework.activity.Initializable;
+
+
+/**
+ * @author Mauro Talevi
+ */
+public class MockAvalonInitializable implements Initializable {
+
+    /**
+     * @see Initializable#initialize()
+     */
+    public void initialize(){
+        // no-op
+    }
+}
</pre></div>
<hr /><a name="file5" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/logger<br /></span>
<div class="fileheader" id="added"><big><b>MockDNALogEnabled.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N MockDNALogEnabled.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MockDNALogEnabled.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,26 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.logger;
+
+import org.codehaus.dna.LogEnabled;
+import org.codehaus.dna.Logger;
+
+
+
+/**
+ * @author Mauro Talevi
+ */
+public class MockDNALogEnabled implements LogEnabled {
+
+    /**
+     * @see org.codehaus.dna.LogEnabled#enableLogging(org.codehaus.dna.Logger)
+     */
+    public void enableLogging( Logger arg0 ) {
+        // no-op
+    }
+}
</pre></div>
<hr /><a name="file6" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/logger<br /></span>
<div class="fileheader" id="added"><big><b>MockAvalonLogEnabled.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N MockAvalonLogEnabled.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MockAvalonLogEnabled.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,25 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.logger;
+
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+
+
+/**
+ * @author Mauro Talevi
+ */
+public class MockAvalonLogEnabled implements LogEnabled {
+
+    /**
+     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging( Logger arg0 ) {
+        // no-op
+    }
+}
</pre></div>
<hr /><a name="file7" /><div class="file">
<span class="pathname">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/logger<br /></span>
<div class="fileheader"><big><b>LoggerAlchemistTestCase.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- LoggerAlchemistTestCase.java	13 Jun 2004 13:35:14 -0000	1.1
+++ LoggerAlchemistTestCase.java	20 Jun 2004 13:38:03 -0000	1.2
@@ -7,6 +7,7 @@
</small></pre><pre class="diff" id="context">  */
 package org.codehaus.spice.alchemist.logger;
 
</pre><pre class="diff" id="added">+import org.codehaus.dna.LogEnabled;
</pre><pre class="diff" id="context"> import junit.framework.TestCase;
 
 public class LoggerAlchemistTestCase
</pre><pre class="diff"><small id="info">@@ -20,10 +21,11 @@
</small></pre><pre class="diff" id="context">         try
         {
             LoggerAlchemist.toDNALogger( null );
</pre><pre class="diff" id="added">+            fail("Expected NPE");
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="removed">-        catch( NullPointerException <span id="removedchars">np</span>e )
</pre><pre class="diff" id="added">+        catch( NullPointerException e )
</pre><pre class="diff" id="context">         {
</pre><pre class="diff" id="removed">-            assertEquals( "npe.getMessage()", "logger", npe.getMessage() );
</pre><pre class="diff" id="added">+            assertEquals( "NPE message", "logger", e.getMessage() );
</pre><pre class="diff" id="context">         }
     }
 
</pre><pre class="diff"><small id="info">@@ -33,11 +35,72 @@
</small></pre><pre class="diff" id="context">         try
         {
             LoggerAlchemist.toAvalonLogger( null );
</pre><pre class="diff" id="added">+            fail("Expected NPE");
</pre><pre class="diff" id="context">         }
</pre><pre class="diff" id="removed">-        catch( NullPointerException <span id="removedchars">np</span>e )
</pre><pre class="diff" id="added">+        catch( NullPointerException e )
</pre><pre class="diff" id="context">         {
</pre><pre class="diff" id="removed">-            assertEquals( "npe.getMessage()", "logger", npe.getMessage() );
</pre><pre class="diff" id="added">+            assertEquals( "NPE message", "logger", e.getMessage() );
</pre><pre class="diff" id="context">         }
     }
</pre><pre class="diff" id="added">+    
+    public void testIsAvalonLogEnabled()
+    {
+        MockAvalonLogEnabled avalonLogEnabled = new MockAvalonLogEnabled();
+        MockDNALogEnabled dnaLogEnabled = new MockDNALogEnabled();
+        assertTrue("Avalon LogEnabled", LoggerAlchemist.isAvalonLogEnabled(avalonLogEnabled));
+        assertTrue("!Avalon LogEnabled", !LoggerAlchemist.isAvalonLogEnabled(dnaLogEnabled));
+    }
</pre><pre class="diff" id="context"> 
</pre><pre class="diff" id="added">+    public void testToAvalonLogEnabled()
+    {
+        MockAvalonLogEnabled avalonLogEnabled = new MockAvalonLogEnabled();
+        MockDNALogEnabled dnaLogEnabled = new MockDNALogEnabled();
+        assertTrue("Avalon LogEnabled", 
+                (LoggerAlchemist.toAvalonLogEnabled(avalonLogEnabled) 
+                 instanceof org.apache.avalon.framework.logger.LogEnabled ));
+        try {
+            LoggerAlchemist.toAvalonLogEnabled( null );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = "Object is not Avalon LogEnabled";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+        try {
+            LoggerAlchemist.toAvalonLogEnabled( dnaLogEnabled );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = dnaLogEnabled.getClass().getName()+ " is not Avalon LogEnabled";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+    }
+    
+    public void testIsDNALogEnabled()
+    {
+        MockAvalonLogEnabled avalonLogEnabled = new MockAvalonLogEnabled();
+        MockDNALogEnabled dnaLogEnabled = new MockDNALogEnabled();
+        assertTrue("DNA LogEnabled", LoggerAlchemist.isDNALogEnabled(dnaLogEnabled));
+        assertTrue("!DNA LogEnabled", !LoggerAlchemist.isDNALogEnabled(avalonLogEnabled));
+    }
+
+    public void testToDNALogEnabled()
+    {
+        MockAvalonLogEnabled avalonLogEnabled = new MockAvalonLogEnabled();
+        MockDNALogEnabled dnaLogEnabled = new MockDNALogEnabled();
+        assertTrue("DNA LogEnabled", 
+                (LoggerAlchemist.toDNALogEnabled(dnaLogEnabled) instanceof LogEnabled ));
+        try {
+            LoggerAlchemist.toDNALogEnabled( null );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = "Object is not DNA LogEnabled";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+        try {
+            LoggerAlchemist.toDNALogEnabled( avalonLogEnabled );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = avalonLogEnabled.getClass().getName()+ " is not DNA LogEnabled";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+    }
</pre><pre class="diff" id="context"> }
</pre></div>
<hr /><a name="file8" /><div class="file">
<span class="pathname">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/logger<br /></span>
<div class="fileheader"><big><b>MockLogger.java</b></big> <small id="info">1.1 -&gt; 1.2</small></div>
<pre class="diff"><small id="info">diff -u -r1.1 -r1.2
--- MockLogger.java	13 Jun 2004 13:35:14 -0000	1.1
+++ MockLogger.java	20 Jun 2004 13:38:03 -0000	1.2
@@ -11,7 +11,7 @@
</small></pre><pre class="diff" id="context"> import java.util.logging.LogRecord;
 import java.util.logging.Logger;
 
</pre><pre class="diff" id="removed">-class MockLogger
</pre><pre class="diff" id="added">+<span id="addedchars">public&nbsp;</span>class MockLogger
</pre><pre class="diff" id="context">     extends Logger
 {
     boolean m_output;
</pre></div>
<hr /><a name="file9" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/configuration<br /></span>
<div class="fileheader" id="added"><big><b>MockAvalonConfigurable.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N MockAvalonConfigurable.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MockAvalonConfigurable.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,25 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.configuration;
+
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+
+
+/**
+ * @author Mauro Talevi
+ */
+public class MockAvalonConfigurable implements Configurable {
+
+    /**
+     * @see Configurable#configure(Configuration)
+     */
+    public void configure( Configuration configuration ) {
+        // no-op
+    }
+}
</pre></div>
<hr /><a name="file10" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/configuration<br /></span>
<div class="fileheader" id="added"><big><b>ConfigurationAlchemistTestCase.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N ConfigurationAlchemistTestCase.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ ConfigurationAlchemistTestCase.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,126 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.configuration;
+
+import junit.framework.TestCase;
+import org.codehaus.dna.Configurable;
+import org.codehaus.dna.Configuration;
+import org.codehaus.dna.impl.DefaultConfiguration;
+
+public class ConfigurationAlchemistTestCase
+    extends TestCase
+{
+    public void testAvalonConfigurationWithNullConfiguration()
+        throws Exception
+    {
+        try
+        {
+            ConfigurationAlchemist.toAvalonConfiguration( null );
+            fail("Expected NPE");
+        }
+        catch( NullPointerException e )
+        {
+            assertEquals( "NPE message", "configuration", e.getMessage() );
+        }
+    }
+
+    public void testDNAConfigurationWithNullConfiguration()
+    	throws Exception
+    {
+        try
+        {
+            ConfigurationAlchemist.toDNAConfiguration( null );
+            fail("Expected NPE");
+        }
+        catch( NullPointerException e )
+        {
+            assertEquals( "NPE message", "configuration", e.getMessage() );
+        }
+    }
+
+    public void testAvalonConfiguration()
+    	throws Exception
+   	{
+        org.apache.avalon.framework.configuration.Configuration configuration =
+            ConfigurationAlchemist.toAvalonConfiguration( new DefaultConfiguration( "name", "location", "") );
+        assertEquals( "configuration name", "name", configuration.getName() );
+        assertEquals( "configuration location", "location", configuration.getLocation() );
+        assertEquals( "configuration namespace", "", configuration.getNamespace() );
+   	}
+    
+    public void testDNAConfiguration()
+    	throws Exception
+	{
+        Configuration configuration = ConfigurationAlchemist.toDNAConfiguration( 
+                new org.apache.avalon.framework.configuration.DefaultConfiguration( "name", "location") );
+        assertEquals( "configuration name", "name", configuration.getName() );
+        assertEquals( "configuration location", "location", configuration.getLocation() );
+        assertEquals( "configuration path", "", configuration.getPath() );
+	}
+    
+    public void testIsAvalonConfigurable()
+    {
+        MockAvalonConfigurable avalonConfigurable = new MockAvalonConfigurable();
+        MockDNAConfigurable dnaConfigurable = new MockDNAConfigurable();
+        assertTrue("Avalon Configurable", ConfigurationAlchemist.isAvalonConfigurable(avalonConfigurable));
+        assertTrue("!Avalon Configurable", !ConfigurationAlchemist.isAvalonConfigurable(dnaConfigurable));
+    }
+
+    public void testToAvalonConfigurable()
+    {
+        MockAvalonConfigurable avalonConfigurable = new MockAvalonConfigurable();
+        MockDNAConfigurable dnaConfigurable = new MockDNAConfigurable();
+        assertTrue("Avalon Configurable", 
+                (ConfigurationAlchemist.toAvalonConfigurable(avalonConfigurable) 
+                 instanceof org.apache.avalon.framework.configuration.Configurable ));
+        try {
+            ConfigurationAlchemist.toAvalonConfigurable( null );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = "Object is not Avalon Configurable";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+        try {
+            ConfigurationAlchemist.toAvalonConfigurable( dnaConfigurable );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = dnaConfigurable.getClass().getName()+ " is not Avalon Configurable";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+    }
+    
+    public void testIsDNAConfigurable()
+    {
+        MockAvalonConfigurable avalonConfigurable = new MockAvalonConfigurable();
+        MockDNAConfigurable dnaConfigurable = new MockDNAConfigurable();
+        assertTrue("DNA Configurable", ConfigurationAlchemist.isDNAConfigurable(dnaConfigurable));
+        assertTrue("!DNA Configurable", !ConfigurationAlchemist.isDNAConfigurable(avalonConfigurable));
+    }
+
+    public void testToDNAConfigurable()
+    {
+        MockAvalonConfigurable avalonConfigurable = new MockAvalonConfigurable();
+        MockDNAConfigurable dnaConfigurable = new MockDNAConfigurable();
+        assertTrue("DNA Configurable", 
+                (ConfigurationAlchemist.toDNAConfigurable(dnaConfigurable) instanceof Configurable ));
+        try {
+            ConfigurationAlchemist.toDNAConfigurable( null );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = "Object is not DNA Configurable";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+        try {
+            ConfigurationAlchemist.toDNAConfigurable( avalonConfigurable );
+            fail("Expected IllegalArgumentException");
+        } catch ( IllegalArgumentException e ) {
+            final String message = avalonConfigurable.getClass().getName()+ " is not DNA Configurable";
+            assertEquals( "IAE message", message, e.getMessage() );
+        }
+    }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file11" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/configuration<br /></span>
<div class="fileheader" id="added"><big><b>MockDNAConfigurable.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N MockDNAConfigurable.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MockDNAConfigurable.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,26 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.configuration;
+
+import org.codehaus.dna.Configurable;
+import org.codehaus.dna.Configuration;
+
+
+
+/**
+ * @author Mauro Talevi
+ */
+public class MockDNAConfigurable implements Configurable {
+
+    /**
+     * @see Configurable#configure(Configuration)
+     */
+    public void configure( Configuration configuration ) {
+        // no-op
+    }
+}
</pre></div>
<hr /><a name="file12" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/instrument<br /></span>
<div class="fileheader" id="added"><big><b>MockDNAInstrumentManager.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N MockDNAInstrumentManager.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MockDNAInstrumentManager.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,65 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.instrument;
+
+import org.apache.excalibur.instrument.InstrumentManager;
+import org.apache.excalibur.instrument.Instrumentable;
+import org.codehaus.dna.Active;
+import org.codehaus.dna.Configurable;
+import org.codehaus.dna.Configuration;
+import org.codehaus.dna.ConfigurationException;
+import org.codehaus.dna.LogEnabled;
+import org.codehaus.dna.Logger;
+
+
+class MockDNAInstrumentManager
+    implements InstrumentManager, LogEnabled, Configurable, Active
+{
+    
+    private String methodCalled;
+    
+    /* (non-Javadoc)
+     * @see org.apache.excalibur.instrument.InstrumentManager#registerInstrumentable(org.apache.excalibur.instrument.Instrumentable, java.lang.String)
+     */
+    public void registerInstrumentable( Instrumentable arg0, String arg1 ) throws Exception {
+        methodCalled = "registerInstrumentable";
+    }
+
+    /* (non-Javadoc)
+     * @see org.codehaus.dna.LogEnabled#enableLogging(org.codehaus.dna.Logger)
+     */
+    public void enableLogging( Logger arg0 ) {
+        methodCalled = "enableLogging";
+    }
+
+    /* (non-Javadoc)
+     * @see org.codehaus.dna.Configurable#configure(org.codehaus.dna.Configuration)
+     */
+    public void configure( Configuration arg0 ) throws ConfigurationException {
+        methodCalled = "configure";
+    }
+
+    /* (non-Javadoc)
+     * @see org.codehaus.dna.Disposable#dispose()
+     */
+    public void dispose() {
+        methodCalled = "dispose";
+    }
+
+    /* (non-Javadoc)
+     * @see org.codehaus.dna.Initializable#initialize()
+     */
+    public void initialize() throws Exception {
+        methodCalled = "initialize";
+    }
+    
+    public String getMethodCalled(){
+        return methodCalled;
+    }    
+
+}
</pre></div>
<hr /><a name="file13" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/instrument<br /></span>
<div class="fileheader" id="added"><big><b>DNAInstrumentManagerTestCase.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N DNAInstrumentManagerTestCase.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ DNAInstrumentManagerTestCase.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,70 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.instrument;
+
+import java.util.logging.Level;
+import junit.framework.TestCase;
+import org.apache.avalon.framework.logger.Jdk14Logger;
+import org.codehaus.dna.Configuration;
+import org.codehaus.dna.impl.DefaultConfiguration;
+import org.codehaus.spice.alchemist.logger.DNALogger;
+import org.codehaus.spice.alchemist.logger.MockLogger;
+
+public class DNAInstrumentManagerTestCase extends TestCase {
+
+    public void testConstructorWithNullManager() throws Exception {
+        try {
+            new DNAInstrumentManager( null );
+            fail("Expected NPE");
+        } catch ( NullPointerException e ) {
+            assertEquals( "e.getMessage()", "manager", e.getMessage() );
+        }
+    }
+
+    public void testRegisterInstrumentable() throws Exception {
+        MockAvalonInstrumentManager avalonManager = new MockAvalonInstrumentManager();
+        DNAInstrumentManager dnaManager = new DNAInstrumentManager( avalonManager );
+        dnaManager.registerInstrumentable(null, null);
+        assertEquals( "registerInstrumentable()", "registerInstrumentable", avalonManager.getMethodCalled() );               
+    }
+
+    public void testDNALifecycleMethodsWithAvalonManager() throws Exception {
+        MockAvalonInstrumentManager mockManager = new MockAvalonInstrumentManager();
+        DNAInstrumentManager dnaManager = new DNAInstrumentManager( mockManager );
+        dnaManager.initialize();
+        assertEquals( "initialize()", "initialize", mockManager.getMethodCalled() );               
+        dnaManager.enableLogging(createDNALogger());
+        assertEquals( "enableLogging()", "enableLogging", mockManager.getMethodCalled() );               
+        dnaManager.configure(createDNAConfiguration());
+        assertEquals( "configure()", "configure", mockManager.getMethodCalled() );               
+        dnaManager.dispose();
+        assertEquals( "dispose()", "dispose", mockManager.getMethodCalled() );               
+    }
+
+    public void testDNALifecycleMethodsWithNonAvalonManager() throws Exception {
+        MockDNAInstrumentManager mockManager = new MockDNAInstrumentManager();
+        DNAInstrumentManager dnaManager = new DNAInstrumentManager( mockManager );
+        dnaManager.initialize();
+        assertNull( "initialize()", mockManager.getMethodCalled() );               
+        dnaManager.enableLogging(createDNALogger());
+        assertNull( "enableLogging()", mockManager.getMethodCalled() );               
+        dnaManager.configure(createDNAConfiguration());
+        assertNull( "configure()", mockManager.getMethodCalled() );               
+        dnaManager.dispose();
+        assertNull( "dispose()", mockManager.getMethodCalled() );               
+    }
+    
+    private Configuration createDNAConfiguration() {
+        return new DefaultConfiguration("","","");
+    }
+
+    private DNALogger createDNALogger()
+    {
+        return new DNALogger( new Jdk14Logger(new MockLogger( Level.INFO ) ) );
+    }    
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<hr /><a name="file14" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/instrument<br /></span>
<div class="fileheader" id="added"><big><b>MockAvalonInstrumentManager.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N MockAvalonInstrumentManager.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ MockAvalonInstrumentManager.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,65 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.instrument;
+
+import org.apache.avalon.framework.activity.Disposable;
+import org.apache.avalon.framework.activity.Initializable;
+import org.apache.avalon.framework.configuration.Configurable;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.logger.LogEnabled;
+import org.apache.avalon.framework.logger.Logger;
+import org.apache.excalibur.instrument.InstrumentManager;
+import org.apache.excalibur.instrument.Instrumentable;
+
+class MockAvalonInstrumentManager
+    implements InstrumentManager, LogEnabled, Configurable, Initializable, Disposable
+{
+    
+    private String methodCalled;
+    
+    /* (non-Javadoc)
+     * @see org.apache.excalibur.instrument.InstrumentManager#registerInstrumentable(org.apache.excalibur.instrument.Instrumentable, java.lang.String)
+     */
+    public void registerInstrumentable( Instrumentable arg0, String arg1 ) throws Exception {
+        methodCalled = "registerInstrumentable";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.logger.LogEnabled#enableLogging(org.apache.avalon.framework.logger.Logger)
+     */
+    public void enableLogging( Logger arg0 ) {
+        methodCalled = "enableLogging";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
+     */
+    public void configure( Configuration arg0 ) throws ConfigurationException {
+        methodCalled = "configure";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        methodCalled = "dispose";
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.avalon.framework.activity.Initializable#initialize()
+     */
+    public void initialize() throws Exception {
+        methodCalled = "initialize";
+    }
+    
+    public String getMethodCalled(){
+        return methodCalled;
+    }    
+
+}
</pre></div>
<hr /><a name="file15" /><div class="file">
<span class="pathname" id="added">spice/components/alchemist/src/test/org/codehaus/spice/alchemist/instrument<br /></span>
<div class="fileheader" id="added"><big><b>InstrumentAlchemistTestCase.java</b></big> <small id="info">added at 1.1</small></div>
<pre class="diff"><small id="info">diff -N InstrumentAlchemistTestCase.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ InstrumentAlchemistTestCase.java	20 Jun 2004 13:38:03 -0000	1.1
@@ -0,0 +1,25 @@
</small></pre><pre class="diff" id="added">+/*
+ * Copyright (C) The Spice Group. All rights reserved.
+ *
+ * This software is published under the terms of the Spice
+ * Software License version 1.1, a copy of which has been included
+ * with this distribution in the LICENSE.txt file.
+ */
+package org.codehaus.spice.alchemist.instrument;
+
+import junit.framework.TestCase;
+
+public class InstrumentAlchemistTestCase extends TestCase {
+
+    public void testDNAConfigurationWithNullConfiguration() 
+    	throws Exception 
+    {
+        try 
+        {
+            InstrumentAlchemist.toDNAInstrumentManager( null );
+            fail( "Expected NPE" );
+        } catch ( NullPointerException e ) {
+            assertEquals( "NPE message", "manager", e.getMessage() );
+        }
+    }
+}
</pre><pre class="diff"><small id="info">\ No newline at end of file
</small></pre></div>
<center><small><a href="http://www.badgers-in-foil.co.uk/projects/cvsspam/" title="commit -&gt; email">CVSspam</a> 0.2.8</small></center>
</body></html>