-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(#254): load scenarios at runtime
- Loading branch information
Showing
36 changed files
with
1,306 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
~ Copyright the original author or authors. | ||
~ | ||
~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
~ you may not use this file except in compliance with the License. | ||
~ You may obtain a copy of the License at | ||
~ | ||
~ http://www.apache.org/licenses/LICENSE-2.0 | ||
~ | ||
~ Unless required by applicable law or agreed to in writing, software | ||
~ distributed under the License is distributed on an "AS IS" BASIS, | ||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
~ See the License for the specific language governing permissions and | ||
~ limitations under the License. | ||
--> | ||
|
||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<parent> | ||
<groupId>org.citrusframework</groupId> | ||
<artifactId>citrus-simulator</artifactId> | ||
<version>3.1.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>citrus-spring-boot-simulator-api</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
<dependencies> | ||
<!-- Citrus --> | ||
<dependency> | ||
<groupId>org.citrusframework</groupId> | ||
<artifactId>citrus-core</artifactId> | ||
<!-- Exclude in order solve org.w3c.dom is accessible from more than one module for jdk 11 --> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>xml-apis</groupId> | ||
<artifactId>xml-apis</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>xerces</groupId> | ||
<artifactId>xercesImpl</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.citrusframework</groupId> | ||
<artifactId>citrus-http</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.citrusframework</groupId> | ||
<artifactId>citrus-ws</artifactId> | ||
<scope>provided</scope> | ||
<optional>true</optional> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.annotation</groupId> | ||
<artifactId>jakarta.annotation-api</artifactId> | ||
</dependency> | ||
|
||
<!-- Spring --> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-web</artifactId> | ||
</dependency> | ||
|
||
<!-- Test scoped --> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...-boot-api/src/main/java/org/citrusframework/simulator/http/HttpScenarioActionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* Copyright the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.citrusframework.simulator.http; | ||
|
||
import org.citrusframework.http.actions.HttpServerActionBuilder; | ||
|
||
public interface HttpScenarioActionBuilder { | ||
|
||
HttpServerActionBuilder.HttpServerReceiveActionBuilder receive(); | ||
|
||
HttpServerActionBuilder.HttpServerSendActionBuilder send(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
...pring-boot-api/src/main/java/org/citrusframework/simulator/scenario/ScenarioEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.citrusframework.simulator.scenario; | ||
|
||
import org.citrusframework.endpoint.AbstractEndpoint; | ||
import org.citrusframework.endpoint.EndpointConfiguration; | ||
import org.citrusframework.message.Message; | ||
import org.citrusframework.messaging.Consumer; | ||
import org.citrusframework.messaging.Producer; | ||
|
||
import java.util.concurrent.CompletableFuture; | ||
|
||
public abstract class ScenarioEndpoint extends AbstractEndpoint implements Producer, Consumer { | ||
|
||
public ScenarioEndpoint(EndpointConfiguration endpointConfiguration) { | ||
super(endpointConfiguration); | ||
} | ||
|
||
public abstract void add(Message request, CompletableFuture<Message> responseFuture); | ||
|
||
abstract void fail(Throwable error); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...-spring-boot-api/src/main/java/org/citrusframework/simulator/scenario/ScenarioRunner.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.citrusframework.simulator.scenario; | ||
|
||
import org.citrusframework.GherkinTestActionRunner; | ||
import org.citrusframework.simulator.http.HttpScenarioActionBuilder; | ||
import org.citrusframework.simulator.soap.SoapScenarioActionBuilder; | ||
|
||
public interface ScenarioRunner extends GherkinTestActionRunner { | ||
|
||
HttpScenarioActionBuilder http(); | ||
|
||
SoapScenarioActionBuilder soap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
.../main/java/org/citrusframework/simulator/scenario/SimpleInitializedSimulatorScenario.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.citrusframework.simulator.scenario; | ||
|
||
import jakarta.annotation.Nullable; | ||
import org.citrusframework.TestCaseRunner; | ||
import org.citrusframework.simulator.correlation.CorrelationHandler; | ||
|
||
public abstract class SimpleInitializedSimulatorScenario implements CorrelationHandler, SimulatorScenarioWithEndpoint { | ||
|
||
private @Nullable ScenarioEndpoint scenarioEndpoint; | ||
|
||
private @Nullable TestCaseRunner testCaseRunner; | ||
|
||
@Override | ||
public @Nullable ScenarioEndpoint getScenarioEndpoint() { | ||
return scenarioEndpoint; | ||
} | ||
|
||
@Override | ||
public void setScenarioEndpoint(@Nullable ScenarioEndpoint scenarioEndpoint) { | ||
this.scenarioEndpoint = scenarioEndpoint; | ||
} | ||
|
||
@Override | ||
public @Nullable TestCaseRunner getTestCaseRunner() { | ||
return testCaseRunner; | ||
} | ||
|
||
@Override | ||
public void setTestCaseRunner(TestCaseRunner testCaseRunner) { | ||
this.testCaseRunner = testCaseRunner; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...i/src/main/java/org/citrusframework/simulator/scenario/SimulatorScenarioWithEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.citrusframework.simulator.scenario; | ||
|
||
import jakarta.annotation.Nullable; | ||
|
||
/** | ||
* Classes implementing this interface will have the {@link ScenarioEndpoint} injected after instantiation at runtime. | ||
* Similar to an initialized Spring bean, but controlled by the simulator. | ||
* <code> | ||
* | ||
* @Override public void afterPropertiesSet() { | ||
* scenarioEndpoint = new ScenarioEndpoint(new ScenarioEndpointConfiguration()); | ||
* } | ||
* </code> | ||
* @see org.springframework.beans.factory.InitializingBean | ||
*/ | ||
public interface SimulatorScenarioWithEndpoint extends SimulatorScenario { | ||
|
||
void setScenarioEndpoint(@Nullable ScenarioEndpoint scenarioEndpoint); | ||
} |
27 changes: 27 additions & 0 deletions
27
...-boot-api/src/main/java/org/citrusframework/simulator/soap/SoapScenarioActionBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Copyright the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.citrusframework.simulator.soap; | ||
|
||
import org.citrusframework.ws.actions.ReceiveSoapMessageAction; | ||
import org.citrusframework.ws.actions.SendSoapMessageAction; | ||
|
||
public interface SoapScenarioActionBuilder { | ||
|
||
ReceiveSoapMessageAction.Builder receive(); | ||
|
||
SendSoapMessageAction.Builder send(); | ||
} |
Oops, something went wrong.