Package org.openengsb.domain.example

Examples of org.openengsb.domain.example.ExampleDomain


     */
    private void createSession() {
        session = rulebase.newStatefulKnowledgeSession();
        listener = new RuleListener();
        session.addEventListener(listener);
        ExampleDomain exampleService = new ExampleDomain() {

            @Override
            public String getInstanceId() {
                return null;
            }
View Full Code Here


    }

    @Test
    public void testLocationUtils_shouldLoadServiceByLocation() throws Exception {
        ExampleDomain service = new DummyService("test");
        Hashtable<String, Object> properties = new Hashtable<String, Object>();
        properties.put("id", "test");
        properties.put(Constants.SERVICE_RANKING, -1);
        properties.put("location.root", new String[]{ "foo" });
        getBundleContext().registerService(ExampleDomain.class.getName(), service, properties);

        service = new DummyService("test2");
        properties = new Hashtable<String, Object>();
        properties.put("id", "test2");
        properties.put("location.foo", new String[]{ "foo" });
        properties.put(Constants.SERVICE_RANKING, 1);
        getBundleContext().registerService(ExampleDomain.class.getName(), service, properties);

        ExampleDomain service2 = getServiceUtils().getService(ExampleDomain.class);
        assertThat(service2.getInstanceId(), is("test2"));

        ContextHolder.get().setCurrentContextId("foo");
        ExampleDomain serviceForLocation =
            (ExampleDomain) getServiceUtils().getServiceForLocation("foo");
        assertThat(serviceForLocation.getInstanceId(), is("test2"));

        ContextHolder.get().setCurrentContextId("foo2");
        serviceForLocation = (ExampleDomain) getServiceUtils().getServiceForLocation("foo");
        assertThat(serviceForLocation.getInstanceId(), is("test"));

        serviceForLocation =
            (ExampleDomain) getServiceUtils().getServiceForLocation("foo", "foo");
        assertThat(serviceForLocation.getInstanceId(), is("test2"));

        serviceForLocation = getServiceUtils().getServiceForLocation(ExampleDomain.class, "foo");
        assertThat(serviceForLocation.getInstanceId(), is("test"));
    }
View Full Code Here

        assertThat(serviceForLocation.getInstanceId(), is("test"));
    }

    @Test
    public void testMutlipleLocations_shouldWork() throws Exception {
        ExampleDomain service = new DummyService("test");
        Hashtable<String, Object> properties = new Hashtable<String, Object>();
        properties.put("id", "test");
        properties.put(Constants.SERVICE_RANKING, -1);
        properties.put("location.root", new String[]{ "main/foo", "main/foo2" });
        getBundleContext().registerService(ExampleDomain.class.getName(), service, properties);

        ExampleDomain fooService = (ExampleDomain) getServiceUtils().getServiceForLocation("main/foo");
        assertThat(fooService.getInstanceId(), is("test"));

        ExampleDomain foo2Service = (ExampleDomain) getServiceUtils().getServiceForLocation("main/foo2");
        assertThat(foo2Service.getInstanceId(), is("test"));
    }
View Full Code Here

        // make sure jms is up and running
        utilsService.getServiceWithId(OutgoingPort.class, "jms-json", 60000);

        SecureSampleConnector remoteConnector = new SecureSampleConnector(openwirePort);
        remoteConnector.start(new ExampleConnector(), new ConnectorDescription("example", "external-connector-proxy"));
        ExampleDomain osgiService = getOsgiService(ExampleDomain.class, "(service.pid=example-remote)", 31000);

        assertThat(getBundleContext().getServiceReferences(ExampleDomain.class.getName(),
            "(service.pid=example-remote)"), not(nullValue()));
        assertThat(osgiService, not(nullValue()));

        remoteConnector.getInvocationHistory().clear();
        osgiService.doSomethingWithMessage("test");
        assertThat(remoteConnector.getInvocationHistory().isEmpty(), is(false));

        remoteConnector.stop();
       
        boolean unregistered = false;
View Full Code Here

    private void registerDummyService() throws Exception {
        if (isOsgiServiceAvailable(ExampleDomain.class, "(service.pid=test)")) {
            // if we get here, the domain is already registered
            return;
        }
        ExampleDomain service = new DummyService("test");
        Hashtable<String, Object> properties = new Hashtable<String, Object>();
        properties.put(Constants.SERVICE_PID, "test");
        properties.put(Constants.SERVICE_RANKING, -1);
        properties.put("location.root", new String[]{ "foo" });
        getBundleContext().registerService(ExampleDomain.class.getName(), service, properties);
View Full Code Here

        wiringService = getOsgiService(WiringService.class);
    }
   
    @Test
    public void testSingleMethodProxies_shouldProxyService() throws Exception {
        ExampleDomain service = new DummyService("test");
        Hashtable<String, Object> properties = new Hashtable<String, Object>();
        properties.put("id", "test");
        properties.put(Constants.SERVICE_RANKING, -1);
        properties.put("location.root", new String[]{ "foo" });
        getBundleContext().registerService(ExampleDomain.class.getName(), service, properties);

        ContextHolder.get().setCurrentContextId("foo");
        ExampleDomain domainEndpoint = wiringService.getDomainEndpoint(ExampleDomain.class, "foo");
        assertThat(domainEndpoint.getInstanceId(), is("test"));

        service = new DummyService("test2");
        properties = new Hashtable<String, Object>();
        properties.put("id", "test2");
        properties.put("location.foo", new String[]{ "foo2", });
        properties.put(Constants.SERVICE_RANKING, 1);

        /* create the proxy before the service is registered */
        ExampleDomain domainEndpoint2 = wiringService.getDomainEndpoint(ExampleDomain.class, "foo2");
        getBundleContext().registerService(ExampleDomain.class.getName(), service, properties);

        assertThat(domainEndpoint2.getInstanceId(), is("test2"));
    }
View Full Code Here

        assertThat(domainEndpoint2.getInstanceId(), is("test2"));
    }

    @Test
    public void testListMethod_shouldListMethods() throws Exception {
        ExampleDomain service = new DummyService("test");
        Hashtable<String, Object> properties = new Hashtable<String, Object>();
        properties.put("id", "test");
        properties.put(Constants.SERVICE_RANKING, -1);
        properties.put("location.foo", new String[]{ "test/foo", "main/foo", "main/bla", });
        getBundleContext().registerService(ExampleDomain.class.getName(), service, properties);
View Full Code Here

        assertThat(ids, not(hasItem("test3")));
    }

    @Test
    public void testServiceDoesExist_shouldNotFindService() throws Exception {
        ExampleDomain service = new DummyService("test");
        Hashtable<String, Object> properties = new Hashtable<String, Object>();
        properties.put("id", "test");
        properties.put(Constants.SERVICE_RANKING, -1);
        properties.put("location.foo", new String[]{ "test/foo", "main/foo", "main/bla", });
        getBundleContext().registerService(ExampleDomain.class.getName(), service, properties);
View Full Code Here

TOP

Related Classes of org.openengsb.domain.example.ExampleDomain

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.