diff options
author | Jan Srnicek <jsrnicek@cisco.com> | 2016-12-02 09:37:22 +0100 |
---|---|---|
committer | Marek Gradzki <mgradzki@cisco.com> | 2016-12-02 13:47:21 +0000 |
commit | 7088e80deb3384c84cefca8f92e92722b1f19fe9 (patch) | |
tree | e64f8ca4c0213d642b0a2f41532b25cf45a9be92 /routing/routing-impl/src/test | |
parent | 14542744e674673847e6f671ee179eeee30b2d5a (diff) |
HONEYCOMB-307 - Prevent re-mapping of already mapped names
Prevent invoking addName while initializing data for names
that are already in mappings
Change-Id: I56063fb28cfb215bbdb1ed745aaa44544ffa77a0
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'routing/routing-impl/src/test')
2 files changed, 30 insertions, 1 deletions
diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java index bcb8e6800..a13364db8 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/helpers/RoutingRequestTestHelper.java @@ -39,6 +39,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.routing.rev public interface RoutingRequestTestHelper extends ByteDataTranslator, FutureProducer, RouteMapper { String ROUTE_PROTOCOL_NAME = "tst-protocol"; + String ROUTE_PROTOCOL_NAME_2 = "tst-protocol-2"; String ROUTE_NAME = "tst-route"; String STATIC_ROUTE_PATH = "/ietf-routing:routing" + "/ietf-routing:routing-instance[ietf-routing:name='" + ROUTE_PROTOCOL_NAME + "']" + diff --git a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java index d734aab66..21a2bdc14 100644 --- a/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java +++ b/routing/routing-impl/src/test/java/io/fd/hc2vpp/routing/write/RoutingProtocolCustomizerTest.java @@ -17,6 +17,7 @@ package io.fd.hc2vpp.routing.write; import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME; +import static io.fd.hc2vpp.routing.helpers.RoutingRequestTestHelper.ROUTE_PROTOCOL_NAME_2; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -39,6 +40,7 @@ public class RoutingProtocolCustomizerTest extends WriterCustomizerTest { private InstanceIdentifier<RoutingProtocol> validId; private RoutingProtocol validData; + private RoutingProtocol validData2; private RoutingProtocol invalidData; private RoutingProtocolCustomizer customizer; private NamingContext routingProtocolContext; @@ -56,6 +58,16 @@ public class RoutingProtocolCustomizerTest extends WriterCustomizerTest { .build()) .build(); + validData2= new RoutingProtocolBuilder() + .setName(ROUTE_PROTOCOL_NAME_2) + .setType(Static.class) + .addAugmentation(RoutingProtocolVppAttr.class, new RoutingProtocolVppAttrBuilder() + .setVppProtocolAttributes(new VppProtocolAttributesBuilder() + .setPrimaryVrf(new VniReference(1L)) + .build()) + .build()) + .build(); + invalidData = new RoutingProtocolBuilder() .setType(Direct.class) .build(); @@ -74,12 +86,28 @@ public class RoutingProtocolCustomizerTest extends WriterCustomizerTest { } } + /** + * Should not fail, just ignore re-mapping same name + * */ @Test - public void testWriteIsStaticAllreadyExist() throws WriteFailedException { + public void testWriteIsStaticSameAllreadyExist() throws WriteFailedException { defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); try { customizer.writeCurrentAttributes(validId, validData, writeContext); } catch (Exception e) { + fail("Test should have passed without throwing exception"); + } + } + + /** + * Should fail, because of attempt to map different name to same index + * */ + @Test + public void testWriteIsStaticOtherAllreadyExist() throws WriteFailedException { + defineMapping(mappingContext, ROUTE_PROTOCOL_NAME, 1, "routing-protocol-context"); + try { + customizer.writeCurrentAttributes(validId, validData2, writeContext); + } catch (Exception e) { assertTrue(e instanceof IllegalStateException); return; } |