use of java.util.Dictionary in project ddf by codice.
the class SourceConfigurationHandlerTest method testConfigurationUpdateActivateConfigActivePriorityNotAvailable.
@Test
public void testConfigurationUpdateActivateConfigActivePriorityNotAvailable() throws Exception {
ArgumentCaptor<Dictionary> captor = ArgumentCaptor.forClass(Dictionary.class);
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE, null);
when(configAdmin.listConfigurations(anyString())).thenReturn(new Configuration[] { config });
Hashtable<String, Object> props = new Hashtable<>();
props.put("id", "TestRegNode");
props.put("origConfig", "origConfigValue");
props.put(RegistryConstants.CONFIGURATION_REGISTRY_ID_PROPERTY, "urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
props.put("bindingType", "Some_Other_Binding_Type");
Configuration newDisabledConfig = mock(Configuration.class);
when(newDisabledConfig.getFactoryPid()).thenReturn("Some_Other_Source_disabled");
when(configAdmin.createFactoryConfiguration("Some_Other_Source_disabled", null)).thenReturn(newDisabledConfig);
doReturn(props).when(newDisabledConfig).getProperties();
Configuration newActiveConfig = mock(Configuration.class);
when(configAdmin.createFactoryConfiguration("Csw_Federated_Source", null)).thenReturn(newActiveConfig);
doReturn("Csw_Federated_Source").when(newActiveConfig).getFactoryPid();
when(config.getProperties()).thenReturn(props);
when(config.getFactoryPid()).thenReturn("Some_Other_Source");
List<String> priority = new ArrayList<>();
priority.add("Top_Priority_Source");
priority.add("CSW_2.0.2");
List<String> bindings = new ArrayList<>();
bindings.add("Top_Priority_Source=Some_Other_Source");
bindings.add("CSW_2.0.2=Csw_Federated_Source");
sch.setBindingTypeFactoryPid(bindings);
sch.setSourceActivationPriorityOrder(priority);
sch.setPreserveActiveConfigurations(false);
sch.setActivateConfigurations(true);
setupSerialExecutor();
sch.handleEvent(updateEvent);
verify(config, times(1)).delete();
verify(configAdmin, times(1)).createFactoryConfiguration("Some_Other_Source_disabled", null);
verify(configAdmin, times(1)).createFactoryConfiguration("Csw_Federated_Source", null);
verify(newActiveConfig).update(captor.capture());
List<Dictionary> values = captor.getAllValues();
assertThat(values.size(), equalTo(1));
Dictionary passedValues = values.get(0);
assertThat(passedValues.get("attId"), equalTo("attValue"));
assertCswProperties(passedValues);
}
use of java.util.Dictionary in project ddf by codice.
the class SourceConfigurationHandlerTest method testDefaultConfigurationLocalNodeCreateNoTitle.
@Test
public void testDefaultConfigurationLocalNodeCreateNoTitle() throws Exception {
ArgumentCaptor<Dictionary> captor = ArgumentCaptor.forClass(Dictionary.class);
mcard.setAttribute(Metacard.TITLE, null);
setupSerialExecutor();
doReturn("Csw_Federated_Source_disabled").when(config).getFactoryPid();
sch.handleEvent(createEvent);
verify(configAdmin, times(1)).createFactoryConfiguration("Csw_Federated_Source_disabled", null);
verify(config).update(captor.capture());
Dictionary passedValues = captor.getValue();
assertThat(passedValues.get("attId"), equalTo("attValue"));
assertThat(passedValues.get("urlBindingName"), equalTo("cswUrl"));
assertThat(passedValues.get("id"), equalTo("urn:uuid:2014ca7f59ac46f495e32b4a67a51276"));
assertThat(passedValues.get("cswUrl"), equalTo("https://localhost:1234/mycsw/endpoint"));
assertThat(passedValues.get("bindingType"), equalTo("CSW_2.0.2"));
assertThat(passedValues.get("customSlot"), equalTo("customValue"));
}
use of java.util.Dictionary in project ddf by codice.
the class SourceConfigurationHandlerTest method testConfigurationCreateActivateConfigWithExistingMatchingActiveConfig.
@Test
public void testConfigurationCreateActivateConfigWithExistingMatchingActiveConfig() throws Exception {
ArgumentCaptor<Dictionary> captor = ArgumentCaptor.forClass(Dictionary.class);
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE, null);
when(configAdmin.listConfigurations(anyString())).thenReturn(new Configuration[] { config });
Hashtable<String, Object> props = new Hashtable<>();
props.put("id", "TestRegNode");
props.put("origConfig", "origConfigValue");
props.put(RegistryConstants.CONFIGURATION_REGISTRY_ID_PROPERTY, "urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
props.put("bindingType", "CSW_2.0.2");
when(config.getProperties()).thenReturn(props);
when(config.getFactoryPid()).thenReturn("Csw_Federated_Source");
sch.setActivateConfigurations(true);
setupSerialExecutor();
sch.handleEvent(createEvent);
verify(config, never()).delete();
verify(configAdmin, never()).createFactoryConfiguration("Csw_Federated_Source", null);
verify(config).update(captor.capture());
Dictionary passedValues = captor.getValue();
assertCswProperties(passedValues);
assertThat(passedValues.get("origConfig"), equalTo("origConfigValue"));
}
use of java.util.Dictionary in project ddf by codice.
the class SourceConfigurationHandlerTest method testDefaultConfigurationLocalNodeCreate.
@Test
public void testDefaultConfigurationLocalNodeCreate() throws Exception {
ArgumentCaptor<Dictionary> captor = ArgumentCaptor.forClass(Dictionary.class);
setupSerialExecutor();
doReturn("Csw_Federated_Source_disabled").when(config).getFactoryPid();
sch.handleEvent(createEvent);
verify(configAdmin, times(1)).createFactoryConfiguration("Csw_Federated_Source_disabled", null);
verify(config).update(captor.capture());
Dictionary passedValues = captor.getValue();
assertThat(passedValues.get("attId"), equalTo("attValue"));
assertCswProperties(passedValues);
}
use of java.util.Dictionary in project ddf by codice.
the class SourceConfigurationHandlerTest method testConfigurationUpdateActivateConfigWithExistingDifferentActiveConfig.
@Test
public void testConfigurationUpdateActivateConfigWithExistingDifferentActiveConfig() throws Exception {
ArgumentCaptor<Dictionary> captor = ArgumentCaptor.forClass(Dictionary.class);
mcard.setAttribute(RegistryObjectMetacardType.REGISTRY_IDENTITY_NODE, null);
when(configAdmin.listConfigurations(anyString())).thenReturn(new Configuration[] { config });
Hashtable<String, Object> props = new Hashtable<>();
props.put("id", "TestRegNode");
props.put("origConfig", "origConfigValue");
props.put(RegistryConstants.CONFIGURATION_REGISTRY_ID_PROPERTY, "urn:uuid:2014ca7f59ac46f495e32b4a67a51276");
props.put("bindingType", "SomeOtherBindingType");
when(config.getProperties()).thenReturn(props);
when(config.getFactoryPid()).thenReturn("Some_Other_Source");
Configuration newConfig = mock(Configuration.class);
doReturn(newConfig).when(configAdmin).createFactoryConfiguration("Csw_Federated_Source_disabled", null);
doReturn("Csw_Federated_Source_disabled").when(newConfig).getFactoryPid();
sch.setActivateConfigurations(true);
setupSerialExecutor();
sch.handleEvent(updateEvent);
verify(configAdmin, times(1)).createFactoryConfiguration("Csw_Federated_Source_disabled", null);
verify(newConfig).update(captor.capture());
List<Dictionary> values = captor.getAllValues();
assertThat(values.size(), equalTo(1));
Dictionary passedValues = values.get(0);
assertCswProperties(passedValues);
}
Aggregations