Skip to content

Commit

Permalink
test: fix hard coded port number
Browse files Browse the repository at this point in the history
allow parallel runs
  • Loading branch information
kofemann committed Jan 3, 2023
1 parent 032d7dc commit 7d6e0fb
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.dcache.oncrpc4j.rpcgen;

import java.net.InetSocketAddress;
import org.dcache.oncrpc4j.rpc.net.IpProtocolType;
import org.dcache.oncrpc4j.rpc.OncRpcProgram;
import org.dcache.oncrpc4j.rpc.OncRpcSvc;
Expand All @@ -14,7 +15,7 @@ public abstract class AbstractCalculatorTest {
protected OncRpcSvc server;
protected CalculatorClient client;
protected String address = "127.0.0.1";
protected int port = 6666;
protected int port = 0;

@Before
public void setup() throws Exception{
Expand All @@ -27,9 +28,12 @@ public void setup() throws Exception{
.build();
server.register(new OncRpcProgram(Calculator.CALCULATOR, Calculator.CALCULATORVERS), serverImpl);
server.start();

InetSocketAddress sockAddr = server.getInetSocketAddress(IpProtocolType.TCP);

client = new CalculatorClient(
InetAddress.getByName(address),
port,
sockAddr.getPort(),
Calculator.CALCULATOR,
Calculator.CALCULATORVERS,
IpProtocolType.TCP);
Expand Down

0 comments on commit 7d6e0fb

Please sign in to comment.