public class IllegalArgumentExceptionTest extends AbstractEndpointTest {
public void run() throws Exception {
//Obtain a serverEndpoint instance
ServerEndpoint se = getServerEndpoint();
IllegalArgumentContext context = new IllegalArgumentContext(null);
//Call enumerateListenEndpoints and extract cookies
se.enumerateListenEndpoints(context);
ArrayList cookies = context.getCookies();
//Obtain a different server endpoint
se = (ServerEndpoint) getConfigObject(ServerEndpoint.class,
"diffEndpoint");
boolean exceptionThrown = false;
try {
se.enumerateListenEndpoints(
new IllegalArgumentContext(cookies));
} catch (IllegalArgumentException e) {
exceptionThrown = true;
}
if (!exceptionThrown) {
throw new TestException("The ServerEndpoint"
+ " implementation does not throw an"
+ " IllegalArgumentException when an invalid"
+ " ListenCookie is returned by the ListenContext");
}
//Close listen operation
ArrayList endpoints = context.getEndpoints();
Iterator it = endpoints.iterator();
while (it.hasNext()) {
((EndpointHolder) it.next()).getListenHandle().close();
}
// wait to make sure resources are released before attempting