Exception for URI /restconf/operations/module_name:rpc ended with slash
[controller.git] / opendaylight / md-sal / sal-remoterpc-connector / implementation / src / test / java / org / opendaylight / controller / sal / connector / remoterpc / RouteIdentifierImplTest.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  * This program and the accompanying materials are made available under the
4  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
5  * and is available at http://www.eclipse.org/legal/epl-v10.html
6  */
7
8 package org.opendaylight.controller.sal.connector.remoterpc;
9
10 import java.net.URI;
11
12 import com.fasterxml.jackson.core.JsonParseException;
13 import org.junit.Assert;
14 import org.junit.Test;
15 import org.opendaylight.controller.sal.connector.api.RpcRouter;
16 import org.opendaylight.controller.sal.connector.remoterpc.dto.RouteIdentifierImpl;
17 import org.opendaylight.yangtools.yang.common.QName;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 public class RouteIdentifierImplTest {
22
23   Logger _logger = LoggerFactory.getLogger(RouteIdentifierImplTest.class);
24
25   private final URI namespace = URI.create("http://cisco.com/example");
26   private final QName QNAME = new QName(namespace, "heartbeat");
27
28   @Test
29   public void testToString() throws Exception {
30     RouteIdentifierImpl rId = new RouteIdentifierImpl();
31     rId.setType(QNAME);
32
33     _logger.debug(rId.toString());
34
35     Assert.assertTrue(true);
36
37   }
38
39   @Test
40   public void testFromString() throws Exception {
41     RouteIdentifierImpl rId = new RouteIdentifierImpl();
42     rId.setType(QNAME);
43
44     String s = rId.toString();
45     _logger.debug("serialized route: {}", s);
46
47     RpcRouter.RouteIdentifier ref = new RouteIdentifierImpl().fromString(s);
48     _logger.debug("deserialized route: {}", ref);
49
50     Assert.assertTrue(true);
51   }
52
53   @Test(expected = JsonParseException.class)
54   public void testFromInvalidString() throws Exception {
55     String invalidInput = "aklhdgadfa;;;;;;;]]]]=]ag" ;
56     RouteIdentifierImpl rId = new RouteIdentifierImpl();
57     rId.fromString(invalidInput);
58
59     _logger.debug("" + rId);
60     Assert.assertTrue(true);
61   }
62 }