@Test public void testExecutePLSQLBuilderWithStatement() { MockBuilder builder = new MockBuilder() { @Override public void configure() { plsql(dataSource) .statement("Test Statement") .statement("Test2 Statement") .statement("Test3 Statement"); } }; builder.run(null, null); Assert.assertEquals(builder.testCase().getActions().size(), 1); Assert.assertEquals( builder.testCase().getActions().get(0).getClass(), ExecutePLSQLAction.class); ExecutePLSQLAction action = (ExecutePLSQLAction) builder.testCase().getActions().get(0); Assert.assertEquals(action.getName(), ExecutePLSQLAction.class.getSimpleName()); Assert.assertEquals(action.isIgnoreErrors(), false); Assert.assertEquals( action.getStatements().toString(), "[Test Statement, Test2 Statement, Test3 Statement]"); Assert.assertNull(action.getScript()); Assert.assertNull(action.getSqlResourcePath()); Assert.assertEquals(action.getDataSource(), dataSource); }
@Test public void testExecutePLSQLBuilderWithSQLResource() throws IOException { MockBuilder builder = new MockBuilder() { @Override public void configure() { plsql(dataSource).sqlResource(sqlResource); } }; reset(sqlResource); expect(sqlResource.getInputStream()) .andReturn(new ByteArrayInputStream("testScript".getBytes())) .once(); replay(sqlResource); builder.run(null, null); Assert.assertEquals(builder.testCase().getActions().size(), 1); Assert.assertEquals( builder.testCase().getActions().get(0).getClass(), ExecutePLSQLAction.class); ExecutePLSQLAction action = (ExecutePLSQLAction) builder.testCase().getActions().get(0); Assert.assertEquals(action.getName(), ExecutePLSQLAction.class.getSimpleName()); Assert.assertEquals(action.isIgnoreErrors(), false); Assert.assertEquals(action.getStatements().size(), 0L); Assert.assertEquals(action.getScript(), "testScript"); Assert.assertEquals(action.getDataSource(), dataSource); }
@Test public void testExecutePLSQLBuilderWithInlineScript() { MockBuilder builder = new MockBuilder(applicationContext) { @Override public void configure() { plsql(dataSource).ignoreErrors(true).sqlScript("testScript"); } }; builder.run(null, null); Assert.assertEquals(builder.testCase().getActions().size(), 1); Assert.assertEquals( builder.testCase().getActions().get(0).getClass(), ExecutePLSQLAction.class); ExecutePLSQLAction action = (ExecutePLSQLAction) builder.testCase().getActions().get(0); Assert.assertEquals(action.getName(), "plsql"); Assert.assertEquals(action.isIgnoreErrors(), true); Assert.assertEquals(action.getStatements().size(), 0L); Assert.assertNull(action.getSqlResourcePath()); Assert.assertEquals(action.getScript(), "testScript"); Assert.assertEquals(action.getDataSource(), dataSource); }