1 20 package org.apache.cactus.integration.ant.container; 21 22 import java.io.File ; 23 24 import junit.framework.Assert; 25 26 import org.apache.cactus.integration.ant.deployment.DeployableFile; 27 import org.apache.cactus.integration.ant.util.AntTaskFactory; 28 import org.apache.commons.logging.Log; 29 import org.apache.tools.ant.types.Path; 30 import org.apache.tools.ant.types.Environment.Variable; 31 32 37 public final class MockContainer implements Container 38 { 39 41 44 private MockHttpServer server; 45 46 50 private Boolean expectedStartUpCalled; 51 52 55 private boolean startUpCalled; 56 57 61 private Boolean expectedShutDownCalled; 62 63 66 private boolean shutDownCalled; 67 68 70 75 public MockContainer(MockHttpServer theServer) 76 { 77 this.server = theServer; 78 } 79 80 83 public MockContainer() 84 { 85 } 86 87 89 92 public String getName() 93 { 94 return null; 95 } 96 97 100 public String getTestContext() 101 { 102 return null; 103 } 104 105 108 public long getStartUpWait() 109 { 110 return 0; 111 } 112 113 116 public int getPort() 117 { 118 return 0; 119 } 120 121 124 public File getToDir() 125 { 126 return null; 127 } 128 129 132 public void init() 133 { 134 } 135 136 139 public boolean isEnabled() 140 { 141 return false; 142 } 143 144 147 public boolean isExcluded(String theTestName) 148 { 149 return false; 150 } 151 152 155 public void setAntTaskFactory(AntTaskFactory theFactory) 156 { 157 } 158 159 162 public void setLog(Log theLog) 163 { 164 } 165 166 169 public void setDeployableFile(DeployableFile theWarFile) 170 { 171 } 172 173 176 public void startUp() 177 { 178 this.startUpCalled = true; 179 if (this.server != null) 180 { 181 Thread thread = new Thread (this.server); 182 thread.start(); 183 } 184 } 185 186 189 public void shutDown() 190 { 191 this.shutDownCalled = true; 192 if (this.server != null) 193 { 194 this.server.stop(); 195 } 196 } 197 198 200 205 public void expectStartUpCalled(boolean isExpected) 206 { 207 this.expectedStartUpCalled = isExpected ? Boolean.TRUE : Boolean.FALSE; 208 } 209 210 215 public void expectShutDownCalled(boolean isExpected) 216 { 217 this.expectedShutDownCalled = isExpected ? Boolean.TRUE : Boolean.FALSE; 218 } 219 220 223 public void verify() 224 { 225 if (this.expectedStartUpCalled != null) 226 { 227 Assert.assertTrue("The startUp() method should " 228 + (this.expectedStartUpCalled.booleanValue() ? "" : "not ") 229 + "have been called", 230 this.expectedStartUpCalled.booleanValue() == startUpCalled); 231 } 232 if (this.expectedShutDownCalled != null) 233 { 234 Assert.assertTrue("The shutDown() method should " 235 + (this.expectedShutDownCalled.booleanValue() ? "" : "not ") 236 + "have been called", 237 this.expectedShutDownCalled.booleanValue() == shutDownCalled); 238 } 239 } 240 241 244 public void setSystemProperties(Variable[] theProperties) 245 { 246 } 248 249 252 public Variable[] getSystemProperties() 253 { 254 throw new RuntimeException ("not implemented"); 255 } 256 257 260 public void setContainerClasspath(Path theClasspath) 261 { 262 } 264 265 268 public Path getContainerClasspath() 269 { 270 throw new RuntimeException ("not implemented"); 271 } 272 } 273 | Popular Tags |