X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-it%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fit%2FNetconfITSecureTest.java;h=bd8e2ed4df623f4c96051429f70cadc11ed9b17f;hp=5f316d11c1cc6e28210d3382d0a78ca23aa01dd6;hb=12db0a738ac10ae139248c253b0bf2980752658d;hpb=11629ca46882ba8f6f717027731ae733afb4356d diff --git a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java index 5f316d11c1..bd8e2ed4df 100644 --- a/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java +++ b/opendaylight/netconf/netconf-it/src/test/java/org/opendaylight/controller/netconf/it/NetconfITSecureTest.java @@ -41,8 +41,6 @@ import org.apache.sshd.server.session.ServerSession; import org.junit.After; import org.junit.Before; import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.auth.AuthProvider; import org.opendaylight.controller.netconf.client.NetconfClientDispatcher; @@ -116,7 +114,7 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest { @Test public void testSecure() throws Exception { final NetconfClientDispatcher dispatch = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer()); - try (TestingNetconfClient netconfClient = new TestingNetconfClient("testing-ssh-client", dispatch, getClientConfiguration(new SimpleNetconfClientSessionListener()))) { + try (TestingNetconfClient netconfClient = new TestingNetconfClient("testing-ssh-client", dispatch, getClientConfiguration(new SimpleNetconfClientSessionListener(), TLS_ADDRESS))) { NetconfMessage response = netconfClient.sendMessage(getGetConfig()); assertFalse("Unexpected error message " + XmlUtil.toString(response.getDocument()), NetconfMessageUtil.isErrorMessage(response)); @@ -143,7 +141,7 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest { final NetconfClientDispatcher dispatch = new NetconfClientDispatcherImpl(getNettyThreadgroup(), getNettyThreadgroup(), getHashedWheelTimer()); final NetconfDeviceCommunicator sessionListener = getSessionListener(); - try (TestingNetconfClient netconfClient = new TestingNetconfClient("testing-ssh-client", dispatch, getClientConfiguration(sessionListener))) { + try (TestingNetconfClient netconfClient = new TestingNetconfClient("testing-ssh-client", dispatch, getClientConfiguration(sessionListener, TLS_ADDRESS))) { final AtomicInteger responseCounter = new AtomicInteger(0); final List>> futures = Lists.newArrayList(); @@ -182,15 +180,15 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest { } } - private NetconfMessage changeMessageId(final NetconfMessage getConfig, final int i) throws IOException, SAXException { + public static NetconfMessage changeMessageId(final NetconfMessage getConfig, final int i) throws IOException, SAXException { String s = XmlUtil.toString(getConfig.getDocument(), false); s = s.replace("101", Integer.toString(i)); return new NetconfMessage(XmlUtil.readXmlToDocument(s)); } - public NetconfClientConfiguration getClientConfiguration(final NetconfClientSessionListener sessionListener) throws IOException { + static NetconfClientConfiguration getClientConfiguration(final NetconfClientSessionListener sessionListener,final InetSocketAddress tlsAddress) throws IOException { final NetconfClientConfigurationBuilder b = NetconfClientConfigurationBuilder.create(); - b.withAddress(TLS_ADDRESS); + b.withAddress(tlsAddress); // Using session listener from sal-netconf-connector since stress test cannot be performed with simple listener b.withSessionListener(sessionListener); b.withReconnectStrategy(new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 5000)); @@ -200,11 +198,8 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest { return b.build(); } - @Mock - private RemoteDevice mockedRemoteDevice; - - private NetconfDeviceCommunicator getSessionListener() { - MockitoAnnotations.initMocks(this); + static NetconfDeviceCommunicator getSessionListener() { + RemoteDevice mockedRemoteDevice = mock(RemoteDevice.class); doNothing().when(mockedRemoteDevice).onRemoteSessionUp(any(NetconfSessionCapabilities.class), any(RemoteDeviceCommunicator.class)); doNothing().when(mockedRemoteDevice).onRemoteSessionDown(); return new NetconfDeviceCommunicator(new RemoteDeviceId("secure-test"), mockedRemoteDevice); @@ -217,7 +212,7 @@ public class NetconfITSecureTest extends AbstractNetconfConfigTest { return mockAuth; } - public AuthenticationHandler getAuthHandler() throws IOException { + public static AuthenticationHandler getAuthHandler() throws IOException { return new LoginPassword(USERNAME, PASSWORD); }