Skip to content

Commit

Permalink
NMS-6903 use a random open port for the test
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Reed committed Sep 26, 2014
1 parent 0b559b0 commit 40d48ab
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@

@RunWith(Parameterized.class)
public class MockSnmpAgentTest {

@Parameters
public static Collection<Object[]> versions() {
return Arrays.asList(new Object[][] {
Expand Down Expand Up @@ -144,7 +143,9 @@ public void setUp() throws Exception {
m_usm = new USM(SecurityProtocols.getInstance(), new OctetString(MPv3.createLocalEngineID()), 0);
SecurityModels.getInstance().addSecurityModel(m_usm);

m_agent = MockSnmpAgent.createAgentAndRun(classPathResource("loadSnmpDataTest.properties"), "127.0.0.1/1691"); // Homage to Empire
m_agent = MockSnmpAgent.createAgentAndRun(classPathResource("loadSnmpDataTest.properties"), "127.0.0.1/0");
Thread.sleep(200);
System.err.println("Started MockSnmpAgent on port " + m_agent.getPort());

m_requestedVarbinds = new ArrayList<AnticipatedRequest>();
}
Expand All @@ -155,6 +156,7 @@ public void tearDown() throws Exception {
if (m_agent != null) {
m_agent.shutDownAndWait();
}
Thread.sleep(200);
}

public AnticipatedRequest request(String requestedOid, Variable requestedValue) {
Expand Down Expand Up @@ -429,7 +431,7 @@ private PDU sendRequestV1V2(PDU pdu, int version) {
PDU response = null;
CommunityTarget target = new CommunityTarget();
target.setCommunity(new OctetString("public"));
target.setAddress(new UdpAddress(InetAddressUtils.addr("127.0.0.1"), 1691));
target.setAddress(new UdpAddress(InetAddressUtils.addr("127.0.0.1"), m_agent.getPort()));
target.setVersion(version);

TransportMapping<UdpAddress> transport = null;
Expand Down Expand Up @@ -471,7 +473,7 @@ private PDU sendRequestV3(PDU pdu) {
UserTarget target = new UserTarget();
target.setSecurityLevel(SecurityLevel.AUTH_PRIV);
target.setSecurityName(userId);
target.setAddress(new UdpAddress(InetAddressUtils.addr("127.0.0.1"), 1691));
target.setAddress(new UdpAddress(InetAddressUtils.addr("127.0.0.1"), m_agent.getPort()));
target.setVersion(SnmpConstants.version3);
target.setTimeout(DEFAULT_TIMEOUT);

Expand Down

0 comments on commit 40d48ab

Please sign in to comment.