use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.start.tls.message.StartTlsMessageBuilder in project bgpcep by opendaylight.
the class AbstractPCEPSessionNegotiator method startNegotiation.
@Override
protected final void startNegotiation() {
Preconditions.checkState(this.state == State.IDLE);
if (this.tlsConfiguration != null) {
this.sendMessage(new StarttlsBuilder().setStartTlsMessage(new StartTlsMessageBuilder().build()).build());
this.state = State.START_TLS_WAIT;
scheduleFailTimer();
LOG.info("Started TLS connection negotiation with peer {}", this.channel);
} else {
startNegotiationWithOpen();
}
this.channel.closeFuture().addListener((ChannelFutureListener) f -> cancelTimers());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.start.tls.message.StartTlsMessageBuilder in project bgpcep by opendaylight.
the class AbstractPCEPSessionTest method setUp.
@Before
public final void setUp() {
MockitoAnnotations.initMocks(this);
final ChannelFuture future = new DefaultChannelPromise(this.channel);
doAnswer(invocation -> {
final Object[] args = invocation.getArguments();
AbstractPCEPSessionTest.this.msgsSend.add((Notification) args[0]);
return future;
}).when(this.channel).writeAndFlush(any(Notification.class));
doReturn(this.channelFuture).when(this.channel).closeFuture();
doReturn(this.channelFuture).when(this.channelFuture).addListener(any(GenericFutureListener.class));
doReturn("TestingChannel").when(this.channel).toString();
doReturn(this.pipeline).when(this.channel).pipeline();
doReturn(this.address).when(this.channel).localAddress();
doReturn(this.address).when(this.channel).remoteAddress();
doReturn(this.eventLoop).when(this.channel).eventLoop();
doReturn(true).when(this.future).cancel(false);
doReturn(this.future).when(this.eventLoop).schedule(any(Runnable.class), any(long.class), any(TimeUnit.class));
doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class), any(ChannelHandler.class));
doReturn(this.pipeline).when(this.pipeline).addFirst(any(ChannelHandler.class));
doReturn(true).when(this.channel).isActive();
doReturn(mock(ChannelFuture.class)).when(this.channel).close();
doReturn(new InetSocketAddress(this.ipAddress, this.port)).when(this.channel).remoteAddress();
doReturn(new InetSocketAddress(this.ipAddress, this.port)).when(this.channel).localAddress();
this.openMsg = new OpenBuilder().setOpenMessage(new OpenMessageBuilder().setOpen(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder().setDeadTimer(DEADTIMER).setKeepalive(KEEP_ALIVE).setSessionId((short) 0).build()).build()).build();
this.kaMsg = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build();
this.startTlsMsg = new StarttlsBuilder().setStartTlsMessage(new StartTlsMessageBuilder().build()).build();
this.closeMsg = new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder().setCClose(new CCloseBuilder().setReason((short) 6).build()).build()).build();
this.listener = new SimpleSessionListener();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.start.tls.message.StartTlsMessageBuilder in project bgpcep by opendaylight.
the class PCEPValidatorTest method testStartTLSMsg.
@Test
public void testStartTLSMsg() throws Exception {
final ByteBuf result = Unpooled.wrappedBuffer(new byte[] { 32, 20, 0, 4 });
final PCEPStartTLSMessageParser parser = new PCEPStartTLSMessageParser(this.objectRegistry);
final StarttlsBuilder builder = new StarttlsBuilder().setStartTlsMessage(new StartTlsMessageBuilder().build());
assertEquals(builder.build(), parser.parseMessage(result.slice(4, result.readableBytes() - 4), Collections.emptyList()));
final ByteBuf buf = Unpooled.buffer(result.readableBytes());
parser.serializeMessage(builder.build(), buf);
assertArrayEquals(result.array(), buf.array());
}
Aggregations