forked from I2P_Developers/i2p.i2p
* New buildTest and prepTest targets
* Fix UDPEndpoint usage in unit tests: - Restore receive() - Handle null UDPTransport * Fix UDPEndpointTestStandalone compilation
This commit is contained in:
15
build.xml
15
build.xml
@ -1292,20 +1292,29 @@
|
||||
<!-- end custom installers -->
|
||||
|
||||
<!-- unit tests -->
|
||||
<target name="updateTest" depends="prepupdate">
|
||||
<target name="buildTest">
|
||||
<ant dir="core/java/" target="jarTest" />
|
||||
<copy file="core/java/build/i2ptest.jar" todir="pkg-temp/lib" />
|
||||
<zip destfile="i2pupdate.zip" basedir="pkg-temp" />
|
||||
<ant dir="router/java/" target="jarTest" />
|
||||
<copy file="core/java/build/i2ptest.jar" todir="build" />
|
||||
<copy file="router/java/build/routertest.jar" todir="build" />
|
||||
</target>
|
||||
<target name="prepTest" depends="prepupdate, buildTest">
|
||||
<!-- overwrite i2p.jar and router.jar with the test versions -->
|
||||
<copy file="build/i2ptest.jar" tofile="pkg-temp/lib/i2p.jar" overwrite="true" />
|
||||
<copy file="build/routertest.jar" tofile="pkg-temp/lib/router.jar" overwrite="true" />
|
||||
</target>
|
||||
<target name="updateTest" depends="prepTest, zipit" />
|
||||
<target name="junit.test" depends="buildProperties, jbigi" >
|
||||
<ant dir="core/java/" target="junit.test" />
|
||||
<ant dir="router/java/" target="junit.test" />
|
||||
</target>
|
||||
<target name="scalatest.test" depends="buildProperties, jbigi" >
|
||||
<ant dir="core/java/" target="scalatest.test" />
|
||||
<!-- note there are no router scala tests yet -->
|
||||
<ant dir="router/java/" target="scalatest.test" />
|
||||
</target>
|
||||
<target name="test" depends="buildProperties, jbigi" >
|
||||
<!-- both junit and scala -->
|
||||
<ant dir="core/java/" target="test" />
|
||||
<ant dir="router/java/" target="test" />
|
||||
</target>
|
||||
|
@ -258,7 +258,10 @@
|
||||
<fileset dir="../../reports/router/junit/" />
|
||||
</replaceregexp>
|
||||
</target>
|
||||
|
||||
<!-- both junit and scala, but we have no scala tests yet -->
|
||||
<target name="test" depends="junit.test"/>
|
||||
|
||||
<!-- test reports -->
|
||||
<target name="scalatest.report">
|
||||
<junitreport todir="../../reports/router/scalatest">
|
||||
|
@ -31,6 +31,8 @@ import net.i2p.util.Log;
|
||||
/**
|
||||
* Generate compressed geoipv6.dat.gz file, and
|
||||
* lookup entries in it.
|
||||
*
|
||||
* @since IPv6
|
||||
*/
|
||||
class GeoIPv6 {
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.i2p.router.transport.udp;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramSocket;
|
||||
import java.net.InetAddress;
|
||||
import java.net.Inet4Address;
|
||||
@ -25,6 +26,7 @@ class UDPEndpoint {
|
||||
private final boolean _isIPv4, _isIPv6;
|
||||
|
||||
/**
|
||||
* @param transport may be null for unit testing ONLY
|
||||
* @param listenPort -1 or the requested port, may not be honored
|
||||
* @param bindAddress null ok
|
||||
*/
|
||||
@ -49,9 +51,11 @@ class UDPEndpoint {
|
||||
throw new SocketException("SSU Unable to bind to a port on " + _bindAddress);
|
||||
}
|
||||
_sender = new UDPSender(_context, _socket, "UDPSender");
|
||||
_receiver = new UDPReceiver(_context, _transport, _socket, "UDPReceiver");
|
||||
_sender.startup();
|
||||
_receiver.startup();
|
||||
if (_transport != null) {
|
||||
_receiver = new UDPReceiver(_context, _transport, _socket, "UDPReceiver");
|
||||
_receiver.startup();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void shutdown() {
|
||||
@ -157,6 +161,25 @@ class UDPEndpoint {
|
||||
public void send(UDPPacket packet) {
|
||||
_sender.add(packet);
|
||||
}
|
||||
|
||||
/**
|
||||
* Blocking call to receive the next inbound UDP packet from any peer.
|
||||
*
|
||||
* UNIT TESTING ONLY. Direct from the socket.
|
||||
* In normal operation, UDPReceiver thread injects to PacketHandler queue.
|
||||
*
|
||||
* @return null if we have shut down, or on failure
|
||||
*/
|
||||
public UDPPacket receive() {
|
||||
UDPPacket packet = UDPPacket.acquire(_context, true);
|
||||
try {
|
||||
_socket.receive(packet.getPacket());
|
||||
return packet;
|
||||
} catch (IOException ioe) {
|
||||
packet.release();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear outbound queue, probably in preparation for sending destroy() to everybody.
|
||||
|
@ -38,7 +38,11 @@ public class UDPEndpointTestStandalone {
|
||||
_log.debug("Building " + i);
|
||||
UDPEndpoint endpoint = new UDPEndpoint(_context, null, base + i, null);
|
||||
_endpoints[i] = endpoint;
|
||||
endpoint.startup();
|
||||
try {
|
||||
endpoint.startup();
|
||||
} catch (SocketException se) {
|
||||
throw new RuntimeException(se);
|
||||
}
|
||||
I2PThread read = new I2PThread(new TestRead(endpoint), "Test read " + i);
|
||||
I2PThread write = new I2PThread(new TestWrite(endpoint), "Test write " + i);
|
||||
//read.setDaemon(true);
|
||||
|
Reference in New Issue
Block a user