use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.
the class SalesforceTestBase method writeRows.
// Returns the rows written (having been re-read so they have their Ids)
protected List<IndexedRecord> writeRows(String random, SalesforceConnectionModuleProperties props, List<IndexedRecord> outputRows) throws Exception {
// $NON-NLS-1$
TSalesforceOutputProperties outputProps = new TSalesforceOutputProperties("output");
outputProps.copyValuesFrom(props);
outputProps.outputAction.setValue(TSalesforceOutputProperties.OutputAction.INSERT);
doWriteRows(outputProps, outputRows);
return readAndCheckRows(random, props, outputRows.size());
}
use of org.talend.components.salesforce.tsalesforceoutput.TSalesforceOutputProperties in project components by Talend.
the class SalesforceSessionReuseTestIT method testOutputReuseSession.
@Ignore("Need to solve test failed randomly")
@Test(timeout = 30_000)
public void testOutputReuseSession() throws Throwable {
File sessionFolder = new File(tempFolder.getRoot().getPath() + "/tsalesforceoutput/");
assertEquals(0, sessionFolder.getTotalSpace());
LOGGER.debug("session folder: " + sessionFolder.getAbsolutePath());
// $NON-NLS-1$
TSalesforceOutputProperties props = (TSalesforceOutputProperties) new TSalesforceOutputProperties("foo").init();
props.module.moduleName.setValue(EXISTING_MODULE_NAME);
props.module.main.schema.setValue(getMakeRowSchema(false));
props.connection = setupProps(null, !ADD_QUOTES);
// setup session function
props.connection.reuseSession.setValue(true);
props.connection.sessionDirectory.setValue(sessionFolder.getAbsolutePath());
// Init session
assertEquals(ValidationResult.Result.OK, testConnection(props).getStatus());
assertNotEquals(0, sessionFolder.getTotalSpace());
// Invalid session, test whether it can be renew the session
invalidSession(props.connection, null);
// length=260
String invalidName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
List<IndexedRecord> records = new ArrayList<>();
IndexedRecord r1 = new GenericData.Record(props.module.main.schema.getValue());
r1.put(0, invalidName);
records.add(r1);
try {
doWriteRows(props, records);
} catch (IOException e) {
// means exception caused by "Name" too long
assertTrue(e.getMessage().contains(invalidName));
LOGGER.debug("expect exception: " + e.getMessage());
}
// Set wrong pwd to test reuse session from session folder
props.connection.userPassword.password.setValue(WRONG_PWD);
try {
doWriteRows(props, records);
} catch (IOException e) {
Throwable caused = e.getCause();
if (caused != null && caused instanceof LoginFault) {
// Maybe throw exception when same account run in parallel
// The session maybe disabled by other test
assertEquals(ExceptionCode.INVALID_LOGIN, ((LoginFault) caused).getExceptionCode());
LOGGER.debug("session is disabled by other test!");
} else {
// means exception caused by "Name" too long
assertTrue(e.getMessage().contains(invalidName));
LOGGER.debug("expect exception: " + e.getMessage());
// This means that the session not disabled by other test
invalidSession(props.connection, null);
// This means that the session is disabled by current test
}
}
// Test reuse session fails with wrong pwd
try {
doWriteRows(props, records);
} catch (IOException e) {
Throwable caused = e.getCause();
// Should login fails with wrong pwd
assertThat(caused, instanceOf(LoginFault.class));
assertEquals(ExceptionCode.INVALID_LOGIN, ((LoginFault) caused).getExceptionCode());
LOGGER.debug("expect login fails: " + e.getMessage());
}
// Disable reuse session function
props.connection.reuseSession.setValue(false);
LOGGER.debug("expect login fails:");
assertEquals(ValidationResult.Result.ERROR, testConnection(props).getStatus());
}
Aggregations