1 20 package org.apache.cactus.integration.ant; 21 22 import org.apache.cactus.integration.ant.container.Container; 23 24 29 public final class TestContainerSet extends AntTestCase 30 { 31 32 34 37 public TestContainerSet() 38 { 39 super("org/apache/cactus/integration/ant/test-containerset.xml"); 40 } 41 42 44 47 protected void setUp() throws Exception 48 { 49 super.setUp(); 50 51 getProject().addDataTypeDefinition("containerset", ContainerSet.class); 52 } 53 54 56 62 public void testEmpty() throws Exception 63 { 64 executeTestTarget(); 65 ContainerSet set = (ContainerSet) getProject().getReference("test"); 66 assertEquals(-1, set.getProxyPort()); 67 assertEquals(-1, set.getTimeout()); 68 Container[] containers = set.getContainers(); 69 assertEquals(0, containers.length); 70 } 71 72 78 public void testEmptyWithProxyPort() throws Exception 79 { 80 executeTestTarget(); 81 ContainerSet set = (ContainerSet) getProject().getReference("test"); 82 assertEquals(8088, set.getProxyPort()); 83 assertEquals(-1, set.getTimeout()); 84 Container[] containers = set.getContainers(); 85 assertEquals(0, containers.length); 86 } 87 88 94 public void testEmptyWithTimeout() throws Exception 95 { 96 executeTestTarget(); 97 ContainerSet set = (ContainerSet) getProject().getReference("test"); 98 assertEquals(-1, set.getProxyPort()); 99 assertEquals(60000, set.getTimeout()); 100 Container[] containers = set.getContainers(); 101 assertEquals(0, containers.length); 102 } 103 104 110 public void testGenericContainer() throws Exception 111 { 112 executeTestTarget(); 113 ContainerSet set = (ContainerSet) getProject().getReference("test"); 114 Container[] containers = set.getContainers(); 115 assertEquals(1, containers.length); 116 Container container = (Container) containers[0]; 117 assertEquals(8080, container.getPort()); 118 } 119 120 126 public void testGenericContainerWithProxyPort() throws Exception 127 { 128 executeTestTarget(); 129 ContainerSet set = (ContainerSet) getProject().getReference("test"); 130 Container[] containers = set.getContainers(); 131 assertEquals(1, containers.length); 132 Container container = containers[0]; 133 assertEquals(8088, container.getPort()); 134 } 135 136 143 public void testGenericContainerWithTasks() throws Exception 144 { 145 executeTestTarget(); 146 ContainerSet set = (ContainerSet) getProject().getReference("test"); 147 Container[] containers = set.getContainers(); 148 149 assertNull("The startup hook should not have been executed", 152 getProject().getProperty("startup.executed")); 153 assertNull("The shutdown hook should not have been executed", 154 getProject().getProperty("shutdown.executed")); 155 156 Container container = containers[0]; 159 container.startUp(); 160 assertEquals("The startup hook should have been executed, ", 161 "true", getProject().getProperty("startup.executed")); 162 container.shutDown(); 163 assertEquals("The shutdown hook should have been executed, ", 164 "true", getProject().getProperty("shutdown.executed")); 165 } 166 167 } 168 | Popular Tags |