Brent Worden
http://www.brent.worden.org/
Index: 
modules/core/src/test/org/apache/geronimo/deployment/DeploymentInfoTest.java
===================================================================
RCS file: 
modules/core/src/test/org/apache/geronimo/deployment/DeploymentInfoTest.java
diff -N 
modules/core/src/test/org/apache/geronimo/deployment/DeploymentInfoTest.java
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 
modules/core/src/test/org/apache/geronimo/deployment/DeploymentInfoTest.java    
    14 Aug 2003 19:02:30 -0000
@@ -0,0 +1,214 @@
+/* ====================================================================
+ * The Apache Software License, Version 1.1
+ *
+ * Copyright (c) 2003 The Apache Software Foundation.  All rights
+ * reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in
+ *    the documentation and/or other materials provided with the
+ *    distribution.
+ *
+ * 3. The end-user documentation included with the redistribution,
+ *    if any, must include the following acknowledgment:
+ *       "This product includes software developed by the
+ *        Apache Software Foundation (http://www.apache.org/)."
+ *    Alternately, this acknowledgment may appear in the software itself,
+ *    if and wherever such third-party acknowledgments normally appear.
+ *
+ * 4. The names "Apache" and "Apache Software Foundation" and
+ *    "Apache Geronimo" must not be used to endorse or promote products
+ *    derived from this software without prior written permission. For
+ *    written permission, please contact [EMAIL PROTECTED]
+ *
+ * 5. Products derived from this software may not be called "Apache",
+ *    "Apache Geronimo", nor may "Apache" appear in their name, without
+ *    prior written permission of the Apache Software Foundation.
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
+ * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * ====================================================================
+ *
+ * This software consists of voluntary contributions made by many
+ * individuals on behalf of the Apache Software Foundation.  For more
+ * information on the Apache Software Foundation, please see
+ * <http://www.apache.org/>.
+ *
+ * ====================================================================
+ */
+package org.apache.geronimo.deployment;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import junit.framework.TestCase;
+
+/**
+ * @version $Revision:$ $Date:$
+ */
+public class DeploymentInfoTest extends TestCase {
+    private ObjectName getObjectName(String domain, String key, String value) {
+        try {
+            return new ObjectName(domain, key, value);
+        } catch(MalformedObjectNameException ex) {
+            fail("can not create ObjectName.");
+            return null;
+        }
+    }
+    
+    private ObjectName get_Name(){
+        return getObjectName("domain", "key", "object");
+    }
+
+    private ObjectName getParent(){
+        return getObjectName("domain", "key", "parent");
+    }
+
+    private ObjectName getFirstChild(){
+        return getObjectName("domain", "key", "first");
+    }
+
+    private ObjectName getSecondChild(){
+        return getObjectName("domain", "key", "second");
+    }
+    
+    private DeploymentInfo getInfo(){
+        return new DeploymentInfo(get_Name(), getParent(), getUrl());
+    }
+    
+    private URL getUrl(){
+        try {
+            return new URL("http://jakarta.apache.org";);
+        } catch(MalformedURLException ex) {
+            fail("can not create URL.");
+            return null;
+        }
+    }
+    
+    public void testDeploymentNullValidValid() {
+        try {
+            new DeploymentInfo(null, getParent(), getUrl());
+        } catch(Exception ex) {
+            fail();
+        }
+    }
+    
+    public void testDeploymentValidNullValid() {
+        try {
+            new DeploymentInfo(get_Name(), null, getUrl());
+        } catch(Exception ex) {
+            fail();
+        }
+    }
+    
+    public void testDeploymentValidValidNull() {
+        try {
+            new DeploymentInfo(get_Name(), getParent(), null);
+        } catch(Exception ex) {
+            fail();
+        }
+    }
+
+    public void testGetURL() {
+        URL expected = getUrl();
+        DeploymentInfo info = new DeploymentInfo(get_Name(), getParent(), 
expected);
+        URL actual = info.getURL();
+        assertEquals(actual, expected);
+    }
+
+    public void testGetName() {
+        ObjectName expected = get_Name();
+        DeploymentInfo info = new DeploymentInfo(expected, getParent(), 
getUrl());
+        ObjectName actual = info.getName();
+        assertEquals(actual, expected);
+    }
+
+    public void testGetParent() {
+        ObjectName expected = getParent();
+        DeploymentInfo info = new DeploymentInfo(get_Name(), expected, 
getUrl());
+        ObjectName actual = info.getParent();
+        assertEquals(actual, expected);
+    }
+
+    public void testAddChild() {
+        ObjectName child = getFirstChild();
+        DeploymentInfo info = getInfo();
+        info.addChild(child);
+        assertTrue(info.getChildren().contains(child));
+        assertEquals(info.getChildren().size(), 1);
+    }
+
+    public void testAddChildTwice() {
+        // same child, two instances
+        ObjectName first = getFirstChild();
+        ObjectName second = getFirstChild();
+        DeploymentInfo info = getInfo();
+        info.addChild(first);
+        info.addChild(second);
+        assertTrue(info.getChildren().contains(first));
+        assertTrue(info.getChildren().contains(second));
+        assertEquals(info.getChildren().size(), 1);
+    }
+
+    public void testAddChildren() {
+        ObjectName first = getFirstChild();
+        ObjectName second = getSecondChild();
+        DeploymentInfo info = getInfo();
+        info.addChild(first);
+        info.addChild(second);
+        assertTrue(info.getChildren().contains(first));
+        assertTrue(info.getChildren().contains(second));
+        assertEquals(info.getChildren().size(), 2);
+    }
+
+    public void testRemoveChild() {
+        ObjectName child = getFirstChild();
+        DeploymentInfo info = getInfo();
+        info.addChild(child);
+        info.removeChild(child);
+        assertFalse(info.getChildren().contains(child));
+        assertEquals(info.getChildren().size(), 0);
+    }
+
+    public void testRemoveChildren() {
+        ObjectName first = getFirstChild();
+        ObjectName second = getSecondChild();
+        DeploymentInfo info = getInfo();
+        info.addChild(first);
+        info.addChild(second);
+        info.removeChild(first);
+        assertFalse(info.getChildren().contains(first));
+        assertTrue(info.getChildren().contains(second));
+        assertEquals(info.getChildren().size(), 1);
+    }
+
+    public void testRemoveChildTwice() {
+        ObjectName first = getFirstChild();
+        DeploymentInfo info = getInfo();
+        info.addChild(first);
+        info.removeChild(first);
+        info.removeChild(first);
+        assertFalse(info.getChildren().contains(first));
+        assertEquals(info.getChildren().size(), 0);
+    }
+}

Reply via email to