Package com.google.enterprise.connector.test

Examples of com.google.enterprise.connector.test.JsonObjectAsMap


  private void addConnector(Instantiator instantiator,
      String name, String typeName, String configString) {
    try {
      Map<String, String> configMap =
          new JsonObjectAsMap(new JSONObject(configString));
      Configuration config = new Configuration(typeName, configMap, null);
      instantiator.setConnectorConfiguration(name, config,
          I18NUtil.getLocaleFromStandardLocaleString("en"), false);
    } catch (ConnectorExistsException cee) {
      fail(cee.toString());
View Full Code Here


  /*
   * Create a configMap from a JSON string.
   */
  private Map<String, String> getConfigMap(String jsonConfigString)
      throws JSONException {
    return new JsonObjectAsMap(new JSONObject(jsonConfigString));
  }
View Full Code Here

    TypeInfo typeInfo = getTypeMap().getTypeInfo(typeName);
    Resource resource = typeInfo.getConnectorInstancePrototype();
    String configXml = StringUtils.streamToString(resource.getInputStream());

    Configuration configuration = new Configuration(typeName,
        new JsonObjectAsMap(new JSONObject(jsonConfigString)),
        configXml.replace("TestConnectorAInstance",
                          "NewTestConnectorAInstance"));

    // This knows that updateConnectorTest passes null for configXml.
    updateConnectorTest(instance, configuration, false);
View Full Code Here

    String jsonConfigString =
        "{Username:foo, Password:bar, Color:red, "
            + "RepositoryFile:MockRepositoryEventLog3.txt}";

    Configuration configuration = new Configuration(typeName,
        new JsonObjectAsMap(new JSONObject(jsonConfigString)), null);

    // This knows that updateConnectorTest passes null for configXml.
    updateConnectorTest(instance, configuration, false);

    // Create a modified connectorInstance.xml.
    TypeInfo typeInfo = getTypeMap().getTypeInfo(typeName);
    Resource resource = typeInfo.getConnectorInstancePrototype();
    String configXml = StringUtils.streamToString(resource.getInputStream());

    Configuration newConfiguration = new Configuration(typeName,
        new JsonObjectAsMap(new JSONObject(jsonConfigString)),
        configXml.replace("TestConnectorAInstance",
                          "NewTestConnectorAInstance"));

    // This knows that updateConnectorTest passes null for configXml.
    updateConnectorTest(instance, newConfiguration, true);
View Full Code Here

  private void updateConnectorTest(ConnectorCoordinatorImpl instance,
      String typeName, boolean update, String jsonConfigString)
      throws JSONException, InstantiatorException, ConnectorNotFoundException,
      ConnectorExistsException, ConnectorTypeNotFoundException {
    Configuration configuration = new Configuration(typeName,
        new JsonObjectAsMap(new JSONObject(jsonConfigString)), null);
    updateConnectorTest(instance, configuration, update);
  }
View Full Code Here

    public ConfigUpdater(ConnectorCoordinatorImpl coordinator, int iterations)
        throws Exception {
      super(coordinator, iterations);
      typeInfo = getTypeMap().getTypeInfo(coordinator.getConnectorTypeName());
      configuration = new Configuration(coordinator.getConnectorTypeName(),
          new JsonObjectAsMap(new JSONObject(JSON_CONFIG)), null);
    }
View Full Code Here

    {
      SimpleConnectorType simpleConnectorType = new SimpleConnectorType();
      simpleConnectorType.setConfigKeys(new String[] {"user", "password"});
      JSONObject jo = new JSONObject(
          "{user:max, dog:snickers, destination:heaven}");
      Map<String, String> map = new JsonObjectAsMap(jo);
      ConfigureResponse configureResponse = simpleConnectorType.validateConfig(
          map, null, null);
      String configForm = configureResponse.getFormSnippet();
      String expectedResult =
        "<tr>\r\n"
          + "<td>user</td>\r\n"
          + "<td><input type=\"text\" value=\"max\" name=\"user\"/></td>\r\n"
          + "</tr>\r\n"
          + "<tr>\r\n"
          + "<td><font color=\"red\">password</font></td>\r\n"
          + "<td><input type=\"password\" name=\"password\"/></td>\r\n"
          + "</tr>\r\n"
          + "<input type=\"hidden\" value=\"heaven\" name=\"destination\"/>\r\n"
          + "<input type=\"hidden\" value=\"snickers\" name=\"dog\"/>\r\n" + "";
      Assert.assertEquals(expectedResult, configForm);
      String message = configureResponse.getMessage();
      Assert.assertTrue(message.length() > 0);
    }

    {
      SimpleConnectorType simpleConnectorType = new SimpleConnectorType();
      simpleConnectorType.setConfigKeys(new String[] {"user", "password"});
      JSONObject jo = new JSONObject("{user:max, password:xyzzy, dog:snickers}");
      Map<String, String> map = new JsonObjectAsMap(jo);
      ConfigureResponse configureResponse = simpleConnectorType.validateConfig(
          map, null, null);
      Assert.assertNull(configureResponse);
    }

    {
      TestConnectorType testConnectorType = new TestConnectorType();
      testConnectorType.setConfigKeys(new String[] {"user", "password"});
      JSONObject jo = new JSONObject("{user:max, password:xyzzy}");
      Map<String, String> map = new JsonObjectAsMap(jo);
      ConfigureResponse configureResponse = testConnectorType.validateConfig(
          map, null, null);
      String configForm = configureResponse.getFormSnippet();
      String expectedResult =
        "<tr>\r\n"
View Full Code Here

  public final void testGetPopulatedConfigForm() throws JSONException {
    {
      SimpleConnectorType simpleConnectorType = new SimpleConnectorType();
      simpleConnectorType.setConfigKeys(new String[] {"user", "password"});
      Map<String, String> map =
          new JsonObjectAsMap(new JSONObject("{user:max, password:foo}"));
      ConfigureResponse configureResponse = simpleConnectorType
          .getPopulatedConfigForm(map, null);
      String configForm = configureResponse.getFormSnippet();
      String expectedResult = "<tr>\r\n" + "<td>user</td>\r\n"
          + "<td><input type=\"text\" name=\"user\" value=\"max\"/></td>\r\n"
View Full Code Here

public final void testGetPopulatedConfigWithSpecialXmlCharForm()
     throws JSONException {
      SimpleConnectorType simpleConnectorType = new SimpleConnectorType();
      simpleConnectorType.setConfigKeys(new String[] {"user", "password"});
      Map<String, String> map =
          new JsonObjectAsMap(new JSONObject("{user:m&x, password:f&<oo}"));
      ConfigureResponse configureResponse = simpleConnectorType
          .getPopulatedConfigForm(map, null);
      String configForm = configureResponse.getFormSnippet();
      String expectedResult = "<tr>\r\n" + "<td>user</td>\r\n"
          + "<td><input type=\"text\" name=\"user\" value=\"m&amp;x\"/></td>\r\n"
View Full Code Here

TOP

Related Classes of com.google.enterprise.connector.test.JsonObjectAsMap

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.