Bump versions to 0.21.7-SNAPSHOT
[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.protocol.pcep.PCEPDeserializerException;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.close.object.CCloseBuilder;
19
20 public class APITest {
21
22     @Test
23     public void testDeserializerException() {
24         final PCEPDeserializerException e = new PCEPDeserializerException("Some error message.");
25         assertEquals("Some error message.", e.getMessage());
26
27         final PCEPDeserializerException e1 = new PCEPDeserializerException("Some error message.",
28             new IllegalArgumentException());
29         assertEquals("Some error message.", e1.getMessage());
30         assertTrue(e1.getCause() instanceof IllegalArgumentException);
31     }
32
33     @Test
34     public void testObjectHeader() {
35         ObjectHeaderImpl header = new ObjectHeaderImpl(null, true);
36         assertEquals("ObjectHeader [objClass=, processed=null, ignored=true]", header.toString());
37         assertTrue(header.getIgnore());
38         assertNull(header.getProcessingRule());
39
40         assertEquals(new ObjectHeaderImpl(null, true).hashCode(),  header.hashCode());
41         assertEquals(new ObjectHeaderImpl(null, true), header);
42     }
43
44     @Test
45     public void testUnknownObject() {
46         UnknownObject un = new UnknownObject(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS);
47         assertFalse(un.getIgnore());
48         assertFalse(un.getProcessingRule());
49         assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS, un.getError());
50         assertEquals(PCEPErrors.CT_AND_SETUP_PRIORITY_DO_NOT_FORM_TE_CLASS.getErrorType(),
51             un.getErrors().get(0).getErrorObject().getType());
52
53         final Object o = new CCloseBuilder().build();
54         UnknownObject unknown = new UnknownObject(PCEPErrors.LSP_RSVP_ERROR, o);
55         assertEquals(Object.class, unknown.implementedInterface());
56         assertEquals(o, unknown.getInvalidObject());
57     }
58 }