{
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"