}
}
@Test
public void validate() {
ConnInstanceTO connectorTO = new ConnInstanceTO();
for (URI location : ConnIdBundleManager.getConnManagers().keySet()) {
if (!location.getScheme().equals("file")) {
connectorTO.setLocation(location.toString());
}
}
// set connector version
connectorTO.setVersion(connidDbTableVersion);
// set connector name
connectorTO.setConnectorName("org.connid.bundles.db.table.DatabaseTableConnector");
// set bundle name
connectorTO.setBundleName("org.connid.bundles.db.table");
connectorTO.setDisplayName("H2Test");
// set the connector configuration using PropertyTO
Set<ConnConfProperty> conf = new HashSet<ConnConfProperty>();
ConnConfPropSchema userSchema = new ConnConfPropSchema();
userSchema.setName("user");
userSchema.setType(String.class.getName());
userSchema.setRequired(false);
ConnConfProperty user = new ConnConfProperty();
user.setSchema(userSchema);
user.setValues(Collections.singletonList("sa"));
ConnConfPropSchema keyColumnSchema = new ConnConfPropSchema();
keyColumnSchema.setName("keyColumn");
keyColumnSchema.setType(String.class.getName());
keyColumnSchema.setRequired(true);
ConnConfProperty keyColumn = new ConnConfProperty();
keyColumn.setSchema(keyColumnSchema);
keyColumn.setValues(Collections.singletonList("id"));
ConnConfPropSchema jdbcUrlTemplateSchema = new ConnConfPropSchema();
jdbcUrlTemplateSchema.setName("jdbcUrlTemplate");
jdbcUrlTemplateSchema.setType(String.class.getName());
jdbcUrlTemplateSchema.setRequired(true);
ConnConfProperty jdbcUrlTemplate = new ConnConfProperty();
jdbcUrlTemplate.setSchema(jdbcUrlTemplateSchema);
jdbcUrlTemplate.setValues(Collections.singletonList("jdbc:h2:tcp://localhost:9092/testdb"));
ConnConfPropSchema passwordColumnSchema = new ConnConfPropSchema();
passwordColumnSchema.setName("passwordColumn");
passwordColumnSchema.setType(String.class.getName());
passwordColumnSchema.setRequired(true);
ConnConfProperty passwordColumn = new ConnConfProperty();
passwordColumn.setSchema(passwordColumnSchema);
passwordColumn.setValues(Collections.singletonList("password"));
ConnConfPropSchema tableSchema = new ConnConfPropSchema();
tableSchema.setName("table");
tableSchema.setType(String.class.getName());
tableSchema.setRequired(true);
ConnConfProperty table = new ConnConfProperty();
table.setSchema(tableSchema);
table.setValues(Collections.singletonList("test"));
ConnConfPropSchema passwordSchema = new ConnConfPropSchema();
passwordSchema.setName("password");
passwordSchema.setType(GuardedString.class.getName());
passwordSchema.setRequired(true);
ConnConfProperty password = new ConnConfProperty();
password.setSchema(passwordSchema);
password.setValues(Collections.singletonList("sa"));
ConnConfPropSchema jdbcDriverSchema = new ConnConfPropSchema();
jdbcDriverSchema.setName("jdbcDriver");
jdbcDriverSchema.setType(String.class.getName());
jdbcDriverSchema.setRequired(true);
ConnConfProperty jdbcDriver = new ConnConfProperty();
jdbcDriver.setSchema(jdbcDriverSchema);
jdbcDriver.setValues(Collections.singletonList("org.h2.Driver"));
conf.add(user);
conf.add(keyColumn);
conf.add(jdbcUrlTemplate);
conf.add(passwordColumn);
conf.add(table);
conf.add(password);
conf.add(jdbcDriver);
// set connector configuration
connectorTO.setConfiguration(conf);
Boolean verify = connectorService.check(connectorTO);
assertTrue(verify);