Methods Summary |
---|
public void | runTests()Main method that launches the unit tests
declare("testTCPClientRscLimit");
testTCPClientRscLimit();
declare("testTCPServerRscLimit");
testTCPServerRscLimit();
declare("testDatagramRscLimit");
testDatagramRscLimit();
|
void | testDatagramRscLimit()Test for datagram resource limit check
boolean exceptionThrown = false;
boolean cleanupFailed = false;
int openCount = 0;
int localServerPort = 10000;
DatagramConnection[] sc =
new DatagramConnection[Constants.UDP_AMS_LIMIT+1];
try {
// Setup
while (openCount < Constants.UDP_AMS_LIMIT) {
String s = "datagram://:" + Integer.toString(localServerPort +
openCount);
sc[openCount] = (DatagramConnection) Connector.open(s);
openCount++;
}
// Actual Test
try {
String s = "datagram://:" + Integer.toString(localServerPort +
openCount);
sc[openCount] = (DatagramConnection) Connector.open(s);
openCount++;
} catch (java.io.IOException io) {
exceptionThrown = true;
}
} finally {
// Cleanup
for (int i = 0; i < openCount; i++) {
try {
sc[i].close();
} catch (java.io.IOException io) {
cleanupFailed = true;
}
}
if (cleanupFailed) {
throw new java.io.IOException("Cleanup failed datagrams");
}
}
assertTrue(exceptionThrown);
|
void | testTCPClientRscLimit()Test for TCP client resource limit check
boolean exceptionThrown = false;
boolean cleanupFailed = false;
int openCount = 0;
SocketConnection[] sc =
new SocketConnection[Constants.TCP_CLI_AMS_LIMIT+1];
try {
// Setup
while (openCount < Constants.TCP_CLI_AMS_LIMIT) {
sc[openCount] = (SocketConnection) Connector.open(
otherSideUri);
openCount++;
}
// Actual Test
try {
sc[openCount] = (SocketConnection) Connector.open(
otherSideUri);
openCount++;
} catch (java.io.IOException io) {
exceptionThrown = true;
}
} catch (ConnectionNotFoundException cnfe) {
fail("Exception while opening "+otherSideUri+": "+cnfe.getMessage()+
". If the host name cannot be resolved, you may " +
"need to change the i3test source to use a host name that" +
" is visible from your network.");
} finally {
// Cleanup
for (int i = 0; i < openCount; i++) {
try {
sc[i].close();
} catch (java.io.IOException io) {
cleanupFailed = true;
}
}
if (cleanupFailed) {
throw new java.io.IOException("Cleanup failed TCP clients");
}
}
assertTrue("expected exception thrown?",exceptionThrown);
|
void | testTCPServerRscLimit()Test for TCP server resource limit check
boolean exceptionThrown = false;
boolean cleanupFailed = false;
int openCount = 0;
int localServerPort = 10000;
ServerSocketConnection[] sc =
new ServerSocketConnection[Constants.TCP_SER_AMS_LIMIT+1];
try {
// Setup
while (openCount < Constants.TCP_SER_AMS_LIMIT) {
String s = "socket://:" + Integer.toString(localServerPort +
openCount);
sc[openCount] = (ServerSocketConnection) Connector.open(s);
openCount++;
}
// Actual Test
try {
String s = "socket://:" + Integer.toString(localServerPort +
openCount);
sc[openCount] = (ServerSocketConnection) Connector.open(s);
openCount++;
} catch (java.io.IOException io) {
exceptionThrown = true;
}
} finally {
// Cleanup
for (int i = 0; i < openCount; i++) {
try {
sc[i].close();
} catch (java.io.IOException io) {
cleanupFailed = true;
}
}
if (cleanupFailed) {
throw new java.io.IOException("Cleanup failed TCP servers");
}
}
assertTrue(exceptionThrown);
|