Author: tpalsulich
Date: Mon Dec 29 18:39:28 2014
New Revision: 1648405

URL: http://svn.apache.org/r1648405
Log:
OODT-762. Migrate commons test resources.

Added:
    oodt/trunk/commons/src/test/java/
    oodt/trunk/commons/src/test/java/org/
    oodt/trunk/commons/src/test/java/org/apache/
    oodt/trunk/commons/src/test/java/org/apache/oodt/
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AbstractTestCase.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AppTest.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfigurationTest.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfiguredTestCaseTest.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/MultiServerTest.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/NaughtyTest.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityStoppedTest.java
   (with props)
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTest.java
   (with props)
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTrackerTest.java
   (with props)
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/CompositeActivityTest.java
   (with props)
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java
   (with props)
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/HistoryTest.java
   (with props)
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/IncidentTest.java
   (with props)
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/exec/
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/exec/TestEnvUtilities.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/filter/
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/filter/TestTimeEventWeightedHash.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/FixedBufferOutputStreamTest.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullInputStreamTest.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullOutputStreamTest.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/TestLoggerOutputStream.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/net/
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/net/NetTest.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/object/
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/object/jndi/
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/object/jndi/ObjectContextTest.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/object/jndi/TestContext.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/object/jndi/TestContextTest.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/util/
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/util/Base64Test.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/util/CacheMapTest.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/util/EnterpriseEntityResolverTest.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/util/LDAPTest.java
    
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/util/UtilityTest.java
    oodt/trunk/commons/src/test/java/org/apache/oodt/commons/util/XMLTest.java
    oodt/trunk/commons/src/test/resources/
    oodt/trunk/commons/src/test/resources/test-multiserver.xml
    oodt/trunk/commons/src/test/resources/test.xml   (with props)

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AbstractTestCase.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AbstractTestCase.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AbstractTestCase.java 
(added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AbstractTestCase.java 
Mon Dec 29 18:39:28 2014
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+package org.apache.oodt.commons;
+
+import java.io.File;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Abstract base class for test cases.
+ *
+ * @author <a href="[email protected]">Jason van Zyl</a>
+ */
+public abstract class AbstractTestCase
+    extends TestCase 
+{
+    /** 
+     * Basedir for all file I/O. Important when running tests from
+     * the reactor.
+     */
+    public String basedir = System.getProperty("basedir");
+    
+    /**
+     * Constructor.
+     */
+    public AbstractTestCase(String testName)
+    {
+        super(testName);
+    }
+    
+    /**
+     * Get test input file.
+     *
+     * @param path Path to test input file.
+     */
+    public String getTestFile(String path)
+    {
+        return new File(basedir,path).getAbsolutePath();
+    }
+}
+

Added: oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AppTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AppTest.java?rev=1648405&view=auto
==============================================================================
--- oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AppTest.java 
(added)
+++ oodt/trunk/commons/src/test/java/org/apache/oodt/commons/AppTest.java Mon 
Dec 29 18:39:28 2014
@@ -0,0 +1,54 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+package org.apache.oodt.commons;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ *
+ * @author <a href="mailto:[email protected]";>Jason van Zyl</a>
+ */
+public class AppTest 
+    extends AbstractTestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public AppTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( AppTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        assertEquals( "maven kicks ass", "maven kicks ass" );
+    }
+}

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfigurationTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfigurationTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfigurationTest.java 
(added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfigurationTest.java 
Mon Dec 29 18:39:28 2014
@@ -0,0 +1,103 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+package org.apache.oodt.commons;
+
+import java.io.*;
+import java.net.MalformedURLException;
+import java.util.*;
+import junit.framework.*;
+import org.w3c.dom.*;
+import org.xml.sax.*;
+
+/** Unit test the {@link Configuration} class.
+ *
+ * @author Kelly
+ */ 
+public class ConfigurationTest extends TestCase {
+       /** Construct the test case for the {@link Configuration} class. */
+       public ConfigurationTest(String name) {
+               super(name);
+       }
+
+       protected void setUp() throws Exception {
+               // Create a temporary test configuration file.
+               tmpFile = File.createTempFile("conf", ".xml");
+               BufferedOutputStream out = new BufferedOutputStream(new 
FileOutputStream(tmpFile));
+               byte[] doc = TEST_DOC.getBytes();
+               out.write(doc, 0, doc.length);
+               out.close();
+               oldValue = System.getProperty(Configuration.ENTITY_DIRS_PROP);
+               System.setProperty(Configuration.ENTITY_DIRS_PROP, 
"/dir/1,/dir/2");
+       }
+
+       protected void tearDown() throws Exception {
+               // Nuke the temporary test configuration file.
+               tmpFile.delete();
+               if (oldValue == null)
+                       
System.getProperties().remove(Configuration.ENTITY_DIRS_PROP);
+               else
+                       System.setProperty(Configuration.ENTITY_DIRS_PROP, 
oldValue);
+       }
+
+       /** Test the various property methods. */
+       public void testConfiguration() throws IOException, SAXException, 
MalformedURLException {
+               Configuration c = new Configuration(tmpFile.toURL());
+               Properties props = new Properties();
+               props.setProperty("globalKey1", "preset-value");
+               c.mergeProperties(props);
+               assertEquals("preset-value", props.getProperty("globalKey1"));
+               assertEquals("globalValue2", props.getProperty("globalKey2"));
+               assertEquals("http://testhost.test.domain:12345";, 
c.getWebServerBaseURL());
+               assertEquals("http://testhost.test.domain:12345/ns.ior";, 
c.getNameServerURL());
+               assertEquals(42, c.getNameServerStateFrequency());
+               assertEquals(4, c.getEntityRefDirs().size());
+               assertTrue(c.getEntityRefDirs().contains("/dir/one"));
+               assertTrue(c.getEntityRefDirs().contains("/dir/two"));
+               assertTrue(c.getEntityRefDirs().contains("/dir/1"));
+               assertTrue(c.getEntityRefDirs().contains("/dir/2"));
+               assertEquals("/dir/1,/dir/2,/dir/one,/dir/two", 
System.getProperty(Configuration.ENTITY_DIRS_PROP));
+               Collection servers = c.getExecServerConfigs();
+               assertEquals(2, servers.size());
+               for (Iterator each = servers.iterator(); each.hasNext();) {
+                       ExecServerConfig esc = (ExecServerConfig) each.next();
+                       if (esc.getClassName().equals("test.Class1")) {
+                               assertEquals("Name1", esc.getObjectKey());
+                               assertEquals(1, esc.getProperties().size());
+                       } else if (esc.getClassName().equals("test.Class2")) {
+                               assertEquals("Name2", esc.getObjectKey());
+                               assertEquals(3, esc.getProperties().size());
+                               for (Iterator i = 
esc.getProperties().entrySet().iterator(); i.hasNext();) {
+                                       Map.Entry entry = (Map.Entry) i.next();
+                                       if (entry.getKey().equals("localKey1"))
+                                               assertEquals("localKey2", 
entry.getValue());
+                                       else if 
(entry.getKey().equals("globalKey2"))
+                                               assertEquals("local-override", 
entry.getValue());
+                                       else if 
(entry.getKey().equals("org.apache.oodt.commons.Configuration.url"))
+                                               ; // This one's OK.
+                                       else fail("Unknown local property \"" + 
entry.getKey() + "\" in exec server");
+                               }
+                       } else fail("Unknown ExecServerConfig \"" + 
esc.getClassName() + "\" in servers from Configuration");
+               }
+       }
+
+       /** The temporary test configuration file. */
+       private File tmpFile;
+
+       /** Old value of the {@link Configuration#ENTITY_DIRS_PROP} system 
property. */
+       public String oldValue;
+
+       private static final String TEST_DOC = "<?xml 
version=\"1.0\"?>\n<!DOCTYPE configuration PUBLIC \"-//JPL//DTD EDA 
Configuration 1.0//EN\" 
\"http://enterprise.jpl.nasa.gov/dtd/configuration.dtd\";>\n<configuration><webServer><host>testhost.test.domain</host><port>12345</port></webServer><nameServer
 
stateFrequency=\"42\"><iiop><version>1.2</version><host>testhost.test.domain</host><port>12345</port><objectKey>TestService</objectKey></iiop></nameServer><xml><entityRef><dir>/dir/one</dir><dir>/dir/two</dir></entityRef></xml><properties><key>globalKey1</key><value>globalValue1</value><key>globalKey2</key><value>globalValue2</value></properties><programs><execServer><class>test.Class1</class><objectKey>Name1</objectKey></execServer><execServer><class>test.Class2</class><objectKey>Name2</objectKey><properties><key>localKey1</key><value>localKey2</value><key>globalKey2</key><value>local-override</value></properties></execServer></programs></configuration>";
+}

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfiguredTestCaseTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfiguredTestCaseTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfiguredTestCaseTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/ConfiguredTestCaseTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,66 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+package org.apache.oodt.commons;
+
+import junit.framework.TestCase;
+import org.xml.sax.SAXParseException;
+
+/**
+ * Unit test the ConfiguredTestCase class.
+ *
+ * @author Kelly
+ */ 
+public class ConfiguredTestCaseTest extends TestCase {
+       /** Construct the test case for the ConfiguredTestCaseTest class.
+        *
+        * @param name Case name
+        */
+       public ConfiguredTestCaseTest(String name) {
+               super(name);
+       }
+
+       public void testIt() throws Exception {
+               Case c = new Case();
+               try {
+                       c.setUp();
+                       assertNotNull(Configuration.configuration);
+               } finally {
+                       c.tearDown();
+               }                       
+       }
+
+       public void testItAgain() throws Exception {
+               Case c = new Case();
+               try {
+                       c.setUp();
+                       assertNotNull(Configuration.configuration);
+               } finally {
+                       c.tearDown();
+               }                       
+       }
+
+       private static class Case extends ConfiguredTestCase {
+               Case() {
+                       super("test");
+               }
+               public void setUp() throws Exception {
+                       super.setUp();
+               }
+               public void tearDown() throws Exception {
+                       super.tearDown();
+               }
+       }               
+}

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/MultiServerTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/MultiServerTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/MultiServerTest.java 
(added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/MultiServerTest.java 
Mon Dec 29 18:39:28 2014
@@ -0,0 +1,100 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+package org.apache.oodt.commons;
+
+import junit.framework.TestCase;
+import java.io.InputStream;
+import java.io.IOException;
+import org.xml.sax.InputSource;
+import java.rmi.server.RemoteObject;
+import javax.xml.parsers.ParserConfigurationException;
+import java.lang.reflect.InvocationTargetException;
+import org.xml.sax.SAXException;
+
+/**
+ * Unit test the MultiServer class.
+ *
+ * @author Kelly
+ */ 
+public class MultiServerTest extends TestCase {
+       /**
+        * Construct the test case for the MultiServer class.
+        *
+        * @param name Case name
+        */
+       public MultiServerTest(String name) {
+               super(name);
+       }
+
+       protected void setUp() throws Exception {
+               super.setUp();
+               testConfig = 
getClass().getResourceAsStream("test-multiserver.xml");
+               if (testConfig == null) throw new IOException("Cannot find 
`test-multiserver.xml'");
+               System.setProperty("my.other.setting", "Don't override");
+       }
+
+       public void testParsing() throws ParserConfigurationException, 
SAXException, IOException, ClassNotFoundException,
+               NoSuchMethodException, InstantiationException, 
IllegalAccessException, InvocationTargetException {
+               InputSource is = new InputSource(testConfig);
+               MultiServer.parseConfig(is);
+               assertEquals("test.app", MultiServer.getAppName());
+               assertEquals(4, MultiServer.getServers().size());
+
+               MultiServer.Server server = (MultiServer.Server) 
MultiServer.getServers().get("urn:eda:rmi:Test1");
+               assertEquals("org.apache.oodt.commons.MultiServerTest$Svr1", 
server.getClassName());
+               assertEquals(MultiServer.BINDING, server.getBindingBehavior());
+
+               server = (MultiServer.Server) 
MultiServer.getServers().get("urn:eda:rmi:Test2");
+               assertEquals("org.apache.oodt.commons.MultiServerTest$Svr2", 
server.getClassName());
+               assertEquals(MultiServer.NONBINDING, 
server.getBindingBehavior());
+
+               server = (MultiServer.Server) 
MultiServer.getServers().get("urn:eda:rmi:Test3");
+               assertEquals("org.apache.oodt.commons.MultiServerTest$Svr3", 
server.getClassName());
+               assertEquals(MultiServer.REBINDING, 
server.getBindingBehavior());
+
+               MultiServer.AutobindingServer s = 
(MultiServer.AutobindingServer) 
MultiServer.getServers().get("urn:eda:rmi:Test4");
+               assertEquals("org.apache.oodt.commons.MultiServerTest$Svr4", 
s.getClassName());
+               assertEquals(MultiServer.AUTO, s.getBindingBehavior());
+               assertEquals(360000L, s.getPeriod());
+
+               assertEquals("My Value", System.getProperty("my.setting"));
+               assertEquals("Don't override", 
System.getProperty("my.other.setting"));
+       }
+
+       public void tearDown() throws Exception {
+               if (testConfig != null) try {
+                       testConfig.close();
+               } catch (IOException ignore) {}
+               System.getProperties().remove("my.setting");
+               System.getProperties().remove("my.other.setting");
+               super.tearDown();
+       }
+
+       private InputStream testConfig;
+
+       public static class Svr1 extends RemoteObject {
+               public Svr1(ExecServer e) {}
+       }
+       public static class Svr2 extends RemoteObject {
+               public Svr2(ExecServer e) {}
+       }
+       public static class Svr3 extends RemoteObject {
+               public Svr3(ExecServer e) {}
+       }
+       public static class Svr4 extends RemoteObject {
+               public Svr4(ExecServer e) {}
+       }
+}

Added: oodt/trunk/commons/src/test/java/org/apache/oodt/commons/NaughtyTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/NaughtyTest.java?rev=1648405&view=auto
==============================================================================
--- oodt/trunk/commons/src/test/java/org/apache/oodt/commons/NaughtyTest.java 
(added)
+++ oodt/trunk/commons/src/test/java/org/apache/oodt/commons/NaughtyTest.java 
Mon Dec 29 18:39:28 2014
@@ -0,0 +1,55 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+package org.apache.oodt.commons;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+/**
+ * Unit test for simple App.
+ *
+ * @author <a href="mailto:[email protected]";>Jason van Zyl</a>
+ */
+public class NaughtyTest
+    extends AbstractTestCase
+{
+    /**
+     * Create the test case
+     *
+     * @param testName name of the test case
+     */
+    public NaughtyTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * @return the suite of tests being tested
+     */
+    public static Test suite()
+    {
+        return new TestSuite( NaughtyTest.class );
+    }
+
+    /**
+     * Rigourous Test :-)
+     */
+    public void testApp()
+    {
+        // Crash and burn!
+    }
+}

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityStoppedTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityStoppedTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityStoppedTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityStoppedTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.activity;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the <code>ActivityStopped</code> class.
+ *
+ * @author Kelly
+ * @version $Revision: 1.1 $
+ */
+public class ActivityStoppedTest extends TestCase {
+       /**
+        * Creates a new {@link ActivityStoppedTest} instance.
+        *
+        * @param name Case name.
+        */
+       public ActivityStoppedTest(String name) {
+               super(name);
+       }
+
+       /**
+        * Test basic <code>ActivityStopped</code> methods.
+        */
+       public void testActivityStopped() {
+               ActivityStopped a = new ActivityStopped();
+               try {
+                       Thread.sleep(100);
+               } catch (InterruptedException ignore) {}
+               ActivityStopped b = new ActivityStopped();
+               assertTrue(!a.equals(b));
+               assertTrue(!b.equals(a));
+               assertTrue(a.getTime().compareTo(b.getTime()) < 0);
+               // Really not much else we can test...
+       }
+}

Propchange: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityStoppedTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.activity;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the {@link Activity} class.
+ *
+ * @author Kelly
+ * @version $Revision: 1.1 $
+ */
+public class ActivityTest extends TestCase {
+       /**
+        * Creates a new {@link ActivityTest} instance.
+        *
+        * @param name Case name.
+        */
+       public ActivityTest(String name) {
+               super(name);
+       }
+
+       /**
+        * Test basic Activity methods.
+        */
+       public void testActivities() {
+               TestActivity ta = new TestActivity();                           
       // Create test activity
+               assertTrue(!"new-id".equals(ta.getID()));                       
       // It should generate a unique ID
+               ta.setID("new-id");                                             
       // Change its ID
+               assertEquals("new-id", ta.getID());                             
       // Make sure it got the change
+               Incident i = new Incident();                                    
       // Now create an incident and...
+               ta.log(i);                                                      
       // ...log it with the activity
+               assertEquals(incident, i);                                      
       // See if it recorded the incident
+               ta.stop();                                                      
       // Now stop the activity
+               assertEquals(ActivityStopped.class, incident.getClass());       
       // And see if it recorded a "stop" incident
+       }
+
+       /** Last received incident from the test activity. */
+       private Incident incident;
+       
+       /**
+        * Testing activity that records incidents to the test case.
+        */
+       private class TestActivity extends Activity {
+               /**
+                * Creates a new {@link TestActivity} instance.
+                */
+               public TestActivity() {
+                       super();
+               }
+
+               /**
+                * Record the last incident to the test case.
+                *
+                * @param incident an {@link Incident} value.
+                */
+               protected void recordIncident(Incident incident) {
+                       ActivityTest.this.incident = incident;
+               }
+       }
+}

Propchange: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTrackerTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTrackerTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTrackerTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTrackerTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,117 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.activity;
+
+import junit.framework.TestCase;
+
+/**
+ * Test the {@link ActivityTracker} class.
+ *
+ * @author Kelly
+ * @version $Revision: 1.1 $
+ */
+public class ActivityTrackerTest extends TestCase {
+       /**
+        * Creates a new {@link ActivityTrackerTest} instance.
+        *
+        * @param name Case name.
+        */
+       public ActivityTrackerTest(String name) {
+               super(name);
+       }
+
+       /**
+        * Save old values of the 
<code>org.apache.oodt.commons.activity.factories</code> and
+        * <code>activity.factories</code> properties.
+        *
+        * @throws Exception if an error occurs.
+        */
+       protected void setUp() throws Exception {
+               super.setUp();
+               longName = 
System.getProperty("org.apache.oodt.commons.activity.factories");
+               shortName = System.getProperty("activity.factories");
+       }
+
+       /**
+        * Test initialization of the activity tracker.
+        *
+        * @throws Exception if an error occurs.
+        */
+       public void testInitialization() throws Exception {
+               
System.getProperties().remove("org.apache.oodt.commons.activity.factories");    
       // Clear the long property
+               System.getProperties().remove("activity.factories");            
       // And the short one
+               ActivityTracker.initializeFactories();                          
       // And initalize
+               Activity activity = ActivityTracker.createActivity();           
       // Have it make an activity
+               assertTrue(activity instanceof NullActivity);                   
       // With neither set, it must be NullActivity
+
+               
System.setProperty("org.apache.oodt.commons.activity.factories",                
       // Now set the long name
+                       
"org.apache.oodt.commons.activity.ActivityTrackerTest$TestFactory");           
// to point to our test factory
+               System.setProperty("activity.factories", "non-existent-class"); 
       // And set the short name to nonsense
+               ActivityTracker.initializeFactories();                          
       // And initialize
+               activity = ActivityTracker.createActivity();                    
       // Have it make an activity
+               assertTrue(activity instanceof TestActivity);                   
       // With just one, it must be our TestActivity
+
+               
System.getProperties().remove("org.apache.oodt.commons.activity.factories");    
       // Clear the long so it must look at short
+               System.setProperty("activity.factories",                        
       // And set the short name to...
+                       
"org.apache.oodt.commons.activity.ActivityTrackerTest$TestFactory"             
// ...not one, but...
+                       + 
",org.apache.oodt.commons.activity.ActivityTrackerTest$TestFactory");        // 
...two factories
+               ActivityTracker.initializeFactories();                          
       // And initialize
+               activity = ActivityTracker.createActivity();                    
       // Now create an activity
+               assertTrue(activity instanceof CompositeActivity);              
       // With > 1, it must be a CompositeActivity
+       }
+
+       /**
+        * Restore old values of the 
<code>org.apache.oodt.commons.activity.factories</code> and
+        * <code>activity.factories</code> properties.
+        *
+        * @throws Exception if an error occurs.
+        */
+       protected void tearDown() throws Exception {
+               if (longName == null)
+                       
System.getProperties().remove("org.apache.oodt.commons.activity.factories");
+               else
+                       
System.setProperty("org.apache.oodt.commons.activity.factories", longName);
+               if (shortName == null)
+                       System.getProperties().remove("activity.factories");
+               else
+                       System.setProperty("activity.factories", shortName);
+               super.tearDown();
+       }
+
+       /**
+        * A test activity that does nothing.
+        */
+       static class TestActivity extends Activity {
+               protected void recordIncident(Incident incident) {}
+       }
+
+       /**
+        * A test activity factory that generates test activities.
+        */
+       static class TestFactory implements ActivityFactory {
+               public Activity createActivity() {
+                       return new TestActivity();
+               }
+       }
+
+       /** Old value of the 
<code>org.apache.oodt.commons.activity.factories</code> property. */
+       private String longName;
+
+       /** Old value of the <code>activity.factories</code> property. */
+       private String shortName;
+}

Propchange: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/ActivityTrackerTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/CompositeActivityTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/CompositeActivityTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/CompositeActivityTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/CompositeActivityTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.activity;
+
+import java.util.Collections;
+import junit.framework.TestCase;
+
+/**
+ * Test the {@link CompositeActivity} class.
+ *
+ * @author Kelly
+ * @version $Revision: 1.1 $
+ */
+public class CompositeActivityTest extends TestCase {
+       /**
+        * Creates a new {@link CompositeActivityTest} instance.
+        *
+        * @param name Case name.
+        */
+       public CompositeActivityTest(String name) {
+               super(name);
+       }
+
+       public void testIt() {
+               try {
+                       new CompositeActivity(null);
+                       fail("Can contruct CompositeActivity with null 
collection");
+               } catch (IllegalArgumentException good) {}
+               try {
+                       new CompositeActivity(Collections.singleton("hello"));
+                       fail("Can construct CompositeActivity with non-Activity 
in collection");
+               } catch (IllegalArgumentException good) {}
+               CompositeActivity ca = new 
CompositeActivity(Collections.singleton(new TestActivity()));
+               Incident i = new Incident();
+               ca.log(i);
+               assertEquals(i, incident);
+       }
+
+       /** Last received incident. */
+       private Incident incident;
+
+       /**
+        * Test activity that records last incidents received into the test 
case.
+        */
+       private class TestActivity extends Activity {
+               protected void recordIncident(Incident i) {
+                       incident = i;
+               }
+       }
+}

Propchange: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/CompositeActivityTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.activity;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.SocketException;
+import junit.framework.TestCase;
+
+/**
+ * Test the {@link DatagramLoggingActivityFactory} class.
+ *
+ * @author Kelly
+ * @version $Revision: 1.1 $
+ */
+public class DatagramLoggingActivityFactoryTest extends TestCase {
+       /**
+        * Creates a new {@link DatagramLoggingActivityFactoryTest} instance.
+        *
+        * @param name Case name.
+        */
+       public DatagramLoggingActivityFactoryTest(String name) {
+               super(name);
+       }
+
+       protected void setUp() throws Exception {
+               super.setUp();
+               oldLongHost = 
System.getProperty("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host");
+               oldShortHost = System.getProperty("activity.host");
+               oldLongPort = 
System.getProperty("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port");
+               oldShortPort = System.getProperty("activity.port");
+       }
+
+       protected void tearDown() throws Exception {
+               
restore("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host", 
oldLongHost);
+               restore("activity.host", oldShortHost);
+               
restore("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port", 
oldLongPort);
+               restore("activity.port", oldShortPort);
+               super.tearDown();
+       }
+
+       /**
+        * Test use of the system properties.
+        *
+        * @throws SocketException if an error occurs.
+        */
+       public void testPropertyPriority() throws SocketException {
+               
System.getProperties().remove("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host");
+               
System.getProperties().remove("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port");
+               System.getProperties().remove("activity.host");
+               System.getProperties().remove("activity.port");
+               try {
+                       new DatagramLoggingActivityFactory();
+                       fail("Can make a DatagramLoggingActivityFactory without 
host property set");
+               } catch (IllegalStateException ex) {}
+
+               
System.setProperty("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host",
 "localhost");
+               System.setProperty("activity.host", "non-existent-host");
+               DatagramLoggingActivityFactory fac = new 
DatagramLoggingActivityFactory();
+               
assertEquals(org.apache.oodt.commons.net.Net.getLoopbackAddress(), fac.host);
+               assertEquals(4556, fac.port);
+               fac.socket.close();
+
+               
System.getProperties().remove("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host");
+               System.setProperty("activity.host", "localhost");
+               fac = new DatagramLoggingActivityFactory();
+               
assertEquals(org.apache.oodt.commons.net.Net.getLoopbackAddress(), fac.host);
+               assertEquals(4556, fac.port);
+               fac.socket.close();
+
+               DatagramSocket soc = new DatagramSocket();
+               int portNum = soc.getLocalPort();
+               
System.setProperty("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port",
 String.valueOf(portNum));
+               System.setProperty("activity.port", "illegal-port-value");
+               fac = new DatagramLoggingActivityFactory();
+               assertEquals(portNum, fac.port);
+               fac.socket.close();
+
+               
System.getProperties().remove("org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port");
+               System.setProperty("activity.port", String.valueOf(portNum));
+               fac = new DatagramLoggingActivityFactory();
+               assertEquals(portNum, fac.port);
+               fac.socket.close();
+               soc.close();
+       }
+
+       /**
+        * Test construction and transmission of datagrams.
+        *
+        * @throws SocketException if an error occurs.
+        * @throws IOException if an error occurs.
+        * @throws ClassNotFoundException if an error occurs.
+        */
+       public void testActivityReceipt() throws SocketException, IOException, 
ClassNotFoundException {
+               DatagramSocket socket = null;
+               try {
+                       byte[] buf = new byte[512];
+                       DatagramPacket packet = new DatagramPacket(buf, 
buf.length);
+                       socket = new DatagramSocket();
+                       System.setProperty("activity.host", "localhost");
+                       System.setProperty("activity.port", 
String.valueOf(socket.getLocalPort()));
+                       DatagramLoggingActivityFactory fac = new 
DatagramLoggingActivityFactory();
+                       Activity a = fac.createActivity();
+                       Incident i = new Incident();
+                       a.log(i);
+                       socket.receive(packet);
+                       ObjectInputStream ois = new ObjectInputStream(new 
ByteArrayInputStream(packet.getData(), packet.getOffset(),
+                               packet.getLength()));
+                       Incident j = (Incident) ois.readObject();
+                       assertEquals(i, j);
+               } finally {
+                       if (socket != null)
+                               socket.close();
+               }
+       }
+
+       /**
+        * Restore a system property.
+        *
+        * @param propName Name of the property to restore.
+        * @param value Old value of the system property, or null if the 
property wasn't previously set.
+        */
+       private static void restore(String propName, String value) {
+               if (value == null)
+                       System.getProperties().remove(propName);
+               else
+                       System.setProperty(propName, value);
+       }
+
+       /** Old value of 
<code>org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.host</code>.
 */
+       private String oldLongHost;
+
+       /** Old value of <code>activity.host</code>. */
+       private String oldShortHost;
+
+       /** Old value of 
<code>org.apache.oodt.commons.activity.DatagramLoggingActivityFactory.port</code>.
 */
+       private String oldLongPort;
+
+       /** Old value of <code>activity.port</code>. */
+       private String oldShortPort;
+}

Propchange: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/DatagramLoggingActivityFactoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/HistoryTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/HistoryTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/HistoryTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/HistoryTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,234 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.activity;
+
+import java.util.List;
+import junit.framework.TestCase;
+
+/**
+ * Test the {@link History} class.
+ *
+ * @author Kelly
+ * @version $Revision: 1.1 $
+ */
+public class HistoryTest extends TestCase implements Storage {
+       /**
+        * Creates a new {@link HistoryTest} instance.
+        *
+        * @param name Case name.
+        */
+       public HistoryTest(String name) {
+               super(name);
+       }
+
+       /**
+        * Save the old idle and close times.
+        *
+        * @throws Exception if an error occurs.
+        */
+       protected void setUp() throws Exception {
+               super.setUp();
+               oldIdle = History.idleTime;
+               oldClose = History.closeTime;
+       }
+
+       /**
+        * Restore the old idle and close times.
+        *
+        * @throws Exception if an error occurs.
+        */
+       protected void tearDown() throws Exception {
+               History.idleTime = oldIdle;
+               History.closeTime = oldClose;
+               super.tearDown();
+       }
+
+       public void testIllegalIncidents() {
+               History.closeTime = 50;
+               Incident one = new Incident();
+               one.setActivityID(new String("a"));                             
       // Want unique objects
+               Incident two = new Incident();
+               two.setActivityID(new String("a"));                             
       // Want unique objects
+               Incident three = new Incident();
+               three.setActivityID("b");
+               History history = new History(one, this);
+               history.addIncident(two);
+               try {
+                       history.addIncident(three);
+                       fail("Able to add Incidents with non-matching activity 
IDs");
+               } catch (IllegalArgumentException good) {}
+       }
+
+       /**
+        * Test a normal, well-behaved lifecylce of (incident, incident, stop) 
with no
+        * idle times.
+        */
+       public void testLifecycle() {
+               History.closeTime = 50;
+               Incident one = new Incident();
+               one.setActivityID("test");
+               History history = new History(one, this);
+               rest();
+               Incident two = new Incident();
+               two.setActivityID("test");
+               history.addIncident(two);
+               rest();
+               ActivityStopped three = new ActivityStopped();
+               three.setActivityID("test");
+               history.addIncident(three);
+               rest();
+               assertNotNull("History never called store", id);
+               assertEquals("test", id);
+               assertNotNull(incidents);
+               assertEquals(3, incidents.size());
+               assertEquals(one, incidents.get(0));
+               assertEquals(two, incidents.get(1));
+               assertEquals(three, incidents.get(2));
+       }
+
+       /**
+        * Test arrival and recording of incidents <i>after</i> the stop 
incident.
+        */
+       public void testPostCloseIncidents() {
+               History.closeTime = 300;
+               Incident one = new Incident();
+               one.setActivityID("test");
+               rest();
+               ActivityStopped two = new ActivityStopped();
+               two.setActivityID("test");
+               rest();
+               Incident three = new Incident();
+               three.setActivityID("test");
+
+               History history = new History(one, this);
+               history.addIncident(two);
+               rest();
+               history.addIncident(three);
+               rest(1200);
+
+               assertNotNull("History never called store", id);
+               assertEquals("test", id);
+               assertNotNull(incidents);
+               assertEquals(3, incidents.size());
+               assertEquals(one, incidents.get(0));
+               assertEquals(two, incidents.get(1));
+               assertEquals(three, incidents.get(2));
+       }
+
+       /**
+        * Test if an idle history is committed when a stop incident is late.
+        */
+       public void testIdleHistory() {
+               History.idleTime = 300;
+               History.closeTime = 100;
+               Incident one = new Incident();
+               one.setActivityID("test");
+               rest();
+               Incident two = new Incident();
+               two.setActivityID("test");
+               rest();
+               ActivityStopped three = new ActivityStopped();
+               three.setActivityID("test");
+
+               History history = new History(one, this);
+               rest();
+               history.addIncident(two);
+               rest(500);
+               history.addIncident(three);
+
+               assertNotNull("History never called store", id);
+               assertEquals("test", id);
+               assertNotNull(incidents);
+               assertEquals(2, incidents.size());
+               assertEquals(one, incidents.get(0));
+               assertEquals(two, incidents.get(1));
+       }
+
+       /**
+        * Test if an idle history is committed and the stop incident arrives 
in time to
+        * be recorded.
+        */
+       public void testPostCommitActivityStop() {
+               History.idleTime = 300;
+               History.closeTime = 500;
+               Incident one = new Incident();
+               one.setActivityID("test");
+               rest();
+               Incident two = new Incident();
+               two.setActivityID("test");
+               rest();
+               ActivityStopped three = new ActivityStopped();
+               three.setActivityID("test");
+
+               History history = new History(one, this);
+               rest();
+               history.addIncident(two);
+               rest(500);
+               history.addIncident(three);
+               rest(400);
+
+               assertNotNull("History never called store", id);
+               assertEquals("test", id);
+               assertNotNull(incidents);
+               assertEquals(3, incidents.size());
+               assertEquals(one, incidents.get(0));
+               assertEquals(two, incidents.get(1));
+               assertEquals(three, incidents.get(2));
+       }
+
+       /**
+        * Our test storage just saves the last received ID and list of 
incidents.
+        *
+        * @param id ID, which should always be <code>test</code>.
+        * @param incidents {@link List} of received {@link Incident}s.
+        */
+       public void store(String id, List incidents) {
+               this.id = id;
+               this.incidents = incidents;
+       }
+
+       /**
+        * Pause the current thread for the given time.
+        *
+        * @param time Milliseconds to sleep.
+        */
+       private static void rest(long time) {
+               try {
+                       Thread.sleep(time);
+               } catch (InterruptedException ignore) {}
+       }
+
+       /**
+        * Pause the current thread for 100 milliseconds.
+        */
+       private static void rest() {
+               rest(100);
+       }
+
+       /** Last stored ID. */
+       private String id;
+
+       /** Last stored list of {@link Incident}s. */
+       private List incidents;
+
+       /** Idle time to restore. */
+       private long oldIdle;
+
+       /** Close time to restore. */
+       private long oldClose;
+}

Propchange: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/HistoryTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/IncidentTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/IncidentTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/IncidentTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/IncidentTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.activity;
+
+import java.util.Date;
+import junit.framework.TestCase;
+
+/**
+ * Test the {@link Incident} class.
+ *
+ * @author Kelly
+ * @version $Revision: 1.1 $
+ */
+public class IncidentTest extends TestCase {
+       /**
+        * Creates a new {@link IncidentTest} instance.
+        *
+        * @param name Case name.
+        */
+       public IncidentTest(String name) {
+               super(name);
+       }
+
+       /**
+        * Make sure incidents get timestamped.
+        */
+       public void testTimestamping() {
+               Incident i = new Incident();
+               rest();
+               assertTrue(new Date().compareTo(i.getTime()) > 0);
+       }
+
+       /**
+        * See if incidents are "well-behaved" objects.
+        */
+       public void testObjectMethods() {
+               Incident a = new Incident();
+               rest();
+               Incident b = new Incident();
+
+               assertEquals(a, a);
+               assertTrue(!a.equals(b));
+               assertTrue(a.compareTo(b) < 0);
+               assertTrue(b.compareTo(a) > 0);
+               int ignore = a.hashCode();
+
+               b.setActivityID("test");
+               assertTrue(!b.equals(a));
+               assertTrue(a.compareTo(b) < 0);
+               assertTrue(b.compareTo(a) > 0);
+               ignore = b.hashCode();
+       }
+
+       /**
+        * Pause current thread for 10 whole milliseconds.
+        */
+       private static void rest() {
+               try {
+                       Thread.sleep(10);
+               } catch (InterruptedException ignore) {}
+       }
+}

Propchange: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/activity/IncidentTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/exec/TestEnvUtilities.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/exec/TestEnvUtilities.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/exec/TestEnvUtilities.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/exec/TestEnvUtilities.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,127 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.exec;
+
+//JDK imports
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.util.Properties;
+
+//Apache Commons
+import org.apache.commons.lang.SystemUtils;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * @author mattmann
+ * @author mstarch
+ * @version $Revision$
+ * 
+ * <p>
+ * Test case for {@link EnvUtilities}
+ * </p>.
+ */
+public class TestEnvUtilities extends TestCase {
+
+    private static final String envVarStr = 
"TOMCAT_HOME=/usr/local/tomcat\nPROMPT=\\u \\p\n";
+
+    private static final String expectedVarStr = 
"TOMCAT_HOME=/usr/local/tomcat\nPROMPT=\\\\u \\\\p\n";
+
+    /**
+     * @since OODT-178
+     * 
+     */
+    public void testPreProcessInputStream() {
+        ByteArrayInputStream is = new 
ByteArrayInputStream(envVarStr.getBytes());
+        InputStream translatedIs = null;
+        try {
+            translatedIs = EnvUtilities.preProcessInputStream(is);
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+
+        assertNotNull(translatedIs);
+        String translatedEnvStr = null;
+        try {
+            translatedEnvStr = EnvUtilities.slurp(translatedIs);
+        } catch (Exception e) {
+            fail(e.getMessage());
+        }
+        assertNotNull(translatedEnvStr);
+        assertEquals(translatedEnvStr, expectedVarStr);
+
+    }
+    /**
+     * Tests two environment variables that should exist in any build 
+     * environment. USER, HOME
+     * By calling (EnvUtilities.getEnv(String))
+     */
+    public void testSetEnvironmentVar() {
+        //Test if an only if HOME and USER is defined (Assumed to be true on 
unix)
+        if (SystemUtils.IS_OS_UNIX) {
+            //Makes the assumption that System.properties() is correct.
+            String userHomeTruth = System.getProperty("user.home");
+            String userNameTruth = System.getProperty("user.name");
+            //Test values
+            String userHomeTest = EnvUtilities.getEnv("HOME");
+            String userNameTest = EnvUtilities.getEnv("USER");
+            //Check all three tests
+            assertEquals(userHomeTruth,userHomeTest);
+            assertEquals(userNameTruth,userNameTest);
+        } 
+    }
+    /**
+     * Tests two environment variables that should exist in any build 
+     * environment. USER, HOME
+     * By getting the environment (EnvUtilities.getEnv()) and reading from 
this.
+     */
+    public void testGetEnvironment() {
+        //Test if an only if HOME and USER is defined (Assumed to be true on 
unix)
+        if (SystemUtils.IS_OS_UNIX) {
+            //Makes the assumption that System.properties() is correct.
+            String userHomeTruth = System.getProperty("user.home");
+            String userNameTruth = System.getProperty("user.name");
+            Properties env = EnvUtilities.getEnv();
+            //Test values
+            String userHomeTest = env.getProperty("HOME");
+            String userNameTest = env.getProperty("USER");
+            //Check all three tests
+            assertEquals(userHomeTruth,userHomeTest);
+            assertEquals(userNameTruth,userNameTest);
+        } 
+    }
+    /**
+     * Tests for consistency between the two methods for getting environment 
variables
+     * in EnvUtilities calling getEnv(String) and calling 
getEnv().getProperty(String).
+     */
+    public void testGetEnvironmentConsistency() {
+        //Test if an only if HOME and USER is defined (Assumed to be true on 
unix)
+        if (SystemUtils.IS_OS_UNIX) {
+            Properties env = EnvUtilities.getEnv();
+            //Test values
+            String userHomeTest1 = env.getProperty("HOME");
+            String userNameTest1 = env.getProperty("USER");
+            String userHomeTest2 = EnvUtilities.getEnv("HOME");
+            String userNameTest2 = EnvUtilities.getEnv("USER");
+            //Check all three tests
+            assertEquals(userHomeTest1,userHomeTest2);
+            assertEquals(userNameTest1,userNameTest2);
+        }
+    }
+}

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/filter/TestTimeEventWeightedHash.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/filter/TestTimeEventWeightedHash.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/filter/TestTimeEventWeightedHash.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/filter/TestTimeEventWeightedHash.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.oodt.commons.filter;
+
+//JDK imports
+import java.util.LinkedList;
+import java.util.List;
+
+//Junit imports
+import junit.framework.TestCase;
+
+/**
+ * @author bfoster
+ * @version $Revision$
+ * 
+ * <p>
+ * Test case for {@link TimeEventWeightedHash}
+ * </p>.
+ */
+public class TestTimeEventWeightedHash extends TestCase {
+
+       public void testBuildHash() {
+             List<TimeEvent> events = new LinkedList<TimeEvent>();
+             events.add(new ObjectTimeEvent<String>(31, 32, 2, "1"));
+             events.add(new ObjectTimeEvent<String>(20, 30, 1, "2"));
+             events.add(new ObjectTimeEvent<String>(1, 8, 2, "3"));
+             events.add(new ObjectTimeEvent<String>(8, 15, 1, "4"));
+             events.add(new ObjectTimeEvent<String>(18, 20, 3, "5"));
+             events.add(new ObjectTimeEvent<String>(10, 12, 1, "6"));
+             events.add(new ObjectTimeEvent<String>(20, 30, 2, "7"));
+             events.add(new ObjectTimeEvent<String>(1, 20, 1, "8"));
+             events.add(new ObjectTimeEvent<String>(11, 13, 1, "9"));
+             events.add(new ObjectTimeEvent<String>(15, 20, 1, "10"));
+             events.add(new ObjectTimeEvent<String>(18, 20, 2, "11"));
+             events.add(new ObjectTimeEvent<String>(1, 15, 1, "12"));
+             events.add(new ObjectTimeEvent<String>(1, 18, 2, "13"));
+             TimeEventWeightedHash timeEventHash = 
TimeEventWeightedHash.buildHash(events);
+             
+             List<ObjectTimeEvent> orderedEvents = (List<ObjectTimeEvent>) 
timeEventHash.getGreatestWeightedPathAsOrderedList();
+             assertEquals(orderedEvents.size(), 3);
+             assertEquals(orderedEvents.get(0).getTimeObject().toString(), 
"13");
+             assertEquals(orderedEvents.get(1).getTimeObject().toString(), 
"7");
+             assertEquals(orderedEvents.get(2).getTimeObject().toString(), 
"1");
+             
+             events = new LinkedList<TimeEvent>();
+             events.add(new ObjectTimeEvent<String>(33, 215, 1, "1"));
+             events.add(new ObjectTimeEvent<String>(215, 359, 1, "2"));
+             events.add(new ObjectTimeEvent<String>(358, 541, 1, "3"));
+             events.add(new ObjectTimeEvent<String>(541, 723, 1, "4"));
+             events.add(new ObjectTimeEvent<String>(723, 904, 1, "5"));
+             events.add(new ObjectTimeEvent<String>(904, 904, 1, "6"));
+             events.add(new ObjectTimeEvent<String>(904, 1045, 1, "7"));
+             events.add(new ObjectTimeEvent<String>(905, 905, 1, "8"));
+             events.add(new ObjectTimeEvent<String>(906, 907, 1, "9"));
+             events.add(new ObjectTimeEvent<String>(907, 908, 1, "10"));
+             events.add(new ObjectTimeEvent<String>(908, 908, 1, "11"));
+             events.add(new ObjectTimeEvent<String>(908, 909, 1, "12"));
+             events.add(new ObjectTimeEvent<String>(923, 924, 1, "13"));
+             events.add(new ObjectTimeEvent<String>(926, 927, 1, "14"));
+             events.add(new ObjectTimeEvent<String>(927, 928, 1, "15"));
+             events.add(new ObjectTimeEvent<String>(942, 943, 1, "16"));
+             events.add(new ObjectTimeEvent<String>(945, 946, 1, "17"));
+             events.add(new ObjectTimeEvent<String>(946, 946, 1, "18"));
+             events.add(new ObjectTimeEvent<String>(947, 947, 1, "19"));
+             events.add(new ObjectTimeEvent<String>(1004, 1005, 1, "20"));
+             events.add(new ObjectTimeEvent<String>(1005, 1005, 1, "21"));
+             events.add(new ObjectTimeEvent<String>(1006, 1006, 1, "22"));
+             events.add(new ObjectTimeEvent<String>(1007, 1007, 1, "23"));
+             events.add(new ObjectTimeEvent<String>(1025, 1026, 1, "24"));
+             events.add(new ObjectTimeEvent<String>(1026, 1026, 1, "25"));
+             events.add(new ObjectTimeEvent<String>(1027, 1028, 1, "26"));
+             events.add(new ObjectTimeEvent<String>(1045, 1046, 1, "27"));
+             events.add(new ObjectTimeEvent<String>(1045, 1225, 1, "28"));
+             events.add(new ObjectTimeEvent<String>(1225, 1406, 1, "29"));
+             events.add(new ObjectTimeEvent<String>(1225, 1226, 1, "30"));
+             events.add(new ObjectTimeEvent<String>(1226, 1227, 1, "31"));
+             events.add(new ObjectTimeEvent<String>(1227, 1227, 1, "32"));
+             events.add(new ObjectTimeEvent<String>(1228, 1228, 1, "33"));
+             events.add(new ObjectTimeEvent<String>(1406, 1546, 1, "34"));
+             events.add(new ObjectTimeEvent<String>(1545, 1725, 1, "35"));
+             events.add(new ObjectTimeEvent<String>(1545, 1554, 1, "36"));
+             events.add(new ObjectTimeEvent<String>(1725, 1906, 1, "37"));
+             events.add(new ObjectTimeEvent<String>(1906, 2047, 1, "38"));
+             events.add(new ObjectTimeEvent<String>(1906, 1922, 1, "39"));
+             events.add(new ObjectTimeEvent<String>(2047, 2228, 1, "40"));
+             events.add(new ObjectTimeEvent<String>(2228, 2412, 1, "41"));
+             timeEventHash = TimeEventWeightedHash.buildHash(events, 2);
+             
+             orderedEvents = (List<ObjectTimeEvent>) 
timeEventHash.getGreatestWeightedPathAsOrderedList();
+             assertEquals(orderedEvents.size(), 14);
+             assertEquals(orderedEvents.get(0).getTimeObject().toString(), 
"1");
+             assertEquals(orderedEvents.get(1).getTimeObject().toString(), 
"2");
+             assertEquals(orderedEvents.get(2).getTimeObject().toString(), 
"3");
+             assertEquals(orderedEvents.get(3).getTimeObject().toString(), 
"4");
+             assertEquals(orderedEvents.get(4).getTimeObject().toString(), 
"5");
+             assertEquals(orderedEvents.get(5).getTimeObject().toString(), 
"7");
+             assertEquals(orderedEvents.get(6).getTimeObject().toString(), 
"28");
+             assertEquals(orderedEvents.get(7).getTimeObject().toString(), 
"29");
+             assertEquals(orderedEvents.get(8).getTimeObject().toString(), 
"34");
+             assertEquals(orderedEvents.get(9).getTimeObject().toString(), 
"35");
+             assertEquals(orderedEvents.get(10).getTimeObject().toString(), 
"37");
+             assertEquals(orderedEvents.get(11).getTimeObject().toString(), 
"38");
+             assertEquals(orderedEvents.get(12).getTimeObject().toString(), 
"40");
+             assertEquals(orderedEvents.get(13).getTimeObject().toString(), 
"41");
+       }
+       
+}

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/FixedBufferOutputStreamTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/FixedBufferOutputStreamTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/FixedBufferOutputStreamTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/FixedBufferOutputStreamTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,183 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+package org.apache.oodt.commons.io;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import junit.framework.TestCase;
+
+/** Unit test for the {@link FixedBufferOutputStream} class.
+ *
+ * @author Kelly
+ */
+public class FixedBufferOutputStreamTest extends TestCase {
+       /** Construct the test case for the {@link FixedBufferOutputStream} 
class.
+        *
+        * @param name Case name.
+        */
+       public FixedBufferOutputStreamTest(String name) {
+               super(name);
+       }
+
+       /** Test the fixed buffer output stream's methods with various illegal 
arguments.
+        */
+       public void testIllegalArgs() throws IOException {
+               try {
+                       new FixedBufferOutputStream(-1);
+                       fail("Illegal size failed to throw exception");
+               } catch (IllegalArgumentException good) {}
+               FixedBufferOutputStream out = new FixedBufferOutputStream(100);
+               try {
+                       out.write(null);
+                       fail("Writing a null byte array failed to throw 
exception");
+               } catch (NullPointerException good) {}
+               try {
+                       out.write(null, 0, 10);
+                       fail("Writing a null byte array failed to throw 
exception");
+               } catch (NullPointerException good) {}
+               try {
+                       out.write(TEST_DATA, -1, 10);
+                       fail("Writing with negative offset failed to throw 
exception");
+               } catch (IndexOutOfBoundsException good) {}
+               try {
+                       out.write(TEST_DATA, TEST_DATA.length + 1, 10);
+                       fail("Writing with offset past end of array failed to 
throw exception");
+               } catch (IndexOutOfBoundsException good) {}
+               try {
+                       out.write(TEST_DATA, 0, -1);
+                       fail("Writing with negative length array failed to 
throw exception");
+               } catch (IndexOutOfBoundsException good) {}
+               try {
+                       out.write(TEST_DATA, 2, 5);
+                       fail("Writing with offset and length exceeding end of 
array failed to throw exception");
+               } catch (IndexOutOfBoundsException good) {}
+       }
+
+       /** Test a stream with space for no bytes at all.
+        */
+       public void testZeroSizeStream() throws IOException {
+               FixedBufferOutputStream out = new FixedBufferOutputStream(0);   
                    // Space for no byte at all
+               out.write(1);                                                   
                    // Write a 1 
+               out.write(2);                                                   
                    // ...and a 2
+               out.write(3);                                                   
                    // ...and a 3
+               out.write(TEST_DATA);                                           
                    // ...and a byte array
+               byte[] buffer = out.getBuffer();                                
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertEquals(0, buffer.length);                                 
                    // But it should be empty
+       }
+
+       /** Test a stream under various conditions.
+        */
+       public void testStream() throws IOException {
+               FixedBufferOutputStream out = new FixedBufferOutputStream(10);  
                    // Space for 10 bytes
+               byte[] buffer = out.getBuffer();                                
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertEquals(0, buffer.length);                                 
                    // Nothing written => 0 length
+               out.write(1);                                                   
                    // [1]
+               buffer = out.getBuffer();                                       
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertEquals(1, buffer.length);                                 
                    // Only 1 byte so far
+               assertEquals(1, buffer[0]);                                     
                    // And it should be a 1
+               out.write(2);                                                   
                    // [1,2]
+               buffer = out.getBuffer();                                       
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertEquals(2, buffer.length);                                 
                    // Two bytes so far
+               assertEquals(1, buffer[0]);                                     
                    // And it should be a 1...
+               assertEquals(2, buffer[1]);                                     
                    // ...and a 2
+               out.write(3);                                                   
                    // [1,2,3]
+               buffer = out.getBuffer();                                       
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertEquals(3, buffer.length);                                 
                    // 3 bytes so far
+               assertEquals(1, buffer[0]);                                     
                    // They are 1
+               assertEquals(2, buffer[1]);                                     
                    // ...and 2
+               assertEquals(3, buffer[2]);                                     
                    // ...and 3
+
+               out.write(TEST_DATA);                                           
                    // [1,2,3,8,9,10,11]
+               buffer = out.getBuffer();                                       
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertEquals(7, buffer.length);                                 
                    // 7 bytes so far, right?
+               assertEquals(1, buffer[0]);                                     
                    // They are 1
+               assertEquals(2, buffer[1]);                                     
                    // ...and 2
+               assertEquals(3, buffer[2]);                                     
                    // ...and 3
+               assertEquals(8, buffer[3]);                                     
                    // ...and 8
+               assertEquals(9, buffer[4]);                                     
                    // ...and 9
+               assertEquals(10, buffer[5]);                                    
                    // ...and 10
+               assertEquals(11, buffer[6]);                                    
                    // ...and 11
+
+               out.write(TEST_DATA);                                           
                    // [2,3,8,9,10,11,8,9,10,11]
+               out.write(TEST_DATA, 1, 2);                                     
                    // [8,9,10,11,8,9,10,11,9,10]
+               buffer = out.getBuffer();                                       
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertEquals(10, buffer.length);                                
                    // Full buffer
+               assertEquals(8, buffer[0]);                                     
                    // They are 8
+               assertEquals(9, buffer[1]);                                     
                    // ...and 9
+               assertEquals(10, buffer[2]);                                    
                    // ...and 10
+               assertEquals(11, buffer[3]);                                    
                    // ...and 11
+               assertEquals(8, buffer[4]);                                     
                    // ...and 8
+               assertEquals(9, buffer[5]);                                     
                    // ...and 9
+               assertEquals(10, buffer[6]);                                    
                    // ...and 10
+               assertEquals(11, buffer[7]);                                    
                    // ...and 11
+               assertEquals(9, buffer[8]);                                     
                    // ...and 9
+               assertEquals(10, buffer[9]);                                    
                    // ...and 10
+
+               out.write(TEST_DATA);                                           
                    // [8,9,10,11,9,10,8,9,10,11]
+               out.write(TEST_DATA, 0, 1);                                     
                    // [9,10,11,9,10,8,9,10,11,8]
+               out.write(42);                                                  
                    // [10,11,9,10,8,9,10,11,8,42]
+               out.write(99);                                                  
                    // [11,9,10,8,9,10,11,8,42,99]
+               out.write(TEST_DATA, 1, 3);                                     
                    // [8,9,10,11,8,42,99,9,10,11]
+               buffer = out.getBuffer();                                       
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertEquals(10, buffer.length);                                
                    // Full buffer
+               assertEquals(8, buffer[0]);                                     
                    // They are 8
+               assertEquals(9, buffer[1]);                                     
                    // ...and 9
+               assertEquals(10, buffer[2]);                                    
                    // ...and 10
+               assertEquals(11, buffer[3]);                                    
                    // ...and 11
+               assertEquals(8, buffer[4]);                                     
                    // ...and 8
+               assertEquals(42, buffer[5]);                                    
                    // ...and 42
+               assertEquals(99, buffer[6]);                                    
                    // ...and 99
+               assertEquals(9, buffer[7]);                                     
                    // ...and 9
+               assertEquals(10, buffer[8]);                                    
                    // ...and 10
+               assertEquals(11, buffer[9]);                                    
                    // ...and 11
+
+               byte[] array = new byte[buffer.length];                         
                    // New test data array that's
+               System.arraycopy(buffer, 0, array, 0, buffer.length);           
                    // the same as the current buf
+               out.write(array);                                               
                    // ...and write that
+               buffer = out.getBuffer();                                       
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertTrue(Arrays.equals(array, buffer));                       
                    // Should get same result
+
+               byte[] big = new byte[buffer.length * 3];                       
                    // More new test data array
+               System.arraycopy(buffer, 0, big, 0, buffer.length);             
                    // ...and add some data
+               System.arraycopy(buffer, 0, big, buffer.length, buffer.length); 
                    // ...and more data
+               System.arraycopy(buffer, 0, big, buffer.length * 2, 
buffer.length);                 // ...and LOTS of data
+               out.write(big, buffer.length, buffer.length * 2);               
                    // Write the last third of it
+               buffer = out.getBuffer();                                       
                    // Get the buffer
+               assertNotNull(buffer);                                          
                    // It should never be null
+               assertTrue(Arrays.equals(array, buffer));                       
                    // Should get same result!
+
+               out.close();                                                    
                    // Close it
+               try {                                                           
                    // ...and try...
+                       out.write(1);                                           
                    // ...to write to it
+                       fail("Writing to a closed stream failed to throw an 
exception");            // Shouldn't get here
+               } catch (IOException good) {}                                   
                    // Should get here
+       }
+
+       /** Some test data in an array. */
+       private static final byte[] TEST_DATA = new byte[] {
+               (byte) 8, (byte) 9, (byte) 10, (byte) 11
+       };
+}

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullInputStreamTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullInputStreamTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullInputStreamTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullInputStreamTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,67 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+package org.apache.oodt.commons.io;
+
+import java.io.IOException;
+import java.io.InputStream;
+import junit.framework.TestCase;
+
+/**
+ * Unit test the {@link NullInputStream} class.
+ *
+ * @author Kelly
+ */ 
+public class NullInputStreamTest extends TestCase {
+        /**
+        * Creates a new <code>NullInputStreamTest</code> instance.
+        *
+        * @param name Test case name.
+        */
+       public NullInputStreamTest(String name) {
+                super(name);
+        }
+
+        protected void setUp() throws Exception {
+                in = new NullInputStream();
+        }
+
+        public void testClosing() {
+                try {
+                        in.close();
+                } catch (IOException ex) {
+                        fail("Should not throw an exception on close: " + 
ex.getMessage());
+                }
+                try {
+                        in.read();
+                        fail("Should not be able to read a closed stream");
+                } catch (IOException ignore) {}
+                try {
+                        in.close();
+                        fail("Should not be able to close a closed stream");
+                } catch (IOException ignore) {}
+        }
+
+        public void testReading() {
+                try {
+                        assertEquals(-1, in.read());
+                } catch (IOException ex) {
+                        fail("Should not throw an exception on reading: " + 
ex.getMessage());
+                }
+        }
+
+        /** The {@link NullInputStream} we're testing. */
+        private NullInputStream in;
+}

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullOutputStreamTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullOutputStreamTest.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullOutputStreamTest.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/NullOutputStreamTest.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,79 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+package org.apache.oodt.commons.io;
+
+import java.io.*;
+import java.util.*;
+import junit.framework.*;
+
+/** Unit test the {@link NullOutputStream} class.
+ *
+ * @author Kelly
+ */ 
+public class NullOutputStreamTest extends TestCase {
+       /** Construct the test case for the {@link NullOutputStream} class. */
+       public NullOutputStreamTest(String name) {
+               super(name);
+       }
+
+       protected void setUp() throws Exception {
+               out = new NullOutputStream();
+       }
+
+       public void testClosing() {
+               try {
+                       out.close();
+               } catch (IOException ex) {
+                       fail("Should not throw an exception on close: " + 
ex.getMessage());
+               }
+               try {
+                       out.write(1);
+                       fail("Should not be able to write to a closed stream");
+               } catch (IOException ignore) {}
+               try {
+                       out.flush();
+                       fail("Should not be able to flush a closed stream");
+               } catch (IOException ignore) {}
+               try {
+                       out.close();
+                       fail("Should not be able to close a closed stream");
+               } catch (IOException ignore) {}
+       }
+
+       public void testFlush() {
+               try {
+                       out.flush();
+               } catch (IOException ex) {
+                       fail("Should not throw an exception on flush: " + 
ex.getMessage());
+               }
+       }
+
+       public void testWriting() {
+               try {
+                       byte[] array = new byte[]{(byte)0, (byte)1, (byte)2};
+                       out.write(1);
+                       out.write(array);
+                       out.write(array, 1, 1);
+               } catch (IOException ex) {
+                       fail("Should not throw an exception on writing: " + 
ex.getMessage());
+               }
+       }
+
+       /** The {@link NullOutputStream} we're testing. */
+       private NullOutputStream out;
+
+}
+

Added: 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/TestLoggerOutputStream.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/TestLoggerOutputStream.java?rev=1648405&view=auto
==============================================================================
--- 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/TestLoggerOutputStream.java
 (added)
+++ 
oodt/trunk/commons/src/test/java/org/apache/oodt/commons/io/TestLoggerOutputStream.java
 Mon Dec 29 18:39:28 2014
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.oodt.commons.io;
+
+//JDK imports
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Handler;
+import java.util.logging.Level;
+import java.util.logging.LogRecord;
+import java.util.logging.Logger;
+
+//JUnit imports
+import junit.framework.TestCase;
+
+/**
+ * Test class for {@link LoggerOutputStream}.
+ *
+ * @author bfoster (Brian Foster)
+ */
+public class TestLoggerOutputStream extends TestCase {
+
+   public void testLogging() throws InstantiationException, IOException {
+      final List<LogRecord> records = new ArrayList<LogRecord>();
+      Logger logger = Logger.getLogger(TestLoggerOutputStream.class.getName());
+      logger.addHandler(new Handler() {
+         @Override
+         public void close() throws SecurityException {}
+         @Override
+         public void flush() {}
+         @Override
+         public void publish(LogRecord record) {
+            records.add(record);
+         }
+      });
+      LoggerOutputStream los = new LoggerOutputStream(logger, 10, Level.INFO);
+      los.write("This is a test write to a log file".getBytes());
+      los.close();
+      assertEquals("This is a ", records.get(0).getMessage());
+      assertEquals("test write", records.get(1).getMessage());
+      assertEquals(" to a log ", records.get(2).getMessage());
+      assertEquals("file", records.get(3).getMessage());
+   }
+}

Added: oodt/trunk/commons/src/test/java/org/apache/oodt/commons/net/NetTest.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/commons/src/test/java/org/apache/oodt/commons/net/NetTest.java?rev=1648405&view=auto
==============================================================================
--- oodt/trunk/commons/src/test/java/org/apache/oodt/commons/net/NetTest.java 
(added)
+++ oodt/trunk/commons/src/test/java/org/apache/oodt/commons/net/NetTest.java 
Mon Dec 29 18:39:28 2014
@@ -0,0 +1,51 @@
+// Licensed to the Apache Software Foundation (ASF) under one or more 
contributor
+// license agreements.  See the NOTICE.txt file distributed with this work for
+// additional information regarding copyright ownership.  The ASF licenses this
+// file to you under the Apache License, Version 2.0 (the "License"); you may 
not
+// use this file except in compliance with the License.  You may obtain a copy 
of
+// the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+// License for the specific language governing permissions and limitations 
under
+// the License.
+
+package org.apache.oodt.commons.net;
+
+import java.net.InetAddress;
+import junit.framework.*;
+
+/** Unit test the {@link Net} class.
+ *
+ * @author Kelly
+ */ 
+public class NetTest extends TestCase {
+       /** Construct the test case for the {@link Net} class.
+        */
+       public NetTest(String name) {
+               super(name);
+       }
+
+       /** Test the {@link Net#getLoopbackAddress} method.
+        */
+       public void testGetLoopbackAddress() {
+               InetAddress addr = Net.getLoopbackAddress();
+               assertNotNull(addr);
+               byte[] bytes = addr.getAddress();
+               assertNotNull(bytes);
+               assertEquals(4, bytes.length);
+               assertEquals(127, bytes[0]);
+               assertEquals(0, bytes[1]);
+               assertEquals(0, bytes[2]);
+               assertEquals(1, bytes[3]);
+       }
+
+       public void testGetLocalHost() {
+               InetAddress addr = Net.getLocalHost();
+               assertNotNull(addr);
+       }
+}
+


Reply via email to