Skip to content

Commit

Permalink
fix(deps): update to citrus v3.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
bbortt committed Aug 19, 2024
1 parent 6a993f3 commit ce7570d
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 41 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# ---------------------------------------------------------------------------
# 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.
# ---------------------------------------------------------------------------

name: nightly

on:
workflow_dispatch:
schedule:
- cron: "0 0 * * *"

jobs:
nightly:
runs-on: ubuntu-latest
steps:
- name: Set up JDK
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Checkout code
uses: actions/checkout@v4
- name: Cache Maven cache
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Info
run: |
java -version
./mvnw -version
- name: Simulator Dependency Report
run: |
./mvnw --no-transfer-progress versions:display-dependency-updates
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
<maven.nexus-staging.plugin.version>1.6.13</maven.nexus-staging.plugin.version>

<lombok.version>1.18.30</lombok.version>
<citrus.version>4.2.1</citrus.version>
<citrus.version>4.3.1</citrus.version>

<spring-boot.version>3.3.0</spring-boot.version>
<spring.version>6.3.0</spring.version>
<spring-boot.version>3.3.2</spring-boot.version>
<spring.version>6.3.2</spring.version>
<testng.version>7.10.2</testng.version>
<wsdl4j.version>1.6.3</wsdl4j.version>
<xerces.version>2.12.2</xerces.version>
Expand All @@ -38,8 +38,8 @@
<!-- see https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-logging/3.3.0 -->
<logback.classic.version>1.5.6</logback.classic.version>

<node.version>v20.12.1</node.version>
<npm.version>10.5.0</npm.version>
<node.version>v22.4.1</node.version>
<npm.version>10.8.1</npm.version>

<skip.gpg>false</skip.gpg>
<reuseForks>true</reuseForks>
Expand Down Expand Up @@ -216,7 +216,7 @@
<dependency>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
<version>3.1.0</version>
<version>5.2.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
import org.apache.xmlbeans.impl.xsd2inst.SampleXmlUtil;
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.simulator.exception.SimulatorException;
import org.citrusframework.spi.CitrusResourceWrapper;
Expand Down Expand Up @@ -52,6 +51,9 @@
import java.util.ArrayList;
import java.util.List;

import static org.apache.xmlbeans.impl.xsd2inst.SampleXmlUtil.createSampleForType;
import static org.springframework.beans.factory.support.BeanDefinitionBuilder.genericBeanDefinition;

/**
* @author Christoph Deppisch
*/
Expand Down Expand Up @@ -127,13 +129,13 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
case SOAP_ACTION -> soapAction;
};

