public class RobustnessTest extends AbstractEndpointTest {
public void run() throws Exception {
ServerEndpoint se = getServerEndpoint();
GetDeliveryDispatcher dispatcher = new GetDeliveryDispatcher();
GetDeliveryContext lc = new GetDeliveryContext(dispatcher);
Endpoint e =
se.enumerateListenEndpoints(lc);
dispatcher.reject();
try {
OutboundRequestIterator ori =
e.newRequest(InvocationConstraints.EMPTY);
while (ori.hasNext()){
OutboundRequest or = ori.next();
ObjectOutputStream oos = new ObjectOutputStream(
or.getRequestOutputStream());
oos.writeInt(1);
oos.close();
}
} catch (Exception e2) {
//Expected exception
log.finest("Expected exception " + e2.getMessage());
}
if (dispatcher.dispatchCalled()!=-1){
throw new TestException("Exception from the "
+ "dispatcher was not propagated");
}
dispatcher.accept();
try {
OutboundRequestIterator ori =
e.newRequest(InvocationConstraints.EMPTY);
while (ori.hasNext()) {
OutboundRequest or = ori.next();
ObjectOutputStream oos = new ObjectOutputStream(
or.getRequestOutputStream());
oos.writeInt(2);
oos.close();
}
} catch (IOException ioe) {
throw new TestException("Endpoint unavailable after"
+ " exception in previous remote call");
}
if (dispatcher.dispatchCalled()!=2){
throw new TestException("Disaptcher was not called"
+ " after failure on previous remote call");
}
}