X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=pcep%2Fimpl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fprotocol%2Fpcep%2Fimpl%2FFiniteStateMachineTest.java;h=0cf55d977011d66a0b23f7ca2d3b94da82ccbc04;hb=103e9670c6ff0f3c3b500b5c2778ba915aea13d1;hp=09274f83cfc05cab8397b9d3e1d2292f6bca9fcf;hpb=7fc4b3dbc2c7abd2a71d8afc73dfc3a8de303c6a;p=bgpcep.git diff --git a/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/FiniteStateMachineTest.java b/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/FiniteStateMachineTest.java index 09274f83cf..0cf55d9770 100644 --- a/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/FiniteStateMachineTest.java +++ b/pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/FiniteStateMachineTest.java @@ -9,256 +9,248 @@ package org.opendaylight.protocol.pcep.impl; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import io.netty.channel.Channel; -import io.netty.channel.ChannelFuture; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelPipeline; -import io.netty.util.HashedWheelTimer; +import static org.opendaylight.protocol.util.CheckTestUtil.checkEquals; + +import com.google.common.base.Ticker; import io.netty.util.concurrent.DefaultPromise; import io.netty.util.concurrent.GlobalEventExecutor; - -import java.util.Arrays; -import java.util.List; - -import org.junit.After; +import java.util.Queue; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; -import org.opendaylight.protocol.pcep.PCEPErrorMapping; -import org.opendaylight.protocol.pcep.PCEPErrors; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcerr; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenMessage; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.OpenMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.Errors; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.error.type.SessionBuilder; +import org.opendaylight.protocol.pcep.impl.spi.Util; +import org.opendaylight.protocol.pcep.spi.PCEPErrors; +import org.opendaylight.protocol.util.CheckTestUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.app.config.rev160707.pcep.dispatcher.config.TlsBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Keepalive; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Open; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Pcerr; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev181109.Starttls; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.OpenMessage; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.OpenBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcerr.message.pcerr.message.Errors; import org.opendaylight.yangtools.yang.binding.Notification; -import com.google.common.collect.Lists; - -public class FiniteStateMachineTest { - - private DefaultPCEPSessionNegotiator serverSession; - - @Mock - private Channel clientListener; +public class FiniteStateMachineTest extends AbstractPCEPSessionTest { - @Mock - private ChannelPipeline pipeline; + private DefaultPCEPSessionNegotiator serverSession; + private DefaultPCEPSessionNegotiator tlsSessionNegotiator; + private final TestTicker ticker = new TestTicker(); - private final List receivedMsgs = Lists.newArrayList(); + @Before + public void setup() { + final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.Open localPrefs = new OpenBuilder().setKeepalive( + (short) 1).build(); + this.serverSession = new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE), + this.channel, this.listener, (short) 1, 20, localPrefs); + this.tlsSessionNegotiator = new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE), + this.channel, this.listener, (short) 1, 20, localPrefs, new TlsBuilder().build()); + } - private Open openmsg; + /** + * Both PCEs accept session characteristics. Also tests KeepAliveTimer and error message and when pce attempts to + * establish pce session for the 2nd time. + */ + @Test + public void testSessionCharsAccBoth() { + this.serverSession.channelActive(null); + assertEquals(1, this.msgsSend.size()); + assertTrue(this.msgsSend.get(0) instanceof Open); + this.serverSession.handleMessage(this.openMsg); + assertEquals(2, this.msgsSend.size()); + assertTrue(this.msgsSend.get(1) instanceof Keepalive); + this.serverSession.handleMessage(this.kaMsg); + assertEquals(this.serverSession.getState(), DefaultPCEPSessionNegotiator.State.FINISHED); + } - private Keepalive kamsg; + /** + * Establish PCEPS TLS connection with peer + */ + @Test + public void testEstablishTLS() { + final DefaultPCEPSessionNegotiator negotiator = new DefaultPCEPSessionNegotiator(new DefaultPromise<>(GlobalEventExecutor.INSTANCE), + this.channel, this.listener, (short) 1, 20, new OpenBuilder().setKeepalive((short) 1).build(), + SslContextFactoryTest.createTlsConfig()); + negotiator.channelActive(null); + assertEquals(1, this.msgsSend.size()); + assertTrue(this.msgsSend.get(0) instanceof Starttls); + assertEquals(DefaultPCEPSessionNegotiator.State.START_TLS_WAIT, negotiator.getState()); + negotiator.handleMessage(this.startTlsMsg); + assertEquals(DefaultPCEPSessionNegotiator.State.OPEN_WAIT, negotiator.getState()); + assertEquals(2, this.msgsSend.size()); + assertTrue(this.msgsSend.get(1) instanceof Open); + negotiator.handleMessage(this.openMsg); + assertEquals(DefaultPCEPSessionNegotiator.State.KEEP_WAIT, negotiator.getState()); + } - @Before - public void setUp() { - MockitoAnnotations.initMocks(this); - final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open localPrefs = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder().setKeepalive( - (short) 1).build(); - this.serverSession = new DefaultPCEPSessionNegotiator(new HashedWheelTimer(), new DefaultPromise(GlobalEventExecutor.INSTANCE), this.clientListener, new SimpleSessionListener(), (short) 1, 20, localPrefs); - doAnswer(new Answer() { - @Override - public Object answer(final InvocationOnMock invocation) { - final Object[] args = invocation.getArguments(); - FiniteStateMachineTest.this.receivedMsgs.add((Notification) args[0]); - return null; - } - }).when(this.clientListener).writeAndFlush(any(Notification.class)); - doReturn("TestingChannel").when(this.clientListener).toString(); - doReturn(this.pipeline).when(this.clientListener).pipeline(); - doReturn(this.pipeline).when(this.pipeline).replace(any(ChannelHandler.class), any(String.class), any(ChannelHandler.class)); - doReturn(mock(ChannelFuture.class)).when(this.clientListener).close(); - 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( - (short) 3).build()).build()).build(); - this.kamsg = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build(); - } + /** + * As Tls is not configured properly, PCE will send error PCEPErrors.NOT_POSSIBLE_WITHOUT_TLS + */ + @Test + public void testFailedToEstablishTLS() { + this.tlsSessionNegotiator.channelActive(null); + assertEquals(1, this.msgsSend.size()); + assertTrue(this.msgsSend.get(0) instanceof Starttls); + assertEquals(DefaultPCEPSessionNegotiator.State.START_TLS_WAIT, this.tlsSessionNegotiator.getState()); + this.tlsSessionNegotiator.handleMessage(this.startTlsMsg); + assertEquals(2, this.msgsSend.size()); + assertTrue(this.msgsSend.get(1) instanceof Pcerr); + final Errors obj = ((Pcerr) this.msgsSend.get(1)).getPcerrMessage().getErrors().get(0); + assertEquals(PCEPErrors.NOT_POSSIBLE_WITHOUT_TLS.getErrorType(), obj.getErrorObject().getType().shortValue()); + assertEquals(PCEPErrors.NOT_POSSIBLE_WITHOUT_TLS.getErrorValue(), obj.getErrorObject().getValue().shortValue()); + assertEquals(DefaultPCEPSessionNegotiator.State.FINISHED, this.tlsSessionNegotiator.getState()); + } - /** - * Both PCEs accept session characteristics. Also tests KeepAliveTimer and error message and when pce attempts to - * establish pce session for the 2nd time. - * - * @throws Exception - */ - @Test - public void testSessionCharsAccBoth() throws Exception { - this.serverSession.channelActive(null); - assertEquals(1, this.receivedMsgs.size()); - assertTrue(this.receivedMsgs.get(0) instanceof Open); - this.serverSession.handleMessage(this.openmsg); - assertEquals(2, this.receivedMsgs.size()); - assertTrue(this.receivedMsgs.get(1) instanceof Keepalive); - this.serverSession.handleMessage(this.kamsg); - assertEquals(this.serverSession.getState(), DefaultPCEPSessionNegotiator.State.Finished); - // Thread.sleep(PCEPSessionImpl.KEEP_ALIVE_TIMER_VALUE * 1000); - // assertEquals(3, this.client.getListMsg().size()); - // assertTrue(this.client.getListMsg().get(2) instanceof PCEPKeepAliveMessage); // test of keepalive timer - // this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(1, 1, 1))); - // assertEquals(3, this.client.getListMsg().size()); - // assertTrue(this.client.getListMsg().get(2) instanceof PCEPErrorMessage); - // for (final Message m : this.client.getListMsg()) { - // if (m instanceof PCEPErrorMessage) { - // final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0); - // assertEquals(PCEPErrors.ATTEMPT_2ND_SESSION, obj.getError()); // test of error type 9 - // } - // } - } + /** + * As PCE does not receive expected message (StartTLS), error PCEPErrors.NON_STARTTLS_MSG_RCVD is send + */ + @Test + public void testTLSUnexpectedMessage() { + this.tlsSessionNegotiator.channelActive(null); + assertEquals(1, this.msgsSend.size()); + assertTrue(this.msgsSend.get(0) instanceof Starttls); + assertEquals(DefaultPCEPSessionNegotiator.State.START_TLS_WAIT, this.tlsSessionNegotiator.getState()); + this.tlsSessionNegotiator.handleMessage(this.openMsg); + assertEquals(2, this.msgsSend.size()); + assertTrue(this.msgsSend.get(1) instanceof Pcerr); + final Errors obj = ((Pcerr) this.msgsSend.get(1)).getPcerrMessage().getErrors().get(0); + assertEquals(PCEPErrors.NON_STARTTLS_MSG_RCVD.getErrorType(), obj.getErrorObject().getType().shortValue()); + assertEquals(PCEPErrors.NON_STARTTLS_MSG_RCVD.getErrorValue(), obj.getErrorObject().getValue().shortValue()); + assertEquals(this.tlsSessionNegotiator.getState(), DefaultPCEPSessionNegotiator.State.FINISHED); + } - /** - * Mock PCE does not accept session characteristics the first time. - * - * @throws Exception - */ - @Test - public void testSessionCharsAccMe() throws Exception { - this.serverSession.channelActive(null); - assertEquals(1, this.receivedMsgs.size()); - assertTrue(this.receivedMsgs.get(0) instanceof Open); - this.serverSession.handleMessage(this.openmsg); - assertEquals(2, this.receivedMsgs.size()); - assertTrue(this.receivedMsgs.get(1) instanceof Keepalive); - this.serverSession.handleMessage(createErrorMessageWOpen(PCEPErrors.NON_ACC_NEG_SESSION_CHAR)); - assertEquals(3, this.receivedMsgs.size()); - assertTrue(this.receivedMsgs.get(2) instanceof Open); - this.serverSession.handleMessage(this.kamsg); - assertEquals(this.serverSession.getState(), DefaultPCEPSessionNegotiator.State.Finished); - } + /** + * Mock PCE does not accept session characteristics the first time. + */ + @Test + public void testSessionCharsAccMe() { + this.serverSession.channelActive(null); + assertEquals(1, this.msgsSend.size()); + assertTrue(this.msgsSend.get(0) instanceof Open); + final Open remote = (Open) this.msgsSend.get(0); + this.serverSession.handleMessage(this.openMsg); + assertEquals(2, this.msgsSend.size()); + assertTrue(this.msgsSend.get(1) instanceof Keepalive); + this.serverSession.handleMessage(Util.createErrorMessage(PCEPErrors.NON_ACC_NEG_SESSION_CHAR, + remote.getOpenMessage().getOpen())); + assertEquals(3, this.msgsSend.size()); + assertTrue(this.msgsSend.get(2) instanceof Open); + this.serverSession.handleMessage(this.kaMsg); + assertEquals(this.serverSession.getState(), DefaultPCEPSessionNegotiator.State.FINISHED); + } - private Pcerr createErrorMessageWOpen(PCEPErrors e) { - final PCEPErrorMapping maping = PCEPErrorMapping.getInstance(); - return new PcerrBuilder().setPcerrMessage( - new PcerrMessageBuilder().setErrorType( - new SessionBuilder().setOpen( - new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.OpenBuilder().setKeepalive( - (short) 1).build()).build()).setErrors( - Arrays.asList(new ErrorsBuilder().setErrorObject( - new ErrorObjectBuilder().setType(maping.getFromErrorsEnum(e).type).setValue( - maping.getFromErrorsEnum(e).value).build()).build())).build()).build(); - } + /** + * Sending different PCEP Message than Open in session establishment phase. + * + * @throws Exception exception + */ + @Test + public void testErrorOneOne() throws Exception { + this.serverSession.channelActive(null); + assertEquals(1, this.msgsSend.size()); + assertTrue(this.msgsSend.get(0) instanceof Open); + this.serverSession.handleMessage(this.kaMsg); + checkEquals(() -> { + for (final Notification m : this.msgsSend) { + if (m instanceof Pcerr) { + final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0); + assertEquals(new Short((short) 1), obj.getErrorObject().getType()); + assertEquals(new Short((short) 1), obj.getErrorObject().getValue()); + } + } + }); + } - /** - * Sending different PCEP Message than Open in session establishment phase. - * - * @throws Exception - */ - @Test - public void testErrorOneOne() throws Exception { - this.serverSession.channelActive(null); - assertEquals(1, this.receivedMsgs.size()); - assertTrue(this.receivedMsgs.get(0) instanceof Open); - this.serverSession.handleMessage(this.kamsg); - for (final Notification m : this.receivedMsgs) { - if (m instanceof Pcerr) { - final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0); - assertEquals(new Short((short) 1), obj.getErrorObject().getType()); - assertEquals(new Short((short) 1), obj.getErrorObject().getValue()); - } - } - } + /** + * KeepWaitTimer expired. + * + * @throws Exception exception + */ + @Test + public void testErrorOneSeven() throws Exception { + this.serverSession.channelActive(null); + assertEquals(1, this.msgsSend.size()); + assertTrue(this.msgsSend.get(0) instanceof Open); + this.serverSession.handleMessage(this.openMsg); + checkEquals(() -> { + for (final Notification m : this.msgsSend) { + if (m instanceof Pcerr) { + final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0); + assertEquals(new Short((short) 1), obj.getErrorObject().getType()); + assertEquals(new Short((short) 7), obj.getErrorObject().getValue()); + } + } + }); + } - /************* Tests commented because of their long duration (tested timers) **************/ + /** + * OpenWait timer expired. + * + * @throws InterruptedException exception + */ + @Test + public void testErrorOneTwo() throws Exception { + this.serverSession.channelActive(null); + assertEquals(1, this.msgsSend.size()); + assertTrue(this.msgsSend.get(0) instanceof OpenMessage); + checkEquals(() -> { + for (final Notification m : this.msgsSend) { + if (m instanceof Pcerr) { + final Errors obj = ((Pcerr) m).getPcerrMessage().getErrors().get(0); + assertEquals(new Short((short) 1), obj.getErrorObject().getType()); + assertEquals(new Short((short) 2), obj.getErrorObject().getValue()); + } + } + }); + } - /** - * OpenWait timer expired. - * - * @throws InterruptedException - */ - @Test - @Ignore - public void testErrorOneTwo() throws InterruptedException { - // this.serverSession.startSession(); - assertEquals(1, this.receivedMsgs.size()); - assertTrue(this.receivedMsgs.get(0) instanceof OpenMessage); - // Thread.sleep(60 * 1000); - // for (final Message m : this.client.getListMsg()) { - // if (m instanceof PcerrMessage) { - // final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0); - // assertEquals(PCEPErrors.NO_OPEN_BEFORE_EXP_OPENWAIT, obj.getError()); - // } - // } - } + @Test + public void testUnknownMessage() throws Exception { + final SimpleSessionListener client = new SimpleSessionListener(); + final PCEPSessionImpl session = new PCEPSessionImpl(client, 5, this.channel, + this.openMsg.getOpenMessage().getOpen(), this.openMsg.getOpenMessage().getOpen()); + PCEPSessionImpl.setTicker(this.ticker); + session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + final Queue qeue = session.getUnknownMessagesTimes(); + CheckTestUtil.checkEquals(() -> assertEquals(1, qeue.size())); + session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + CheckTestUtil.checkEquals(() -> assertEquals(2, qeue.size())); + session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + CheckTestUtil.checkEquals(() -> assertEquals(3, qeue.size())); + session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + CheckTestUtil.checkEquals(() -> assertEquals(4, qeue.size())); + session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + CheckTestUtil.checkEquals(() -> assertEquals(3, qeue.size())); + session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + CheckTestUtil.checkEquals(() -> assertEquals(3, qeue.size())); + session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + CheckTestUtil.checkEquals(() -> assertEquals(4, qeue.size())); + session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + CheckTestUtil.checkEquals(() -> assertEquals(5, qeue.size())); + session.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); + synchronized (client) { + while (client.up) { + client.wait(); + } + } + CheckTestUtil.checkEquals(() -> assertTrue(!client.up)); + } - /** - * KeepWaitTimer expired. - * - * @throws InterruptedException - */ - @Test - @Ignore - public void testErrorOneSeven() throws InterruptedException { - // // this.serverSession.startSession(); - // assertEquals(1, this.client.getListMsg().size()); - // assertTrue(this.client.getListMsg().get(0) instanceof OpenMessage); - // this.client.sendMessage(new PCEPOpenMessage(new OpenObject(3, 9, 2))); - // Thread.sleep(this.serverSession.getKeepAliveTimerValue() * 1000); - // for (final Message m : this.client.getListMsg()) { - // if (m instanceof PcerrMessage) { - // final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0); - // assertEquals(PCEPErrors.NO_MSG_BEFORE_EXP_KEEPWAIT, obj.getError()); - // } - // } - } + private final class TestTicker extends Ticker { + private long counter = 0L; - @Test - @Ignore - public void testUnknownMessage() throws InterruptedException { - // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - // assertEquals(1, this.serverSession.unknownMessagesTimes.size()); - // Thread.sleep(10000); - // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - // assertEquals(2, this.serverSession.unknownMessagesTimes.size()); - // Thread.sleep(10000); - // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - // assertEquals(3, this.serverSession.unknownMessagesTimes.size()); - // Thread.sleep(20000); - // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - // assertEquals(4, this.serverSession.unknownMessagesTimes.size()); - // Thread.sleep(30000); - // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - // assertEquals(3, this.serverSession.unknownMessagesTimes.size()); - // Thread.sleep(10000); - // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - // assertEquals(3, this.serverSession.unknownMessagesTimes.size()); - // Thread.sleep(5000); - // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - // assertEquals(4, this.serverSession.unknownMessagesTimes.size()); - // Thread.sleep(1000); - // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - // assertEquals(5, this.serverSession.unknownMessagesTimes.size()); - // Thread.sleep(1000); - // this.serverSession.handleMalformedMessage(PCEPErrors.CAPABILITY_NOT_SUPPORTED); - // synchronized (this.client) { - // while (!this.client.down) { - // try { - // this.client.wait(); - // } catch (final InterruptedException e) { - // e.printStackTrace(); - // } - // } - // } - // assertTrue(this.client.down); - } + TestTicker() { + } - @After - public void tearDown() { - } + @Override + public long read() { + if (this.counter == 8) { + this.counter++; + return 60000000003L; + } else if (this.counter == 10) { + this.counter++; + return 60000000006L; + } + return this.counter++; + } + } }