Package com.google.enterprise.connector.spi

Examples of com.google.enterprise.connector.spi.ConfigureResponse


    assertFalse(message + " does not contain " + label, index == -1);
    return configRes.getFormSnippet();
  }

  public void testValidConfig() {
    ConfigureResponse configRes = connectorType.validateConfig(configMap,
        Locale.ENGLISH, mdbConnectorFactory);
    if (configRes != null) {
      fail(configRes.getMessage());
    }
  }
View Full Code Here


  }

  public void testUpdateQuery() throws Exception {
    Map<String, String> newConfigMap = Maps.newHashMap(configMap);
    newConfigMap.put(SQL_QUERY, "update TestEmpTable set dept = 42");
    ConfigureResponse configRes = connectorType.validateConfig(
        newConfigMap, Locale.ENGLISH, mdbConnectorFactory);
    assertEquals(BUNDLE.getString("TEST_SQL_QUERY"), configRes.getMessage());

    // Verify that the table was not really updated.
    assertEmptyResultSet("select id from TestEmpTable where dept = 42");
  }
View Full Code Here

  }

  public void testInvalidQuery() {
    Map<String, String> newConfigMap = Maps.newHashMap(configMap);
    newConfigMap.put(SQL_QUERY, "choose the red pill");
    ConfigureResponse configRes = connectorType.validateConfig(
        newConfigMap, Locale.ENGLISH, mdbConnectorFactory);
    assertEquals(BUNDLE.getString("TEST_SQL_QUERY"), configRes.getMessage());
  }
View Full Code Here

  public void testParameterizedQueryAndMutiplePrimaryKeys() {
    Map<String, String> newConfigMap = Maps.newHashMap(this.configMap);
    newConfigMap.put(SQL_QUERY,
                     "select * from TestEmpTable where id > #{value}");
    newConfigMap.put(PRIMARY_KEYS_STRING, "id,fname");
    ConfigureResponse configRes = this.connectorType.validateConfig(
        newConfigMap, Locale.ENGLISH, mdbConnectorFactory);
    assertEquals(
        BUNDLE.getString("TEST_PRIMARY_KEYS_AND_KEY_VALUE_PLACEHOLDER"),
        configRes.getMessage());
  }
View Full Code Here

  private void testFieldNames(Map<String, String> properties,
      String propertyName, String[] propertyValues, String expectedValue,
      String bundleMessage) {
    StringBuilder errors = new StringBuilder();
    for (String propertyValue : propertyValues) {
      ConfigureResponse configRes =
          validateConfig(properties, propertyName, propertyValue);
      if (configRes.getMessage() != null
          || configRes.getFormSnippet() != null) {
        errors.append(propertyName + "=" + propertyValue + ": "
            + configRes.getMessage() + "\n");
      } else if (expectedValue != null
          && !configRes.getConfigData().get(propertyName).equals(
              expectedValue)) {
        errors.append(propertyName + "=" + propertyValue + ": expected:<" +
            expectedValue + "> but was:<"
            + configRes.getConfigData().get(propertyName) + ">\n");
      }
    }

    ConfigureResponse configRes =
        validateConfig(properties, propertyName, INVALID_FIELD_NAME);
    if (configRes.getMessage() == null) {
      errors.append(propertyName + "=" + INVALID_FIELD_NAME
          + ": Unexpected null\n");
    } else if (!configRes.getMessage().equals(
        BUNDLE.getString(bundleMessage))) {
      errors.append(propertyName + "=" + INVALID_FIELD_NAME + ": "
          + configRes.getMessage() + "\n");
    }

    if (errors.length() > 0) {
      fail(errors.toString());
    }
View Full Code Here

      String propertyName, String propertyValue) {
    Map<String, String> newConfigMap = Maps.newHashMap();
    newConfigMap.putAll(configMap);
    newConfigMap.putAll(properties);
    newConfigMap.put(propertyName, propertyValue);
    ConfigureResponse response = connectorType.validateConfig(
        newConfigMap, Locale.ENGLISH, mdbConnectorFactory);

    // We need to pass the map we created, which was modified by
    // validateConfig, back to the caller.
    if (response == null) {
      return new ConfigureResponse(null, null, newConfigMap);
    } else {
      return response;
    }
  }
View Full Code Here

  }

  public void testPrimaryKeyEmptyValues() {
    StringBuilder errors = new StringBuilder();
    for (String empty : new String[] { ",", "   ", "   , ,," }) {
      ConfigureResponse configRes = validateConfig(
          ImmutableMap.<String, String>of(), PRIMARY_KEYS_STRING, empty);
      if (configRes.getMessage() == null) {
        errors.append("primaryKeysString=" + empty
            + ": Unexpected null\n");
      } else if (!configRes.getMessage().equals(
              BUNDLE.getString("TEST_PRIMARY_KEYS"))) {
        errors.append("primaryKeysString=" + empty + ": "
            + configRes.getMessage() + "\n");
      }
    }

    if (errors.length() > 0) {
      fail(errors.toString());
View Full Code Here

        SINGLE_FIELD_NAMES, ACTUAL_FIELD_NAME, "INVALID_COLUMN_NAME");
  }

  private void testOneFieldWithoutAnother(String oneField, String oneValue,
      String missingField) {
    ConfigureResponse response = validateConfig(
        ImmutableMap.of(EXT_METADATA_TYPE, DOC_ID), oneField, oneValue);
    assertNotNull(response.getMessage());
    assertTrue(response.getMessage(), response.getMessage().startsWith(
        BUNDLE.getString("MISSING_ATTRIBUTES")));
    assertTrue(response.getMessage(), response.getMessage().endsWith(
        BUNDLE.getString(missingField)));
  }
View Full Code Here

   */
  public void testParameterizedQueryAndSinglePrimaryKeys() {
    Map<String, String> newConfigMap = Maps.newHashMap(this.configMap);
    newConfigMap.put(SQL_QUERY,
        "select * from TestEmpTable where id > #{value}");
    ConfigureResponse configRes = this.connectorType.validateConfig(
        newConfigMap, Locale.ENGLISH, mdbConnectorFactory);
    if (configRes != null) {
      fail(configRes.getMessage());
    }
  }
View Full Code Here

  /** Tests an authZ query with no #{username} placeholder. */
  public void testInvalidAuthZQuery() throws Exception {
    Map<String, String> newConfigMap = Maps.newHashMap(configMap);
    newConfigMap.put(AUTHZ_QUERY, "choose the red pill");
    ConfigureResponse configRes = connectorType.validateConfig(
        newConfigMap, Locale.ENGLISH, mdbConnectorFactory);
    assertEquals(BUNDLE.getString("INVALID_AUTH_QUERY"),
        configRes.getMessage());
  }
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.spi.ConfigureResponse

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.