Replaced reference from deprecated junit.framework.Assert to org.junit.Assert
[bgpcep.git] / pcep / testtool / src / test / java / org / opendaylight / protocol / pcep / testtool / PCEPTestingToolTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.protocol.pcep.testtool;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
13
14 import org.junit.Assert;
15 import org.junit.Test;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.keepalive.message.KeepaliveMessageBuilder;
19
20 public class PCEPTestingToolTest {
21
22     @Test
23     public void testSessionEstablishment() {
24         try {
25             Main.main(new String[]{"-a", "127.0.0.3:12345", "-ka", "10", "-d", "0", "--stateful", "--active", "--instant"});
26             PCCMock.main(new String[0]);
27         } catch (Exception e) {
28             Assert.fail();
29         }
30     }
31
32     @Test
33     public void testSimpleSessionListener() {
34         final TestingSessionListener ssl = new TestingSessionListener();
35         assertEquals(0, ssl.messages().size());
36         ssl.onMessage(null, new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build()).build());
37         assertEquals(1, ssl.messages().size());
38         assertTrue(ssl.messages().get(0) instanceof KeepaliveMessage);
39         assertFalse(ssl.isUp());
40         ssl.onSessionUp(null);
41         assertTrue(ssl.isUp());
42         ssl.onSessionDown(null, null);
43         assertFalse(ssl.isUp());
44     }
45 }