Skip to content

Commit

Permalink
KAA-1279: Fixed about 100 warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
sashadidukh committed Sep 30, 2016
1 parent 28b70aa commit 6b746c2
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 62 deletions.
Expand Up @@ -27,26 +27,28 @@
import java.security.InvalidKeyException; import java.security.InvalidKeyException;
import java.security.PublicKey; import java.security.PublicKey;


public class IPTransportInfo extends GenericTransportInfo { public class IpTransportInfo extends GenericTransportInfo {
public static final Logger LOG = LoggerFactory // NOSONAR public static final Logger LOG = LoggerFactory // NOSONAR
.getLogger(IPTransportInfo.class); .getLogger(IpTransportInfo.class);
private static final Charset UTF8 = Charset.forName("UTF-8"); private static final Charset UTF8 = Charset.forName("UTF-8");


private final String host; private final String host;
private final int port; private final int port;
private final PublicKey publicKey; private final PublicKey publicKey;


public IPTransportInfo(TransportConnectionInfo parent) { public IpTransportInfo(TransportConnectionInfo parent) {
super(parent.getServerType(), new ProtocolMetaData(parent.getAccessPointId(), new ProtocolVersionPair(parent.getTransportId() super(parent.getServerType(), new ProtocolMetaData(parent.getAccessPointId(),
.getProtocolId(), parent.getTransportId().getProtocolVersion()), ByteBuffer.wrap(parent.getConnectionInfo()))); new ProtocolVersionPair(parent.getTransportId()
.getProtocolId(), parent.getTransportId().getProtocolVersion()),
ByteBuffer.wrap(parent.getConnectionInfo())));
ByteBuffer buf = md.getConnectionInfo().duplicate(); ByteBuffer buf = md.getConnectionInfo().duplicate();
byte[] publicKeyData = new byte[buf.getInt()]; byte[] publicKeyData = new byte[buf.getInt()];
buf.get(publicKeyData); buf.get(publicKeyData);
try { try {
this.publicKey = KeyUtil.getPublic(publicKeyData); this.publicKey = KeyUtil.getPublic(publicKeyData);
} catch (InvalidKeyException e) { } catch (InvalidKeyException ex) {
LOG.error("Can't initialize public key", e); LOG.error("Can't initialize public key", ex);
throw new RuntimeException(e); throw new RuntimeException(ex);
} }
byte[] hostData = new byte[buf.getInt()]; byte[] hostData = new byte[buf.getInt()];
buf.get(hostData); buf.get(hostData);
Expand All @@ -66,14 +68,14 @@ public PublicKey getPublicKey() {
return publicKey; return publicKey;
} }


public String getURL() { public String getUrl() {
return "http://" + host + ":" + port; return "http://" + host + ":" + port;
} }


@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.append("IPTransportInfo [host="); builder.append("IpTransportInfo [host=");
builder.append(host); builder.append(host);
builder.append(", port="); builder.append(", port=");
builder.append(port); builder.append(port);
Expand Down
Expand Up @@ -27,8 +27,8 @@


import org.junit.Test; import org.junit.Test;
import org.kaaproject.kaa.client.channel.BootstrapTransport; import org.kaaproject.kaa.client.channel.BootstrapTransport;
import org.kaaproject.kaa.client.channel.IPTransportInfo; import org.kaaproject.kaa.client.channel.IpTransportInfo;
import org.kaaproject.kaa.client.channel.IPTransportInfoTest; import org.kaaproject.kaa.client.channel.IpTransportInfoTest;
import org.kaaproject.kaa.client.channel.KaaDataChannel; import org.kaaproject.kaa.client.channel.KaaDataChannel;
import org.kaaproject.kaa.client.channel.KaaDataDemultiplexer; import org.kaaproject.kaa.client.channel.KaaDataDemultiplexer;
import org.kaaproject.kaa.client.channel.KaaDataMultiplexer; import org.kaaproject.kaa.client.channel.KaaDataMultiplexer;
Expand Down Expand Up @@ -98,8 +98,8 @@ public void testOperationsServerInfoRetrieving() throws TransportException, NoSu
KeyPair keyPair = keyGen.genKeyPair(); KeyPair keyPair = keyGen.genKeyPair();


List<ProtocolMetaData> list = new ArrayList<ProtocolMetaData>(); List<ProtocolMetaData> list = new ArrayList<ProtocolMetaData>();
ProtocolMetaData md = IPTransportInfoTest.buildMetaData(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, ProtocolMetaData md = IpTransportInfoTest.buildMetaData(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889,
keyPair.getPublic()); keyPair.getPublic());
list.add(md); list.add(md);


ChanelManagerMock channelManager = spy(new ChanelManagerMock()); ChanelManagerMock channelManager = spy(new ChanelManagerMock());
Expand Down Expand Up @@ -136,8 +136,8 @@ public void testUseServerByDnsName() throws NoSuchAlgorithmException {
KeyPair keyPair = keyGen.genKeyPair(); KeyPair keyPair = keyGen.genKeyPair();


List<ProtocolMetaData> list = new ArrayList<ProtocolMetaData>(); List<ProtocolMetaData> list = new ArrayList<ProtocolMetaData>();
ProtocolMetaData md = IPTransportInfoTest.buildMetaData(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, ProtocolMetaData md = IpTransportInfoTest.buildMetaData(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889,
keyPair.getPublic()); keyPair.getPublic());
list.add(md); list.add(md);


manager.onProtocolListUpdated(list); manager.onProtocolListUpdated(list);
Expand All @@ -147,7 +147,7 @@ public void testUseServerByDnsName() throws NoSuchAlgorithmException {
verify(transport, times(1)).sync(); verify(transport, times(1)).sync();


list = new ArrayList<ProtocolMetaData>(); list = new ArrayList<ProtocolMetaData>();
md = IPTransportInfoTest.buildMetaData(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost2", 9889, keyPair.getPublic()); md = IpTransportInfoTest.buildMetaData(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost2", 9889, keyPair.getPublic());
list.add(md); list.add(md);


manager.onProtocolListUpdated(list); manager.onProtocolListUpdated(list);
Expand Down Expand Up @@ -208,7 +208,7 @@ public void setFailoverManager(FailoverManager failoverManager) {


@Override @Override
public void onTransportConnectionInfoUpdated(TransportConnectionInfo newServer) { public void onTransportConnectionInfoUpdated(TransportConnectionInfo newServer) {
receivedUrl = new IPTransportInfo(newServer).getURL(); receivedUrl = new IpTransportInfo(newServer).getUrl();
serverUpdated = true; serverUpdated = true;
} }


Expand Down
Expand Up @@ -70,8 +70,8 @@ public void testChannelSync() throws Exception {
KaaDataDemultiplexer demultiplexer = Mockito.mock(KaaDataDemultiplexer.class); KaaDataDemultiplexer demultiplexer = Mockito.mock(KaaDataDemultiplexer.class);
DefaultBootstrapChannelMock channel = new DefaultBootstrapChannelMock(client, state, failoverManager, 2); DefaultBootstrapChannelMock channel = new DefaultBootstrapChannelMock(client, state, failoverManager, 2);


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo(ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID,
"localhost", 9889, KeyUtil.generateKeyPair().getPublic()); "localhost", 9889, KeyUtil.generateKeyPair().getPublic());


channel.setServer(server); channel.setServer(server);


Expand Down Expand Up @@ -110,8 +110,8 @@ public void testShutdown() throws Exception {
channel.setMultiplexer(multiplexer); channel.setMultiplexer(multiplexer);
channel.shutdown(); channel.shutdown();


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo(ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID,
"localhost", 9889, KeyUtil.generateKeyPair().getPublic()); "localhost", 9889, KeyUtil.generateKeyPair().getPublic());
channel.setServer(server); channel.setServer(server);


channel.sync(TransportType.BOOTSTRAP); channel.sync(TransportType.BOOTSTRAP);
Expand Down
Expand Up @@ -79,8 +79,8 @@ public void testEmptyBootstrapManager() {
@Test @Test
public void testAddHttpLpChannel() throws NoSuchAlgorithmException, InvalidKeySpecException { public void testAddHttpLpChannel() throws NoSuchAlgorithmException, InvalidKeySpecException {
Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>(); Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>();
bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Collections.singletonList(IPTransportInfoTest.createTestServerInfo( bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Collections.singletonList(IpTransportInfoTest.createTestServerInfo(
ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic()))); ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic())));
BootstrapManager bootstrapManager = Mockito.mock(BootstrapManager.class); BootstrapManager bootstrapManager = Mockito.mock(BootstrapManager.class);


KaaDataChannel channel = Mockito.mock(KaaDataChannel.class); KaaDataChannel channel = Mockito.mock(KaaDataChannel.class);
Expand All @@ -95,8 +95,8 @@ public void testAddHttpLpChannel() throws NoSuchAlgorithmException, InvalidKeySp
channelManager.addChannel(channel); channelManager.addChannel(channel);
channelManager.addChannel(channel); channelManager.addChannel(channel);


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo( TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(
ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9999, KeyUtil.generateKeyPair().getPublic()); ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9999, KeyUtil.generateKeyPair().getPublic());
channelManager.onTransportConnectionInfoUpdated(server); channelManager.onTransportConnectionInfoUpdated(server);
Mockito.verify(failoverManager, Mockito.times(1)).onServerChanged(Mockito.any(TransportConnectionInfo.class)); Mockito.verify(failoverManager, Mockito.times(1)).onServerChanged(Mockito.any(TransportConnectionInfo.class));


Expand All @@ -118,8 +118,8 @@ public void testAddHttpLpChannel() throws NoSuchAlgorithmException, InvalidKeySp
@Test @Test
public void testAddBootstrapChannel() throws NoSuchAlgorithmException, InvalidKeySpecException { public void testAddBootstrapChannel() throws NoSuchAlgorithmException, InvalidKeySpecException {
Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>(); Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>();
TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo( TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(
ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic()); ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic());
bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Collections.singletonList(server)); bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Collections.singletonList(server));


BootstrapManager bootstrapManager = Mockito.mock(BootstrapManager.class); BootstrapManager bootstrapManager = Mockito.mock(BootstrapManager.class);
Expand Down Expand Up @@ -162,8 +162,8 @@ public void testOperationServerFailed() throws NoSuchAlgorithmException, Invalid
KaaInternalChannelManager channelManager = new DefaultChannelManager(bootstrapManager, bootststrapServers, null, null); KaaInternalChannelManager channelManager = new DefaultChannelManager(bootstrapManager, bootststrapServers, null, null);
channelManager.addChannel(channel); channelManager.addChannel(channel);


TransportConnectionInfo opServer = IPTransportInfoTest.createTestServerInfo( TransportConnectionInfo opServer = IpTransportInfoTest.createTestServerInfo(
ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9999, KeyUtil.generateKeyPair().getPublic()); ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9999, KeyUtil.generateKeyPair().getPublic());
channelManager.onTransportConnectionInfoUpdated(opServer); channelManager.onTransportConnectionInfoUpdated(opServer);


channelManager.onServerFailed(opServer, FailoverStatus.NO_CONNECTIVITY); channelManager.onServerFailed(opServer, FailoverStatus.NO_CONNECTIVITY);
Expand All @@ -175,10 +175,10 @@ public void testOperationServerFailed() throws NoSuchAlgorithmException, Invalid
public void testBootstrapServerFailed() throws NoSuchAlgorithmException, InvalidKeySpecException { public void testBootstrapServerFailed() throws NoSuchAlgorithmException, InvalidKeySpecException {
final Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>(); final Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>();
bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Arrays.asList( bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Arrays.asList(
IPTransportInfoTest.createTestServerInfo( IpTransportInfoTest.createTestServerInfo(
ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic()), ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic()),
IPTransportInfoTest.createTestServerInfo( IpTransportInfoTest.createTestServerInfo(
ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost2", 9889, KeyUtil.generateKeyPair().getPublic()))); ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost2", 9889, KeyUtil.generateKeyPair().getPublic())));
BootstrapManager bootstrapManager = Mockito.mock(BootstrapManager.class); BootstrapManager bootstrapManager = Mockito.mock(BootstrapManager.class);


final KaaDataChannel channel = Mockito.mock(KaaDataChannel.class); final KaaDataChannel channel = Mockito.mock(KaaDataChannel.class);
Expand Down Expand Up @@ -214,8 +214,8 @@ public void run() {
public void testSingleBootstrapServerFailed() throws NoSuchAlgorithmException, InvalidKeySpecException { public void testSingleBootstrapServerFailed() throws NoSuchAlgorithmException, InvalidKeySpecException {
Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>(); Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>();
bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Arrays.asList( bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Arrays.asList(
IPTransportInfoTest.createTestServerInfo( IpTransportInfoTest.createTestServerInfo(
ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic()))); ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic())));
BootstrapManager bootstrapManager = Mockito.mock(BootstrapManager.class); BootstrapManager bootstrapManager = Mockito.mock(BootstrapManager.class);


KaaDataChannel channel = Mockito.mock(KaaDataChannel.class); KaaDataChannel channel = Mockito.mock(KaaDataChannel.class);
Expand Down Expand Up @@ -270,12 +270,12 @@ public void testRemoveHttpLpChannel() throws NoSuchAlgorithmException, InvalidKe
channelManager.addChannel(channel1); channelManager.addChannel(channel1);
channelManager.addChannel(channel2); channelManager.addChannel(channel2);


TransportConnectionInfo opServer = IPTransportInfoTest.createTestServerInfo( TransportConnectionInfo opServer = IpTransportInfoTest.createTestServerInfo(
ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9999, KeyUtil.generateKeyPair().getPublic()); ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9999, KeyUtil.generateKeyPair().getPublic());
channelManager.onTransportConnectionInfoUpdated(opServer); channelManager.onTransportConnectionInfoUpdated(opServer);


TransportConnectionInfo opServer2 = IPTransportInfoTest.createTestServerInfo( TransportConnectionInfo opServer2 = IpTransportInfoTest.createTestServerInfo(
ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic()); ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic());


channelManager.onTransportConnectionInfoUpdated(opServer2); channelManager.onTransportConnectionInfoUpdated(opServer2);


Expand All @@ -286,8 +286,8 @@ public void testRemoveHttpLpChannel() throws NoSuchAlgorithmException, InvalidKe


channelManager.removeChannel(channel2); channelManager.removeChannel(channel2);


TransportConnectionInfo opServer3 = IPTransportInfoTest.createTestServerInfo( TransportConnectionInfo opServer3 = IpTransportInfoTest.createTestServerInfo(
ServerType.OPERATIONS, TransportProtocolIdConstants.TCP_TRANSPORT_ID, "localhost", 9009, KeyUtil.generateKeyPair().getPublic()); ServerType.OPERATIONS, TransportProtocolIdConstants.TCP_TRANSPORT_ID, "localhost", 9009, KeyUtil.generateKeyPair().getPublic());
channelManager.addChannel(channel3); channelManager.addChannel(channel3);
channelManager.onTransportConnectionInfoUpdated(opServer3); channelManager.onTransportConnectionInfoUpdated(opServer3);


Expand Down Expand Up @@ -490,8 +490,8 @@ public void testResume() throws NoSuchAlgorithmException, InvalidKeySpecExceptio


private Map<TransportProtocolId, List<TransportConnectionInfo>> getDefaultBootstrapServers() throws NoSuchAlgorithmException { private Map<TransportProtocolId, List<TransportConnectionInfo>> getDefaultBootstrapServers() throws NoSuchAlgorithmException {
Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>(); Map<TransportProtocolId, List<TransportConnectionInfo>> bootststrapServers = new HashMap<>();
TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo( TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(
ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic()); ServerType.BOOTSTRAP, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic());
bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Collections.singletonList(server)); bootststrapServers.put(TransportProtocolIdConstants.HTTP_TRANSPORT_ID, Collections.singletonList(server));
return bootststrapServers; return bootststrapServers;
} }
Expand Down
Expand Up @@ -81,8 +81,8 @@ public void testChannelSync() throws Exception {
KaaDataDemultiplexer demultiplexer = Mockito.mock(KaaDataDemultiplexer.class); KaaDataDemultiplexer demultiplexer = Mockito.mock(KaaDataDemultiplexer.class);
DefaultOperationHttpChannelFake channel = new DefaultOperationHttpChannelFake(client, state, failoverManager, 2); DefaultOperationHttpChannelFake channel = new DefaultOperationHttpChannelFake(client, state, failoverManager, 2);


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS,
TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic()); TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic());


channel.setServer(server); channel.setServer(server);


Expand Down Expand Up @@ -122,8 +122,8 @@ public void testShutdown() throws Exception {
channel.setMultiplexer(multiplexer); channel.setMultiplexer(multiplexer);
channel.shutdown(); channel.shutdown();


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS,
TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic()); TransportProtocolIdConstants.HTTP_TRANSPORT_ID, "localhost", 9889, KeyUtil.generateKeyPair().getPublic());
channel.setServer(server); channel.setServer(server);


channel.sync(TransportType.EVENT); channel.sync(TransportType.EVENT);
Expand Down
Expand Up @@ -82,8 +82,8 @@ public void testSync() throws Exception {
tcpChannel.sync(TransportType.USER); // will cause call to KaaDataMultiplexer.compileRequest(...) after "CONNECT" messsage tcpChannel.sync(TransportType.USER); // will cause call to KaaDataMultiplexer.compileRequest(...) after "CONNECT" messsage
tcpChannel.sync(TransportType.PROFILE); tcpChannel.sync(TransportType.PROFILE);


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.TCP_TRANSPORT_ID, TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.TCP_TRANSPORT_ID,
"localhost", 9009, KeyUtil.generateKeyPair().getPublic()); "localhost", 9009, KeyUtil.generateKeyPair().getPublic());


tcpChannel.setServer(server); // causes call to KaaDataMultiplexer.compileRequest(...) for "CONNECT" messsage tcpChannel.setServer(server); // causes call to KaaDataMultiplexer.compileRequest(...) for "CONNECT" messsage
byte[] rawConnack = new byte[]{0x20, 0x02, 0x00, 0x01}; byte[] rawConnack = new byte[]{0x20, 0x02, 0x00, 0x01};
Expand Down Expand Up @@ -123,8 +123,8 @@ public void testConnectivity() throws NoSuchAlgorithmException {
FailoverManager failoverManager = Mockito.mock(FailoverManager.class); FailoverManager failoverManager = Mockito.mock(FailoverManager.class);
DefaultOperationTcpChannel channel = new DefaultOperationTcpChannel(clientState, failoverManager, null); DefaultOperationTcpChannel channel = new DefaultOperationTcpChannel(clientState, failoverManager, null);


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.TCP_TRANSPORT_ID, TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.TCP_TRANSPORT_ID,
"www.test.fake", 999, KeyUtil.generateKeyPair().getPublic()); "www.test.fake", 999, KeyUtil.generateKeyPair().getPublic());


ConnectivityChecker checker = Mockito.mock(ConnectivityChecker.class); ConnectivityChecker checker = Mockito.mock(ConnectivityChecker.class);
Mockito.when(checker.checkConnectivity()).thenReturn(false); Mockito.when(checker.checkConnectivity()).thenReturn(false);
Expand Down
Expand Up @@ -97,8 +97,8 @@ public void testChannelSync() throws Exception {
KaaDataDemultiplexer demultiplexer = Mockito.mock(KaaDataDemultiplexer.class); KaaDataDemultiplexer demultiplexer = Mockito.mock(KaaDataDemultiplexer.class);
DefaultOperationsChannelFake channel = new DefaultOperationsChannelFake(client, state, failoverManager, 3); DefaultOperationsChannelFake channel = new DefaultOperationsChannelFake(client, state, failoverManager, 3);


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID,
"localhost", 9889, KeyUtil.generateKeyPair().getPublic()); "localhost", 9889, KeyUtil.generateKeyPair().getPublic());


channel.setDemultiplexer(null); channel.setDemultiplexer(null);
channel.setDemultiplexer(demultiplexer); channel.setDemultiplexer(demultiplexer);
Expand Down Expand Up @@ -145,8 +145,8 @@ public void testServerFailed() throws Exception {
channel.setDemultiplexer(demultiplexer); channel.setDemultiplexer(demultiplexer);
channel.setMultiplexer(multiplexer); channel.setMultiplexer(multiplexer);


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID,
"localhost", 9889, KeyUtil.generateKeyPair().getPublic()); "localhost", 9889, KeyUtil.generateKeyPair().getPublic());
channel.setServer(server); channel.setServer(server);


Mockito.verify(failoverManager, Mockito.times(1)).onServerFailed(Mockito.any(TransportConnectionInfo.class), Mockito.any(FailoverStatus.class)); Mockito.verify(failoverManager, Mockito.times(1)).onServerFailed(Mockito.any(TransportConnectionInfo.class), Mockito.any(FailoverStatus.class));
Expand Down Expand Up @@ -179,8 +179,8 @@ public void testShutdown() throws Exception {
channel.setMultiplexer(multiplexer); channel.setMultiplexer(multiplexer);
channel.shutdown(); channel.shutdown();


TransportConnectionInfo server = IPTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID, TransportConnectionInfo server = IpTransportInfoTest.createTestServerInfo(ServerType.OPERATIONS, TransportProtocolIdConstants.HTTP_TRANSPORT_ID,
"localhost", 9889, KeyUtil.generateKeyPair().getPublic()); "localhost", 9889, KeyUtil.generateKeyPair().getPublic());
channel.setServer(server); channel.setServer(server);


channel.sync(TransportType.EVENT); channel.sync(TransportType.EVENT);
Expand Down

0 comments on commit 6b746c2

Please sign in to comment.