Package org.osgi.service.discovery

Examples of org.osgi.service.discovery.ServiceEndpointDescription


       
        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(Constants.EXPORTED_CONFIGS, Constants.RS_CONFIG_TYPE);
       
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl("MyInterface", props);
        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof JaxRSPojoConfigurationTypeHandler);       
        assertSame(dp, ((PojoConfigurationTypeHandler) handler).getDistributionProvider());
    }
View Full Code Here


        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(Constants.EXPORTED_CONFIGS, Constants.RS_CONFIG_TYPE);
        props.put(Constants.EXPORTED_INTENTS, "HTTP");
       
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl("MyInterface", props);
        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof JaxRSPojoConfigurationTypeHandler);       
        assertSame(dp, ((PojoConfigurationTypeHandler) handler).getDistributionProvider());
    }
View Full Code Here

        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
        Map<String, Object> props = new HashMap<String, Object>();
        props.put(Constants.EXPORTED_CONFIGS, Constants.RS_CONFIG_TYPE);
        props.put(Constants.EXPORTED_INTENTS, "SOAP HTTP");
       
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl("MyInterface", props);
        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof PojoConfigurationTypeHandler);
        assertTrue(!(handler instanceof JaxRSPojoConfigurationTypeHandler));
        assertSame(dp, ((PojoConfigurationTypeHandler) handler).getDistributionProvider());
View Full Code Here

        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
       
        Map<String, Object> sdProps = new HashMap<String, Object>();
        sdProps.put("osgi.remote.configuration.type", Constants.WS_CONFIG_TYPE);
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
                Collections.singletonList("MyInterface"), sdProps);

        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof PojoConfigurationTypeHandler);       
View Full Code Here

        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
       
        Map<String, Object> sdProps = new HashMap<String, Object>();
        // use default for this: sdProps.put(Constants.CONFIG_TYPE_PROPERTY, Constants.POJO_CONFIG_TYPE);
        sdProps.put(Constants.WS_ADDRESS_PROPERTY, "http://localhost:9876/abcd");
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
                Collections.singletonList("MyInterface"), sdProps);

        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof PojoConfigurationTypeHandler);       
View Full Code Here

        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
       
        Map<String, Object> sdProps = new HashMap<String, Object>();
        sdProps.put("osgi.remote.configuration.type", Constants.WS_CONFIG_TYPE);
        sdProps.put(Constants.WS_HTTP_SERVICE_CONTEXT, "/abc");
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
                Collections.singletonList("MyInterface"), sdProps);
       
        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof HttpServiceConfigurationTypeHandler);
View Full Code Here

        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
       
        Map<String, Object> sdProps = new HashMap<String, Object>();
        sdProps.put("osgi.remote.configuration.type", Constants.WSDL_CONFIG_TYPE);
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
                Collections.singletonList("MyInterface"), sdProps);
       
        CxfDistributionProvider dp = new DistributionProviderImpl(bc);
        ConfigurationTypeHandler handler = f.getHandler(bc, sd, dp, new HashMap<String, Object>());
        assertTrue(handler instanceof WsdlConfigurationTypeHandler);       
View Full Code Here

       
        ConfigTypeHandlerFactory f = ConfigTypeHandlerFactory.getInstance();
       
        Map<String, Object> sdProps = new HashMap<String, Object>();
        sdProps.put("osgi.remote.configuration.type", "foobar");
        ServiceEndpointDescription sd = new ServiceEndpointDescriptionImpl(
                Collections.singletonList("MyInterface"), sdProps);
       
        assertNull("Should not get a handler as this an unsupported config type",
                f.getHandler(bc, sd, null, new HashMap<String, Object>()));       
    }
View Full Code Here

    @Override
    public boolean equals(Object obj) {
        if (!(obj instanceof ServiceEndpointDescription)) {
            return false;
        }
        ServiceEndpointDescription other = (ServiceEndpointDescription)obj;
       
        return interfaceNames.equals(other.getProvidedInterfaces())
               && properties.equals(other.getProperties());
    }
