Search in sources :

Example 1 with LookupRegistry

use of org.opendaylight.controller.config.api.LookupRegistry in project controller by opendaylight.

the class LookupTest method setUp.

@Before
public void setUp() throws Exception {
    testingRegistry = new TestingConfigRegistry();
    testingRegistryON = ConfigRegistry.OBJECT_NAME;
    mbs.registerMBean(testingRegistry, testingRegistryON);
    jmxRegistryClient = new ConfigRegistryJMXClient(ManagementFactory.getPlatformMBeanServer());
    testingTransactionController = new TestingConfigTransactionController();
    testingTransactionControllerON = new ObjectName(ObjectNameUtil.ON_DOMAIN + ":" + ObjectNameUtil.TYPE_KEY + "=TransactionController");
    mbs.registerMBean(testingTransactionController, testingTransactionControllerON);
    jmxTransactionClient = new ConfigTransactionJMXClient(null, testingTransactionControllerON, ManagementFactory.getPlatformMBeanServer());
    HashSet<ConfigRegistryClient> registryClients = Sets.newHashSet(jmxRegistryClient);
    HashSet<ConfigTransactionClient> configTransactionClients = Sets.newHashSet(jmxTransactionClient);
    lookupProvidersToClients = ImmutableMap.of((LookupRegistry) testingRegistry, registryClients, testingTransactionController, configTransactionClients);
}
Also used : LookupRegistry(org.opendaylight.controller.config.api.LookupRegistry) ObjectName(javax.management.ObjectName) Before(org.junit.Before)

Example 2 with LookupRegistry

use of org.opendaylight.controller.config.api.LookupRegistry in project controller by opendaylight.

the class LookupTest method test.

private void test(final Method method, final Object[] args) throws Exception {
    for (Entry<LookupRegistry, ? extends Set<? extends LookupRegistry>> entry : lookupProvidersToClients.entrySet()) {
        Object expected = method.invoke(entry.getKey(), args);
        for (LookupRegistry client : entry.getValue()) {
            Object actual = method.invoke(client, args);
            assertEquals("Error while comparing " + entry.getKey() + " with client " + client, expected, actual);
        }
    }
}
Also used : LookupRegistry(org.opendaylight.controller.config.api.LookupRegistry)

Example 3 with LookupRegistry

use of org.opendaylight.controller.config.api.LookupRegistry in project controller by opendaylight.

the class ServiceReferenceRegistryImpl method createInitialSRLookupRegistry.

/**
 * Static constructor for config registry. Since only transaction can write to
 * this registry, it will return blank state.
 *
 * @return service reference registry
 */
public static CloseableServiceReferenceReadableRegistry createInitialSRLookupRegistry() {
    // since this is initial state, just throw exception:
    LookupRegistry lookupRegistry = new LookupRegistry() {

        @Override
        public Set<ObjectName> lookupConfigBeans() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<ObjectName> lookupConfigBeans(final String moduleName) {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<ObjectName> lookupConfigBeans(final String moduleName, final String instanceName) {
            throw new UnsupportedOperationException();
        }

        @Override
        public ObjectName lookupConfigBean(final String moduleName, final String instanceName) throws InstanceNotFoundException {
            throw new UnsupportedOperationException();
        }

        @Override
        public void checkConfigBeanExists(final ObjectName objectName) throws InstanceNotFoundException {
            throw new InstanceNotFoundException("Cannot find " + objectName + " - Tried to use mocking registry");
        }

        @Override
        public Set<String> getAvailableModuleFactoryQNames() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<ObjectName> lookupRuntimeBeans() {
            throw new UnsupportedOperationException();
        }

        @Override
        public Set<ObjectName> lookupRuntimeBeans(final String moduleName, final String instanceName) {
            throw new UnsupportedOperationException();
        }

        @Override
        public String toString() {
            return "initial";
        }
    };
    ServiceReferenceTransactionRegistratorFactory serviceReferenceRegistratorFactory = () -> new ServiceReferenceRegistrator() {

        @Override
        public String getNullableTransactionName() {
            throw new UnsupportedOperationException();
        }

        @Override
        public ServiceReferenceJMXRegistration registerMBean(final ServiceReferenceMXBeanImpl object, final ObjectName on) throws InstanceAlreadyExistsException {
            throw new UnsupportedOperationException();
        }

        @Override
        public void close() {
        }
    };
    return new ServiceReferenceRegistryImpl(Collections.<String, ModuleFactory>emptyMap(), lookupRegistry, serviceReferenceRegistratorFactory, false);
}
Also used : ServiceReferenceMXBeanImpl(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBeanImpl) InstanceNotFoundException(javax.management.InstanceNotFoundException) LookupRegistry(org.opendaylight.controller.config.api.LookupRegistry) ServiceReferenceTransactionRegistratorFactory(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactory) ServiceReferenceRegistrator(org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator) ObjectName(javax.management.ObjectName)

Example 4 with LookupRegistry

use of org.opendaylight.controller.config.api.LookupRegistry in project controller by opendaylight.

the class LookupTest method testException.

@Test
public void testException() {
    for (Entry<LookupRegistry, ? extends Set<? extends LookupRegistry>> entry : lookupProvidersToClients.entrySet()) {
        for (LookupRegistry client : entry.getValue()) {
            try {
                client.lookupConfigBean(InstanceNotFoundException.class.getSimpleName(), "");
                fail(client.toString());
            } catch (final InstanceNotFoundException e) {
            }
        }
    }
}
Also used : InstanceNotFoundException(javax.management.InstanceNotFoundException) LookupRegistry(org.opendaylight.controller.config.api.LookupRegistry) Test(org.junit.Test)

Aggregations

LookupRegistry (org.opendaylight.controller.config.api.LookupRegistry)4 InstanceNotFoundException (javax.management.InstanceNotFoundException)2 ObjectName (javax.management.ObjectName)2 Before (org.junit.Before)1 Test (org.junit.Test)1 ServiceReferenceMXBeanImpl (org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceMXBeanImpl)1 ServiceReferenceRegistrator (org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator)1 ServiceReferenceTransactionRegistratorFactory (org.opendaylight.controller.config.manager.impl.jmx.ServiceReferenceRegistrator.ServiceReferenceTransactionRegistratorFactory)1