\r
/**\r
* @author michal.polkorab\r
- *\r
+ * @author timotej.kubas\r
*/\r
public class IntegrationTest {\r
\r
- /** Name of file in which OpenFLow protocol messages are stored in binary format */\r
+ private static final Logger LOGGER = LoggerFactory\r
+ .getLogger(IntegrationTest.class);\r
private static int port;\r
private static final FEATURE_SUPPORT DEFAULT_TLS_SUPPORT = FEATURE_SUPPORT.NOT_SUPPORTED;\r
private static final int SWITCH_IDLE_TIMEOUT = 2000;\r
-\r
- protected static final Logger LOGGER = LoggerFactory\r
- .getLogger(IntegrationTest.class);\r
-\r
private static final long CONNECTION_TIMEOUT = 2000;\r
private InetAddress startupAddress;\r
private MockPlugin mockPlugin;\r
port = server.getPort();\r
}\r
\r
+ /**\r
+ * @throws Exception\r
+ */\r
@After\r
public void tearDown() throws Exception {\r
Thread.sleep(500);\r
}\r
\r
/**\r
- * Library integration and communication test\r
+ * Library integration and communication test with handshake\r
* @throws Exception \r
*/\r
@Test\r
}\r
\r
/**\r
- * Library integration and communication test\r
+ * Library integration and communication test with handshake + echo exchange\r
* @throws Exception \r
*/\r
@Test\r
/**\r
* @param amountOfCLients \r
* @return new clients up and running\r
- * @throws InterruptedException\r
- * @throws ExecutionException\r
+ * @throws ExecutionException if some client could not start\r
*/\r
private List<SimpleClient> createAndStartClient(int amountOfCLients, ScenarioHandler scenarioHandler)\r
- throws InterruptedException, ExecutionException {\r
+ throws ExecutionException {\r
List<SimpleClient> clientsHorde = new ArrayList<>();\r
for (int i = 0; i < amountOfCLients; i++) {\r
LOGGER.debug("startup address in createclient: " + startupAddress.getHostAddress());\r
private ConnectionAdapter adapter;\r
private SettableFuture<Void> finishedFuture;\r
private int idleCounter = 0;\r
- \r
+\r
+ /** Creates MockPlugin */\r
public MockPlugin() {\r
LOGGER.info("Creating MockPlugin");\r
finishedFuture = SettableFuture.create();\r
LOGGER.debug("adapter: "+adapter);\r
}\r
\r
+ /**\r
+ * @return finishedFuture object\r
+ */\r
public SettableFuture<Void> getFinishedFuture() {\r
return finishedFuture;\r
}\r
LOGGER.debug("switch status: "+notification.getInfo());\r
idleCounter ++;\r
}\r
- \r
+\r
+ /**\r
+ * @return number of occured idleEvents\r
+ */\r
public int getIdleCounter() {\r
return idleCounter;\r
}\r
private Object transferProtocol;\r
private FEATURE_SUPPORT tlsSupport;\r
private long switchIdleTimeout;\r
- \r
- // TODO - implement transferProtocol\r
+\r
+ /**\r
+ * Creates {@link TestingConnConfigImpl}\r
+ * @param address \r
+ * @param port\r
+ * @param tlsSupport\r
+ * @param switchIdleTimeout\r
+ */\r
public TestingConnConfigImpl(InetAddress address, int port, FEATURE_SUPPORT tlsSupport, long switchIdleTimeout) {\r
this.address = address;\r
this.port = port;\r
this.tlsSupport = tlsSupport;\r
this.switchIdleTimeout = switchIdleTimeout;\r
}\r
- \r
+\r
@Override\r
public InetAddress getAddress() {\r
return address;\r
<level value="DEBUG" />\r
<appender-ref ref="console" />\r
</logger>\r
+ <logger name="org.opendaylight.openflowjava.protocol.impl.clients" additivity="false">\r
+ <level value="DEBUG" />\r
+ <appender-ref ref="console" />\r
+ </logger>\r
\r
<root>\r
<priority value="INFO" />\r
/* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */
package org.opendaylight.openflowjava.protocol.impl.clients;
-
+/**
+ * Uniting interface used for scenario support
+ * @author michal.polkorab
+ *
+ */
public interface ClientEvent {
+ /**
+ * Common method for triggering events
+ * @return true if event executed successfully
+ */
public boolean eventExecuted();
}
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
/**
+ * Class for providing prepared handshake scenario
+ *
* @author michal.polkorab
- *
*/
public class ScenarioFactory {
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+/**
+ *
+ * @author michal.polkorab
+ *
+ */
public class ScenarioHandler extends Thread {
private static final Logger LOGGER = LoggerFactory.getLogger(ScenarioHandler.class);
private Stack<ClientEvent> scenario;
private BlockingQueue<byte[]> ofMsg;
private ChannelHandlerContext ctx;
+ private int eventNumber;
/**
*
public void run() {
int freezeCounter = 0;
while (!scenario.isEmpty()) {
+ LOGGER.debug("Running event #" + eventNumber);
ClientEvent peek = scenario.peek();
if (peek instanceof WaitForMessageEvent) {
LOGGER.debug("WaitForMessageEvent");
}
if (peek.eventExecuted()) {
scenario.pop();
+ eventNumber++;
freezeCounter = 0;
} else {
freezeCounter++;
this.notify();
}
}
-
+
+ /**
+ * @return true if scenario is done / empty
+ */
public boolean isEmpty() {
return scenario.isEmpty();
}
+ /**
+ * @return scenario
+ */
public Stack<ClientEvent> getScenario() {
return scenario;
}
+ /**
+ * @param scenario scenario filled with desired events
+ */
public void setScenario(Stack<ClientEvent> scenario) {
this.scenario = scenario;
}
+ /**
+ * @param ctx context which will be used for sending messages (SendEvents)
+ */
public void setCtx(ChannelHandlerContext ctx) {
this.ctx = ctx;
}
+ /**
+ * @param message received message that is compared to expected message
+ */
public void addOfMsg(byte[] message) {
ofMsg.add(message);
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
+/**
+ * Class representing sending message event
+ *
+ * @author michal.polkorab
+ */
public class SendEvent implements ClientEvent {
protected static final Logger LOGGER = LoggerFactory.getLogger(SendEvent.class);
protected byte[] msgToSend;
protected ChannelHandlerContext ctx;
+ /**
+ * @param msgToSend message to be sent
+ */
public SendEvent(byte[] msgToSend) {
this.msgToSend = msgToSend;
}
return true;
}
+ /**
+ * @param ctx context which will be used for sending messages (SendEvents)
+ */
public void setCtx(ChannelHandlerContext ctx) {
this.ctx = ctx;
}
\r
/**\r
* @param isOnlineFuture future notifier of connected channel\r
+ * @param scenarioHandler handler of scenario events\r
*/\r
public SimpleClientHandler(SettableFuture<Boolean> isOnlineFuture, ScenarioHandler scenarioHandler) {\r
this.isOnlineFuture = isOnlineFuture;\r
}\r
}\r
\r
+ /**\r
+ * @param scenarioHandler handler of scenario events\r
+ */\r
public void setScenario(ScenarioHandler scenarioHandler) {\r
this.scenarioHandler = scenarioHandler;\r
}\r
/**
* @param isOnlineFuture future notifier of connected channel
+ * @param secured true if {@link SimpleClient} should use encrypted communication
*/
public SimpleClientInitializer(SettableFuture<Boolean> isOnlineFuture, boolean secured) {
this.isOnlineFuture = isOnlineFuture;
isOnlineFuture = null;
}
-
+
+ /**
+ * @param scenarioHandler handler of scenario events
+ */
public void setScenario(ScenarioHandler scenarioHandler) {
this.scenarioHandler = scenarioHandler;
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+/**
+ * Class representing sleep (wait) event
+ *
+ * @author michal.polkorab
+ */
public class SleepEvent implements ClientEvent {
private static final Logger LOGGER = LoggerFactory.getLogger(SleepEvent.class);
private long sleepTime;
-
+
+ /**
+ *
+ * @param sleepTime time of {@link Thread#sleep(long)} in milliseconds
+ */
public SleepEvent(long sleepTime) {
this.sleepTime = sleepTime;
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-
-
+/**
+ * Class representing waiting on message
+ * @author michal.polkorab
+ */
public class WaitForMessageEvent implements ClientEvent {
private static final Logger LOGGER = LoggerFactory.getLogger(WaitForMessageEvent.class);
private byte[] headerExpected;
private byte[] headerReceived;
- public WaitForMessageEvent(byte[] headerAwaited) {
- this.headerExpected = headerAwaited;
+ /**
+ * @param headerExpected header (first 8 bytes) of expected message
+ */
+ public WaitForMessageEvent(byte[] headerExpected) {
+ this.headerExpected = headerExpected;
}
@Override
return true;
}
+ /**
+ * @param headerReceived header (first 8 bytes) of expected message
+ */
public void setHeaderReceived(byte[] headerReceived) {
this.headerReceived = headerReceived;
}