Skip to content

Commit 7d6e0fb

Browse files
committed
test: fix hard coded port number
allow parallel runs
1 parent 032d7dc commit 7d6e0fb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

oncrpc4j-rpcgen/src/test/java/org/dcache/oncrpc4j/rpcgen/AbstractCalculatorTest.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.dcache.oncrpc4j.rpcgen;
22

3+
import java.net.InetSocketAddress;
34
import org.dcache.oncrpc4j.rpc.net.IpProtocolType;
45
import org.dcache.oncrpc4j.rpc.OncRpcProgram;
56
import org.dcache.oncrpc4j.rpc.OncRpcSvc;
@@ -14,7 +15,7 @@ public abstract class AbstractCalculatorTest {
1415
protected OncRpcSvc server;
1516
protected CalculatorClient client;
1617
protected String address = "127.0.0.1";
17-
protected int port = 6666;
18+
protected int port = 0;
1819

1920
@Before
2021
public void setup() throws Exception{
@@ -27,9 +28,12 @@ public void setup() throws Exception{
2728
.build();
2829
server.register(new OncRpcProgram(Calculator.CALCULATOR, Calculator.CALCULATORVERS), serverImpl);
2930
server.start();
31+
32+
InetSocketAddress sockAddr = server.getInetSocketAddress(IpProtocolType.TCP);
33+
3034
client = new CalculatorClient(
3135
InetAddress.getByName(address),
32-
port,
36+
sockAddr.getPort(),
3337
Calculator.CALCULATOR,
3438
Calculator.CALCULATORVERS,
3539
IpProtocolType.TCP);

0 commit comments

Comments
 (0)