Merge "Fixed lookup of created routes in BGP Topology Exporter."
[bgpcep.git] / pcep / spi / src / test / java / org / opendaylight / protocol / pcep / spi / APITest.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.spi;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertNull;
13 import static org.junit.Assert.assertTrue;
14
15 import org.junit.Test;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.close.object.CCloseBuilder;
18
19 public class APITest {
20
21     @Test
22     public void testDeserializerException() {
23         final PCEPDeserializerException e = new PCEPDeserializerException("Some error message.");
24         assertEquals("Some error message.", e.getMessage());
25
26         final PCEPDeserializerException e1 = new PCEPDeserializerException("Some error message.", new IllegalArgumentException());
27         assertEquals("Some error message.", e1.getMessage());
28         assertTrue(e1.getCause() instanceof IllegalArgumentException);
29     }
30
31     @Test
32     public void testObjectHeader() {
33         ObjectHeaderImpl header = new ObjectHeaderImpl(null, true);
34         assertEquals("ObjectHeader [objClass=, processed=null, ignored=true]", header.toString());
35         assertTrue(header.isIgnore());
36         assertNull(header.isProcessingRule());
37
38         assertEquals(new ObjectHeaderImpl(null, true).hashCode(),  header.hashCode());
39         assertTrue(new ObjectHeaderImpl(null, true).equals(header));
40     }
41
42     @Test
43     public void testUnknownObject() {
44         UnknownObject un = new UnknownObject(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS);
45         assertFalse(un.isIgnore());
46         assertFalse(un.isProcessingRule());
47         assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS, un.getError());
48         assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS.getErrorType(), un.getErrors().get(0).getErrorObject().getType().shortValue());
49
50         final Object o = new CCloseBuilder().build();
51         UnknownObject unknown = new UnknownObject(PCEPErrors.LSP_RSVP_ERROR, o);
52         assertEquals(Object.class, unknown.getImplementedInterface());
53         assertEquals(o, unknown.getInvalidObject());
54     }
55 }