Best Citrus code snippet using com.consol.citrus.dsl.builder.KubernetesActionBuilder.endpoints
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:KubernetesActionBuilder.java
...79 }80 /**81 * Endpoints action builder.82 */83 public EndpointsActionBuilder endpoints() {84 return new EndpointsActionBuilder();85 }86 /**87 * Nodes action builder.88 */89 public NodesActionBuilder nodes() {90 return new NodesActionBuilder();91 }92 /**93 * Events action builder.94 */95 public EventsActionBuilder events() {96 return new EventsActionBuilder();97 }98 /**99 * Namespaces action builder.100 */101 public NamespacesActionBuilder namespaces() {102 return new NamespacesActionBuilder();103 }104 /**105 * Base kubernetes action builder with namespace.106 */107 public class NamespacedActionBuilder<R extends KubernetesResource> extends BaseActionBuilder<NamespacedActionBuilder<R>, R> {108 /**109 * Constructor using command.110 * @param command111 */112 NamespacedActionBuilder(KubernetesCommand<R> command) {113 super(command);114 }115 /**116 * Sets the namespace parameter.117 * @param key118 * @return119 */120 public NamespacedActionBuilder<R> namespace(String key) {121 command.namespace(key);122 return this;123 }124 }125 /**126 * Base kubernetes action builder with name option.127 */128 public class NamedActionBuilder<R extends KubernetesResource> extends BaseActionBuilder<NamedActionBuilder<R>, R> {129 /**130 * Constructor using command.131 * @param command132 */133 NamedActionBuilder(KubernetesCommand<R> command) {134 super(command);135 }136 /**137 * Sets the name parameter.138 * @param key139 * @return140 */141 public NamedActionBuilder<R> name(String key) {142 command.name(key);143 return this;144 }145 /**146 * Sets the namespace parameter.147 * @param key148 * @return149 */150 public NamedActionBuilder<R> namespace(String key) {151 command.namespace(key);152 return this;153 }154 }155 /**156 * Base kubernetes action builder.157 */158 public class BaseActionBuilder<T extends BaseActionBuilder, R extends KubernetesResource> extends AbstractTestActionBuilder<KubernetesExecuteAction> {159 /** Kubernetes command */160 protected final KubernetesCommand<R> command;161 /** Self reference for fluent API */162 protected T self;163 /**164 * Constructor using command.165 * @param command166 */167 BaseActionBuilder(KubernetesCommand<R> command) {168 super(KubernetesActionBuilder.this.action);169 self = (T) this;170 this.command = command;171 command(command);172 }173 /**174 * Adds expected command result.175 * @param result176 * @return177 */178 public T result(String result) {179 action.setCommandResult(result);180 return self;181 }182 /**183 * Adds JsonPath command result validation.184 * @param path185 * @param value186 * @return187 */188 public T validate(String path, Object value) {189 action.getCommandResultExpressions().put(path, value);190 return self;191 }192 /**193 * Adds command result callback.194 * @param callback195 * @return196 */197 public T validate(CommandResultCallback<R> callback) {198 command.validate(callback);199 return self;200 }201 /**202 * Sets the label parameter.203 * @param key204 * @param value205 * @return206 */207 public T label(String key, String value) {208 command.label(key, value);209 return self;210 }211 /**212 * Sets the label parameter.213 * @param key214 * @return215 */216 public T label(String key) {217 command.label(key);218 return self;219 }220 /**221 * Sets the without label parameter.222 * @param key223 * @param value224 * @return225 */226 public T withoutLabel(String key, String value) {227 command.withoutLabel(key, value);228 return self;229 }230 /**231 * Sets the without label parameter.232 * @param key233 * @return234 */235 public T withoutLabel(String key) {236 command.withoutLabel(key);237 return self;238 }239 /**240 * Sets command.241 * @param command242 * @return243 */244 protected T command(KubernetesCommand<R> command) {245 KubernetesActionBuilder.this.command(command);246 return self;247 }248 }249 /**250 * Pods action builder.251 */252 public class PodsActionBuilder {253 /**254 * List pods.255 */256 public NamespacedActionBuilder<PodList> list() {257 ListPods command = new ListPods();258 return new NamespacedActionBuilder<>(command);259 }260 /**261 * Creates new pod.262 * @param pod263 */264 public NamedActionBuilder<Pod> create(Pod pod) {265 CreatePod command = new CreatePod();266 command.setPod(pod);267 return new NamedActionBuilder<>(command);268 }269 /**270 * Create new pod from template.271 * @param template272 */273 public NamedActionBuilder<Pod> create(Resource template) {274 CreatePod command = new CreatePod();275 command.setTemplateResource(template);276 return new NamedActionBuilder<>(command);277 }278 /**279 * Create new pod from template path.280 * @param templatePath281 */282 public NamedActionBuilder<Pod> create(String templatePath) {283 CreatePod command = new CreatePod();284 command.setTemplate(templatePath);285 return new NamedActionBuilder<>(command);286 }287 /**288 * Gets pod by name.289 * @param name290 */291 public NamedActionBuilder<Pod> get(String name) {292 GetPod command = new GetPod();293 command.name(name);294 return new NamedActionBuilder<>(command);295 }296 /**297 * Deletes pod by name.298 * @param name299 */300 public NamedActionBuilder<DeleteResult> delete(String name) {301 DeletePod command = new DeletePod();302 command.name(name);303 return new NamedActionBuilder<>(command);304 }305 /**306 * Watch pods.307 */308 public NamedActionBuilder<Pod> watch() {309 return new NamedActionBuilder<>(new WatchPods());310 }311 }312 /**313 * Services action builder.314 */315 public class ServicesActionBuilder {316 /**317 * List services.318 */319 public NamespacedActionBuilder<ServiceList> list() {320 return new NamespacedActionBuilder<>(new ListServices());321 }322 /**323 * Creates new service.324 * @param pod325 */326 public NamedActionBuilder<Service> create(Service pod) {327 CreateService command = new CreateService();328 command.setService(pod);329 return new NamedActionBuilder<>(command);330 }331 /**332 * Create new service from template.333 * @param template334 */335 public NamedActionBuilder<Service> create(Resource template) {336 CreateService command = new CreateService();337 command.setTemplateResource(template);338 return new NamedActionBuilder<>(command);339 }340 /**341 * Create new service from template path.342 * @param templatePath343 */344 public NamedActionBuilder<Service> create(String templatePath) {345 CreateService command = new CreateService();346 command.setTemplate(templatePath);347 return new NamedActionBuilder<>(command);348 }349 /**350 * Gets service by name.351 * @param name352 */353 public NamedActionBuilder<Service> get(String name) {354 GetService command = new GetService();355 command.name(name);356 return new NamedActionBuilder<>(command);357 }358 /**359 * Deletes service by name.360 * @param name361 */362 public NamedActionBuilder<DeleteResult> delete(String name) {363 DeleteService command = new DeleteService();364 command.name(name);365 return new NamedActionBuilder<>(command);366 }367 /**368 * Watch services.369 */370 public NamedActionBuilder<Service> watch() {371 return new NamedActionBuilder<>(new WatchServices());372 }373 }374 /**375 * Endpoints action builder.376 */377 public class EndpointsActionBuilder {378 /**379 * List endpoints.380 */381 public NamespacedActionBuilder<EndpointsList> list() {382 return new NamespacedActionBuilder<>(new ListEndpoints());383 }384 }385 /**386 * Nodes action builder.387 */388 public class NodesActionBuilder {389 /**390 * List nodes.391 */392 public BaseActionBuilder<BaseActionBuilder, NodeList> list() {393 return new BaseActionBuilder<>(new ListNodes());394 }395 /**396 * Watch nodes.397 */398 public BaseActionBuilder<BaseActionBuilder, Node> watch() {399 return new BaseActionBuilder<>(new WatchNodes());400 }401 }402 /**403 * Namespaces action builder.404 */405 public class NamespacesActionBuilder {406 /**407 * List namespaces.408 */409 public BaseActionBuilder<BaseActionBuilder, NamespaceList> list() {410 return new BaseActionBuilder<>(new ListNamespaces());411 }412 /**413 * Watch namespaces.414 */415 public BaseActionBuilder<BaseActionBuilder, Namespace> watch() {416 return new BaseActionBuilder<>(new WatchNamespaces());417 }418 }419 /**420 * Events action builder.421 */422 public class EventsActionBuilder {423 /**424 * List endpoints.425 */426 public NamespacedActionBuilder<EventList> list() {427 return new NamespacedActionBuilder<>(new ListEvents());428 }429 }430 /**431 * ReplicationControllers action builder.432 */433 public class ReplicationControllersActionBuilder {434 /**435 * List replication controllers.436 */437 public NamespacedActionBuilder<ReplicationControllerList> list() {438 return new NamespacedActionBuilder<>(new ListReplicationControllers());...
Source:JUnit4CitrusTestRunner.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.*;20import com.consol.citrus.context.TestContext;21import com.consol.citrus.dsl.builder.*;22import com.consol.citrus.dsl.runner.*;23import com.consol.citrus.dsl.simulation.TestSimulator;24import com.consol.citrus.junit.CitrusJUnit4Runner;25import com.consol.citrus.script.GroovyAction;26import com.consol.citrus.server.Server;27import org.slf4j.Logger;28import org.slf4j.LoggerFactory;29import org.springframework.context.ApplicationContext;30import java.lang.reflect.Method;31import java.util.Date;32/**33 * JUnit Citrus test provides Java DSL access to builder pattern methods in34 * CitrusTestDesigner by simple method delegation.35 *36 * @author Christoph Deppisch37 * @since 2.338 */39public class JUnit4CitrusTestRunner extends JUnit4CitrusTest implements TestRunner, TestSimulator {40 /** Logger */41 protected final Logger log = LoggerFactory.getLogger(getClass());42 /** Test builder delegate */43 private TestRunner testRunner;44 @Override45 public void simulate(Method method, TestContext context, ApplicationContext applicationContext) {46 setApplicationContext(applicationContext);47 testRunner = new TestRunnerSimulation(createTestRunner(new CitrusJUnit4Runner.CitrusFrameworkMethod(method, method.getName(), method.getDeclaringClass().getPackage().getName()), context).getTestCase(), applicationContext, context);48 }49 @Override50 protected TestRunner createTestRunner(CitrusJUnit4Runner.CitrusFrameworkMethod frameworkMethod, TestContext context) {51 testRunner = super.createTestRunner(frameworkMethod, context);52 return testRunner;53 }54 @Override55 protected final boolean isDesignerMethod(Method method) {56 return false;57 }58 @Override59 protected final boolean isRunnerMethod(Method method) {60 return true;61 }62 @Override63 public TestCase getTestCase() {64 return testRunner.getTestCase();65 }66 @Override67 public void testClass(Class<?> type) {68 testRunner.testClass(type);69 }70 @Override71 public void name(String name) {72 testRunner.name(name);73 }74 @Override75 public void description(String description) {76 testRunner.description(description);77 }78 @Override79 public void author(String author) {80 testRunner.author(author);81 }82 @Override83 public void packageName(String packageName) {84 testRunner.packageName(packageName);85 }86 @Override87 public void status(TestCaseMetaInfo.Status status) {88 testRunner.status(status);89 }90 @Override91 public void creationDate(Date date) {92 testRunner.creationDate(date);93 }94 @Override95 public void start() {96 testRunner.start();97 }98 @Override99 public void stop() {100 testRunner.stop();101 }102 @Override103 public <T> T variable(String name, T value) {104 return testRunner.variable(name, value);105 }106 @Override107 public <T extends TestAction> T run(T testAction) {108 return testRunner.run(testAction);109 }110 @Override111 public ApplyTestBehaviorAction applyBehavior(com.consol.citrus.dsl.runner.TestBehavior behavior) {112 return testRunner.applyBehavior(behavior);113 }114 @Override115 public <T extends AbstractActionContainer> AbstractTestContainerBuilder<T> container(T container) {116 return testRunner.container(container);117 }118 @Override119 public CreateVariablesAction createVariable(String variableName, String value) {120 return testRunner.createVariable(variableName, value);121 }122 @Override123 public AntRunAction antrun(BuilderSupport<AntRunBuilder> configurer) {124 return testRunner.antrun(configurer);125 }126 @Override127 public EchoAction echo(String message) {128 return testRunner.echo(message);129 }130 @Override131 public ExecutePLSQLAction plsql(BuilderSupport<ExecutePLSQLBuilder> configurer) {132 return testRunner.plsql(configurer);133 }134 @Override135 public ExecuteSQLAction sql(BuilderSupport<ExecuteSQLBuilder> configurer) {136 return testRunner.sql(configurer);137 }138 @Override139 public ExecuteSQLQueryAction query(BuilderSupport<ExecuteSQLQueryBuilder> configurer) {140 return testRunner.query(configurer);141 }142 @Override143 public ReceiveTimeoutAction receiveTimeout(BuilderSupport<ReceiveTimeoutBuilder> configurer) {144 return testRunner.receiveTimeout(configurer);145 }146 @Override147 public FailAction fail(String message) {148 return testRunner.fail(message);149 }150 @Override151 public InputAction input(BuilderSupport<InputActionBuilder> configurer) {152 return testRunner.input(configurer);153 }154 @Override155 public LoadPropertiesAction load(String filePath) {156 return testRunner.load(filePath);157 }158 @Override159 public TestAction purgeQueues(BuilderSupport<PurgeJmsQueuesBuilder> configurer) {160 return testRunner.purgeQueues(configurer);161 }162 @Override163 public PurgeMessageChannelAction purgeChannels(BuilderSupport<PurgeChannelsBuilder> configurer) {164 return testRunner.purgeChannels(configurer);165 }166 @Override167 public PurgeEndpointAction purgeEndpoints(BuilderSupport<PurgeEndpointsBuilder> configurer) {168 return testRunner.purgeEndpoints(configurer);169 }170 @Override171 public ReceiveMessageAction receive(BuilderSupport<ReceiveMessageBuilder> configurer) {172 return testRunner.receive(configurer);173 }174 @Override175 public SendMessageAction send(BuilderSupport<SendMessageBuilder> configurer) {176 return testRunner.send(configurer);177 }178 @Override179 public SleepAction sleep() {180 return testRunner.sleep();181 }182 @Override183 public SleepAction sleep(long milliseconds) {184 return testRunner.sleep(milliseconds);185 }186 @Override187 @Deprecated188 public Wait waitFor(BuilderSupport<WaitBuilder> configurer) {189 return testRunner.waitFor(configurer);190 }191 @Override192 public WaitBuilder waitFor() {193 return testRunner.waitFor();194 }195 @Override196 public StartServerAction start(Server... servers) {197 return testRunner.start(servers);198 }199 @Override200 public StartServerAction start(Server server) {201 return testRunner.start(server);202 }203 @Override204 public StopServerAction stop(Server... servers) {205 return testRunner.stop(servers);206 }207 @Override208 public StopServerAction stop(Server server) {209 return testRunner.stop(server);210 }211 @Override212 public StopTimeAction stopTime() {213 return testRunner.stopTime();214 }215 @Override216 public StopTimeAction stopTime(String id) {217 return testRunner.stopTime(id);218 }219 @Override220 public StopTimeAction stopTime(String id, String suffix) {221 return testRunner.stopTime(id, suffix);222 }223 @Override224 public TraceVariablesAction traceVariables() {225 return testRunner.traceVariables();226 }227 @Override228 public TraceVariablesAction traceVariables(String... variables) {229 return testRunner.traceVariables(variables);230 }231 @Override232 public GroovyAction groovy(BuilderSupport<GroovyActionBuilder> configurer) {233 return testRunner.groovy(configurer);234 }235 @Override236 public TransformAction transform(BuilderSupport<TransformActionBuilder> configurer) {237 return testRunner.transform(configurer);238 }239 @Override240 public AssertExceptionBuilder assertException() {241 return testRunner.assertException();242 }243 @Override244 public CatchExceptionBuilder catchException() {245 return testRunner.catchException();246 }247 @Override248 public AssertSoapFaultBuilder assertSoapFault() {249 return testRunner.assertSoapFault();250 }251 @Override252 public ConditionalBuilder conditional() {253 return testRunner.conditional();254 }255 @Override256 public IterateBuilder iterate() {257 return testRunner.iterate();258 }259 @Override260 public ParallelBuilder parallel() {261 return testRunner.parallel();262 }263 @Override264 public RepeatOnErrorBuilder repeatOnError() {265 return testRunner.repeatOnError();266 }267 @Override268 public RepeatBuilder repeat() {269 return testRunner.repeat();270 }271 @Override272 public SequenceBuilder sequential() {273 return testRunner.sequential();274 }275 @Override276 public AsyncBuilder async() {277 return testRunner.async();278 }279 @Override280 public TimerBuilder timer() {281 return testRunner.timer();282 }283 @Override284 public StopTimerAction stopTimer(String timerId) {285 return testRunner.stopTimer(timerId);286 }287 @Override288 public StopTimerAction stopTimers() {289 return testRunner.stopTimers();290 }291 @Override292 public TestAction docker(BuilderSupport<DockerActionBuilder> configurer) {293 return testRunner.docker(configurer);294 }295 @Override296 public TestAction kubernetes(BuilderSupport<KubernetesActionBuilder> configurer) {297 return testRunner.kubernetes(configurer);298 }299 @Override300 public TestAction selenium(BuilderSupport<SeleniumActionBuilder> configurer) {301 return testRunner.selenium(configurer);302 }303 @Override304 public TestAction http(BuilderSupport<HttpActionBuilder> configurer) {305 return testRunner.http(configurer);306 }307 @Override308 public TestAction soap(BuilderSupport<SoapActionBuilder> configurer) {309 return testRunner.soap(configurer);310 }311 @Override312 public TestAction camel(BuilderSupport<CamelRouteActionBuilder> configurer) {313 return testRunner.camel(configurer);314 }315 @Override316 public TestAction zookeeper(BuilderSupport<ZooActionBuilder> configurer) {317 return testRunner.zookeeper(configurer);318 }319 @Override320 public Template applyTemplate(BuilderSupport<TemplateBuilder> configurer) {321 return testRunner.applyTemplate(configurer);322 }323 @Override324 public FinallySequenceBuilder doFinally() {325 return testRunner.doFinally();326 }327}...
endpoints
Using AI Code Generation
1import com.consol.citrus.dsl.builder.KubernetesActionBuilder;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.kubernetes.client.KubernetesClient;4import com.consol.citrus.kubernetes.command.EndpointType;5import org.springframework.beans.factory.annotation.Autowired;6import org.springframework.beans.factory.annotation.Qualifier;7import org.springframework.core.io.ClassPathResource;8import org.springframework.core.io.Resource;9public class Endpoints {10 @Qualifier("kubernetesClient")11 private KubernetesClient kubernetesClient;12 private TestRunner builder;13 public void testEndpoints() {14 builder.kubernetes(kubernetesClient)15 .endpoints()16 .endpointType(EndpointType.ENDPOINTS)17 .name("my-service")18 .namespace("my-namespace")19 .endpoints();20 }21}22import com.consol.citrus.dsl.builder.KubernetesActionBuilder;23import com.consol.citrus.dsl.runner.TestRunner;24import com.consol.citrus.kubernetes.client.KubernetesClient;25import com.consol.citrus.kubernetes.command.EventListType;26import org.springframework.beans.factory.annotation.Autowired;27import org.springframework.beans.factory.annotation.Qualifier;28import org.springframework.core.io.ClassPathResource;29import org.springframework.core.io.Resource;30public class Events {31 @Qualifier("kubernetesClient")32 private KubernetesClient kubernetesClient;33 private TestRunner builder;34 public void testEvents() {35 builder.kubernetes(kubernetesClient)36 .events()37 .eventListType(EventListType.EVENTS)38 .namespace("my-namespace")39 .events();40 }41}42import com.consol.citrus.dsl.builder.KubernetesActionBuilder;43import com.consol.citrus.dsl.runner.TestRunner;44import com.consol.citrus.kubernetes.client.KubernetesClient;45import org.springframework.beans.factory.annotation.Autowired;46import org.springframework.beans.factory.annotation.Qualifier;47import org.springframework.core.io.ClassPathResource;48import org.springframework.core.io.Resource;49public class Exec {50 @Qualifier("kubernetesClient")51 private KubernetesClient kubernetesClient;
endpoints
Using AI Code Generation
1package com.consol.citrus.dsl;2import com.consol.citrus.dsl.runner.TestRunner;3import com.consol.citrus.dsl.builder.KubernetesActionBuilder;4import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints;5import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint;6import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset;7import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Address;8import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Address.TargetRef;9import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Address.TargetRef.Port;10import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port;11import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber;12import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.PortName;13import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort;14import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort.Protocol;15import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort.Protocol.PortNumber;16import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort.Protocol.PortNumber.PortName;17import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort.Protocol.PortNumber.TargetPort;18import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort.Protocol.PortName;19import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort.PortName;20import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort.TargetPort;21import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort.TargetPort.Protocol;22import com.consol.citrus.dsl.builder.KubernetesActionBuilder.Endpoints.Endpoint.Subset.Port.PortNumber.TargetPort.TargetPort.Protocol.PortNumber;23import com.consol.citrus.dsl.builder.Kubernetes
endpoints
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.endpoint.CitrusEndpoints;3import com.consol.citrus.kubernetes.client.KubernetesClient;4import com.consol.citrus.kubernetes.message.KubernetesMessageHeaders;5import com.consol.citrus.message.MessageType;6import com.consol.citrus.testng.AbstractTestNGUnitTest;7import org.testng.annotations.Test;8import static com.consol.citrus.actions.ExecutePLSQLAction.Builder.executePLSQL;9import static com.consol.citrus.actions.ExecuteSQLQueryAction.Builder.executeSQLQuery;10import static com.consol.citrus.actions.PurgeJmsQueuesAction.Builder.purgeQueues;11import static com.consol.citrus.actions.ReceiveMessageAction.Builder.receive;12import static com.consol.citrus.actions.SendMessageAction.Builder.send;13import static com.consol.citrus.actions.SleepAction.Builder.sleep;14import static com.consol.citrus.dsl.builder.Builder.*;15import static com.consol.citrus.dsl.builder.KubernetesActionBuilder.kubernetes;16import static com.consol.citrus.dsl.builder.KubernetesEndpointBuilder.kubernetes;17import static com.consol.citrus.dsl.builder.KubernetesEndpoints.kubernetes;18public class KubernetesActionBuilderTest extends AbstractTestNGUnitTest {19 .kubernetes()20 .client()21 .build();22 public void testKubernetesActionBuilder() {23 variable("name", "citrus:randomString(10)");24 variable("label", "citrus:concat('app=', citrus:randomNumber(3))");25 description("Kubernetes endpoint test");26 parallel(27 sequential(28 send(kubernetesClient)29 .endpoint(kubernetes()30 .client(kubernetesClient)31 .build())32 .message()33 .body("{" +34 " \"metadata\": {" +35 " \"name\": \"${name}\"," +36 " \"labels\": {" +37 " \"${label}\": \"true\"" +38 " }" +39 " }," +40 " \"spec\": {" +41 " \"containers\": [{" +42 " \"name\": \"${name}\"," +
endpoints
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.endpoint.KubernetesEndpointConfigurator;3import com.consol.citrus.dsl.endpoint.KubernetesEndpoints;4import com.consol.citrus.kubernetes.client.KubernetesClient;5import com.consol.citrus.kubernetes.config.annotation.KubernetesConfig;6import com.consol.citrus.kubernetes.endpoint.KubernetesEndpoint;7import org.springframework.context.annotation.Bean;8import org.springframework.context.annotation.Configuration;9public class KubernetesActionBuilderEndpoints {10 public KubernetesEndpoints kubernetesEndpoints(KubernetesClient kubernetesClient) {11 return new KubernetesEndpoints() {12 public KubernetesEndpointConfigurator kubernetes() {13 return new KubernetesEndpointConfigurator(new KubernetesEndpoint(), kubernetesClient);14 }15 };16 }17}18package com.consol.citrus.dsl.builder;19import com.consol.citrus.dsl.endpoint.KubernetesEndpointConfigurator;20import com.consol.citrus.dsl.endpoint.KubernetesEndpoints;21import com.consol.citrus.kubernetes.client.KubernetesClient;22import com.consol.citrus.kubernetes.config.annotation.KubernetesConfig;23import com.consol.citrus.kubernetes.endpoint.KubernetesEndpoint;24import org.springframework.context.annotation.Bean;25import org.springframework.context.annotation.Configuration;26public class KubernetesActionBuilderEndpoints {27 public KubernetesEndpoints kubernetesEndpoints(KubernetesClient kubernetesClient) {28 return new KubernetesEndpoints() {29 public KubernetesEndpointConfigurator kubernetes() {30 return new KubernetesEndpointConfigurator(new KubernetesEndpoint(), kubernetesClient);31 }32 };33 }34}35package com.consol.citrus.dsl.builder;36import com.consol.citrus.dsl.endpoint.KubernetesEndpointConfigurator;37import com.consol.citrus.dsl.endpoint.KubernetesEndpoints;38import com.consol.citrus.kubernetes.client.KubernetesClient;39import com.consol.citrus.kubernetes.config.annotation.KubernetesConfig;40import com.consol.citrus.kubernetes.endpoint.KubernetesEndpoint;41import org.springframework.context.annotation.Bean;42import org.springframework.context.annotation.Configuration;43public class KubernetesActionBuilderEndpoints {
endpoints
Using AI Code Generation
1public class 3 extends AbstractTestNGCitrusTest {2 public void 3() {3 variable("name", "citrus:randomNumber(10)");4 variable("namespace", "citrus:randomNumber(10)");5 variable("apiVersion", "v1");6 variable("kind", "Pod");7 variable("port", "8080");8 variable("host", "localhost");9 variable("protocol", "TCP");10 variable("path", "citrus:concat('/', citrus:randomNumber(10))");11 variable("serviceName", "citrus:randomNumber(10)");12 variable("servicePort", "80");13 variable("selector", "app=citrus");14 variable("replicas", "1");15 variable("status", "Running");16 variable("message", "Hello World!");17 variable("mode", "ReadWriteOnce");18 variable("accessModes", "ReadWriteOnce");19 variable("storage", "5Gi");20 variable("type", "NodePort");21 variable("image", "nginx");22 variable("containerName", "nginx");23 variable("containerPort", "80");24 variable("imagePullPolicy", "IfNotPresent");25 variable("restartPolicy", "Always");
endpoints
Using AI Code Generation
1public class 3 extends AbstractTestNGCitrusTest {2 public void 3() {3 variable("namespace", "citrus");4 http(httpActionBuilder -> httpActionBuilder.client("httpClient")5 .send()6 .post()7 .payload("{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"name\":\"${namespace}\"}}")8 .contentType("application/json"));9 http(httpActionBuilder -> httpActionBuilder.client("httpClient")10 .receive()11 .response(HttpStatus.CREATED));12 kubernetes(kubernetesActionBuilder -> kubernetesActionBuilder.client("kubernetesClient")13 .endpoint("endpoints")14 .namespace("${namespace}")15 .name("citrus")16 .action("list"));17 kubernetes(kubernetesActionBuilder -> kubernetesActionBuilder.client("kubernetesClient")18 .endpoint("endpoints")19 .namespace("${namespace}")20 .name("citrus")21 .action("get"));22 kubernetes(kubernetesActionBuilder -> kubernetesActionBuilder.client("kubernetesClient")23 .endpoint("endpoints")24 .namespace("${namespace}")25 .name("citrus")26 .action("create"));27 kubernetes(kubernetesActionBuilder -> kubernetesActionBuilder.client("kubernetesClient")28 .endpoint("endpoints")29 .namespace("${namespace}")30 .name("citrus")31 .action("update"));32 kubernetes(kubernetesActionBuilder -> kubernetesActionBuilder.client("kubernetesClient")33 .endpoint("endpoints")34 .namespace("${namespace}")35 .name("citrus")36 .action("delete"));37 }38}39public class 4 extends AbstractTestNGCitrusTest {40 public void 4() {41 variable("namespace", "citrus");42 http(httpActionBuilder -> httpActionBuilder.client("httpClient")43 .send()44 .post()45 .payload("{\"apiVersion\":\"v1\",\"kind\":\"Namespace\",\"metadata\":{\"name\":\"${namespace}\"}}")46 .contentType("application/json"));47 http(httpActionBuilder -> httpActionBuilder.client("httpClient")48 .receive()49 .response(HttpStatus.CREATED));50 kubernetes(kubernetesActionBuilder -> kubernetesActionBuilder.client("kubernetesClient")51 .endpoint("events")52 .namespace("${namespace}")
endpoints
Using AI Code Generation
1package com.consol.citrus.dsl.endpoint;2import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;3import org.testng.annotations.Test;4public class KubernetesCreateServiceWithLabelSelector extends TestNGCitrusTestDesigner {5 public void configure() {6 variable("serviceName", "test-service");7 variable("serviceLabelKey", "app");8 variable("serviceLabelValue", "test-app");9 kubernetes()10 .client(kubernetesClient()11 .username("admin")12 .password("password")13 .build())14 .endpoints()15 .createService()16 .withNewMetadata()17 .withName("${serviceName}")18 .endMetadata()19 .withNewSpec()20 .withSelector()21 .withMatchLabels("${serviceLabelKey}", "${serviceLabelValue}")22 .endSelector()23 .addNewPort()24 .withPort(80)25 .withTargetPort(9376)26 .endPort()27 .endSpec()28 .end()29 .build();30 }31}32package com.consol.citrus.dsl.endpoint;33import com.consol.citrus.dsl.testng.TestNGCitrusTestDesigner;34import org.testng.annotations.Test;35public class KubernetesCreateServiceWithLabelSelector extends TestNGCitrusTestDesigner {36 public void configure() {37 variable("serviceName", "test-service");38 variable("serviceLabelKey", "app");39 variable("serviceLabelValue", "test-app");40 kubernetes()41 .client(kubernetesClient()42 .username("admin")43 .password("password")44 .build())45 .endpoints()46 .createService()47 .withNewMetadata()48 .withName("${serviceName}")49 .endMetadata()50 .withNewSpec()51 .withSelector()52 .withMatchLabels("${serviceLabelKey}", "${serviceLabelValue}")53 .endSelector()54 .addNewPort()55 .withPort(80)56 .withTargetPort(9376)57 .endPort()
endpoints
Using AI Code Generation
1package com.consol.citrus.dsl.builder;2import com.consol.citrus.dsl.junit.JUnit4CitrusTest;3import com.consol.citrus.kubernetes.actions.KubernetesExecuteAction;4import com.consol.citrus.kubernetes.client.KubernetesClient;5import com.consol.citrus.kubernetes.command.Endpoint;6import com.consol.citrus.kubernetes.command.Service;7import com.consol.citrus.kubernetes.command.Deployment;8import org.springframework.beans.factory.annotation.Autowired;9import org.springframework.context.annotation.Bean;10import org.springframework.context.annotation.Import;11import org.testng.annotations.Test;12import java.util.ArrayList;13import java.util.List;14public class KubernetesEndpointsIT extends JUnit4CitrusTest {15 private KubernetesClient kubernetesClient;16 public void testKubernetesEndpoints() {17 List<Endpoint> endpoints = new ArrayList<>();18 endpoints.add(new Endpoint("http", "8080", "8080"));19 List<Service> services = new ArrayList<>();20 services.add(new Service("test-service", "test-service", "80", "80", endpoints));21 List<Deployment> deployments = new ArrayList<>();22 deployments.add(new Deployment("test-deployment", "test-deployment", "nginx", "nginx", "1.7.9", "80", "80", 1));23 variable("endpoints", endpoints);24 variable("services", services);25 variable("deployments", deployments);26 run(new KubernetesExecuteAction.Builder()27 .client(kubernetesClient)28 .endpoints(endpoints)29 .services(services)30 .deployments(deployments)31 .build());32 }33 public KubernetesClient kubernetesClient() {34 return new KubernetesClient();35 }36}37package com.consol.citrus.dsl.builder;38import com.consol.citrus.dsl.junit.JUnit4CitrusTest;39import com.consol.citrus.kubernetes.actions.KubernetesExecuteAction;40import com.consol.citrus.kubernetes.client.KubernetesClient;41import com.consol.citrus.kubernetes.command.Deployment;42import com.consol.citrus.kubernetes.command.Endpoint;
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!!