use of org.opendaylight.openflowjava.protocol.impl.clients.OFClient in project openflowplugin by opendaylight.
the class IntegrationTest method testTlsHandshake.
/**
* Library integration and secured communication test with handshake.
*/
@Test
public void testTlsHandshake() throws Exception {
setUp(TransportProtocol.TLS);
final int amountOfCLients = 1;
final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
final ScenarioHandler handler = new ScenarioHandler(scenario);
final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE);
final OFClient firstClient = clients.get(0);
firstClient.getScenarioDone().get();
Thread.sleep(1000);
LOGGER.debug("testTlsHandshake() Finished");
}
use of org.opendaylight.openflowjava.protocol.impl.clients.OFClient in project openflowplugin by opendaylight.
the class IntegrationTest method testTlsHandshakeAndEcho.
/**
* Library integration and secured communication test with handshake + echo exchange.
*/
@Test
public void testTlsHandshakeAndEcho() throws Exception {
setUp(TransportProtocol.TLS);
final int amountOfCLients = 1;
final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
scenario.addFirst(new SleepEvent(1000));
scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));
scenario.addFirst(new SleepEvent(1000));
scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
final ScenarioHandler handler = new ScenarioHandler(scenario);
final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TLS, ClientType.SIMPLE);
final OFClient firstClient = clients.get(0);
firstClient.getScenarioDone().get();
LOGGER.debug("testTlsHandshakeAndEcho() Finished");
}
use of org.opendaylight.openflowjava.protocol.impl.clients.OFClient in project openflowplugin by opendaylight.
the class IntegrationTest method createAndStartClient.
/**
* Creates and start a client.
*
* @param amountOfCLients number of clients
* @param protocol true if encrypted connection should be used
* @return new clients up and running
* @throws ExecutionException if some client could not start
*/
private List<OFClient> createAndStartClient(final int amountOfCLients, final ScenarioHandler scenarioHandler, final TransportProtocol protocol, final ClientType clientType) throws ExecutionException, InterruptedException, TimeoutException {
final List<OFClient> clientsHorde = new ArrayList<>();
for (int i = 0; i < amountOfCLients; i++) {
LOGGER.debug("startup address in createclient: {}", startupAddress.getHostAddress());
OFClient sc = null;
if (clientType == ClientType.SIMPLE) {
if (protocol.equals(TransportProtocol.TCP)) {
sc = new SimpleClient(startupAddress.getHostAddress(), port);
sc.setSecuredClient(false);
} else if (protocol.equals(TransportProtocol.TLS)) {
sc = new SimpleClient(startupAddress.getHostAddress(), port);
sc.setSecuredClient(true);
} else {
sc = new UdpSimpleClient(startupAddress.getHostAddress(), port);
}
} else if (clientType == ClientType.LISTENING) {
sc = new ListeningSimpleClient(0);
sc.setScenarioHandler(scenarioHandler);
sc.setSecuredClient(false);
} else {
LOGGER.error("Unknown type of client.");
throw new IllegalStateException("Unknown type of client.");
}
sc.setScenarioHandler(scenarioHandler);
clientsHorde.add(sc);
// sc.run();
thread = new Thread(sc);
thread.start();
}
for (final OFClient sc : clientsHorde) {
sc.getIsOnlineFuture().get(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
}
return clientsHorde;
}
use of org.opendaylight.openflowjava.protocol.impl.clients.OFClient in project openflowplugin by opendaylight.
the class IntegrationTest method testUdpHandshakeAndEcho.
/**
* Library udp integration and communication test with handshake + echo exchange.
*/
@Test
public void testUdpHandshakeAndEcho() throws Exception {
setUp(TransportProtocol.UDP);
final int amountOfCLients = 1;
final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
scenario.addFirst(new SleepEvent(1000));
scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));
scenario.addFirst(new SleepEvent(1000));
scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
final ScenarioHandler handler = new ScenarioHandler(scenario);
final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.UDP, ClientType.SIMPLE);
final OFClient firstClient = clients.get(0);
firstClient.getScenarioDone().get();
LOGGER.debug("testUdpHandshakeAndEcho() Finished");
}
use of org.opendaylight.openflowjava.protocol.impl.clients.OFClient in project openflowplugin by opendaylight.
the class IntegrationTest method testHandshakeAndEcho.
/**
* Library integration and communication test with handshake + echo exchange.
*/
@Test
public void testHandshakeAndEcho() throws Exception {
setUp(TransportProtocol.TCP);
final int amountOfCLients = 1;
final Deque<ClientEvent> scenario = ScenarioFactory.createHandshakeScenario();
scenario.addFirst(new SleepEvent(1000));
scenario.addFirst(new SendEvent(ByteBufUtils.hexStringToBytes("04 02 00 08 00 00 00 04")));
scenario.addFirst(new SleepEvent(1000));
scenario.addFirst(new WaitForMessageEvent(ByteBufUtils.hexStringToBytes("04 03 00 08 00 00 00 04")));
final ScenarioHandler handler = new ScenarioHandler(scenario);
final List<OFClient> clients = createAndStartClient(amountOfCLients, handler, TransportProtocol.TCP, ClientType.SIMPLE);
final OFClient firstClient = clients.get(0);
firstClient.getScenarioDone().get();
LOGGER.debug("testHandshakeAndEcho() Finished");
}
Aggregations