use of ddf.catalog.endpoint.CatalogEndpoint in project ddf by codice.
the class FederationAdminTest method testBindEndpoint.
@Test
public void testBindEndpoint() throws Exception {
List<RegistryPackageType> regObjects = Collections.singletonList((RegistryPackageType) getRegistryObjectFromResource("/csw-full-registry-package.xml"));
when(federationAdminService.getRegistryObjects()).thenReturn(regObjects);
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
when(federationAdminService.getRegistryMetacards()).thenReturn(Collections.singletonList(mcard));
ServiceReference reference = mock(ServiceReference.class);
CatalogEndpoint endpoint = mock(CatalogEndpoint.class);
Map<String, String> props = new HashMap<>();
props.put(CatalogEndpoint.ID_KEY, "myId");
when(endpoint.getEndpointProperties()).thenReturn(props);
when(context.getService(reference)).thenReturn(endpoint);
federationAdmin.bindEndpoint(reference);
Map<String, Object> autoValues = (Map<String, Object>) federationAdmin.getLocalNodes().get("autoPopulateValues");
assertThat(autoValues.size(), is(1));
Collection bindingValues = (Collection) autoValues.get("ServiceBinding");
assertThat(bindingValues.size(), is(1));
Map<String, String> bindings = (Map<String, String>) bindingValues.iterator().next();
assertThat(bindings.get(CatalogEndpoint.ID_KEY), equalTo("myId"));
}
use of ddf.catalog.endpoint.CatalogEndpoint in project ddf by codice.
the class FederationAdminTest method testUnbindEndpoint.
@Test
public void testUnbindEndpoint() throws Exception {
List<RegistryPackageType> regObjects = Collections.singletonList((RegistryPackageType) getRegistryObjectFromResource("/csw-full-registry-package.xml"));
when(federationAdminService.getRegistryObjects()).thenReturn(regObjects);
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_ID, "urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
when(federationAdminService.getRegistryMetacards()).thenReturn(Collections.singletonList(mcard));
ServiceReference reference = mock(ServiceReference.class);
CatalogEndpoint endpoint = mock(CatalogEndpoint.class);
Map<String, String> props = new HashMap<>();
props.put(CatalogEndpoint.ID_KEY, "myId");
when(endpoint.getEndpointProperties()).thenReturn(props);
when(context.getService(reference)).thenReturn(endpoint);
federationAdmin.bindEndpoint(reference);
federationAdmin.unbindEndpoint(reference);
Map<String, Object> autoValues = (Map<String, Object>) federationAdmin.getLocalNodes().get("autoPopulateValues");
assertThat(autoValues.size(), is(1));
Collection bindingValues = (Collection) autoValues.get("ServiceBinding");
assertThat(bindingValues.size(), is(0));
}
use of ddf.catalog.endpoint.CatalogEndpoint in project ddf by codice.
the class FederationAdmin method unbindEndpoint.
public void unbindEndpoint(ServiceReference reference) {
BundleContext context = getContext();
if (reference != null && context != null) {
CatalogEndpoint endpoint = (CatalogEndpoint) context.getService(reference);
Map<String, String> properties = endpoint.getEndpointProperties();
endpointMap.remove(properties.get(CatalogEndpoint.ID_KEY));
}
}
use of ddf.catalog.endpoint.CatalogEndpoint in project ddf by codice.
the class FederationAdmin method bindEndpoint.
public void bindEndpoint(ServiceReference reference) {
BundleContext context = getContext();
if (reference != null && context != null) {
CatalogEndpoint endpoint = (CatalogEndpoint) context.getService(reference);
Map<String, String> properties = endpoint.getEndpointProperties();
endpointMap.put(properties.get(CatalogEndpoint.ID_KEY), properties);
}
}
use of ddf.catalog.endpoint.CatalogEndpoint in project ddf by codice.
the class TestFederation method testCatalogEndpointExposure.
@Test
public void testCatalogEndpointExposure() throws InvalidSyntaxException {
// Check the service references
ArrayList<String> expectedEndpoints = new ArrayList<>();
expectedEndpoints.add("endpointUrl");
expectedEndpoints.add("cswUrl");
CatalogEndpoint endpoint = getServiceManager().getService(CatalogEndpoint.class);
String urlBindingName = endpoint.getEndpointProperties().get(CatalogEndpointImpl.URL_BINDING_NAME_KEY);
assertTrue("Catalog endpoint url binding name: '" + urlBindingName + "' is expected.", expectedEndpoints.contains(urlBindingName));
}
Aggregations