use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class RepositoryUpdateTest method testRepositoryChange.
@Test
public void testRepositoryChange() throws PersistenceException {
//$NON-NLS-1$
String id = "testId";
try {
//$NON-NLS-1$ //$NON-NLS-2$
IComponent component = ComponentsFactoryProvider.getInstance().get("tSalesforceInput", "DI");
Node node = new Node(component, new Process(new FakePropertyImpl()));
GenericConnection connection = (GenericConnection) createBasicConnection(id).getConnection();
setupPropertiesWithoutProxy(id);
updateNode(id, node, connection);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.userPassword.userId", "\"myUser\"");
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.userPassword.password", "\"myPassword\"");
//$NON-NLS-1$
testRepositoryValue(node, "connection.proxy.useProxy", Boolean.FALSE);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.host", "\"\"");
//$NON-NLS-1$
testRepositoryValue(node, "connection.proxy.port", null);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.userPassword.userId", "\"\"");
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.userPassword.password", "\"\"");
setupPropertiesWithProxy(id);
updateNode(id, node, connection);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.userPassword.userId", "\"myUser\"");
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.userPassword.password", "\"myPassword\"");
//$NON-NLS-1$
testRepositoryValue(node, "connection.proxy.useProxy", Boolean.TRUE);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.host", "\"host\"");
//$NON-NLS-1$
testRepositoryValue(node, "connection.proxy.port", 1234);
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.userPassword.userId", "\"proxyUser\"");
//$NON-NLS-1$ //$NON-NLS-2$
testRepositoryValue(node, "connection.proxy.userPassword.password", "\"proxyPassword\"");
} finally {
IRepositoryViewObject object = ProxyRepositoryFactory.getInstance().getLastVersion(id);
if (object != null) {
ProxyRepositoryFactory.getInstance().deleteObjectPhysical(object);
}
}
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class ProcessErrorUtilTest method testGetAllErrorMess.
/**
* Test method for
* {@link org.talend.designer.runprocess.ui.ProcessComposite#getAllErrorMess(org.talend.designer.runprocess.IProcessMessage)}
* .
*/
@Test
public void testGetAllErrorMess() {
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property1.setId("property1");
//$NON-NLS-1$
property1.setVersion("0.1");
//$NON-NLS-1$
property1.setLabel("ParentJob");
Process process = new Process(property1);
IComponent tOracleSPComponent = ComponentsFactoryProvider.getInstance().get("tOracleSP", ComponentCategory.CATEGORY_4_DI.getName());
Node tOracleSP_1 = new Node(tOracleSPComponent, process);
process.addNodeContainer(new NodeContainer(tOracleSP_1));
RunProcessContext context = new RunProcessContext(process);
String errorMessage1 = "Exception in component tOracleSP_1 (ParentJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
ProcessMessage message1 = new ProcessMessage(MsgType.STD_ERR, errorMessage1);
HashMap<String, IProcessMessage> errorMessMap = ProcessErrorUtil.getAllErrorMess(message1, context);
Assert.assertEquals(errorMessMap.get(tOracleSP_1.getUniqueName()).getContent(), errorMessage1);
String errorMessage2 = "Exception in component tOracleSP_1 (ChildJob)\njava.sql.SQLException: ORA-20000: Failed to execute one or more sql statements";
ProcessMessage message2 = new ProcessMessage(MsgType.STD_ERR, errorMessage2);
HashMap<String, IProcessMessage> errorMessMap2 = ProcessErrorUtil.getAllErrorMess(message2, context);
Assert.assertNull(errorMessMap2.get(tOracleSP_1.getUniqueName()));
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class JavaProcessorUtilitiesTest method testComputeLibrariesPathWithMissingJars.
@Test
public void testComputeLibrariesPathWithMissingJars() {
boolean headless = CommonsPlugin.isHeadless();
try {
// don't popup dialog to block ui
CommonsPlugin.setHeadless(true);
IComponent tLibraryLoadComponent = ComponentsFactoryProvider.getInstance().get("tLibraryLoad", ComponentCategory.CATEGORY_4_DI.getName());
Property property = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property.setId("property");
//$NON-NLS-1$
property.setVersion("0.1");
//$NON-NLS-1$
property.setLabel("test");
Process process = new Process(property);
Node tLibraryLoad_1 = new Node(tLibraryLoadComponent, process);
process.addNodeContainer(new NodeContainer(tLibraryLoad_1));
tLibraryLoad_1.getElementParameter("LIBRARY").setValue("computeLibrariesPath.jar");
Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
ProcessorException exception = null;
try {
JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
} catch (ProcessorException e) {
exception = e;
}
if (exception != null) {
Assert.assertTrue(exception.getMessage().contains("computeLibrariesPath.jar"));
} else {
fail("computeLibrariesPath failed for process test{tLibraryLoad},computeLibrariesPath.jar not found but no exception");
}
} finally {
CommonsPlugin.setHeadless(headless);
}
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class JavaProcessorUtilitiesTest method testComputeLibrariesPath.
@Test
public void testComputeLibrariesPath() {
boolean headless = CommonsPlugin.isHeadless();
try {
CommonsPlugin.setHeadless(true);
IComponent tFixedFlowComponent = ComponentsFactoryProvider.getInstance().get("tFixedFlowInput", ComponentCategory.CATEGORY_4_DI.getName());
IComponent tLogRowComponent = ComponentsFactoryProvider.getInstance().get("tLogRow", ComponentCategory.CATEGORY_4_DI.getName());
Property property = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property.setId("property");
//$NON-NLS-1$
property.setVersion("0.1");
//$NON-NLS-1$
property.setLabel("test");
Process process = new Process(property);
Node tFixedFlowInput_1 = new Node(tFixedFlowComponent, process);
createMetadataColumns(tFixedFlowInput_1.getMetadataList().get(0), 1);
Node tLogRow_1 = new Node(tLogRowComponent, process);
createMetadataColumns(tLogRow_1.getMetadataList().get(0), 1);
process.addNodeContainer(new NodeContainer(tFixedFlowInput_1));
process.addNodeContainer(new NodeContainer(tLogRow_1));
new Connection(tFixedFlowInput_1, tLogRow_1, EConnectionType.FLOW_MAIN, EConnectionType.FLOW_MAIN.getName(), "tFixedFlowInput_1", "row1", "row1", false);
Set<ModuleNeeded> neededLibraries = CorePlugin.getDefault().getDesignerCoreService().getNeededLibrariesForProcess(process, false);
try {
JavaProcessorUtilities.computeLibrariesPath(neededLibraries, process, new HashSet<ModuleNeeded>());
} catch (ProcessorException e) {
fail("computeLibrariesPath failed for process test{tFixedFlowInput->tLogRow}");
}
} finally {
CommonsPlugin.setHeadless(headless);
}
}
use of org.talend.core.model.components.IComponent in project tdi-studio-se by Talend.
the class RunProcessContextTest method testLoadLog4jContextFromProcess.
@Test
public void testLoadLog4jContextFromProcess() {
Property property1 = PropertiesFactory.eINSTANCE.createProperty();
//$NON-NLS-1$
property1.setId("property1");
//$NON-NLS-1$
property1.setVersion("0.1");
//$NON-NLS-1$
property1.setLabel("job1");
Process process = new Process(property1);
IComponent tMysqlInputComponent = //$NON-NLS-1$
ComponentsFactoryProvider.getInstance().get(//$NON-NLS-1$
"tMysqlInput", ComponentCategory.CATEGORY_4_DI.getName());
Node tMysqlInput_1 = new Node(tMysqlInputComponent, process);
process.addNodeContainer(new NodeContainer(tMysqlInput_1));
RunProcessContext context = new RunProcessContext(process);
Assert.assertFalse(context.isUseCustomLevel());
//$NON-NLS-1$
Assert.assertEquals("", context.getLog4jLevel());
//
process.getElementParameter(EParameterName.LOG4J_RUN_ACTIVATE.getName()).setValue(true);
//$NON-NLS-1$
process.getElementParameter(EParameterName.LOG4J_RUN_LEVEL.getName()).setValue("Info");
context.loadLog4jContextFromProcess();
Assert.assertTrue(context.isUseCustomLevel());
//$NON-NLS-1$
Assert.assertEquals("Info", context.getLog4jLevel());
}
Aggregations