broker/RawClient: code formatter used

This commit is contained in:
Andreas Mager
2017-02-01 17:13:44 +01:00
parent 324721e155
commit ab282cea23
@@ -1,3 +1,4 @@
package io.moquette.testclient; package io.moquette.testclient;
import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.Bootstrap;
@@ -11,15 +12,14 @@ import io.netty.util.ReferenceCountUtil;
import io.moquette.Utils; import io.moquette.Utils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/** /**
* This class is used to have a fluent interface to interact with a server. * This class is used to have a fluent interface to interact with a server. Inspired by
* Inspired by org.kaazing.robot * org.kaazing.robot
*/ */
public class RawClient { public class RawClient {
@@ -41,9 +41,9 @@ public class RawClient {
@Override @Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception { public void channelInactive(ChannelHandlerContext ctx) throws Exception {
//m_client.setConnectionLost(true); // m_client.setConnectionLost(true);
disconnectLatch.countDown(); disconnectLatch.countDown();
ctx.close(/*false*/); ctx.close(/* false */);
} }
} }
@@ -71,6 +71,7 @@ public class RawClient {
b.channel(NioSocketChannel.class); b.channel(NioSocketChannel.class);
b.option(ChannelOption.SO_KEEPALIVE, true); b.option(ChannelOption.SO_KEEPALIVE, true);
b.handler(new ChannelInitializer<SocketChannel>() { b.handler(new ChannelInitializer<SocketChannel>() {
@Override @Override
public void initChannel(SocketChannel ch) throws Exception { public void initChannel(SocketChannel ch) throws Exception {
ChannelPipeline pipeline = ch.pipeline(); ChannelPipeline pipeline = ch.pipeline();
@@ -117,14 +118,14 @@ public class RawClient {
/** /**
* Write just String bytes not length * Write just String bytes not length
* */ */
public RawClient write(String str) { public RawClient write(String str) {
ByteBuf out = Unpooled.buffer(str.length()); ByteBuf out = Unpooled.buffer(str.length());
byte[] raw; byte[] raw;
try { try {
raw = str.getBytes("UTF-8"); raw = str.getBytes("UTF-8");
//NB every Java platform has got UTF-8 encoding by default, so this // NB every Java platform has got UTF-8 encoding by default, so this
//exception are never raised. // exception are never raised.
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
throw new IllegalStateException(ex); throw new IllegalStateException(ex);
} }
@@ -153,14 +154,14 @@ public class RawClient {
/** /**
* Expect the closing of the underling channel, with timeout * Expect the closing of the underling channel, with timeout
* */ */
public void closed(long timeout) throws InterruptedException { public void closed(long timeout) throws InterruptedException {
disconnectLatch.await(timeout, TimeUnit.MILLISECONDS); disconnectLatch.await(timeout, TimeUnit.MILLISECONDS);
} }
/** /**
* Expect closing the connect with unbound time * Expect closing the connect with unbound time
* */ */
public void closed() throws InterruptedException { public void closed() throws InterruptedException {
disconnectLatch.await(); disconnectLatch.await();
} }