public void test() throws EtlExecutorException { EtlExecutor se = prepareExecutor(null); se.execute(); assertEquals("jdbc:hsqldb:mem:propertiestest", params.getUrl()); assertEquals("sa", params.getUser()); assertEquals("", params.getPassword()); // check substituted properties in a context assertEquals("1", ctx.getParameter("a")); assertEquals("bar", ctx.getParameter("foo")); assertEquals("1", ctx.getParameter("var")); assertEquals("1|1|1|1|1|1", ctx.getParameter("b")); assertEquals("jdbc:hsqldb:mem", ctx.getParameter("url.prefix")); assertEquals("propertiestest", ctx.getParameter("dbname")); assertEquals("org.hsqldb.jdbcDriver", ctx.getParameter("driver")); assertEquals("org.hsqldb.jdbcDriver", ctx.getParameter("driver")); assertEquals("jdbc:hsqldb:mem:propertiestest", ctx.getParameter("url")); assertEquals("sa", ctx.getParameter("user")); assertEquals("", ctx.getParameter("password")); Map<String, String> extra = new HashMap<String, String>(); extra.put("var", "2"); se = prepareExecutor(extra); se.execute(); assertEquals("2", ctx.getParameter("var")); assertEquals("2|2|2|2|2|2", ctx.getParameter("b")); }
/** * A runnable adapter for {@link #execute()} method. * * <p>Please note that due to a checked exceptions limitation a {@link * scriptella.core.SystemException} is thrown instead of the {@link * scriptella.execution.EtlExecutorException}. * * @throws SystemException a wrapped {@link scriptella.execution.EtlExecutorException}. * @see #execute() */ public void run() throws SystemException { try { execute(); } catch (EtlExecutorException e) { throw new SystemException(e.getMessage(), e); } }
/** * Executes ETL based on a specified configuration. * * @param indicator progress indicator to use. * @return execution statistics for ETL execution. * @throws EtlExecutorException if ETL fails. */ @ThreadSafe public ExecutionStatistics execute(final ProgressIndicator indicator) throws EtlExecutorException { EtlContext ctx = null; JmxEtlManager etlManager = null; try { ctx = prepare(indicator); if (jmxEnabled) { etlManager = new JmxEtlManager(ctx); etlManager.register(); } execute(ctx); ctx.getProgressCallback().step(5, "Commiting transactions"); commitAll(ctx); } catch (Throwable e) { if (ctx != null) { rollbackAll(ctx); } throw new EtlExecutorException(e); } finally { if (ctx != null) { closeAll(ctx); ctx.getStatisticsBuilder().etlComplete(); ctx.getProgressCallback().complete(); } if (etlManager != null) { etlManager.unregister(); } } return ctx.getStatisticsBuilder().getStatistics(); }
public void test() throws EtlExecutorException { getConnection("text"); // Call just to close the DB final ByteArrayOutputStream out = new ByteArrayOutputStream(); testURLHandler = new TestURLHandler() { public InputStream getInputStream(final URL u) { return new ByteArrayInputStream( ("10,Ten,Ten,12-07-2012 10:00,10.1\n" + "11, Eleven , Eleven , 12-07-2012 11:00,-null-") .getBytes()); } public OutputStream getOutputStream(final URL u) { return out; } public int getContentLength(final URL u) { throw new UnsupportedOperationException(); } }; final EtlExecutor se = newEtlExecutor(); se.execute(); // 10,11 where parsed from CSV, 1,2,3 were directly inserted into DB String expectedResult = "1/One/One/11-07-2012 22:33/-null-\n" + "2/Two/ Two /11-07-2012 20:00/2.10\n" + "3/Three/ Three /11-07-2012 20:00/3.10\n" + "10/Ten/Ten/12-07-2012 10:00/10.10\n" + "11/Eleven/ Eleven /12-07-2012 11:00/-null-\n"; assertEquals(expectedResult, out.toString()); }