X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fsal%2Fsal-binding-broker-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2FRuntimeCodeGeneratorTest.java;fp=opendaylight%2Fsal%2Fyang-prototype%2Fsal%2Fsal-binding-broker-impl%2Fsrc%2Ftest%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fsal%2Fbinding%2Ftest%2FRuntimeCodeGeneratorTest.java;h=0000000000000000000000000000000000000000;hb=fe024ad74b8656c3ee61b9ddff6009a779aa2189;hp=5dddd1ab9d6965a8935b557d70ec28ce635f8399;hpb=437c1bdb967072319e81774bdcf570b2fb0f7b89;p=controller.git diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java deleted file mode 100644 index 5dddd1ab9d..0000000000 --- a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/test/java/org/opendaylight/controller/sal/binding/test/RuntimeCodeGeneratorTest.java +++ /dev/null @@ -1,142 +0,0 @@ -package org.opendaylight.controller.sal.binding.test; -import static org.junit.Assert.*; - -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; - -import javassist.ClassPool; - -import org.junit.Before; -import org.junit.Test; -import static org.opendaylight.controller.sal.binding.codegen.RuntimeCodeHelper.*; -import org.opendaylight.controller.sal.binding.codegen.impl.RuntimeCodeGenerator; -import org.opendaylight.controller.sal.binding.test.mock.FooService; -import org.opendaylight.controller.sal.binding.test.mock.ReferencableObject; -import org.opendaylight.controller.sal.binding.test.mock.ReferencableObjectKey; -import org.opendaylight.controller.sal.binding.test.mock.SimpleInput; -import org.opendaylight.yangtools.yang.binding.Augmentation; -import org.opendaylight.yangtools.yang.binding.BaseIdentity; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableItem; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; - -import static org.mockito.Mockito.*; - - -public class RuntimeCodeGeneratorTest { - - private RuntimeCodeGenerator codeGenerator; - - - @Before - public void initialize() { - this.codeGenerator = new RuntimeCodeGenerator(ClassPool.getDefault()); - } - - @Test - public void testGenerateDirectProxy() { - Class product = codeGenerator.generateDirectProxy(FooService.class); - assertNotNull(product); - } - - @Test - public void testGenerateRouter() throws Exception { - Class product = codeGenerator.generateRouter(FooService.class); - assertNotNull(product); - assertNotNull(product.getSimpleName()); - assertEquals("2 fields should be generated.",2,product.getFields().length); - - verifyRouting(product.newInstance()); - } - - private void verifyRouting(FooService product) { - Map routingTable = new HashMap<>(); - setRoutingTable(product, BaseIdentity.class, routingTable); - - assertSame("Returned routing table should be same instance",routingTable,getRoutingTable(product, BaseIdentity.class)); - - int servicesCount = 2; - int instancesPerService = 3; - - InstanceIdentifier[][] identifiers = identifiers(servicesCount,instancesPerService); - FooService service[] = new FooService[] { - mock(FooService.class, "Instance 0"), - mock(FooService.class,"Instance 1") - }; - - for(int i = 0;i pathArg = new IdentifiableItem<>(ReferencableObject.class,key); - return new InstanceIdentifier(Arrays.asList(pathArg), ReferencableObject.class); - } - - private static class SimpleInputImpl implements SimpleInput { - private final InstanceIdentifier identifier; - - public SimpleInputImpl(InstanceIdentifier _identifier) { - this.identifier = _identifier; - } - - @Override - public > E getAugmentation(Class augmentationType) { - return null; - } - - @Override - public InstanceIdentifier getIdentifier() { - return this.identifier; - } - } -}