Author: pferraro
Date: 2008-10-22 12:43:53 -0400 (Wed, 22 Oct 2008)
New Revision: 1985
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java
Log:
Unit tests pass again
Modified:
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java
===================================================================
---
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java 2008-10-22
16:23:30 UTC (rev 1984)
+++
trunk/mod_cluster/src/test/java/org/jboss/modcluster/ModClusterServiceTestCase.java 2008-10-22
16:43:53 UTC (rev 1985)
@@ -272,9 +272,9 @@
EasyMock.expect(this.partition.getDistributedReplicantManager()).andReturn(drm);
drm.add("myservice:domain", this.modClusterService.drmEntry);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(engine.getService()).andReturn(service);
EasyMock.expect(service.findConnectors()).andReturn(new Connector[] { connector
});
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
EasyMock.expect(this.nodeConfig.getDomain()).andReturn("domain");
EasyMock.expect(this.nodeConfig.getFlushPackets()).andReturn(Boolean.TRUE);
@@ -427,6 +427,8 @@
{
Context context = EasyMock.createStrictMock(Context.class);
+ EasyMock.replay(context);
+
// Test not initialized
try
{
@@ -438,49 +440,51 @@
{
// Expected
}
+
+ EasyMock.verify(context);
+ EasyMock.reset(context);
init();
// Test context not started
- Container container = EasyMock.createStrictMock(Container.class);
+ Host host = EasyMock.createStrictMock(Host.class);
- recordAddContext(context, container);
+ recordAddContext(context, host);
- EasyMock.replay(context, container);
+ EasyMock.replay(context, host);
this.modClusterService.addContext(context);
- EasyMock.verify(context, container);
- EasyMock.reset(context, container);
+ EasyMock.verify(context, host);
+ EasyMock.reset(context, host);
// Test context started
Engine engine = EasyMock.createStrictMock(Engine.class);
- Host host = EasyMock.createStrictMock(Host.class);
Capture<MCMPRequest> capturedRequest = new Capture<MCMPRequest>();
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getName()).andReturn("parent-container");
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(context.isStarted()).andReturn(true);
// Building request
- EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getPath()).andReturn("/context");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
- EasyMock.replay(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.replay(this.clusteredMCMPHandler, context, engine, host);
this.modClusterService.addContext(context);
- EasyMock.verify(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.verify(this.clusteredMCMPHandler, context, engine, host);
MCMPRequest request = capturedRequest.getValue();
@@ -495,7 +499,7 @@
Assert.assertEquals("/context", parameters.get("Context"));
Assert.assertEquals("host,alias1,alias2",
parameters.get("Alias"));
- EasyMock.reset(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.reset(this.clusteredMCMPHandler, context, engine, host);
}
@Test
@@ -503,6 +507,8 @@
{
Context context = EasyMock.createStrictMock(Context.class);
+ EasyMock.replay(context);
+
// Test not initialized
try
{
@@ -514,36 +520,38 @@
{
// Expected
}
+
+ EasyMock.verify(context);
+ EasyMock.reset(context);
init();
// Test initialized
- Container container = EasyMock.createStrictMock(Container.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
Host host = EasyMock.createStrictMock(Host.class);
Capture<MCMPRequest> capturedRequest = new Capture<MCMPRequest>();
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getName()).andReturn("parent-container");
-
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
+
// Building request
- EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getPath()).andReturn("/context");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
- EasyMock.replay(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.replay(this.clusteredMCMPHandler, context, engine, host);
this.modClusterService.startContext(context);
- EasyMock.verify(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.verify(this.clusteredMCMPHandler, context, engine, host);
MCMPRequest request = capturedRequest.getValue();
@@ -558,7 +566,7 @@
Assert.assertEquals("/context", parameters.get("Context"));
Assert.assertEquals("host,alias1,alias2",
parameters.get("Alias"));
- EasyMock.reset(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.reset(this.clusteredMCMPHandler, context, engine, host);
}
@Test
@@ -566,6 +574,8 @@
{
Context context = EasyMock.createStrictMock(Context.class);
+ EasyMock.replay(context);
+
// Test not initialized
try
{
@@ -577,36 +587,38 @@
{
// Expected
}
+
+ EasyMock.verify(context);
+ EasyMock.reset(context);
init();
// Test initialized
- Container container = EasyMock.createStrictMock(Container.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
Host host = EasyMock.createStrictMock(Host.class);
Capture<MCMPRequest> capturedRequest = new Capture<MCMPRequest>();
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getName()).andReturn("parent-container");
-
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
+
// Building request
- EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getPath()).andReturn("/context");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
- EasyMock.replay(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.replay(this.clusteredMCMPHandler, context, engine, host);
this.modClusterService.stopContext(context);
- EasyMock.verify(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.verify(this.clusteredMCMPHandler, context, engine, host);
MCMPRequest request = capturedRequest.getValue();
@@ -621,7 +633,7 @@
Assert.assertEquals("/context", parameters.get("Context"));
Assert.assertEquals("host,alias1,alias2",
parameters.get("Alias"));
- EasyMock.reset(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.reset(this.clusteredMCMPHandler, context, engine, host);
}
@Test
@@ -644,48 +656,48 @@
init();
// Test initialized - no jvm route
- Container container = EasyMock.createStrictMock(Container.class);
Engine engine = EasyMock.createStrictMock(Engine.class);
+ Host host = EasyMock.createStrictMock(Host.class);
- this.recordRemoveContext(context, container, engine);
+ this.recordRemoveContext(context, host, engine);
- EasyMock.replay(context, container, engine);
+ EasyMock.replay(context, host, engine);
this.modClusterService.removeContext(context);
- EasyMock.verify(context, container, engine);
- EasyMock.reset(context, container, engine);
+ EasyMock.verify(context, host, engine);
+ EasyMock.reset(context, host, engine);
// Test initialized - jvm route exists
- Host host = EasyMock.createStrictMock(Host.class);
Capture<MCMPRequest> capturedRequest = new Capture<MCMPRequest>();
// Expect log message
EasyMock.expect(context.getPath()).andReturn("/context");
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getName()).andReturn("parent-container");
-
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getName()).andReturn("host");
+
+ // jvm route null check
+ EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
-
+
// Building request
- EasyMock.expect(context.getPath()).andReturn("/context");
EasyMock.expect(context.getParent()).andReturn(host);
+ EasyMock.expect(host.getParent()).andReturn(engine);
+ EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getParent()).andReturn(host);
EasyMock.expect(host.getName()).andReturn("host");
EasyMock.expect(host.findAliases()).andReturn(new String[] { "alias1",
"alias2" });
- EasyMock.expect(context.getParent()).andReturn(container);
- EasyMock.expect(container.getParent()).andReturn(engine);
- EasyMock.expect(engine.getJvmRoute()).andReturn("host1");
+ EasyMock.expect(context.getPath()).andReturn("/context");
this.clusteredMCMPHandler.sendRequest(EasyMock.capture(capturedRequest));
- EasyMock.replay(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.replay(this.clusteredMCMPHandler, context, engine, host);
this.modClusterService.removeContext(context);
- EasyMock.verify(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.verify(this.clusteredMCMPHandler, context, engine, host);
MCMPRequest request = capturedRequest.getValue();
@@ -700,7 +712,7 @@
Assert.assertEquals("/context", parameters.get("Context"));
Assert.assertEquals("host,alias1,alias2",
parameters.get("Alias"));
- EasyMock.reset(this.clusteredMCMPHandler, context, container, engine, host);
+ EasyMock.reset(this.clusteredMCMPHandler, context, engine, host);
}
@SuppressWarnings("unchecked")