View Full Code Here

        assertEquals(1, dsnCallbacks.size());
        DiscoveredServiceNotification dsn = dsnCallbacks.iterator().next();
        assertEquals(Collections.singleton(String.class.getName()), dsn.getInterfaces());
        assertEquals(DiscoveredServiceNotification.AVAILABLE, dsn.getType());
        assertEquals(0, dsn.getFilters().size());
        ServiceEndpointDescription sed = dsn.getServiceEndpointDescription();
        assertEquals(Collections.singleton(String.class.getName()), sed.getProvidedInterfaces());   
       
        Properties expected = new Properties();
        expected.load(new ByteArrayInputStream(propBytes.toByteArray()));
        expected.put("service.exported.configs", "org.apache.cxf.ws");
        expected.put("org.apache.cxf.ws.address", "http://somehost:12345/some/context");
       
        assertEquals(expected, sed.getProperties());
        EasyMock.verify(zk);
       
        // Again with the same data
        EasyMock.reset(zk);
        EasyMock.expect(zk.getChildren(Util.getZooKeeperPath(String.class.getName()), false))
            .andReturn(Arrays.asList("x#y#z"));
        EasyMock.expect(zk.getData(Util.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null))
            .andReturn(propBytes.toByteArray());
        EasyMock.replay(zk);

        dsnCallbacks.clear();
        assertEquals("Precondition failed", 0, dsnCallbacks.size());
        dml.change();
        assertEquals(0, dsnCallbacks.size());
       
        EasyMock.verify(zk);
        //----------------------------------------------------------------
        // Test DiscoveredServiceNotification.MODIFIED
        //----------------------------------------------------------------
        Properties modified = new Properties();
        modified.put("c", "d");
        modified.put(ServicePublication.ENDPOINT_LOCATION, "http://somehost:999/some/context");
        modified.put("service.exported.configs", "org.apache.cxf.rs");
        ByteArrayOutputStream modBytes = new ByteArrayOutputStream();
        modified.store(modBytes, "");
       
        EasyMock.reset(zk);
        EasyMock.expect(zk.getChildren(Util.getZooKeeperPath(String.class.getName()), false))
            .andReturn(Arrays.asList("x#y#z"));
        EasyMock.expect(zk.getData(Util.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null))
            .andReturn(modBytes.toByteArray());
        EasyMock.replay(zk);

        dsnCallbacks.clear();
        assertEquals("Precondition failed", 0, dsnCallbacks.size());
        dml.change();
        assertEquals(1, dsnCallbacks.size());
        DiscoveredServiceNotification dsn2 = dsnCallbacks.iterator().next();
        assertEquals(Collections.singleton(String.class.getName()), dsn2.getInterfaces());
        assertEquals(DiscoveredServiceNotification.MODIFIED, dsn2.getType());
        assertEquals(0, dsn2.getFilters().size());
        ServiceEndpointDescription sed2 = dsn2.getServiceEndpointDescription();
        assertEquals(Collections.singleton(String.class.getName()), sed2.getProvidedInterfaces());       
        assertEquals(modified, sed2.getProperties());
       
        EasyMock.verify(zk);

        //----------------------------------------------------------------
        // Test DiscoveredServiceNotification.MODIFIED2
        //----------------------------------------------------------------
        Properties modified2 = new Properties();
        modified2.put("c", "d2");
        modified2.put(ServicePublication.ENDPOINT_LOCATION, "http://somehost:112/some/context");
        modified2.put("service.exported.configs", "org.apache.cxf.ws");
        modified2.put("org.apache.cxf.ws.address", "http://somewhereelse/123");
        ByteArrayOutputStream modBytes2 = new ByteArrayOutputStream();
        modified2.store(modBytes2, "");
       
        EasyMock.reset(zk);
        EasyMock.expect(zk.getChildren(Util.getZooKeeperPath(String.class.getName()), false))
            .andReturn(Arrays.asList("x#y#z"));
        EasyMock.expect(zk.getData(Util.getZooKeeperPath(String.class.getName()) + "/x#y#z", false, null))
            .andReturn(modBytes2.toByteArray());
        EasyMock.replay(zk);

        dsnCallbacks.clear();
        assertEquals("Precondition failed", 0, dsnCallbacks.size());
        dml.change();
        assertEquals(1, dsnCallbacks.size());
        DiscoveredServiceNotification dsn3 = dsnCallbacks.iterator().next();
        assertEquals(Collections.singleton(String.class.getName()), dsn3.getInterfaces());
        assertEquals(DiscoveredServiceNotification.MODIFIED, dsn3.getType());
        assertEquals(0, dsn3.getFilters().size());
        ServiceEndpointDescription sed3 = dsn3.getServiceEndpointDescription();
        assertEquals(Collections.singleton(String.class.getName()), sed3.getProvidedInterfaces());       
        assertEquals(modified2, sed3.getProperties());
       
        EasyMock.verify(zk);
        //----------------------------------------------------------------
        // Test DiscoveredServiceNotification.UNAVAILABLE
        //----------------------------------------------------------------
        EasyMock.reset(zk);
        EasyMock.expect(zk.getChildren(Util.getZooKeeperPath(String.class.getName()), false))
            .andReturn(Collections.<String>emptyList());
        EasyMock.replay(zk);

        dsnCallbacks.clear();
        assertEquals("Precondition failed", 0, dsnCallbacks.size());
        dml.change();
        assertEquals(1, dsnCallbacks.size());
        DiscoveredServiceNotification dsn4 = dsnCallbacks.iterator().next();
        assertEquals(Collections.singleton(String.class.getName()), dsn4.getInterfaces());
        assertEquals(DiscoveredServiceNotification.UNAVAILABLE, dsn4.getType());
        assertEquals(0, dsn4.getFilters().size());
        ServiceEndpointDescription sed4 = dsn4.getServiceEndpointDescription();
        assertEquals(Collections.singleton(String.class.getName()), sed4.getProvidedInterfaces());       
        assertEquals(modified2, sed4.getProperties());
       
        EasyMock.verify(zk);
       
        // Try the same again...
        EasyMock.reset(zk);
View Full Code Here

TOP

Related Classes of org.osgi.service.discovery.ServiceEndpointDescription

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.