TestServerEndpoint tse = new TestServerEndpoint(getListenPort());
BasicJeriExporter exporter =
new BasicJeriExporter(tse, new BasicILFactory());
TestServiceImpl service = new TestServiceImpl();
TestService stub = (TestService) exporter.export(service);
TestEndpoint te = tse.getTestEndpoint();
//make a call
stub.doSomething();
//Verify that the 3-arg connect method is called
if (methodCalls.get(connect2)==null) {
throw new TestException("The ConnectionManager"
+ " did not call 3-arg connect on the ConnectionEndpoint");
}
//Verify that the 1-arg connect method is called
if (methodCalls.get(connect1)==null) {
throw new TestException("The ConnectionManager"
+ " did not call 1-arg connect on the ConnectionEndpoint");
}
//Verify that writeRequestData is called
if (methodCalls.get(writeRequestData)==null) {
throw new TestException("The ConnectionManager"
+ " did not call writeRequestData on the Connection");
}
//Verify that readResponseData is called
if (methodCalls.get(readResponseData)==null) {
throw new TestException("The ConnectionManager"
+ " did not call readResponseData on the Connection");
}
//Verify that populateContext is called
if (methodCalls.get(populateContext)==null) {
throw new TestException("The ConnectionManager"
+ " did not call populateContext on the Connection");
}
//Verify that getUnfulfilledConstraints is called
if (methodCalls.get(getUnfulfilledConstraints)==null) {
throw new TestException("The ConnectionManager"
+ " did not call getUnfulfilledConstraints on the"
+ " Connection");
}
//Verify that the single-arg connect is not called if the 3-arg
//connect is called
clearMethodCalls();
stub.doSomething();
//Verify that the 3-arg connect method is called
if (methodCalls.get(connect2)==null) {
throw new TestException("The ConnectionManager"
+ " did not call 3-arg connect on the ConnectionEndpoint");
}
//Verify that the single-arg connect method is not called
if (methodCalls.get(connect1)!=null) {
throw new TestException("The ConnectionManager called"
+ " 1-arg connect even though a connection was returned on"
+ " call to 3-arg connect");
}
//Check exceptions
clearMethodCalls();
te.setException("connect");
boolean exceptionThrown = false;
try {
stub.doSomething();
} catch (Exception e) {
if (e.getMessage().equals("Bogus Exception")) {
exceptionThrown = true;
} else {
e.printStackTrace();
}
}
if (!exceptionThrown) {
throw new TestException("The ConnectionManager"
+ " does not propagate an exception thrown in"
+ " ConnectionEndpoint.connect");
}
clearMethodCalls();
te.setException("writeRequestData");
exceptionThrown = false;
try {
stub.doSomething();
} catch (Exception e) {
if (e.getMessage().equals("Bogus Exception")) {