use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class KinesisDatastoreRuntimeTestIT method doHealthChecks.
@Test
public void doHealthChecks() {
KinesisDatastoreProperties props = getDatastore();
RuntimeInfo ri = def.getRuntimeInfo(props);
try (SandboxedInstance si = RuntimeUtil.createRuntimeClass(ri, getClass().getClassLoader())) {
DatastoreRuntime runtime = (DatastoreRuntime) si.getInstance();
runtime.initialize(null, props);
Iterable<ValidationResult> validationResults = runtime.doHealthChecks(null);
Assert.assertEquals(ValidationResult.OK, validationResults.iterator().next());
// Wrong access key
{
KinesisDatastoreProperties wrongAccess = getDatastore();
wrongAccess.accessKey.setValue("wrong");
runtime.initialize(null, wrongAccess);
validationResults = runtime.doHealthChecks(null);
Assert.assertEquals(ValidationResult.Result.ERROR, validationResults.iterator().next().getStatus());
}
// Wrong screct key
{
KinesisDatastoreProperties wrongSecret = getDatastore();
wrongSecret.secretKey.setValue("wrong");
runtime.initialize(null, wrongSecret);
validationResults = runtime.doHealthChecks(null);
Assert.assertEquals(ValidationResult.Result.ERROR, validationResults.iterator().next().getStatus());
}
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class SalesforceBulkExecReaderTestIT method executeBulkInsert.
/**
* Test runtime of tSalesforceOutputBulk
*/
private void executeBulkInsert(TSalesforceBulkExecProperties bulkExecProperties, String random, int count) throws Throwable {
TSalesforceBulkExecDefinition definition = (TSalesforceBulkExecDefinition) getComponentService().getComponentDefinition(TSalesforceBulkExecDefinition.COMPONENT_NAME);
RuntimeInfo runtimeInfo = definition.getRuntimeInfo(ExecutionEngine.DI, bulkExecProperties, ConnectorTopology.OUTGOING);
try (SandboxedInstance sandboxedInstance = RuntimeUtil.createRuntimeClass(runtimeInfo, definition.getClass().getClassLoader())) {
SalesforceSource boundedSource = (SalesforceSource) sandboxedInstance.getInstance();
boundedSource.initialize(null, bulkExecProperties);
BoundedReader boundedReader = boundedSource.createReader(null);
try {
boolean hasRecord = boundedReader.start();
List<IndexedRecord> rows = new ArrayList<>();
while (hasRecord) {
rows.add((IndexedRecord) boundedReader.getCurrent());
hasRecord = boundedReader.advance();
}
checkRows(random, rows, count);
} finally {
boundedReader.close();
}
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class SalesforceModuleProperties method beforeModuleName.
// consider beforeActivate and beforeRender (change after to afterActivate)
public ValidationResult beforeModuleName() throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, getEffectiveConnection());
ValidationResult vr = ss.validate(null);
if (vr.getStatus() == ValidationResult.Result.OK) {
try {
List<NamedThing> moduleNames = ss.getSchemaNames(null);
moduleName.setPossibleNamedThingValues(moduleNames);
} catch (Exception ex) {
return ExceptionUtil.exceptionToValidationResult(ex);
}
} else {
return vr;
}
return ValidationResult.OK;
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class SalesforceModuleProperties method afterModuleName.
public ValidationResult afterModuleName() throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, getEffectiveConnection());
ValidationResult vr = ss.validate(null);
if (vr.getStatus() == ValidationResult.Result.OK) {
try {
Schema schema = ss.getEndpointSchema(null, moduleName.getStringValue());
main.schema.setValue(schema);
moduleName.setPossibleValues(Collections.emptyList());
} catch (Exception ex) {
throw new ComponentException(ExceptionUtil.exceptionToValidationResult(ex));
}
} else {
throw new ComponentException(vr);
}
return ValidationResult.OK;
}
}
use of org.talend.daikon.sandbox.SandboxedInstance in project components by Talend.
the class SalesforceConnectionProperties method validateTestConnection.
public ValidationResult validateTestConnection() throws Exception {
try (SandboxedInstance sandboxedInstance = getSandboxedInstance(SOURCE_OR_SINK_CLASS, USE_CURRENT_JVM_PROPS)) {
SalesforceRuntimeSourceOrSink ss = (SalesforceRuntimeSourceOrSink) sandboxedInstance.getInstance();
ss.initialize(null, SalesforceConnectionProperties.this);
ValidationResultMutable vr = new ValidationResultMutable(ss.validate(null));
if (vr.getStatus() == ValidationResult.Result.OK) {
vr.setMessage(MESSAGES.getMessage("connection.success"));
getForm(FORM_WIZARD).setAllowForward(true);
} else {
getForm(FORM_WIZARD).setAllowForward(false);
}
return vr;
}
}
Aggregations