if (beanFactory instanceof BeanDefinitionRegistry) {
logger.info("Register auto generated scenario as bean definition: " + scenarioName);
BeanDefinitionBuilder beanDefinitionBuilder = BeanDefinitionBuilder.genericBeanDefinition(WsdlOperationScenario.class)
if (beanFactory instanceof BeanDefinitionRegistry beanDefinitionRegistry) {
logger.info("Register auto generated scenario as bean definition: {}", scenarioName);
BeanDefinitionBuilder beanDefinitionBuilder = genericBeanDefinition(WsdlOperationScenario.class)
.addConstructorArgValue(operation)
.addPropertyValue("soapAction", soapAction)
.addPropertyValue("input", generateRequest(operation, SampleXmlUtil.createSampleForType(requestElem)))
.addPropertyValue("output", generateResponse(operation, SampleXmlUtil.createSampleForType(responseElem)));
.addPropertyValue("input", generateRequest(operation, createSampleForType(requestElem)))
.addPropertyValue("output", generateResponse(operation, createSampleForType(responseElem)));

if (beanFactory.containsBeanDefinition("inboundXmlDataDictionary")) {
beanDefinitionBuilder.addPropertyReference("inboundDataDictionary", "inboundXmlDataDictionary");
Expand All @@ -143,10 +145,10 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
beanDefinitionBuilder.addPropertyReference("outboundDataDictionary", "outboundXmlDataDictionary");
}

((BeanDefinitionRegistry) beanFactory).registerBeanDefinition(scenarioName, beanDefinitionBuilder.getBeanDefinition());
beanDefinitionRegistry.registerBeanDefinition(scenarioName, beanDefinitionBuilder.getBeanDefinition());
} else {
logger.info("Register auto generated scenario as singleton: " + scenarioName);
WsdlOperationScenario scenario = createScenario(operation, soapAction, generateRequest(operation, SampleXmlUtil.createSampleForType(requestElem)), generateResponse(operation, SampleXmlUtil.createSampleForType(responseElem)));
logger.info("Register auto generated scenario as singleton: {}", scenarioName);
WsdlOperationScenario scenario = createScenario(operation, soapAction, generateRequest(operation, createSampleForType(requestElem)), generateResponse(operation, createSampleForType(responseElem)));
beanFactory.registerSingleton(scenarioName, scenario);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,18 @@
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import java.util.regex.Pattern;
import java.util.stream.Stream;

import static java.lang.String.format;
import static org.assertj.core.api.Assertions.assertThat;
import static org.citrusframework.simulator.ws.WsdlScenarioGenerator.WsdlScenarioNamingStrategy.INPUT;
import static org.citrusframework.simulator.ws.WsdlScenarioGenerator.WsdlScenarioNamingStrategy.OPERATION;
import static org.citrusframework.simulator.ws.WsdlScenarioGenerator.WsdlScenarioNamingStrategy.SOAP_ACTION;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.params.provider.Arguments.arguments;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.doReturn;
Expand All @@ -46,38 +53,35 @@
@ExtendWith(MockitoExtension.class)
class WsdlScenarioGeneratorTest {

private static final String SCENARIO_INPUT = String.format("<v1:TestRequest name=\"string\" id=\"100\" flag=\"false\" xmlns:v1=\"http://www.citrusframework.org/schema/samples/TestService/v1\">%n" +
private static final String SCENARIO_INPUT = format("<v1:TestRequest name=\"string\" id=\"100\" flag=\"(true|false)\" xmlns:v1=\"http://www.citrusframework.org/schema/samples/TestService/v1\">%n" +
" <v1:name>string</v1:name>%n" +
" <v1:id>100</v1:id>%n" +
" <v1:flag>true</v1:flag>%n" +
" <v1:flag>(true|false)</v1:flag>%n" +
" <v1:restricted>stringstri</v1:restricted>%n" +
"</v1:TestRequest>");
public static final Pattern SCENARIO_INPUT_PATTERN = Pattern.compile(SCENARIO_INPUT);

private static final String SCENARIO_OUTPUT = String.format("<v1:TestResponse name=\"string\" id=\"100\" flag=\"false\" xmlns:v1=\"http://www.citrusframework.org/schema/samples/TestService/v1\">%n" +
private static final String SCENARIO_OUTPUT = format("<v1:TestResponse name=\"string\" id=\"100\" flag=\"(true|false)\" xmlns:v1=\"http://www.citrusframework.org/schema/samples/TestService/v1\">%n" +
" <v1:name>string</v1:name>%n" +
" <v1:id>100</v1:id>%n" +
" <v1:flag>true</v1:flag>%n" +
" <v1:flag>(true|false)</v1:flag>%n" +
" <v1:restricted>stringstri</v1:restricted>%n" +
"</v1:TestResponse>");
public static final Pattern SCENARIO_OUTPUT_PATTERN = Pattern.compile(SCENARIO_OUTPUT);

@Mock
private ConfigurableListableBeanFactory beanFactoryMock;

@Mock
private DefaultListableBeanFactory beanRegistryMock;
private WsdlScenarioGenerator fixture;

static Stream<Arguments> testGenerateScenarios() {
return data();
}

static Stream<Arguments> testGenerateScenariosWithRegistry() {
return data();
}
private WsdlScenarioGenerator fixture;

static Stream<Arguments> data() {
return Stream.of(
Arguments.of("TestRequest", WsdlScenarioGenerator.WsdlScenarioNamingStrategy.INPUT, "/TestService/test", SCENARIO_INPUT, SCENARIO_OUTPUT),
Arguments.of("test", WsdlScenarioGenerator.WsdlScenarioNamingStrategy.OPERATION, "/TestService/test", SCENARIO_INPUT, SCENARIO_OUTPUT),
Arguments.of("/TestService/test", WsdlScenarioGenerator.WsdlScenarioNamingStrategy.SOAP_ACTION, "/TestService/test", SCENARIO_INPUT, SCENARIO_OUTPUT)
arguments("TestRequest", INPUT, "/TestService/test", SCENARIO_INPUT, SCENARIO_OUTPUT),
arguments("test", OPERATION, "/TestService/test", SCENARIO_INPUT, SCENARIO_OUTPUT),
arguments("/TestService/test", SOAP_ACTION, "/TestService/test", SCENARIO_INPUT, SCENARIO_OUTPUT)
);
}

Expand All @@ -86,17 +90,17 @@ void beforeEachSetup() {
fixture = new WsdlScenarioGenerator(new Resources.ClasspathResource("schema/TestService.wsdl"));
}

@MethodSource
@ParameterizedTest
@MethodSource("data")
void testGenerateScenarios(String scenarioName, WsdlScenarioGenerator.WsdlScenarioNamingStrategy namingStrategy, String soapAction, String input, String output) {
fixture.setNamingStrategy(namingStrategy);

doAnswer(invocation -> {
WsdlOperationScenario scenario = (WsdlOperationScenario) invocation.getArguments()[1];

assertEquals(scenario.getSoapAction(), soapAction);
assertEquals(scenario.getInput(), input);
assertEquals(scenario.getOutput(), output);
assertEquals(soapAction, scenario.getSoapAction());
assertThat(scenario.getInput()).matches(SCENARIO_INPUT_PATTERN);
assertThat(scenario.getOutput()).matches(SCENARIO_OUTPUT_PATTERN);

return null;
}).when(beanFactoryMock).registerSingleton(eq(scenarioName), any(WsdlOperationScenario.class));
Expand All @@ -106,17 +110,17 @@ void testGenerateScenarios(String scenarioName, WsdlScenarioGenerator.WsdlScenar
verify(beanFactoryMock).registerSingleton(eq(scenarioName), any(WsdlOperationScenario.class));
}

@MethodSource
@ParameterizedTest
@MethodSource("data")
void testGenerateScenariosWithRegistry(String scenarioName, WsdlScenarioGenerator.WsdlScenarioNamingStrategy namingStrategy, String soapAction, String input, String output) {
fixture.setNamingStrategy(namingStrategy);

doAnswer(invocation -> {
BeanDefinition scenario = (BeanDefinition) invocation.getArguments()[1];

assertEquals(scenario.getPropertyValues().get("soapAction"), soapAction);
assertEquals(scenario.getPropertyValues().get("input"), input);
assertEquals(scenario.getPropertyValues().get("output"), output);
assertEquals(soapAction, scenario.getPropertyValues().get("soapAction"));
assertThat(scenario.getPropertyValues().get("input")).asString().matches(SCENARIO_INPUT_PATTERN);
assertThat(scenario.getPropertyValues().get("output")).asString().matches(SCENARIO_OUTPUT_PATTERN);
assertNull(scenario.getPropertyValues().get("inboundDataDictionary"));
assertNull(scenario.getPropertyValues().get("outboundDataDictionary"));

Expand All @@ -136,9 +140,9 @@ void generateScenariosWithDataDictionaries() {
doAnswer(invocation -> {
BeanDefinition scenario = (BeanDefinition) invocation.getArguments()[1];

assertEquals(scenario.getPropertyValues().get("soapAction"), "/TestService/test");
assertEquals(scenario.getPropertyValues().get("input"), SCENARIO_INPUT);
assertEquals(scenario.getPropertyValues().get("output"), SCENARIO_OUTPUT);
assertEquals("/TestService/test", scenario.getPropertyValues().get("soapAction"));
assertThat(scenario.getPropertyValues().get("input")).asString().matches(SCENARIO_INPUT_PATTERN);
assertThat(scenario.getPropertyValues().get("output")).asString().matches(SCENARIO_OUTPUT_PATTERN);
assertNotNull(scenario.getPropertyValues().get("inboundDataDictionary"));
assertNotNull(scenario.getPropertyValues().get("outboundDataDictionary"));

Expand Down

0 comments on commit ce7570d

Please sign in to comment.