How to use statements method of com.consol.citrus.dsl.builder.ExecutePLSQLBuilder class

Best Citrus code snippet using com.consol.citrus.dsl.builder.ExecutePLSQLBuilder.statements

Source:ExecutePLSQLBuilder.java Github

copy

Full Screen

...24import java.io.IOException;25import java.nio.charset.Charset;26import java.util.List;27/**28 * Creates an ExecutePLSQLAction, which executes PLSQL statements either declared inline as29 * PLSQL statements or given by an external file resource.30 *31 * @author Christoph Deppisch32 * @since 2.333 */34public class ExecutePLSQLBuilder extends AbstractTestActionBuilder<ExecutePLSQLAction> {35 /**36 * Constructor using action field.37 * @param action38 */39 public ExecutePLSQLBuilder(ExecutePLSQLAction action) {40 super(action);41 }42 /**43 * Default constructor.44 */45 public ExecutePLSQLBuilder() {46 super(new ExecutePLSQLAction());47 }48 /**49 * Sets the Spring JDBC template to use.50 * @param jdbcTemplate51 * @return52 */53 public ExecutePLSQLBuilder jdbcTemplate(JdbcTemplate jdbcTemplate) {54 action.setJdbcTemplate(jdbcTemplate);55 return this;56 }57 /**58 * Sets the transaction manager to use.59 * @param transactionManager60 * @return61 */62 public ExecutePLSQLBuilder transactionManager(PlatformTransactionManager transactionManager) {63 action.setTransactionManager(transactionManager);64 return this;65 }66 /**67 * Sets the transaction timeout to use.68 * @param transactionTimeout69 * @return70 */71 public ExecutePLSQLBuilder transactionTimeout(int transactionTimeout) {72 action.setTransactionTimeout(String.valueOf(transactionTimeout));73 return this;74 }75 /**76 * Sets the transaction timeout to use.77 * @param transactionTimeout78 * @return79 */80 public ExecutePLSQLBuilder transactionTimeout(String transactionTimeout) {81 action.setTransactionTimeout(transactionTimeout);82 return this;83 }84 /**85 * Sets the transaction isolation level to use.86 * @param isolationLevel87 * @return88 */89 public ExecutePLSQLBuilder transactionIsolationLevel(String isolationLevel) {90 action.setTransactionIsolationLevel(isolationLevel);91 return this;92 }93 /**94 * Sets the SQL data source.95 * @param dataSource96 * @return97 */98 public ExecutePLSQLBuilder dataSource(DataSource dataSource) {99 action.setDataSource(dataSource);100 return this;101 }102 /**103 * Adds a list of statements to execute.104 * @param statements105 */106 public ExecutePLSQLBuilder statements(List<String> statements) {107 action.getStatements().addAll(statements);108 return this;109 }110 /**111 * Adds a new statement tp the list of SQL executions.112 * @param sql113 * @return114 */115 public ExecutePLSQLBuilder statement(String sql) {116 action.getStatements().add(sql);117 return this;118 }119 /**120 * Setter for external file resource containing the SQL statements to execute.121 * @param filePath122 */123 public ExecutePLSQLBuilder sqlResource(String filePath) {124 action.setSqlResourcePath(filePath);125 return this;126 }127 /**128 * Setter for external file resource containing the SQL statements to execute.129 * @param sqlResource130 */131 public ExecutePLSQLBuilder sqlResource(Resource sqlResource) {132 return sqlResource(sqlResource, FileUtils.getDefaultCharset());133 }134 /**135 * Setter for external file resource containing the SQL statements to execute.136 * @param sqlResource137 * @param charset138 */139 public ExecutePLSQLBuilder sqlResource(Resource sqlResource, Charset charset) {140 try {141 action.setScript(FileUtils.readToString(sqlResource, charset));142 } catch (IOException e) {143 throw new CitrusRuntimeException("Failed to read sql resource", e);144 }145 return this;146 }147 /**148 * Setter for inline script.149 * @param script...

Full Screen

Full Screen

statements

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.builder.ExecutePLSQLBuilder;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import com.consol.citrus.message.MessageType;5public class ExecutePLSQLStatements extends TestNGCitrusTestDesigner {6 public void configure() {7 TestRunner runner = createTestRunner();8 ExecutePLSQLBuilder builder = new ExecutePLSQLBuilder();9 builder.name("ExecutePLSQLStatements");10 builder.dataSource("jdbc/myDataSource");11 builder.statements("CREATE TABLE mytable (id NUMBER, name VARCHAR2(20));");12 builder.statements("INSERT INTO mytable VALUES (1, 'John');");13 builder.statements("INSERT INTO mytable VALUES (2, 'Jane');");14 builder.statements("INSERT INTO mytable VALUES (3, 'Joe');");15 builder.statements("INSERT INTO mytable VALUES (4, 'Jill');");16 builder.statements("INSERT INTO mytable VALUES (5, 'Jack');");17 builder.statements("SELECT * FROM mytable;");18 builder.execute(runner);19 }20}21import com.consol.citrus.dsl.builder.ExecutePLSQLBuilder;22import com.consol.citrus.dsl.runner.TestRunner;23import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;24import com.consol.citrus.message.MessageType;25public class ExecutePLSQLStatements extends TestNGCitrusTestDesigner {26 public void configure() {27 TestRunner runner = createTestRunner();28 ExecutePLSQLBuilder builder = new ExecutePLSQLBuilder();29 builder.name("ExecutePLSQLStatements");30 builder.dataSource("jdbc/myDataSource");31 builder.statements("CREATE

Full Screen

Full Screen

statements

Using AI Code Generation

copy

Full Screen

1package com.consol.citrus.dsl.builder;2import java.util.ArrayList;3import java.util.List;4import com.consol.citrus.dsl.runner.TestRunner;5import com.consol.citrus.exceptions.CitrusRuntimeException;6import com.consol.citrus.message.MessageType;7import com.consol.citrus.testng.AbstractTestNGUnitTest;8import org.mockito.Mockito;9import org.testng.Assert;10import org.testng.annotations.Test;11public class ExecutePLSQLBuilderTest extends AbstractTestNGUnitTest {12 public void testExecutePLSQLBuilder() {13 MockTestRunner builder = new MockTestRunner(getClass().getSimpleName(), applicationContext, context) {14 public void execute() {15 executePLSQL(new ExecutePLSQLBuilder() {16 public void configure() {17 dataSource("myDataSource");18 statements("BEGIN " +19 "INSERT INTO TEST_TABLE (ID, NAME) VALUES (1, 'Citrus');" +20 "INSERT INTO TEST_TABLE (ID, NAME) VALUES (2, 'Citrus');" +21 "END;");22 }23 });24 }25 };26 builder.execute();27 Assert.assertEquals(builder.testCase().getActions().size(), 1);28 Assert.assertEquals(builder.testCase().getActions().get(0).getClass(), ExecutePLSQLAction.class);29 ExecutePLSQLAction action = (ExecutePLSQLAction) builder.testCase().getActions().get(0);30 Assert.assertEquals(action.getName(), "execute-plsql");31 Assert.assertEquals(action.getStatements().size(), 1);32 Assert.assertEquals(action.getStatements().get(0), "BEGIN INSERT INTO TEST_TABLE (ID, NAME) VALUES (1, 'Citrus');INSERT INTO TEST_TABLE (ID, NAME) VALUES (2, 'Citrus');END;");

Full Screen

Full Screen

statements

Using AI Code Generation

copy

Full Screen

1import com.consol.citrus.dsl.builder.ExecutePLSQLBuilder;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;4import com.consol.citrus.jdbc.message.JdbcMessageHeaders;5import org.springframework.jdbc.datasource.DriverManagerDataSource;6import org.springframework.jdbc.datasource.SingleConnectionDataSource;7import org.testng.annotations.Test;8public class ExecutePLSQLBuilderTest extends TestNGCitrusTestDesigner {9 public void executePLSQLBuilder() {10 DriverManagerDataSource dataSource = new DriverManagerDataSource();11 dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");12 dataSource.setUrl("jdbc:oracle:thin:@localhost:1521:XE");13 dataSource.setUsername("system");14 dataSource.setPassword("oracle");15 SingleConnectionDataSource singleConnectionDataSource = new SingleConnectionDataSource();16 singleConnectionDataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");17 singleConnectionDataSource.setUrl("jdbc:oracle:thin:@localhost:1521:XE");18 singleConnectionDataSource.setUsername("system");19 singleConnectionDataSource.setPassword("oracle");20 TestRunner runner = createTestRunner();21 runner.variable("id", "1");22 runner.variable("name", "John Doe");23 runner.variable("age", "25");24 .sql(dataSource)25 .statement("CREATE TABLE CITRUS (ID NUMBER, NAME VARCHAR2(255), AGE NUMBER)")26 .commit()27 .statement("INSERT INTO CITRUS (ID, NAME, AGE) VALUES (${id}, '${name}', ${age})")28 .commit()29 .statement("UPDATE CITRUS SET NAME = 'Jane Doe' WHERE ID = ${id}")30 .commit()31 .statement("DELETE FROM CITRUS WHERE ID = ${id}")32 .commit()33 .statement("DROP TABLE CITRUS")34 .commit()35 .statement("CREATE TABLE CITRUS (ID NUMBER, NAME VARCHAR2(255), AGE NUMBER)")36 .commit()37 .statement("INSERT INTO CITRUS (ID, NAME, AGE) VALUES (${id}, '${name}', ${age})")38 .commit()39 .statement("UPDATE CITRUS SET NAME = 'Jane Doe' WHERE ID =

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Citrus automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful