// Test that connectors not in the import set are not removed on import
// if noRemove is true.
public final void testNoRemove() throws Exception {
Context context = Context.getInstance();
ConnectorCoordinatorMap ccm = getCoordinatorMap();
addConnector("connector-01", "red");
addConnector("connector-02", "blue");
ImportExportConnectorList connectors = ImportExport.getConnectors();
assertTrue(connectors.size() == 2);
// Change the colors, so they get imported differently.
for (ImportExportConnector connector : connectors) {
Map<String, String> configMap = connector.getConfigMap();
String color = configMap.get("Color");
configMap.put("Color", (color.equals("red") ? "blue" : "red"));
}
String exportXml = ImportExportConnectorListTest.asXmlString(connectors);
connectors = fromXmlString(exportXml);
assertTrue(connectors.size() == 2);
// Add a new connector.
addConnector("connector-03", "green");
Set<String> connectorNames = ccm.getConnectorNames();
assertTrue(connectorNames.contains("connector-01"));
assertTrue(connectorNames.contains("connector-02"));
assertTrue(connectorNames.contains("connector-03"));
ImportExport.setConnectors(connectors, true);
connectorNames = ccm.getConnectorNames();
assertTrue(connectorNames.contains("connector-01"));
assertTrue(connectorNames.contains("connector-02"));
assertTrue(connectorNames.contains("connector-03"));
ConnectorCoordinator coordinator = ccm.get("connector-01");
Configuration config = coordinator.getConnectorConfiguration();
assertEquals("type", "TestConnectorA", config.getTypeName());
ImportExportConnectorTest.assertContains(config.getMap(), "Color", "blue");
assertEquals("checkpoint", "checkpoint", coordinator.getConnectorState());
Schedule schedule = coordinator.getConnectorSchedule();
assertFalse(schedule.isDisabled());
assertTrue((schedule.getLoad() == 100));
assertTrue((schedule.getRetryDelayMillis() == 300000));
assertEquals("0-0", schedule.getTimeIntervals());
coordinator = ccm.get("connector-02");
config = coordinator.getConnectorConfiguration();
assertEquals("type", "TestConnectorA", config.getTypeName());
ImportExportConnectorTest.assertContains(config.getMap(), "Color", "red");
assertEquals("checkpoint", "checkpoint", coordinator.getConnectorState());
schedule = coordinator.getConnectorSchedule();