diff --git a/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectCloseTest.java b/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectCloseTest.java index 4fa2ddf31de9c57d37796dcf460e3a873d994fe6..b62e610a2d97bbede2e5248508b3f3b23280455e 100644 --- a/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectCloseTest.java +++ b/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectCloseTest.java @@ -5,6 +5,10 @@ import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.util.Properties; +import org.junit.Test; + +import junit.framework.TestCase; + import net.i2p.I2PAppContext; import net.i2p.client.I2PClient; import net.i2p.client.I2PClientFactory; @@ -18,23 +22,20 @@ import net.i2p.util.Log; * EOF. * */ -public class ConnectCloseTest { +public class ConnectCloseTest extends TestCase { private Log _log; private I2PSession _server; - public void test() { - try { - I2PAppContext context = I2PAppContext.getGlobalContext(); - _log = context.logManager().getLog(ConnectCloseTest.class); - _log.debug("creating server session"); - _server = createSession(); - _log.debug("running server"); - runServer(context, _server); - _log.debug("running client"); - runClient(context, createSession()); - } catch (Exception e) { - _log.error("error running", e); - } - try { Thread.sleep(10*60*1000); } catch (Exception e) {} + + @Test + public void test() throws Exception { + I2PAppContext context = I2PAppContext.getGlobalContext(); + _log = context.logManager().getLog(ConnectCloseTest.class); + _log.debug("creating server session"); + _server = createSession(); + _log.debug("running server"); + runServer(context, _server); + _log.debug("running client"); + runClient(context, createSession()); } private void runClient(I2PAppContext ctx, I2PSession session) { @@ -130,9 +131,4 @@ public class ConnectCloseTest { throw new RuntimeException("b0rk b0rk b0rk"); } } - - public static void main(String args[]) { - ConnectCloseTest ct = new ConnectCloseTest(); - ct.test(); - } } diff --git a/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectInactivityTest.java b/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectInactivityTest.java index 33804fb6a7166efbc581175374837d43cbf26c14..96937d781024d2292b4caa9c8b3df3c8c1ecf3d0 100644 --- a/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectInactivityTest.java +++ b/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectInactivityTest.java @@ -4,6 +4,10 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Properties; +import org.junit.Test; + +import junit.framework.TestCase; + import net.i2p.I2PAppContext; import net.i2p.client.I2PClient; import net.i2p.client.I2PClientFactory; @@ -14,25 +18,23 @@ import net.i2p.util.Log; /** * */ -public class ConnectInactivityTest { +public class ConnectInactivityTest extends TestCase{ private Log _log; private I2PSession _client; private I2PSession _server; - public void test() { - try { - I2PAppContext context = I2PAppContext.getGlobalContext(); - _log = context.logManager().getLog(ConnectTest.class); - _log.debug("creating server session"); - _server = createSession(); - _log.debug("running server"); - runServer(context, _server); - _log.debug("creating client session"); - _client = createSession(); - _log.debug("running client"); - runClient(context, _client); - } catch (Exception e) { - _log.error("error running", e); - } + + @Test + public void test() throws Exception { + I2PAppContext context = I2PAppContext.getGlobalContext(); + _log = context.logManager().getLog(ConnectTest.class); + _log.debug("creating server session"); + _server = createSession(); + _log.debug("running server"); + runServer(context, _server); + _log.debug("creating client session"); + _client = createSession(); + _log.debug("running client"); + runClient(context, _client); } private void runClient(I2PAppContext ctx, I2PSession session) { @@ -123,9 +125,4 @@ public class ConnectInactivityTest { throw new RuntimeException("b0rk b0rk b0rk"); } } - - public static void main(String args[]) { - ConnectInactivityTest ct = new ConnectInactivityTest(); - ct.test(); - } } diff --git a/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectTest.java b/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectTest.java index de9da9d89be8b6ab16d50574f216952bf3228dee..5d6237816cfedab2b6a4e9f99003c314b0c96927 100644 --- a/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectTest.java +++ b/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectTest.java @@ -4,6 +4,11 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Properties; +import org.junit.Before; +import org.junit.Test; + +import junit.framework.TestCase; + import net.i2p.I2PAppContext; import net.i2p.client.I2PClient; import net.i2p.client.I2PClientFactory; @@ -14,25 +19,28 @@ import net.i2p.util.Log; /** * */ -public class ConnectTest { +public class ConnectTest extends TestCase { private Log _log; private I2PSession _server; - public void test() { - try { - I2PAppContext context = I2PAppContext.getGlobalContext(); - _log = context.logManager().getLog(ConnectTest.class); - _log.debug("creating server session"); - _server = createSession(); - _log.debug("running server"); - runServer(context, _server); - for (int i = 0; i < 5; i++) { - _log.debug("running client"); - runClient(context, createSession()); - } - } catch (Exception e) { - _log.error("error running", e); + + @Before + public void setUp() throws Exception { + System.setProperty(I2PClient.PROP_TCP_HOST, "localhost"); + System.setProperty(I2PClient.PROP_TCP_PORT, "11001"); + } + + @Test + public void test() throws Exception { + I2PAppContext context = I2PAppContext.getGlobalContext(); + _log = context.logManager().getLog(ConnectTest.class); + _log.debug("creating server session"); + _server = createSession(); + _log.debug("running server"); + runServer(context, _server); + for (int i = 0; i < 5; i++) { + _log.debug("running client"); + runClient(context, createSession()); } - try { Thread.sleep(10*60*1000); } catch (Exception e) {} } private void runClient(I2PAppContext ctx, I2PSession session) { @@ -122,11 +130,4 @@ public class ConnectTest { throw new RuntimeException("b0rk b0rk b0rk"); } } - - public static void main(String args[]) { - System.setProperty(I2PClient.PROP_TCP_HOST, "localhost"); - System.setProperty(I2PClient.PROP_TCP_PORT, "11001"); - ConnectTest ct = new ConnectTest(); - ct.test(); - } } diff --git a/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectTimeoutTest.java b/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectTimeoutTest.java index c0dff316ebbca6293d60e6dfd384a43578ea7472..249142c3f01b5b36e8c2eaf417663ba8b3f4ecee 100644 --- a/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectTimeoutTest.java +++ b/apps/streaming/java/test/junit/net/i2p/client/streaming/ConnectTimeoutTest.java @@ -4,6 +4,10 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.util.Properties; +import org.junit.Test; + +import junit.framework.TestCase; + import net.i2p.I2PAppContext; import net.i2p.client.I2PClient; import net.i2p.client.I2PClientFactory; @@ -15,28 +19,24 @@ import net.i2p.util.Log; * Try to connect to a new nonexistant peer and, of course, * timeout. */ -public class ConnectTimeoutTest { +public class ConnectTimeoutTest extends TestCase { private Log _log; private I2PSession _client; private I2PSession _server; private Destination _serverDest; - public void testNonexistant() { + @Test + public void testNonexistant() throws Exception { + I2PAppContext context = I2PAppContext.getGlobalContext(); + _log = context.logManager().getLog(ConnectTest.class); + _log.debug("creating server dest"); try { - I2PAppContext context = I2PAppContext.getGlobalContext(); - _log = context.logManager().getLog(ConnectTest.class); - _log.debug("creating server dest"); - try { - _serverDest = I2PClientFactory.createClient().createDestination(new ByteArrayOutputStream()); - } catch (Exception e) {} - _log.debug("creating client session"); - _client = createSession(); - _log.debug("running client"); - runClient(context, _client); - } catch (Exception e) { - _log.error("error running", e); - } - while (true) { synchronized (this) { try { wait(); } catch (Exception e) {} } } + _serverDest = I2PClientFactory.createClient().createDestination(new ByteArrayOutputStream()); + } catch (Exception e) {} + _log.debug("creating client session"); + _client = createSession(); + _log.debug("running client"); + runClient(context, _client); } private void runClient(I2PAppContext ctx, I2PSession session) { @@ -91,11 +91,6 @@ public class ConnectTimeoutTest { } } - public static void main(String args[]) { - ConnectTimeoutTest ct = new ConnectTimeoutTest(); - ct.testNonexistant(); - } - private static Properties getProps() { Properties p = new Properties(); p.setProperty(I2PSocketManagerFactory.PROP_MANAGER, I2PSocketManagerFull.class.getName()); diff --git a/apps/streaming/java/test/junit/net/i2p/client/streaming/EchoLargeTest.java b/apps/streaming/java/test/junit/net/i2p/client/streaming/EchoLargeTest.java index dc1b0dbb61602363bf7eb396ba81f9fcb180a3a8..f47112827c3a7bbaa5199b9336c3a639d56cb9a3 100644 --- a/apps/streaming/java/test/junit/net/i2p/client/streaming/EchoLargeTest.java +++ b/apps/streaming/java/test/junit/net/i2p/client/streaming/EchoLargeTest.java @@ -6,6 +6,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; +import org.junit.Test; + +import junit.framework.TestCase; + import net.i2p.I2PAppContext; import net.i2p.client.I2PClient; import net.i2p.client.I2PClientFactory; @@ -17,27 +21,23 @@ import net.i2p.util.Log; /** * */ -public class EchoLargeTest { +public class EchoLargeTest extends TestCase { private Log _log; private I2PSession _client; private I2PSession _server; - public void test() { - try { - I2PAppContext context = I2PAppContext.getGlobalContext(); - _log = context.logManager().getLog(ConnectTest.class); - _log.debug("creating server session"); - _server = createSession(); - _log.debug("running server"); - runServer(context, _server); - _log.debug("creating client session"); - _client = createSession(); - _log.debug("running client"); - runClient(context, _client); - } catch (Exception e) { - _log.error("error running", e); - } - try { Thread.sleep(300*1000); } catch (Exception e) {} + @Test + public void test() throws Exception { + I2PAppContext context = I2PAppContext.getGlobalContext(); + _log = context.logManager().getLog(ConnectTest.class); + _log.debug("creating server session"); + _server = createSession(); + _log.debug("running server"); + runServer(context, _server); + _log.debug("creating client session"); + _client = createSession(); + _log.debug("running client"); + runClient(context, _client); } private void runClient(I2PAppContext ctx, I2PSession session) { @@ -192,9 +192,4 @@ public class EchoLargeTest { throw new RuntimeException("b0rk b0rk b0rk"); } } - - public static void main(String args[]) { - EchoLargeTest et = new EchoLargeTest(); - et.test(); - } } diff --git a/apps/streaming/java/test/junit/net/i2p/client/streaming/EchoTest.java b/apps/streaming/java/test/junit/net/i2p/client/streaming/EchoTest.java index 1946aa4f61d331cf822538dd05863516b624623d..b110175b70fabcc8604cc73767b07010e62e3761 100644 --- a/apps/streaming/java/test/junit/net/i2p/client/streaming/EchoTest.java +++ b/apps/streaming/java/test/junit/net/i2p/client/streaming/EchoTest.java @@ -6,6 +6,10 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; +import org.junit.Test; + +import junit.framework.TestCase; + import net.i2p.I2PAppContext; import net.i2p.client.I2PClient; import net.i2p.client.I2PClientFactory; @@ -16,26 +20,23 @@ import net.i2p.util.Log; /** * */ -public class EchoTest { +public class EchoTest extends TestCase { private Log _log; private I2PSession _client; private I2PSession _server; - public void test() { - try { - I2PAppContext context = I2PAppContext.getGlobalContext(); - _log = context.logManager().getLog(ConnectTest.class); - _log.debug("creating server session"); - _server = createSession(); - _log.debug("running server"); - runServer(context, _server); - _log.debug("creating client session"); - _client = createSession(); - _log.debug("running client"); - runClient(context, _client); - } catch (Exception e) { - _log.error("error running", e); - } - try { Thread.sleep(300*1000); } catch (Exception e) {} + + @Test + public void test() throws Exception { + I2PAppContext context = I2PAppContext.getGlobalContext(); + _log = context.logManager().getLog(ConnectTest.class); + _log.debug("creating server session"); + _server = createSession(); + _log.debug("running server"); + runServer(context, _server); + _log.debug("creating client session"); + _client = createSession(); + _log.debug("running client"); + runClient(context, _client); } private void runClient(I2PAppContext ctx, I2PSession session) { @@ -170,9 +171,4 @@ public class EchoTest { throw new RuntimeException("b0rk b0rk b0rk"); } } - - public static void main(String args[]) { - EchoTest et = new EchoTest(); - et.test(); - } } diff --git a/apps/streaming/java/test/junit/net/i2p/client/streaming/MessageInputStreamTest.java b/apps/streaming/java/test/junit/net/i2p/client/streaming/MessageInputStreamTest.java index 564bfb0054818b3c4b591d284c73e8219940173a..f42727248bcabb623404aa1f4ee9d58cff6b4eff 100644 --- a/apps/streaming/java/test/junit/net/i2p/client/streaming/MessageInputStreamTest.java +++ b/apps/streaming/java/test/junit/net/i2p/client/streaming/MessageInputStreamTest.java @@ -4,6 +4,11 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collections; +import org.junit.Before; +import org.junit.Test; + +import junit.framework.TestCase; + import net.i2p.I2PAppContext; import net.i2p.data.ByteArray; import net.i2p.data.DataHelper; @@ -12,15 +17,17 @@ import net.i2p.util.Log; /** * Stress test the MessageInputStream */ -public class MessageInputStreamTest { +public class MessageInputStreamTest extends TestCase { private I2PAppContext _context; private Log _log; - public MessageInputStreamTest() { + @Before + public void setUp() { _context = I2PAppContext.getGlobalContext(); _log = _context.logManager().getLog(MessageInputStreamTest.class); } + @Test public void testInOrder() { byte orig[] = new byte[256*1024]; _context.random().nextBytes(orig); @@ -46,6 +53,7 @@ public class MessageInputStreamTest { } } + @Test public void testRandomOrder() { byte orig[] = new byte[256*1024]; _context.random().nextBytes(orig); @@ -77,6 +85,7 @@ public class MessageInputStreamTest { } } + @Test public void testRandomDups() { byte orig[] = new byte[256*1024]; _context.random().nextBytes(orig); @@ -110,6 +119,7 @@ public class MessageInputStreamTest { } } + @Test public void testStaggered() { byte orig[] = new byte[256*1024]; byte read[] = new byte[orig.length]; @@ -148,17 +158,4 @@ public class MessageInputStreamTest { _log.info("Passed test: staggered"); } - - public static void main(String args[]) { - MessageInputStreamTest t = new MessageInputStreamTest(); - try { - t.testInOrder(); - t.testRandomOrder(); - t.testRandomDups(); - t.testStaggered(); - } catch (Exception e) { - e.printStackTrace(); - } - try { Thread.sleep(10*1000); } catch (InterruptedException ie) {} - } }