Package com.google.enterprise.connector.instantiator

Examples of com.google.enterprise.connector.instantiator.ConnectorCoordinatorMap


        "ConnectorCoordinatorMap", ConnectorCoordinatorMap.class);
  }

  private void addConnector(String name, String color) throws Exception {
    Context context = Context.getInstance();
    ConnectorCoordinatorMap ccm = getCoordinatorMap();
    ConnectorCoordinator coordinator = ccm.getOrAdd(name);
    String typeName = "TestConnectorA";
    Map<String, String> configMap = new HashMap<String, String>(CONFIG_MAP);
    configMap.put("Color", color);
    Configuration config = new Configuration(typeName, configMap, null);
    ConfigureResponse response = coordinator.setConnectorConfiguration(
View Full Code Here


  // Tests the correct construction of List<ImportExportConnector> from
  // an existing installation.
  public final void testGetConnectors() throws Exception {
    Context context = Context.getInstance();
    ConnectorCoordinatorMap ccm = getCoordinatorMap();

    addConnector("connector-01", "red");
    addConnector("connector-02", "blue");

    ImportExportConnectorList connectors = ImportExport.getConnectors();
View Full Code Here

  // Test that the exported XML is in the legacy ImportExport
  // format for the GSA: Stringified Schedules, no traversal state,
  // plain-text passwords.
  public final void testExportFormat() throws Exception {
    Context context = Context.getInstance();
    ConnectorCoordinatorMap ccm = getCoordinatorMap();

    addConnector("connector-01", "red");

    ImportExportConnectorList connectors = ImportExport.getConnectors();
    assertTrue(connectors.size() == 1);
View Full Code Here

  // Tests that an import into a barren installation creates new
  // connectors in the import set.
  public final void testSetConnectors() 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);

    String exportXml = ImportExportConnectorListTest.asXmlString(connectors);

    // Now blow away the context, including our connectors.
    refreshContext();
    context = Context.getInstance();
    ccm = getCoordinatorMap();
    assertTrue(ccm.getConnectorNames().isEmpty());

    connectors = fromXmlString(exportXml);
    assertTrue(connectors.size() == 2);

    ImportExport.setConnectors(connectors, true);

    Set<String> connectorNames = ccm.getConnectorNames();
    assertTrue(connectorNames.contains("connector-01"));
    assertTrue(connectorNames.contains("connector-02"));

    ConnectorCoordinator coordinator = ccm.get("connector-01");
    Configuration config = coordinator.getConnectorConfiguration();
    assertEquals("type", "TestConnectorA", config.getTypeName());
    ImportExportConnectorTest.assertContains(config.getMap(), "Color", "red");
    assertNull("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", "blue");
    assertNull("checkpoint", coordinator.getConnectorState());
    schedule = coordinator.getConnectorSchedule();
View Full Code Here

  // Tests that imported connectors over an existing installation
  // modifies the configuration, but leaves unimported data (like
  // the checkoint) in place.
  public final void testUpdateConnectors() 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);

    ImportExport.setConnectors(connectors, true);

    Set<String> connectorNames = ccm.getConnectorNames();
    assertTrue(connectorNames.contains("connector-01"));
    assertTrue(connectorNames.contains("connector-02"));

    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();
View Full Code Here

  // 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();
View Full Code Here

  }

  // Test that connectors not in the import set are removed on import.
  public final void testDoRemove() 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, false);

    connectorNames = ccm.getConnectorNames();
    assertTrue(connectorNames.contains("connector-01"));
    assertTrue(connectorNames.contains("connector-02"));
    assertFalse(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();
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.instantiator.ConnectorCoordinatorMap

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.