diff --git a/test/org/ice4j/MessageEventDispatchingTest.java b/test/org/ice4j/MessageEventDispatchingTest.java index 4aeda55..720990b 100644 --- a/test/org/ice4j/MessageEventDispatchingTest.java +++ b/test/org/ice4j/MessageEventDispatchingTest.java @@ -300,9 +300,12 @@ public class MessageEventDispatchingTest extends TestCase } /** - * Indicates that no response has been received. + * Called when the associated transaction expires. + * + * @param evt the StunTimeoutEvent containing a reference to + * the failed Message and the expired transaction. */ - public synchronized void processTimeout() + public synchronized void processTimeout(StunTimeoutEvent evt) { receivedResponses.add("timeout"); notifyAll(); diff --git a/test/org/ice4j/TransactionSupportTests.java b/test/org/ice4j/TransactionSupportTests.java index d31ca76..8c1311a 100644 --- a/test/org/ice4j/TransactionSupportTests.java +++ b/test/org/ice4j/TransactionSupportTests.java @@ -56,10 +56,23 @@ public class TransactionSupportTests extends TestCase */ Response bindingResponse = null; + /** + * The tool that collects requests. + */ PlainRequestCollector requestCollector = null; + + /** + * The tool that collects responses. + */ PlainResponseCollector responseCollector = null; - protected void setUp() throws Exception + /** + * Inits sockets. + * + * @throws Exception if something goes bad. + */ + protected void setUp() + throws Exception { super.setUp(); @@ -88,7 +101,13 @@ public class TransactionSupportTests extends TestCase ""); } - protected void tearDown() throws Exception + /** + * Frees all sockets that we are currently using. + * + * @throws Exception if something does not go as planned. + */ + protected void tearDown() + throws Exception { StunStack.getInstance().removeSocket(clientAddress); StunStack.getInstance().removeSocket(serverAddress); @@ -302,6 +321,12 @@ public class TransactionSupportTests extends TestCase evt2.getMessage().getTransactionID())); } + /** + * Tests whether the properties for configuring the maximum number of + * retransmissions in a transaction are working properly. + * + * @throws Exception if the gods so decide. + */ public void testClientTransactionMaxRetransmisssionsConfigurationParameter() throws Exception { @@ -334,6 +359,12 @@ public class TransactionSupportTests extends TestCase } + /** + * Tests whether the properties for configuring the minimum transaction + * wait interval is working properly. + * + * @throws Exception if we are having a bad day. + */ public void testMinWaitIntervalConfigurationParameter() throws Exception { @@ -369,6 +400,12 @@ public class TransactionSupportTests extends TestCase 2, reqs.size()); } + /** + * Tests whether the properties for configuring the maximum transaction + * wait interval is working properly. + * + * @throws Exception if the gods so decide. + */ public void testMaxWaitIntervalConfigurationParameter() throws Exception { @@ -410,10 +447,23 @@ public class TransactionSupportTests extends TestCase reqs.size()); } - private class PlainRequestCollector implements RequestListener{ + /** + * A simply utility for asynchronous collection of requests. + */ + private class PlainRequestCollector + implements RequestListener + { + /** + * + */ private Vector receivedRequestsVector = new Vector(); + /** + * Logs the newly received request. + * + * @param evt the {@link StunMessageEvent} to log. + */ public void requestReceived(StunMessageEvent evt) { synchronized(this) @@ -446,6 +496,9 @@ public class TransactionSupportTests extends TestCase return newVec; } + /** + * Blocks until a request arrives or 50 ms pass. + */ public void waitForRequest() { synchronized(this) @@ -460,17 +513,34 @@ public class TransactionSupportTests extends TestCase } } + /** + * A simple utility for asynchronously collecting responses. + */ private class PlainResponseCollector implements ResponseCollector { + /** + * The responses we've collected so far. + */ public final Vector receivedResponses = new Vector(); + /** + * Logs the received responseEvt + * + * @param responseEvt the event to log. + */ public void processResponse(StunMessageEvent responseEvt) { receivedResponses.add(responseEvt); } - public void processTimeout() + /** + * Called when the associated transaction expires. + * + * @param evt the StunTimeoutEvent containing a reference to + * the failed Message and the expired transaction. + */ + public void processTimeout(StunTimeoutEvent evt) { receivedResponses.add("timeout"); } @@ -489,18 +559,4 @@ public class TransactionSupportTests extends TestCase receivedResponses.add("unreachable"); } } - - /* - public TransactionSupportTests(String name) - { - super(name); - } - public static Test suite() - { - TestSuite suite = new TestSuite(); - suite.addTest(new TransactionSupportTests( - "testMaxWaitIntervalConfigurationParameter")); - return suite; - } - */ } diff --git a/test/org/ice4j/stack/ShallowStackTest.java b/test/org/ice4j/stack/ShallowStackTest.java index d82e2fe..03c235e 100644 --- a/test/org/ice4j/stack/ShallowStackTest.java +++ b/test/org/ice4j/stack/ShallowStackTest.java @@ -279,11 +279,22 @@ public class ShallowStackTest extends TestCase { } //--------------------------------------- listener implementations --------- + /** + * A simple utility that allows us to asynchronously collect messages. + */ public class SimpleResponseCollector implements ResponseCollector { + + /** + * The response that we've just collected or null if none + * arrived while we were waiting. + */ Response collectedResponse = null; + /** + * Logs the received response and notifies the wait method. + */ public synchronized void processResponse(StunMessageEvent evt) { collectedResponse = (Response)evt.getMessage(); @@ -291,7 +302,12 @@ public class ShallowStackTest extends TestCase { notifyAll(); } - public synchronized void processTimeout() + /** + * Logs the timeout event for later use. + * + * @param evt the timeout event that has just occurred. + */ + public synchronized void processTimeout(StunTimeoutEvent evt) { logger.info("Timeout"); notifyAll(); @@ -313,6 +329,9 @@ public class ShallowStackTest extends TestCase { notifyAll(); } + /** + * Blocks until a request arrives or 50 ms pass. + */ public synchronized void waitForResponse() { try @@ -327,11 +346,24 @@ public class ShallowStackTest extends TestCase { } } + /** + * A utility class for asynchronously collecting requests. + */ public class SimpleRequestCollector implements RequestListener { + /** + * The one request that this collector has received or null if + * none arrived while we were waiting. + */ private Request collectedRequest = null; + /** + * Indicates that a StunRequest has just been received. + * + * @param evt the StunMessageEvent containing the details of + * the newly received request. + */ public void requestReceived(StunMessageEvent evt) { synchronized(this) @@ -343,6 +375,9 @@ public class ShallowStackTest extends TestCase { } } + /** + * Blocks until a request arrives or 50 ms pass. + */ public void waitForRequest() { synchronized(this)