@Test public void testCreateEndpoint() throws Exception { Bundle bundle = mock(Bundle.class); BundleDelegatingClassLoader classLoader = new BundleDelegatingClassLoader(bundle, getClass().getClassLoader()); Registry registry = mock(Registry.class); AggregationStrategy aggregationStrategy = mock(AggregationStrategy.class); when(registry.lookup(eq("aggregationStrategy"), eq(Object.class))).thenReturn(aggregationStrategy); CamelContext camelContext = mock(CamelContext.class); when(camelContext.getApplicationContextClassLoader()).thenReturn(classLoader); when(camelContext.getRegistry()).thenReturn(registry); OsgiComponent component = new OsgiComponent(); component.setCamelContext(camelContext); Map<String, Object> params = new HashMap<String, Object>(); params.put("parallelProcessing", true); params.put("streaming", true); params.put("aggregationStrategy", "#aggregationStrategy"); params.put("prop1", "val1"); params.put("prop2", 2); params.put("prop3", Boolean.TRUE); OsgiMulticastEndpoint endpoint = (OsgiMulticastEndpoint) component.createEndpoint("osgi:multicast:test", "multicast:test", params); assertThat(endpoint.isParallelProcessing(), equalTo(true)); assertThat(endpoint.isStreaming(), equalTo(true)); assertThat(endpoint.getAggregationStrategy(), sameInstance(aggregationStrategy)); assertThat(params.isEmpty(), equalTo(true)); Map<String, Object> props = endpoint.getProps(); assertThat(props.size(), equalTo(5)); assertThat((String) props.get("prop1"), equalTo("val1")); assertThat((Integer) props.get("prop2"), equalTo(2)); assertThat((Boolean) props.get("prop3"), equalTo(Boolean.TRUE)); assertThat((String) props.get(Constants.OBJECTCLASS), equalTo(OsgiComponent.OBJECT_CLASS)); assertThat((String) props.get(OsgiComponent.SERVICE_NAME_PROP), equalTo("test")); }
@Override protected Endpoint createEndpoint(String uri, String path, Map<String, Object> params) throws Exception { OsgiEndpointType endpointType = OsgiEndpointType.fromPath(path); OsgiDefaultEndpoint endpoint = endpointType.createEndpoint(uri, this); setProperties(endpoint, params); Map<String, Object> props = new HashMap<String, Object>(); props.put(Constants.OBJECTCLASS, OBJECT_CLASS); props.put(SERVICE_NAME_PROP, endpointType.getName(path)); for(Iterator<Entry<String, Object>> iter = params.entrySet().iterator(); iter.hasNext(); ) { Entry<String, Object> entry = iter.next(); props.put(entry.getKey(), entry.getValue()); iter.remove(); } convertProperties(props); endpoint.setProps(props); return endpoint; }
OsgiComponent extends DefaultComponent { @Override protected Endpoint createEndpoint(String uri, String path, Map<String, Object> params) throws Exception { OsgiEndpointType endpointType = OsgiEndpointType.fromPath(path); OsgiDefaultEndpoint endpoint = endpointType.createEndpoint(uri, this); setProperties(endpoint, params); Map<String, Object> props = new HashMap<String, Object>(); props.put(Constants.OBJECTCLASS, OBJECT_CLASS); props.put(SERVICE_NAME_PROP, endpointType.getName(path)); for(Iterator<Entry<String, Object>> iter = params.entrySet().iterator(); iter.hasNext(); ) { Entry<String, Object> entry = iter.next(); props.put(entry.getKey(), entry.getValue()); iter.remove(); } convertProperties(props); endpoint.setProps(props); return endpoint; } }
OsgiComponent extends DefaultComponent { @Override protected Endpoint createEndpoint(String uri, String path, Map<String, Object> params) throws Exception { OsgiEndpointType endpointType = OsgiEndpointType.fromPath(path); OsgiDefaultEndpoint endpoint = endpointType.createEndpoint(uri, this); setProperties(endpoint, params); Map<String, Object> props = new HashMap<String, Object>(); props.put(Constants.OBJECTCLASS, OBJECT_CLASS); props.put(SERVICE_NAME_PROP, endpointType.getName(path)); for(Iterator<Entry<String, Object>> iter = params.entrySet().iterator(); iter.hasNext(); ) { Entry<String, Object> entry = iter.next(); props.put(entry.getKey(), entry.getValue()); iter.remove(); } convertProperties(props); endpoint.setProps(props); return endpoint; }  }
OsgiComponent extends DefaultComponent { @Override protected Endpoint createEndpoint(String uri, String path, Map<String, Object> params) throws Exception { OsgiEndpointType endpointType = OsgiEndpointType.fromPath(path); OsgiDefaultEndpoint endpoint = endpointType.createEndpoint(uri, this); setProperties(endpoint, params); Map<String, Object> props = new HashMap<String, Object>(); props.put(Constants.OBJECTCLASS, OBJECT_CLASS); props.put(SERVICE_NAME_PROP, endpointType.getName(path)); for(Iterator<Entry<String, Object>> iter = params.entrySet().iterator(); iter.hasNext(); ) { Entry<String, Object> entry = iter.next(); props.put(entry.getKey(), entry.getValue()); iter.remove(); } convertProperties(props); endpoint.setProps(props); return endpoint; }   }
OsgiComponent extends DefaultComponent { @Override protected Endpoint createEndpoint(String uri, String path, Map<String, Object> params) throws Exception { OsgiEndpointType endpointType = OsgiEndpointType.fromPath(path); OsgiDefaultEndpoint endpoint = endpointType.createEndpoint(uri, this); setProperties(endpoint, params); Map<String, Object> props = new HashMap<String, Object>(); props.put(Constants.OBJECTCLASS, OBJECT_CLASS); props.put(SERVICE_NAME_PROP, endpointType.getName(path)); for(Iterator<Entry<String, Object>> iter = params.entrySet().iterator(); iter.hasNext(); ) { Entry<String, Object> entry = iter.next(); props.put(entry.getKey(), entry.getValue()); iter.remove(); } convertProperties(props); endpoint.setProps(props); return endpoint; }    }