Best Citrus code snippet using com.consol.citrus.dsl.builder.InputActionBuilder.result
Source:DefaultTestRunner.java
1/*2 * Copyright 2006-2015 the original author or authors.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package com.consol.citrus.dsl.runner;17import com.consol.citrus.*;18import com.consol.citrus.actions.*;19import com.consol.citrus.container.*;20import com.consol.citrus.context.TestContext;21import com.consol.citrus.dsl.builder.*;22import com.consol.citrus.dsl.container.FinallySequence;23import com.consol.citrus.exceptions.CitrusRuntimeException;24import com.consol.citrus.exceptions.TestCaseFailedException;25import com.consol.citrus.message.MessageType;26import com.consol.citrus.report.TestActionListeners;27import com.consol.citrus.script.GroovyAction;28import com.consol.citrus.server.Server;29import org.slf4j.Logger;30import org.slf4j.LoggerFactory;31import org.springframework.context.ApplicationContext;32import org.springframework.util.CollectionUtils;33import java.util.*;34/**35 * Default test runner implementation. Provides Java DSL methods for test actions. Immediately executes test actions as36 * they were built. This way the test case grows with each test action and changes for instance to the test context (variables) are37 * immediately visible.38 *39 * @author Christoph Deppisch40 * @since 2.341 */42public class DefaultTestRunner implements TestRunner {43 /** Logger */44 private static Logger log = LoggerFactory.getLogger(DefaultTestRunner.class);45 /** This builders test case */46 private final TestCase testCase;47 /** This runners test context */48 private TestContext context;49 /** Spring bean application context */50 private ApplicationContext applicationContext;51 /** Optional stack of containers cached for execution */52 protected Stack<AbstractActionContainer> containers = new Stack<>();53 /** Default constructor */54 public DefaultTestRunner() {55 this(new TestCase());56 testClass(this.getClass());57 name(this.getClass().getSimpleName());58 packageName(this.getClass().getPackage().getName());59 }60 /**61 * Constructor initializing test case.62 * @param testCase63 */64 protected DefaultTestRunner(TestCase testCase) {65 this.testCase = testCase;66 }67 /**68 * Constructor using Spring bean application context.69 * @param applicationContext70 * @param context71 */72 public DefaultTestRunner(ApplicationContext applicationContext, TestContext context) {73 this();74 this.applicationContext = applicationContext;75 this.context = context;76 try {77 initialize();78 } catch (Exception e) {79 throw new CitrusRuntimeException("Failed to setup test runner", e);80 }81 }82 protected void initialize() {83 testCase.setTestRunner(true);84 testCase.setTestActionListeners(applicationContext.getBean(TestActionListeners.class));85 if (!applicationContext.getBeansOfType(SequenceBeforeTest.class).isEmpty()) {86 testCase.setBeforeTest(CollectionUtils.arrayToList(applicationContext.getBeansOfType(SequenceBeforeTest.class).values().toArray()));87 }88 if (!applicationContext.getBeansOfType(SequenceAfterTest.class).isEmpty()) {89 testCase.setAfterTest(CollectionUtils.arrayToList(applicationContext.getBeansOfType(SequenceAfterTest.class).values().toArray()));90 }91 }92 @Override93 public void testClass(Class<?> type) {94 getTestCase().setTestClass(type);95 }96 @Override97 public void name(String name) {98 testCase.setBeanName(name);99 testCase.setName(name);100 }101 @Override102 public void description(String description) {103 getTestCase().setDescription(description);104 }105 @Override106 public void author(String author) {107 getTestCase().getMetaInfo().setAuthor(author);108 }109 @Override110 public void packageName(String packageName) {111 getTestCase().setPackageName(packageName);112 }113 @Override114 public void status(TestCaseMetaInfo.Status status) {115 getTestCase().getMetaInfo().setStatus(status);116 }117 @Override118 public void creationDate(Date date) {119 getTestCase().getMetaInfo().setCreationDate(date);120 }121 @Override122 public void start() {123 testCase.start(context);124 }125 @Override126 public void stop() {127 try {128 if (!CollectionUtils.isEmpty(context.getExceptions())) {129 CitrusRuntimeException ex = context.getExceptions().remove(0);130 testCase.setTestResult(TestResult.failed(testCase.getName(), testCase.getTestClass().getName(), ex));131 throw new TestCaseFailedException(ex);132 }133 } finally {134 testCase.finish(context);135 }136 }137 @Override138 public <T> T variable(String name, T value) {139 testCase.getVariableDefinitions().put(name, value);140 if (value instanceof String) {141 String resolved = context.replaceDynamicContentInString(value.toString());142 context.setVariable(name, resolved);143 return (T) resolved;144 } else {145 context.setVariable(name, value);146 return value;147 }148 }149 @Override150 public <T extends TestAction> T run(T testAction) {151 if (testAction instanceof TestActionContainer) {152 if (containers.lastElement().equals(testAction)) {153 containers.pop();154 } else {155 throw new CitrusRuntimeException("Invalid use of action containers - the container execution is not expected!");156 }157 if (testAction instanceof FinallySequence) {158 testCase.getFinalActions().addAll(((FinallySequence) testAction).getActions());159 return testAction;160 }161 }162 if (!containers.isEmpty()) {163 containers.lastElement().addTestAction(testAction);164 } else {165 testCase.addTestAction(testAction);166 testCase.executeAction(testAction, context);167 }168 return testAction;169 }170 @Override171 public ApplyTestBehaviorAction applyBehavior(TestBehavior behavior) {172 ApplyTestBehaviorAction action = new ApplyTestBehaviorAction(this, behavior);173 behavior.setApplicationContext(applicationContext);174 action.execute(context);175 return action;176 }177 @Override178 public <T extends AbstractActionContainer> AbstractTestContainerBuilder<T> container(T container) {179 AbstractTestContainerBuilder<T> containerBuilder = new AbstractTestContainerBuilder<T>(this, container) {};180 containers.push(containerBuilder.build());181 return containerBuilder;182 }183 @Override184 public CreateVariablesAction createVariable(String variableName, String value) {185 CreateVariablesAction action = new CreateVariablesAction();186 action.getVariables().put(variableName, value);187 return run(action);188 }189 @Override190 public AntRunAction antrun(BuilderSupport<AntRunBuilder> configurer) {191 AntRunBuilder builder = new AntRunBuilder();192 configurer.configure(builder);193 return run(builder.build());194 }195 @Override196 public EchoAction echo(String message) {197 EchoAction action = new EchoAction();198 action.setMessage(message);199 return run(action);200 }201 @Override202 public ExecutePLSQLAction plsql(BuilderSupport<ExecutePLSQLBuilder> configurer) {203 ExecutePLSQLBuilder builder = new ExecutePLSQLBuilder();204 configurer.configure(builder);205 return run(builder.build());206 }207 @Override208 public ExecuteSQLAction sql(BuilderSupport<ExecuteSQLBuilder> configurer) {209 ExecuteSQLBuilder builder = new ExecuteSQLBuilder();210 configurer.configure(builder);211 return run(builder.build());212 }213 @Override214 public ExecuteSQLQueryAction query(BuilderSupport<ExecuteSQLQueryBuilder> configurer) {215 ExecuteSQLQueryBuilder builder = new ExecuteSQLQueryBuilder();216 configurer.configure(builder);217 return run(builder.build());218 }219 @Override220 public FailAction fail(String message) {221 FailAction action = new FailAction();222 action.setMessage(message);223 return run(action);224 }225 @Override226 public InputAction input(BuilderSupport<InputActionBuilder> configurer) {227 InputActionBuilder builder = new InputActionBuilder();228 configurer.configure(builder);229 return run(builder.build());230 }231 @Override232 public ReceiveTimeoutAction receiveTimeout(BuilderSupport<ReceiveTimeoutBuilder> configurer) {233 ReceiveTimeoutBuilder builder = new ReceiveTimeoutBuilder();234 configurer.configure(builder);235 return run(builder.build());236 }237 @Override238 public LoadPropertiesAction load(String filePath) {239 LoadPropertiesAction action = new LoadPropertiesAction();240 action.setFilePath(filePath);241 return run(action);242 }243 @Override244 public TestAction purgeQueues(BuilderSupport<PurgeJmsQueuesBuilder> configurer) {245 PurgeJmsQueuesBuilder builder = new PurgeJmsQueuesBuilder()246 .withApplicationContext(applicationContext);247 configurer.configure(builder);248 return run(builder.build());249 }250 @Override251 public PurgeMessageChannelAction purgeChannels(BuilderSupport<PurgeChannelsBuilder> configurer) {252 PurgeChannelsBuilder builder = new PurgeChannelsBuilder();253 builder.channelResolver(applicationContext);254 configurer.configure(builder);255 return run(builder.build());256 }257 @Override258 public PurgeEndpointAction purgeEndpoints(BuilderSupport<PurgeEndpointsBuilder> configurer) {259 PurgeEndpointsBuilder builder = new PurgeEndpointsBuilder()260 .withApplicationContext(applicationContext);261 configurer.configure(builder);262 return run(builder.build());263 }264 @Override265 public ReceiveMessageAction receive(BuilderSupport<ReceiveMessageBuilder> configurer) {266 ReceiveMessageBuilder<ReceiveMessageAction, ReceiveMessageBuilder> builder = new ReceiveMessageBuilder()267 .messageType(MessageType.XML)268 .withApplicationContext(applicationContext);269 configurer.configure(builder);270 return (ReceiveMessageAction) run(builder.build().getDelegate());271 }272 @Override273 public SendMessageAction send(BuilderSupport<SendMessageBuilder> configurer) {274 SendMessageBuilder<SendMessageAction, SendMessageBuilder> builder = new SendMessageBuilder()275 .withApplicationContext(applicationContext);276 configurer.configure(builder);277 return (SendMessageAction) run(builder.build().getDelegate());278 }279 @Override280 public SleepAction sleep() {281 return run(new SleepAction());282 }283 @Override284 public SleepAction sleep(long milliseconds) {285 SleepAction action = new SleepAction();286 action.setMilliseconds(String.valueOf(milliseconds));287 return run(action);288 }289 @Override290 @Deprecated291 public Wait waitFor(BuilderSupport<WaitBuilder> configurer) {292 WaitBuilder builder = new WaitBuilder(null, new Wait());293 configurer.configure(builder);294 containers.push(builder.build());295 return run(builder.build());296 }297 @Override298 public WaitBuilder waitFor() {299 WaitBuilder builder = new WaitBuilder(this, new Wait());300 containers.push(builder.build());301 return builder;302 }303 @Override304 public StartServerAction start(Server... servers) {305 StartServerAction action = new StartServerAction();306 action.getServerList().addAll(Arrays.asList(servers));307 return run(action);308 }309 @Override310 public StartServerAction start(Server server) {311 StartServerAction action = new StartServerAction();312 action.setServer(server);313 return run(action);314 }315 @Override316 public StopServerAction stop(Server... servers) {317 StopServerAction action = new StopServerAction();318 action.getServerList().addAll(Arrays.asList(servers));319 return run(action);320 }321 @Override322 public StopServerAction stop(Server server) {323 StopServerAction action = new StopServerAction();324 action.setServer(server);325 return run(action);326 }327 @Override328 public StopTimeAction stopTime() {329 return run(new StopTimeAction());330 }331 @Override332 public StopTimeAction stopTime(String id) {333 StopTimeAction action = new StopTimeAction();334 action.setId(id);335 return run(action);336 }337 @Override338 public StopTimeAction stopTime(String id, String suffix) {339 StopTimeAction action = new StopTimeAction();340 action.setId(id);341 action.setSuffix(suffix);342 return run(action);343 }344 @Override345 public TraceVariablesAction traceVariables() {346 return run(new TraceVariablesAction());347 }348 @Override349 public TraceVariablesAction traceVariables(String... variables) {350 TraceVariablesAction action = new TraceVariablesAction();351 action.setVariableNames(Arrays.asList(variables));352 return run(action);353 }354 @Override355 public GroovyAction groovy(BuilderSupport<GroovyActionBuilder> configurer) {356 GroovyActionBuilder builder = new GroovyActionBuilder();357 configurer.configure(builder);358 return run(builder.build());359 }360 @Override361 public TransformAction transform(BuilderSupport<TransformActionBuilder> configurer) {362 TransformActionBuilder builder = new TransformActionBuilder();363 configurer.configure(builder);364 return run(builder.build());365 }366 @Override367 public AssertExceptionBuilder assertException() {368 AssertExceptionBuilder builder = new AssertExceptionBuilder(this);369 containers.push(builder.build());370 return builder;371 }372 @Override373 public CatchExceptionBuilder catchException() {374 CatchExceptionBuilder builder = new CatchExceptionBuilder(this);375 containers.push(builder.build());376 return builder;377 }378 @Override379 public AssertSoapFaultBuilder assertSoapFault() {380 AssertSoapFaultBuilder builder = new AssertSoapFaultBuilder(this)381 .withApplicationContext(applicationContext);382 containers.push(builder.build());383 return builder;384 }385 @Override386 public ConditionalBuilder conditional() {387 ConditionalBuilder builder = new ConditionalBuilder(this);388 containers.push(builder.build());389 return builder;390 }391 @Override392 public IterateBuilder iterate() {393 IterateBuilder builder = new IterateBuilder(this);394 containers.push(builder.build());395 return builder;396 }397 @Override398 public ParallelBuilder parallel() {399 ParallelBuilder builder = new ParallelBuilder(this);400 containers.push(builder.build());401 return builder;402 }403 @Override404 public RepeatOnErrorBuilder repeatOnError() {405 RepeatOnErrorBuilder builder = new RepeatOnErrorBuilder(this);406 containers.push(builder.build());407 return builder;408 }409 @Override410 public RepeatBuilder repeat() {411 RepeatBuilder builder = new RepeatBuilder(this);412 containers.push(builder.build());413 return builder;414 }415 @Override416 public SequenceBuilder sequential() {417 SequenceBuilder builder = new SequenceBuilder(this);418 containers.push(builder.build());419 return builder;420 }421 @Override422 public AsyncBuilder async() {423 AsyncBuilder builder = new AsyncBuilder(this);424 containers.push(builder.build());425 return builder;426 }427 @Override428 public TimerBuilder timer() {429 TimerBuilder builder = new TimerBuilder(this);430 containers.push(builder.build());431 return builder;432 }433 @Override434 public StopTimerAction stopTimer(String timerId) {435 StopTimerAction action = new StopTimerAction();436 action.setTimerId(timerId);437 return run(action);438 }439 @Override440 public StopTimerAction stopTimers() {441 StopTimerAction action = new StopTimerAction();442 return run(action);443 }444 @Override445 public TestAction docker(BuilderSupport<DockerActionBuilder> configurer) {446 DockerActionBuilder builder = new DockerActionBuilder();447 configurer.configure(builder);448 return run(builder.build());449 }450 @Override451 public TestAction kubernetes(BuilderSupport<KubernetesActionBuilder> configurer) {452 KubernetesActionBuilder builder = new KubernetesActionBuilder();453 configurer.configure(builder);454 return run(builder.build());455 }456 @Override457 public TestAction selenium(BuilderSupport<SeleniumActionBuilder> configurer) {458 SeleniumActionBuilder builder = new SeleniumActionBuilder();459 configurer.configure(builder);460 return run(builder.build());461 }462 @Override463 public TestAction http(BuilderSupport<HttpActionBuilder> configurer) {464 HttpActionBuilder builder = new HttpActionBuilder()465 .withApplicationContext(applicationContext);466 configurer.configure(builder);467 return run(builder.build()).getDelegate();468 }469 @Override470 public TestAction soap(BuilderSupport<SoapActionBuilder> configurer) {471 SoapActionBuilder builder = new SoapActionBuilder()472 .withApplicationContext(applicationContext);473 configurer.configure(builder);474 return run(builder.build()).getDelegate();475 }476 @Override477 public TestAction camel(BuilderSupport<CamelRouteActionBuilder> configurer) {478 CamelRouteActionBuilder builder = new CamelRouteActionBuilder()479 .withApplicationContext(applicationContext);480 configurer.configure(builder);481 return run(builder.build()).getDelegate();482 }483 @Override484 public TestAction zookeeper(BuilderSupport<ZooActionBuilder> configurer) {485 ZooActionBuilder builder = new ZooActionBuilder()486 .withApplicationContext(applicationContext);487 configurer.configure(builder);488 return run(builder.build());489 }490 @Override491 public Template applyTemplate(BuilderSupport<TemplateBuilder> configurer) {492 TemplateBuilder builder = new TemplateBuilder();493 configurer.configure(builder);494 builder.load(applicationContext);495 configurer.configure(builder);496 return run(builder.build());497 }498 @Override499 public FinallySequenceBuilder doFinally() {500 FinallySequenceBuilder builder = new FinallySequenceBuilder(this);501 containers.push(builder.build());502 return builder;503 }504 /**505 * Gets the test context.506 * @return507 */508 public TestContext getTestContext() {509 return context;510 }511 /**512 * Sets the test context.513 * @param context514 */515 public void setTestContext(TestContext context) {516 this.context = context;517 }518 /**519 * Gets the value of the applicationContext property.520 *521 * @return the applicationContext522 */523 public ApplicationContext getApplicationContext() {524 return applicationContext;525 }526 /**527 * Sets the application context either from ApplicationContextAware injection or from outside.528 * @param applicationContext529 */530 public void setApplicationContext(ApplicationContext applicationContext) {531 this.applicationContext = applicationContext;532 }533 @Override534 public TestCase getTestCase() {535 return testCase;536 }537}...
Source:JUnit4CitrusTestDesigner.java
1/*2 * Copyright 2006-2015 the original author or authors.3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package com.consol.citrus.dsl.junit;17import com.consol.citrus.*;18import com.consol.citrus.actions.*;19import com.consol.citrus.container.AbstractActionContainer;20import com.consol.citrus.context.TestContext;21import com.consol.citrus.dsl.builder.*;22import com.consol.citrus.dsl.design.*;23import com.consol.citrus.dsl.simulation.TestSimulator;24import com.consol.citrus.endpoint.Endpoint;25import com.consol.citrus.exceptions.TestCaseFailedException;26import com.consol.citrus.junit.CitrusJUnit4Runner;27import com.consol.citrus.server.Server;28import org.slf4j.Logger;29import org.slf4j.LoggerFactory;30import org.springframework.context.ApplicationContext;31import org.springframework.core.io.Resource;32import org.springframework.util.ReflectionUtils;33import javax.sql.DataSource;34import java.lang.reflect.Method;35import java.util.Date;36import java.util.Map;37/**38 * JUnit Citrus test provides Java DSL access to builder pattern methods in39 * CitrusTestDesigner by simple method delegation.40 *41 * @author Christoph Deppisch42 * @since 2.343 */44public class JUnit4CitrusTestDesigner extends JUnit4CitrusTest implements TestDesigner, TestSimulator {45 /** Logger */46 protected final Logger log = LoggerFactory.getLogger(getClass());47 /** Test builder delegate */48 private TestDesigner testDesigner;49 @Override50 public void simulate(Method method, TestContext context, ApplicationContext applicationContext) {51 setApplicationContext(applicationContext);52 testDesigner = new TestDesignerSimulation(createTestDesigner(new CitrusJUnit4Runner.CitrusFrameworkMethod(method, method.getName(), method.getDeclaringClass().getPackage().getName()), context).getTestCase(), applicationContext, context);53 }54 @Override55 protected TestDesigner createTestDesigner(CitrusJUnit4Runner.CitrusFrameworkMethod frameworkMethod, TestContext context) {56 testDesigner = super.createTestDesigner(frameworkMethod, context);57 return testDesigner;58 }59 @Override60 protected void invokeTestMethod(CitrusJUnit4Runner.CitrusFrameworkMethod frameworkMethod, TestCase testCase, TestContext context) {61 if (isConfigure(frameworkMethod.getMethod())) {62 try {63 configure();64 citrus.run(testCase, context);65 } catch (TestCaseFailedException e) {66 throw e;67 } catch (Exception | AssertionError e) {68 testCase.setTestResult(TestResult.failed(testCase.getName(), testCase.getTestClass().getName(), e));69 testCase.finish(context);70 throw new TestCaseFailedException(e);71 }72 } else {73 super.invokeTestMethod(frameworkMethod, testCase, context);74 }75 }76 @Override77 protected final boolean isDesignerMethod(Method method) {78 return true;79 }80 @Override81 protected final boolean isRunnerMethod(Method method) {82 return false;83 }84 @Override85 protected void executeTest() {86 run(new CitrusJUnit4Runner.CitrusFrameworkMethod(ReflectionUtils.findMethod(this.getClass(), "configure"),87 this.getClass().getSimpleName(), this.getClass().getPackage().getName()));88 }89 /**90 * Main entrance method for builder pattern usage. Subclasses may override91 * this method and call Java DSL builder methods for adding test actions and92 * basic test case properties.93 */94 protected void configure() {95 }96 /**97 * Checks if the given method is this designer's configure method.98 * @param method99 * @return100 */101 private boolean isConfigure(Method method) {102 return method.getDeclaringClass().equals(this.getClass()) && method.getName().equals("configure");103 }104 @Override105 public TestCase getTestCase() {106 return testDesigner.getTestCase();107 }108 @Override109 public void testClass(Class<?> type) {110 testDesigner.testClass(type);111 }112 @Override113 public void name(String name) {114 testDesigner.name(name);115 }116 @Override117 public void description(String description) {118 testDesigner.description(description);119 }120 @Override121 public void author(String author) {122 testDesigner.author(author);123 }124 @Override125 public void packageName(String packageName) {126 testDesigner.packageName(packageName);127 }128 @Override129 public void status(TestCaseMetaInfo.Status status) {130 testDesigner.status(status);131 }132 @Override133 public void creationDate(Date date) {134 testDesigner.creationDate(date);135 }136 @Override137 public void variable(String name, Object value) {138 testDesigner.variable(name, value);139 }140 @Override141 public CreateVariablesAction createVariable(String variableName, String value) {142 return testDesigner.createVariable(variableName, value);143 }144 @Override145 public void action(TestAction testAction) {146 testDesigner.action(testAction);147 }148 @Override149 public ApplyTestBehaviorAction applyBehavior(TestBehavior behavior) {150 return testDesigner.applyBehavior(behavior);151 }152 @Override153 public <T extends AbstractActionContainer> AbstractTestContainerBuilder<T> container(T container) {154 return testDesigner.container(container);155 }156 @Override157 public AntRunBuilder antrun(String buildFilePath) {158 return testDesigner.antrun(buildFilePath);159 }160 @Override161 public EchoAction echo(String message) {162 return testDesigner.echo(message);163 }164 @Override165 public ExecutePLSQLBuilder plsql(DataSource dataSource) {166 return testDesigner.plsql(dataSource);167 }168 @Override169 public ExecuteSQLBuilder sql(DataSource dataSource) {170 return testDesigner.sql(dataSource);171 }172 @Override173 public ExecuteSQLQueryBuilder query(DataSource dataSource) {174 return testDesigner.query(dataSource);175 }176 @Override177 public ReceiveTimeoutBuilder receiveTimeout(Endpoint messageEndpoint) {178 return testDesigner.receiveTimeout(messageEndpoint);179 }180 @Override181 public ReceiveTimeoutBuilder receiveTimeout(String messageEndpointName) {182 return testDesigner.receiveTimeout(messageEndpointName);183 }184 @Override185 public FailAction fail(String message) {186 return testDesigner.fail(message);187 }188 @Override189 public InputActionBuilder input() {190 return testDesigner.input();191 }192 @Override193 public JavaActionBuilder java(String className) {194 return testDesigner.java(className);195 }196 @Override197 public JavaActionBuilder java(Class<?> clazz) {198 return testDesigner.java(clazz);199 }200 @Override201 public JavaActionBuilder java(Object instance) {202 return testDesigner.java(instance);203 }204 @Override205 public LoadPropertiesAction load(String filePath) {206 return testDesigner.load(filePath);207 }208 @Override209 public PurgeJmsQueuesBuilder purgeQueues() {210 return testDesigner.purgeQueues();211 }212 @Override213 public PurgeChannelsBuilder purgeChannels() {214 return testDesigner.purgeChannels();215 }216 @Override217 public PurgeEndpointsBuilder purgeEndpoints() {218 return testDesigner.purgeEndpoints();219 }220 @Override221 public ReceiveMessageBuilder receive(Endpoint messageEndpoint) {222 return testDesigner.receive(messageEndpoint);223 }224 @Override225 public ReceiveMessageBuilder receive(String messageEndpointName) {226 return testDesigner.receive(messageEndpointName);227 }228 @Override229 public SendMessageBuilder send(Endpoint messageEndpoint) {230 return testDesigner.send(messageEndpoint);231 }232 @Override233 public SendMessageBuilder send(String messageEndpointName) {234 return testDesigner.send(messageEndpointName);235 }236 @Override237 public SleepAction sleep() {238 return testDesigner.sleep();239 }240 @Override241 public SleepAction sleep(long milliseconds) {242 return testDesigner.sleep(milliseconds);243 }244 @Override245 public SleepAction sleep(double seconds) {246 return testDesigner.sleep(seconds);247 }248 @Override249 public WaitBuilder waitFor() {250 return testDesigner.waitFor();251 }252 @Override253 public StartServerAction start(Server... servers) {254 return testDesigner.start(servers);255 }256 @Override257 public StartServerAction start(Server server) {258 return testDesigner.start(server);259 }260 @Override261 public StopServerAction stop(Server... servers) {262 return testDesigner.stop(servers);263 }264 @Override265 public StopServerAction stop(Server server) {266 return testDesigner.stop(server);267 }268 @Override269 public StopTimeAction stopTime() {270 return testDesigner.stopTime();271 }272 @Override273 public StopTimeAction stopTime(String id) {274 return testDesigner.stopTime(id);275 }276 @Override277 public StopTimeAction stopTime(String id, String suffix) {278 return testDesigner.stopTime(id, suffix);279 }280 @Override281 public TraceVariablesAction traceVariables() {282 return testDesigner.traceVariables();283 }284 @Override285 public TraceVariablesAction traceVariables(String... variables) {286 return testDesigner.traceVariables(variables);287 }288 @Override289 public GroovyActionBuilder groovy(String script) {290 return testDesigner.groovy(script);291 }292 @Override293 public GroovyActionBuilder groovy(Resource scriptResource) {294 return testDesigner.groovy(scriptResource);295 }296 @Override297 public TransformActionBuilder transform() {298 return testDesigner.transform();299 }300 @Override301 public AssertExceptionBuilder assertException() {302 return testDesigner.assertException();303 }304 @Override305 public CatchExceptionBuilder catchException() {306 return testDesigner.catchException();307 }308 @Override309 public AssertSoapFaultBuilder assertSoapFault() {310 return testDesigner.assertSoapFault();311 }312 @Override313 public ConditionalBuilder conditional() {314 return testDesigner.conditional();315 }316 @Override317 public IterateBuilder iterate() {318 return testDesigner.iterate();319 }320 @Override321 public ParallelBuilder parallel() {322 return testDesigner.parallel();323 }324 @Override325 public RepeatOnErrorBuilder repeatOnError() {326 return testDesigner.repeatOnError();327 }328 @Override329 public RepeatBuilder repeat() {330 return testDesigner.repeat();331 }332 @Override333 public SequenceBuilder sequential() {334 return testDesigner.sequential();335 }336 @Override337 public AsyncBuilder async() {338 return testDesigner.async();339 }340 @Override341 public StopTimerAction stopTimer(String timerId) {342 return testDesigner.stopTimer(timerId);343 }344 @Override345 public StopTimerAction stopTimers() {346 return testDesigner.stopTimers();347 }348 @Override349 public TimerBuilder timer() {350 return testDesigner.timer();351 }352 @Override353 public DockerActionBuilder docker() {354 return testDesigner.docker();355 }356 @Override357 public KubernetesActionBuilder kubernetes() {358 return testDesigner.kubernetes();359 }360 @Override361 public SeleniumActionBuilder selenium() {362 return testDesigner.selenium();363 }364 @Override365 public HttpActionBuilder http() {366 return testDesigner.http();367 }368 @Override369 public SoapActionBuilder soap() {370 return testDesigner.soap();371 }372 @Override373 public CamelRouteActionBuilder camel() {374 return testDesigner.camel();375 }376 @Override377 public ZooActionBuilder zookeeper() {378 return testDesigner.zookeeper();379 }380 @Override381 public TemplateBuilder applyTemplate(String name) {382 return testDesigner.applyTemplate(name);383 }384 @Override385 public FinallySequenceBuilder doFinally() {386 return testDesigner.doFinally();387 }388 /**389 * Get the test variables.390 * @return391 */392 protected Map<String, Object> getVariables() {393 if (testDesigner instanceof DefaultTestDesigner) {394 return ((DefaultTestDesigner) testDesigner).getVariables();395 } else {396 return testDesigner.getTestCase().getVariableDefinitions();397 }398 }399}...
Source:InputActionBuilder.java
...48 return this;49 }50 51 /**52 * Stores the result to a test variable.53 * @param variable the variable to set54 */55 public InputActionBuilder result(String variable) {56 action.setVariable(variable);57 return this;58 }59 60 /**61 * Sets the valid answers.62 * @param answers the validAnswers to set63 */64 public InputActionBuilder answers(String... answers) {65 if (answers.length == 0) {66 throw new CitrusRuntimeException("Please specify proper answer possibilities for input action");67 }68 69 StringBuilder validAnswers = new StringBuilder();...
result
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.TestAction;3import com.consol.citrus.actions.ReceiveMessageAction;4import com.consol.citrus.context.TestContext;5import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;6import com.consol.citrus.message.Message;7import com.consol.citrus.message.MessageType;8import com.consol.citrus.validation.builder.DefaultMessageBuilder;9import com.consol.citrus.validation.xml.XmlMessageValidationContext;10import com.consol.citrus.validation.xml.XmlMessageValidationErrorHandler;11import com.consol.citrus.validation.xml.XmlMessageValidationProcessor;12import com.consol.citrus.validation.xml.XpathMessageValidationContext;13import com.consol.citrus.xml.XsdSchemaRepository;14import java.util.*;15public class ReceiveMessageActionBuilder implements TestActionBuilder.TestActionContainer {16 private final ReceiveMessageAction receiveMessageAction;17 public ReceiveMessageActionBuilder() {18 receiveMessageAction = new ReceiveMessageAction();19 }20 public ReceiveMessageActionBuilder message(Message message) {21 receiveMessageAction.setMessage(message);22 return this;23 }24 public ReceiveMessageActionBuilder message(MessageType messageType, String messagePayload) {25 receiveMessageAction.setMessageType(messageType);26 receiveMessageAction.setMessagePayload(messagePayload);27 return this;28 }29 public ReceiveMessageActionBuilder message(String messagePayload) {30 receiveMessageAction.setMessagePayload(messagePayload);31 return this;32 }33 public ReceiveMessageActionBuilder messageType(MessageType messageType) {34 receiveMessageAction.setMessageType(messageType);35 return this;36 }37 public ReceiveMessageActionBuilder messageBuilder(DefaultMessageBuilder messageBuilder) {38 receiveMessageAction.setMessageBuilder(messageBuilder);39 return this;40 }41 public ReceiveMessageActionBuilder messageValidator(XmlMessageValidationProcessor messageValidator) {42 receiveMessageAction.setMessageValidator(messageValidator);43 return this;44 }45 public ReceiveMessageActionBuilder schemaRepository(XsdSchemaRepository schemaRepository) {46 receiveMessageAction.setSchemaRepository(schemaRepository);47 return this;48 }49 public ReceiveMessageActionBuilder validationContext(XmlMessageValidationContext validationContext) {50 receiveMessageAction.setValidationContext(validationContext);51 return this;52 }53 public ReceiveMessageActionBuilder messageSelector(String messageSelector) {54 receiveMessageAction.setMessageSelector(messageSelector);55 return this;56 }57 public ReceiveMessageActionBuilder messageSelector(Map<String, Object> messageSelector) {
result
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.actions.EchoAction;3import com.consol.citrus.context.TestContext;4import com.consol.citrus.dsl.TestRunner;5import com.consol.citrus.dsl.builder.InputActionBuilder;6public class InputActionBuilderTest {7 public static void main(String[] args) {8 TestRunner runner = new TestRunner();9 InputActionBuilder builder = runner.input();10 builder.message("myMessage");11 builder.header("myHeader");12 builder.payload("myPayload");13 builder.result("myResult");14 builder.build();15 }16}17Recommended Posts: How to use the header() method of com.consol.citrus.dsl.builder.InputActionBuilder class?18How to use the message() method of com.consol.citrus.dsl.builder.InputActionBuilder class?19How to use the payload() method of com.consol.citrus.dsl.builder.InputActionBuilder class?20How to use the message() method of com.consol.citrus.dsl.builder.ReceiveActionBuilder class?21How to use the header() method of com.consol.citrus.dsl.builder.ReceiveActionBuilder class?22How to use the payload() method of com.consol.citrus.dsl.builder.ReceiveActionBuilder class?23How to use the result() method of com.consol.citrus.dsl.builder.ReceiveActionBuilder class?24How to use the message() method of com.consol.citrus.dsl.builder.SendActionBuilder class?25How to use the header() method of com.consol.citrus.dsl.builder.SendActionBuilder class?26How to use the payload() method of com.consol.citrus.dsl.builder.SendActionBuilder class?27How to use the result() method of com.consol.citrus.dsl.builder.SendActionBuilder class?28How to use the message() method of com.consol.cit
result
Using AI Code Generation
1package com.consol.citrus.dsl.testng;2import com.consol.citrus.dsl.builder.InputActionBuilder;3import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;4import com.consol.citrus.dsl.builder.SendMessageActionBuilder;5import com.consol.citrus.dsl.builder.SendSoapMessageActionBuilder;6import com.consol.citrus.dsl.builder.SendTcpMessageActionBuilder;7import com.consol.citrus.dsl.builder.SendWebSocketMessageActionBuilder;8import com.consol.citrus.dsl.builder.SetVariableActionBuilder;9import com.consol.citrus.dsl.builder.SleepActionBuilder;10import com.consol.citrus.dsl.builder.StartServerActionBuilder;11import com.consol.citrus.dsl.builder.StopServerActionBuilder;12import com.consol.citrus.dsl.builder.StopTimeActionBuilder;13import com.consol.citrus.dsl.builder.TraceVariablesActionBuilder;14import com.consol.citrus.dsl.builder.ValidateActionBuilder;15import com.consol.citrus.dsl.builder.WaitActionBuilder;16import com.consol.citrus.dsl.builder.WaitConditionActionBuilder;17import com.consol.citrus.dsl.builder.WhileActionBuilder;18import com.consol.citrus.dsl.builder.XpathMessageConstructionInterceptorBuilder;19import com.consol.citrus.dsl.builder.XpathPayloadVariableExtractorBuilder;20import com.consol.citrus.dsl.builder.XpathResultExpressionBuilder;21import com.consol.citrus.dsl.builder.XPathSelectMessageValidatorBuilder;22import com.consol.citrus.dsl.builder.XmlMessageConstructionInterceptorBuilder;23import com.consol.citrus.dsl.builder.XmlPayloadVariableExtractorBuilder;24import com.consol.citrus.dsl.builder.XmlResultExpressionBuilder;25import com.consol.citrus.dsl.builder.XmlSchemaValidationContextBuilder;26import com.consol.citrus.dsl.builder.XmlSchemaValidationMessageValidatorBuilder;27import com.consol.citrus.dsl.builder.XmlSchemaValidationProcessorBuilder;28import com.consol.citrus.dsl.builder.XmlStringMessageValidatorBuilder;29import com.consol.citrus.dsl.builder.XmlStringResultExpressionBuilder;30import com.consol.citrus.dsl.builder.XmlXPathMessageValidatorBuilder;31import com.consol.citrus.dsl.builder.XmlXPathResultExpressionBuilder;32import com.consol.citrus.dsl.builder.XQueryMessageConstructionInterceptorBuilder;33import com.consol.citrus.dsl.builder.XQueryPayloadVariableExtractorBuilder;34import com.consol.citrus.dsl.builder.XQueryResultExpressionBuilder;35import com.consol.citrus.dsl
result
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.builder.AbstractTestContainerBuilder;3import com.consol.citrus.dsl.builder.DelegatingTestContainerBuilder;4import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;5import com.consol.citrus.dsl.builder.SendMessageActionBuilder;6import com.consol.citrus.message.MessageType;7import com.consol.citrus.testng.AbstractTestNGUnitTest;8import com.consol.citrus.validation.builder.DefaultMessageBuilder;9import com.consol.citrus.validation.builder.StaticMessageContentBuilder;10import com.consol.citrus.validation.json.JsonTextMessageValidationContext;11import com.consol.citrus.validation.script.GroovyScriptMessageProcessor;12import com.consol.citrus.variable.MessageHeaderVariableExtractor;13import org.testng.annotations.Test;14import java.util.Arrays;15import java.util.Collections;16import static com.consol.citrus.actions.CreateVariablesAction.Builder.createVariable;17import static com.consol.citrus.actions.EchoAction.Builder.echo;18import static com.consol.citrus.actions.FailAction.Builder.fail;19import static com.consol.citrus.actions.PurgeEndpointAction.Builder.purge;20import static com.consol.citrus.actions.SendMessageAction.Builder.send;21import static com.consol.citrus.actions.StopTimeAction.Builder.stopTime;22import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeAction;23import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeBuilder;24import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeBuilderAction;25import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeBuilderVariable;26import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeBuilderVariableAction;27import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeVariable;28import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeVariableAction;29import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeVariableBuilder;30import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeVariableBuilderAction;31import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeVariableBuilderVariable;32import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeVariableBuilderVariableAction;33import static com.consol.citrus.actions.StopTimeAction.Builder.stopTimeVariableVariable;34import static com.consol.citrus.actions.Stop
result
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.actions.ReceiveMessageAction;3import com.consol.citrus.dsl.builder.ReceiveMessageActionBuilder;4import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder;5import com.consol.citrus.dsl.builder.ReceiveTimeoutBuilder.ReceiveTimeoutBuilderSupport;6import com.consol.citrus.message.MessageType;7import com.consol.citrus.validation.builder.StaticMessageContentBuilder;8import com.consol.citrus.validation.xml.XmlMessageValidationContext;9import org.springframework.core.io.Resource;10import org.springframework.util.StringUtils;11import java.util.HashMap;12import java.util.Map;13public class ReceiveMessageActionBuilder extends AbstractTestActionBuilder<ReceiveMessageAction> implements ReceiveTimeoutBuilderSupport<ReceiveMessageActionBuilder> {14 private final ReceiveMessageAction receiveMessageAction = new ReceiveMessageAction();15 public ReceiveMessageActionBuilder(ReceiveMessageAction action) {16 super(action);17 }18 public ReceiveMessageActionBuilder() {19 super(new ReceiveMessageAction());20 }21 public ReceiveMessageActionBuilder endpoint(String endpointUri) {22 receiveMessageAction.setEndpointUri(endpointUri);23 return this;24 }25 public ReceiveMessageActionBuilder endpoint(Resource resource) {26 receiveMessageAction.setEndpointResource(resource);27 return this;28 }29 public ReceiveMessageActionBuilder endpoint(MessageEndpointBuilder endpoint) {30 receiveMessageAction.setEndpoint(endpoint.build());31 return this;32 }33 public ReceiveMessageActionBuilder message(String message) {34 receiveMessageAction.setMessage(new StaticMessageContentBuilder(message));35 return this;36 }
result
Using AI Code Generation
1public class 3 extends TestNGCitrusTestDesigner {2 public void 3() {3 variable("var1", "value1");4 variable("var2", "value2");5 variable("var3", "value3");6 variable("var4", "value4");7 variable("var5", "value5");8 variable("var6", "value6");9 variable("var7", "value7");10 variable("var8", "value8");11 variable("var9", "value9");12 variable("var10", "value10");13 variable("var11", "value11");14 variable("var12", "value12");15 variable("var13", "value13");16 variable("var14", "value14");17 variable("var15", "value15");18 variable("var16", "value16");19 variable("var17", "value17");20 variable("var18", "value18");21 variable("var19", "value19");22 variable("var20", "value20");23 variable("var21", "value21");24 variable("var22", "value22");25 variable("var23", "value23");26 variable("var24", "value24");27 variable("var25", "value25");28 variable("var26", "value26");29 variable("var27", "value27");30 variable("var28", "value28");31 variable("var29", "value29");32 variable("var30", "value30");33 variable("var31", "value31");34 variable("var32", "value32");35 variable("var33", "value33");36 variable("var34", "value34");37 variable("var35", "value35");38 variable("var36", "value36");39 variable("var37", "value37");40 variable("var38", "value38");41 variable("var39", "value39");42 variable("var40", "value40");43 variable("var41", "value41");44 variable("var42", "value42");45 variable("var43", "value43");46 variable("var44", "value44");47 variable("var45", "value45");48 variable("var46", "value46");49 variable("var47", "value47");50 variable("var48
result
Using AI Code Generation
1public class 3 extends TestNGCitrusTestDesigner {2 public void configure() {3 variable("var1", "value1");4 variable("var2", "value2");5 variable("var3", "value3");6 echo("${var1}, ${var2}, ${var3}");7 variable("var1", "value4");8 variable("var2", "value5");9 variable("var3", "value6");10 echo("${var1}, ${var2}, ${var3}");11 }12}13public class 4 extends TestNGCitrusTestDesigner {14 public void configure() {15 variable("var1", "value1");16 variable("var2", "value2");17 variable("var3", "value3");18 echo("${var1}, ${var2}, ${var3}");19 variable("var1", "value4");20 variable("var2", "value5");21 variable("var3", "value6");22 echo("${var1}, ${var2}, ${var3}");23 }24}25public class 5 extends TestNGCitrusTestDesigner {26 public void configure() {27 variable("var1", "value1");28 variable("var2", "value2");29 variable("var3", "value3");30 echo("${var1}, ${var2}, ${var3}");31 variable("var1", "value4");32 variable("var2", "value5");33 variable("var3", "value6");34 echo("${var1}, ${var2}, ${var3}");35 }36}37public class 6 extends TestNGCitrusTestDesigner {38 public void configure() {39 variable("var1", "value1");40 variable("var2", "value2");41 variable("var3", "value3");42 echo("${var1}, ${var2}, ${var3}");43 variable("var1", "value4");
result
Using AI Code Generation
1public class 3 extends TestNGCitrusTestDesigner {2 public void configure() {3 echo("Hello World!");4 }5}6public class 4 extends TestNGCitrusTestDesigner {7 public void configure() {8 echo("Hello World!");9 }10}11public class 5 extends TestNGCitrusTestDesigner {12 public void configure() {13 echo("Hello World!");14 }15}16public class 6 extends TestNGCitrusTestDesigner {17 public void configure() {18 echo("Hello World!");19 }20}21public class 7 extends TestNGCitrusTestDesigner {22 public void configure() {23 echo("Hello World!");24 }25}26public class 8 extends TestNGCitrusTestDesigner {27 public void configure() {28 echo("Hello World!");29 }30}31public class 9 extends TestNGCitrusTestDesigner {32 public void configure() {33 echo("Hello World!");34 }35}36public class 10 extends TestNGCitrusTestDesigner {37 public void configure() {38 echo("Hello World!");39 }40}41public class 11 extends TestNGCitrusTestDesigner {42 public void configure() {43 echo("Hello World!");44 }45}
result
Using AI Code Generation
1public class 3 {2 public static void main(String[] args) {3 Citrus citrus = Citrus.newInstance();4 citrus.run(new TestCase() {5 public void execute(TestContext context) {6 echo("Hello World!");7 echo("Hello World
result
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class ResultJavaITest extends TestNGCitrusTestDesigner {5public void resultJavaITest() {6http(action -> action.client(httpClient).receive().response(HttpStatus.OK).messageType(MessageType.PLAINTEXT));7}8}9package com.consol.citrus.dsl.builder;10import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;11import org.testng.annotations.Test;12public class ResultJavaITest extends TestNGCitrusTestDesigner {13public void resultJavaITest() {14receiveTimeout(action -> action.endpoint(myEndpoint).timeout(5000L));15}16}17package com.consol.citrus.dsl.builder;18import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;19import org.testng.annotations.Test;20public class ResultJavaITest extends TestNGCitrusTestDesigner {21public void resultJavaITest() {22sendTimeout(action -> action.endpoint(myEndpoint).timeout(5000L));23}24}25package com.consol.citrus.dsl.builder;26import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;27import org.testng.annotations.Test;28public class ResultJavaITest extends TestNGCitrusTestDesigner {29public void resultJavaITest() {30stopTime(action -> action.name("myTimer"));31}32}33package com.consol.citrus.dsl.builder;34import com
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!