Package org.openengsb.core.api

Examples of org.openengsb.core.api.DomainProvider


        AdminAccessConnector adminAccessConnector = new AdminAccessConnector();
        adminAccessConnector.setUserManager(userManager);
        registerServiceAtLocation(adminAccessConnector, "authorization/admin", "root", AuthorizationDomain.class,
            Domain.class);

        DomainProvider authDomainProvider = createDomainProviderMock(AuthorizationDomain.class, "authorization");
        CompositeConnectorProvider compositeConnectorProvider = new CompositeConnectorProvider();
        compositeConnectorProvider.setBundleContext(bundleContext);
        ConnectorInstanceFactory cFactory = compositeConnectorProvider.createFactory(authDomainProvider);
        Connector instance = cFactory.createNewInstance("auth-admin");
        Dictionary<String, Object> props = new Hashtable<String, Object>();
View Full Code Here


    }

    private String getDomainTypeOfServiceName(String domainName) {
        Filter filter =
            FilterUtils.makeFilter(DomainProvider.class, String.format("(%s=%s)", Constants.DOMAIN_KEY, domainName));
        DomainProvider dp = (DomainProvider) serviceUtils.getService(filter);
        if (dp == null || dp.getDomainInterface() == null) {
            return null;
        }
        return dp.getDomainInterface().getCanonicalName();
    }
View Full Code Here

     * where all String-methods return the name again.
     *
     * Also the service is registered with the mocked service-registry with the given name as domain-value
     */
    protected DomainProvider createDomainProviderMock(final Class<? extends Domain> interfaze, String name) {
        DomainProvider domainProviderMock = mock(DomainProvider.class);
        LocalizableString testDomainLocalizedStringMock = mock(LocalizableString.class);
        when(testDomainLocalizedStringMock.getString(Mockito.<Locale> any())).thenReturn(name);
        when(domainProviderMock.getId()).thenReturn(name);
        when(domainProviderMock.getName()).thenReturn(testDomainLocalizedStringMock);
        when(domainProviderMock.getDescription()).thenReturn(testDomainLocalizedStringMock);
        when(domainProviderMock.getDomainInterface()).thenAnswer(new Answer<Class<? extends Domain>>() {
            @Override
            public Class<? extends Domain> answer(InvocationOnMock invocation) {
                return interfaze;
            }
        });
View Full Code Here

        factoryProps.put(Constants.DOMAIN_KEY, "test");
        registerService(factory, factoryProps, ConnectorInstanceFactory.class);
    }

    private void registerMockedDomainProvider() {
        DomainProvider domainProvider = mock(DomainProvider.class);
        when(domainProvider.getDomainInterface()).thenAnswer(new Answer<Class<? extends Domain>>() {
            @Override
            public Class<? extends Domain> answer(InvocationOnMock invocation) throws Throwable {
                return NullDomain.class;
            }
        });
View Full Code Here

        virtualConnectorProvider = mock(VirtualConnectorProvider.class);
        when(virtualConnectorProvider.createFactory(any(DomainProvider.class))).thenAnswer(
            new Answer<ConnectorInstanceFactory>() {
                @Override
                public ConnectorInstanceFactory answer(InvocationOnMock invocation) throws Throwable {
                    DomainProvider domainProvider = (DomainProvider) invocation.getArguments()[0];
                    return new DummyVirtualConnectorFactory(domainProvider);
                }
            });
        when(virtualConnectorProvider.getId()).thenReturn("virtual-test-connector");
        pseudoConnectorManager = new VirtualConnectorManager(bundleContext);
View Full Code Here

        osgiServiceMock = mock(DefaultOsgiUtilsService.class);
        final List<DomainProvider> domainProviders = new ArrayList<DomainProvider>();
        final List<Domain> domainEndpoints = new ArrayList<Domain>();
        Domain domainEndpoint = new NullDomainImpl("id");
        domainEndpoints.add(domainEndpoint);
        DomainProvider domainProviderMock = mock(DomainProvider.class);
        when(domainProviderMock.getDomainInterface()).thenAnswer(new Answer<Class<? extends Domain>>() {
            @Override
            public Class<? extends Domain> answer(InvocationOnMock invocationOnMock) throws Throwable {
                return NullDomain.class;
            }
        });
        LocalizableString descriptionMock = mock(LocalizableString.class);
        LocalizableString nameDescritptionMock = mock(LocalizableString.class);
        when(descriptionMock.getString(any(Locale.class))).thenReturn("Dummy description");
        when(nameDescritptionMock.getString(any(Locale.class))).thenReturn("Dummy Name");
        when(domainProviderMock.getDescription()).thenReturn(descriptionMock);
        when(domainProviderMock.getName()).thenReturn(nameDescritptionMock);
        domainProviders.add(domainProviderMock);

        when(osgiServiceMock.listServices(DomainProvider.class)).thenAnswer(new Answer<List<DomainProvider>>() {
            @Override
            public List<DomainProvider> answer(InvocationOnMock invocationOnMock) throws Throwable {
View Full Code Here

        assertThat(list.get(1).getId(), is("b"));
        assertThat(list.get(2).getId(), is("z"));
    }

    private DomainProvider mockDomainProvider(String id) {
        DomainProvider p1 = mock(DomainProvider.class);
        when(p1.getId()).thenReturn(id);
        return p1;
    }
View Full Code Here

                    // do nothing
                }

                @Override
                public Object addingService(ServiceReference reference) {
                    DomainProvider newProvider = (DomainProvider) bundleContext.getService(reference);
                    createNewFactoryForDomainProvider(newProvider);
                    return newProvider;
                }

            });
View Full Code Here

        HashMap<String, String> attributes = new HashMap<String, String>();
        attributes.put("compositeStrategy", "accessControlStrategy");
        attributes.put("queryString", "(location.foo=authorization/*)");

        DomainProvider provider = createDomainProviderMock(AuthorizationDomain.class, "accessControl");
        CompositeConnectorProvider compositeConnectorProvider = new CompositeConnectorProvider();
        compositeConnectorProvider.setBundleContext(bundleContext);
        ConnectorInstanceFactory factory = compositeConnectorProvider.createFactory(provider);
        accessControl = (AuthorizationDomain) factory.createNewInstance("authProvider");

View Full Code Here

@RunWith(JUnit4TestRunner.class)
public class OsgiServiceUtilIT extends AbstractPreConfiguredExamTestHelper {

    @Test
    public void testOsgiServiceUtilMethods_shouldFindService() throws Exception {
        DomainProvider provider = getServiceUtils().getService(DomainProvider.class);
        assertThat(provider, notNullValue());
        provider =
            (DomainProvider) getServiceUtils().getService(FilterUtils.makeFilter(DomainProvider.class,
                String.format("(%s=example)", org.openengsb.core.api.Constants.DOMAIN_KEY)));
        assertThat(provider, notNullValue());

        assertThat(provider.getId(), is("example"));
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.DomainProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.