+ " ServerEndpoint.enumerateListenEndpoints is not"
+ " serializable");
}
//Verify that an outbound request can be obtained from the Endpoint
OutboundRequestIterator ori =
e.newRequest(InvocationConstraints.EMPTY);
int response = 0;
while (ori.hasNext()) {
//Verify that the outbound request can be used to communicate
//with the server side of the connection
OutboundRequest or = ori.next();
ObjectOutputStream oos =
new ObjectOutputStream(or.getRequestOutputStream());
oos.writeInt(this.hashCode());
oos.close();
ObjectInputStream ois = new ObjectInputStream(
or.getResponseInputStream());
response = ois.readInt();
ois.close();
//Verify UnsupportedOperationException
ArrayList al = new ArrayList();
al.add(new Object());
Collection uc = Collections.unmodifiableCollection(al);
exceptionThrown = false;
try {
uc.add(new Object());
//This is an implementation specific check
//comment code line above this comment if implementation
//is expected to populate the passed in context
or.populateContext(uc);
} catch (UnsupportedOperationException uoe) {
//This exception would only occur if one of the
//JERI layers attempts to write context information
//to the collection
exceptionThrown = true;
}
if (!exceptionThrown){
throw new TestException("Passing an unmodifiable"
+ " collection to populateContext does not result"
+ " in UnsupportedOperationException");
}
//Verify idempotency of input/output streams
InputStream i1 = or.getResponseInputStream();
InputStream i2 = or.getResponseInputStream();
OutputStream o1 = or.getRequestOutputStream();
OutputStream o2 = or.getRequestOutputStream();
if (o1!=o2||i1!=i2) {
throw new TestException("Idempotency of streams"
+ " is not maintained");
}
}
//Verify NoSuchElementException
exceptionThrown = false;
try {
ori.next();
} catch (NoSuchElementException nse) {
exceptionThrown = true;
}
if (!exceptionThrown) {
throw new TestException("Calling next on an iterator"
+ " that has returned false from hasNext does not throw"
+ " NoSuchElementException");
}
Iterator it = endpoints.iterator();
while(it.hasNext()) {
EndpointHolder eph = (EndpointHolder) it.next();
SETRequestHandler rh = (SETRequestHandler)
eph.getRequestHandler();
if (response != rh.hashCode()){
throw new TestException("The response received"
+ "does not match the response sent by the server"
+ "side of the connection. Server sent "
+ rh.hashCode() + ", but the client got " + response);
}
ArrayList requests = rh.getRequests();
if (requests.size()!=1){
throw new TestException("The RequestDisptcher"
+ " received the incorrect number of requests. "
+ "Expected 1 and received " + requests.size());
}
Iterator requestIterator = requests.iterator();
while (requestIterator.hasNext()){
Integer value = (Integer) requestIterator.next();
if (value.intValue()!=this.hashCode()){
throw new TestException("The data read from"
+ " the InboundRequest does not match the data"
+ " written to the OutboundRequest. Wrote "
+ this.hashCode() + " read " + value);
}
}
ServerEndpoint.ListenHandle lh = eph.getListenHandle();
//Close the listen operation
lh.close();
}
//Verify that new requests are not received after close has
//been called on the ListenHandle
try {
ori = e.newRequest(InvocationConstraints.EMPTY);
while (ori.hasNext()) {
OutboundRequest or = ori.next();
ObjectOutputStream oos =
new ObjectOutputStream(or.getRequestOutputStream());
oos.writeInt(this.hashCode());
oos.close();
}