Search in sources :

Example 1 with CatalogEndpoint

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"));
}
Also used : HashMap(java.util.HashMap) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) Collection(java.util.Collection) CatalogEndpoint(ddf.catalog.endpoint.CatalogEndpoint) Map(java.util.Map) HashMap(java.util.HashMap) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Example 2 with CatalogEndpoint

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));
}
Also used : HashMap(java.util.HashMap) RegistryPackageType(oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType) Collection(java.util.Collection) CatalogEndpoint(ddf.catalog.endpoint.CatalogEndpoint) Map(java.util.Map) HashMap(java.util.HashMap) ServiceReference(org.osgi.framework.ServiceReference) Test(org.junit.Test)

Example 3 with CatalogEndpoint

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));
    }
}
Also used : CatalogEndpoint(ddf.catalog.endpoint.CatalogEndpoint) BundleContext(org.osgi.framework.BundleContext)

Example 4 with CatalogEndpoint

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);
    }
}
Also used : CatalogEndpoint(ddf.catalog.endpoint.CatalogEndpoint) BundleContext(org.osgi.framework.BundleContext)

Example 5 with CatalogEndpoint

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));
}
Also used : ArrayList(java.util.ArrayList) Matchers.containsString(org.hamcrest.Matchers.containsString) CatalogEndpoint(ddf.catalog.endpoint.CatalogEndpoint) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Aggregations

CatalogEndpoint (ddf.catalog.endpoint.CatalogEndpoint)5 Test (org.junit.Test)3 Collection (java.util.Collection)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 RegistryPackageType (oasis.names.tc.ebxml_regrep.xsd.rim._3.RegistryPackageType)2 BundleContext (org.osgi.framework.BundleContext)2 ServiceReference (org.osgi.framework.ServiceReference)2 ArrayList (java.util.ArrayList)1 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)1 SkipUnstableTest (org.codice.ddf.itests.common.annotations.SkipUnstableTest)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1