<property name="test.timeout" value="2000000"/>
<property name="test.src.dir" location="${basedir}/test"/>
<property name="test.log.dir" value="${build.test}/log"/>
+ <property name="test.port" value="9090" />
<target name="junit-test" description="Run the JUnit test suite" depends="compile-test">
<mkdir dir="${test.log.dir}"/>
<junit
printsummary="yes" showoutput="${test.output}"
- haltonfailure="no" fork="yes" forkmode="once" maxmemory="512m"
+ haltonfailure="no" fork="yes" maxmemory="512m"
errorProperty="tests.failed" failureProperty="tests.failed"
timeout="${test.timeout}"
>
<sysproperty key="build.test" value="${build.test}"/>
+ <sysproperty key="test.port" value="${test.port}" />
<classpath refid="test.classpath"/>
<formatter type="${test.junit.output.format}" />
<batchtest todir="${test.log.dir}" unless="testcase">
import org.apache.thrift.server.TNonblockingServer;
import org.apache.thrift.transport.TNonblockingServerSocket;
import org.apache.thrift.transport.TNonblockingSocket;
+import org.apache.thrift.server.ServerTestBase;
import thrift.test.CompactProtoTestStruct;
import thrift.test.Srv;
public JankyRunnable(TAsyncClientManager acm, int numCalls) throws Exception {
this.acm_ = acm;
this.numCalls_ = numCalls;
- this.clientSocket_ = new TNonblockingSocket("localhost", 12345);
+ this.clientSocket_ = new TNonblockingSocket(ServerTestBase.HOST, ServerTestBase.PORT);
this.client_ = new Srv.AsyncClient(new TBinaryProtocol.Factory(), acm_, clientSocket_);
}
public void testIt() throws Exception {
// put up a server
- final TNonblockingServer s = new TNonblockingServer(new Srv.Processor(new SrvHandler()), new TNonblockingServerSocket(12345));
+ final TNonblockingServer s = new TNonblockingServer(new Srv.Processor(new SrvHandler()),
+ new TNonblockingServerSocket(ServerTestBase.PORT));
new Thread(new Runnable() {
@Override
public void run() {
TAsyncClientManager acm = new TAsyncClientManager();
// connect an async client
- TNonblockingSocket clientSock = new TNonblockingSocket("localhost", 12345);
+ TNonblockingSocket clientSock = new TNonblockingSocket(
+ ServerTestBase.HOST, ServerTestBase.PORT);
Srv.AsyncClient client = new Srv.AsyncClient(new TBinaryProtocol.Factory(), acm, clientSock);
final Object o = new Object();
assertTrue(voidAfterOnewayReturned.get());
// make multiple calls with deserialization in the selector thread (repro Eric's issue)
- int numThreads = 500;
+ int numThreads = 200;
int numCallsPerThread = 100;
List<JankyRunnable> runnables = new ArrayList<JankyRunnable>();
List<Thread> threads = new ArrayList<Thread>();
new TBinaryProtocol.Factory(),
new TCompactProtocol.Factory());
- protected static final String HOST = "localhost";
- protected static final int PORT = 9090;
+ public static final String HOST = "localhost";
+ public static final int PORT = Integer.valueOf(
+ System.getProperty("test.port", "9090"));
protected static final int SOCKET_TIMEOUT = 1000;
private static final Xtruct XSTRUCT = new Xtruct("Zero", (byte) 1, -3, -5);
private static final Xtruct2 XSTRUCT2 = new Xtruct2((byte)1, XSTRUCT, 5);