Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 17, 21, 23 ]
java: [ 17, 21, 25 ]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand All @@ -34,7 +34,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 17, 21, 23 ]
java: [ 17, 21, 25 ]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand Down Expand Up @@ -64,7 +64,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 17, 21, 23 ]
java: [ 17, 21, 25 ]
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ We are happy You are considering contributing to jbehave-support! 😃
Before you start, please read this short guide, so You don`t get lost. If You have any questions, do not hesitate to ask in GitHub discussions.

## Dev environment
This project is written in Java 17, however we are aiming for LTS Java and latest Java compatibility (CI is run against 17, 21 and latest Java - currently 23).
This project is written in Java 17, however we are aiming for LTS Java and latest Java compatibility (CI is run against 17, 21 and latest Java - currently 25).

We are using the latest version of IntelliJ IDEA as an IDE. These are the plugins you need:
* SonarLint
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ along with support for [verification](jbehave-support-core/docs/General.md#verif
[expression commands](jbehave-support-core/docs/Expression-commands.md) and
basic [reporting](jbehave-support-core/docs/Reporting.md).

Currently supported Java versions are 17, 21 and 23 (latest LTS and latest version).
Currently supported Java versions are 17, 21 and 25 (latest LTS and latest version).

## Contents
1. [Modules](#modules)
Expand Down Expand Up @@ -54,7 +54,7 @@ Contributors guide can be found in [CONTRIBUTING.md](CONTRIBUTING.md)

To show you how to set up a project using the jbehave-support library, I am going to make a test that Google searches `EmbedITCZ jbehave-support` and checks the result. To learn more about this example check out [Web-testing.md](jbehave-support-core/docs/Web-testing.md).

Of course you can use jbehave-support for much more than just selenium based testing. For example server communication ([SOAP](jbehave-support-core/docs/examples/Web-service.md), [REST](jbehave-support-core/docs/examples/Rest.md) or database manipulation ([SQL](jbehave-support-core/docs/Sql-steps.md)).
Of course you can use jbehave-support for much more than just selenium based testing. For example server communication ([SOAP](jbehave-support-core/docs/examples/Web-service.md), [REST](jbehave-support-core/docs/examples/Rest.md)) or database manipulation ([SQL](jbehave-support-core/docs/Sql-steps.md)).

### Add to Java project as a Maven dependency

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-liquibase</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.sql.SQLException;


import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.h2.tools.Server;
Expand Down Expand Up @@ -31,4 +32,5 @@ public Server initServer() {
}
return h2Server;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
import org.springframework.security.config.web.PathPatternRequestMatcherBuilderFactoryBean;
import org.springframework.security.web.SecurityFilterChain;

import static org.springframework.security.web.util.matcher.AntPathRequestMatcher.antMatcher;

@Configuration
public class SecurityConfig {

@Bean
public SecurityFilterChain basicAuthFilterChain(HttpSecurity http) throws Exception {
return http
.csrf(csrf -> csrf.disable())
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(matcherRegistry ->
matcherRegistry
.requestMatchers(antMatcher("/rest/secure/**")).fullyAuthenticated()
.requestMatchers(antMatcher("/**")).permitAll()
.requestMatchers("/rest/secure/**").fullyAuthenticated()
.requestMatchers("/**").permitAll()
)
.httpBasic(Customizer.withDefaults())
.headers(headersConfigurer -> headersConfigurer.frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,11 @@ public ResponseEntity handleBase64Request(HttpServletRequest request) throws IOE

@PostMapping("/mirror/")
public ResponseEntity<Mirror> mirror(@RequestBody Mirror mirror) {
return (ResponseEntity<Mirror>) new ResponseEntity(mirror,
mirror.getHeaders().stream().collect(
toMap(Header::getKey, h -> Collections.singletonList(h.getValue()), (a, b) -> {
a.addAll(b);
return a;
}, HttpHeaders::new)),
HttpStatus.valueOf(mirror.getHttpStatus()));
var httpHeaders = new HttpHeaders();
if (mirror.getHeaders() != null) {
mirror.getHeaders().forEach(h -> httpHeaders.add(h.getKey(), h.getValue()));
}

return new ResponseEntity<>(mirror, httpHeaders, HttpStatus.valueOf(mirror.getHttpStatus()));
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,26 @@
package org.jbehavesupport.core.test.app;

import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.ws.config.annotation.WsConfigurerAdapter;
import org.springframework.ws.config.annotation.WsConfigurer;
import org.springframework.ws.transport.http.MessageDispatcherServlet;
import org.springframework.ws.wsdl.wsdl11.DefaultWsdl11Definition;
import org.springframework.xml.xsd.SimpleXsdSchema;
import org.springframework.xml.xsd.XsdSchema;

@Configuration
public class WebServiceConfig extends WsConfigurerAdapter {
public class WebServiceConfig implements WsConfigurer {

@Bean
public ServletRegistrationBean<MessageDispatcherServlet> messageDispatcherServlet(ApplicationContext applicationContext) {
MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext);
servlet.setTransformWsdlLocations(true);
return new ServletRegistrationBean<>(servlet, "/services/*");
}

@Bean(name = "name")
public DefaultWsdl11Definition defaultWsdl11Definition(XsdSchema countriesSchema) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
spring:
jackson:
constructor-detector: explicit-only
Comment thread
Mejdlo marked this conversation as resolved.
datasource:
port: 11112
url: jdbc:h2:tcp://localhost:${spring.datasource.port}/mem:test;MODE=ORACLE
Expand All @@ -10,6 +12,7 @@ spring:
name: sa
password: sa


server:
port: 11110

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
</configuration>
</execution>
</executions>

</plugin>
</plugins>
</build>
Expand Down
8 changes: 4 additions & 4 deletions jbehave-support-core/docs/Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ We removed `org.jbehavesupport.core.internal.ConditionalOnMissingBean` annotatio
### Deprecated code removal
We have removed all previously deprecated code - please refer to [Deprecated.md](Deprecated.md) for more details how to migrate.

### Spring 6 upgrade
We are currently using Spring 6 internally, this brings with it several other requirements:
### Spring 7 upgrade
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe keep the old one as it is and create a new section Version 2.1.x (maybe begs a question of framework upgrade does not warrant major 3.x version, but due to the limited breaking changes I would say 2.1.0? What do you think?)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am used to major.minor.fix so I would prefer probably 3.0.0, since java and spring boot will be updated. But surely we could use 2.1.0 😄 Jakub has created version 3.0.0-RC for now to be able to test it properly in our test project (since we are probably the only team that is using it properly) but sure, we can use 2.1.0 after the release.

We are currently using Spring 7 internally, this brings with it several other requirements:

> #### Java 17
>We now currently require Java 17 as a minimal Java version (previously 8).
>We now currently require Java 17 as a minimal Java version.
>
> #### Jakarta EE 9
>Spring 6 internally brings with it upgrade to Jakarta EE 9, this means migration from old `javax.*` to `jakarta.*` packages, please consult guides on the Internet (and or your IDE support for migration) if needed.

### Spring Boot 3 introduction
### Spring Boot 4 introduction
We are now internally using Spring Boot - this means that ideally your main test configuration file should be annotated with both `@SpringBootConfiguration` and `@EnableAutoConfiguration`.
4 changes: 2 additions & 2 deletions jbehave-support-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@
<artifactId>lombok</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private void printRestMessage(final Writer writer, final RestMessageContext mess
private void printHeaders(final Writer writer, HttpHeaders headers) {
if (headers != null) {
printBegin(writer, HEADERS_TAG);
headers.entrySet().forEach(he -> printSelfClosed(writer, HEADER_TAG, getHeaderAttributes(he)));
headers.forEach((key, values) -> printSelfClosed(writer, HEADER_TAG, getHeaderAttributes(key, values)));
printEnd(writer, HEADERS_TAG);
}
}
Expand Down Expand Up @@ -159,10 +159,10 @@ private Map<String, String> getResponseMessageAttributes(RestMessageContext mess
return responseMessageAttributes;
}

private Map<String, String> getHeaderAttributes(Map.Entry<String, List<String>> header) {
private Map<String, String> getHeaderAttributes(String key, List<String> values) {
Map<String, String> headerAttributes = new HashMap<>();
headerAttributes.put("key", header.getKey());
headerAttributes.put("value", header.getValue().get(0));
headerAttributes.put("key", key);
headerAttributes.put("value", values.isEmpty() ? "" : values.get(0));
return headerAttributes;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private void storeResponse(final HttpStatusCodeException e) {

private HttpEntity createRequestEntity(ExamplesTable data) throws IOException {
if (data == null) { //return dummy
return new HttpEntity<>("", null);
return new HttpEntity<>("", HttpHeaders.EMPTY);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - did the old null cause issues? But yeah, this new version is definitely more readable 👍

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous implementation is not usable anymore due to the latest changes and Intellj Idea has been screaming on me 🙂

}
List<Triple<String, Object, String>> requestDataList = ExamplesTableUtil.convertTriple(data, NAME, DATA, ALIAS);
HttpHeaders headers = createHeaders(requestDataList);
Expand Down Expand Up @@ -443,8 +443,7 @@ private void verifyResponseHeaders(HttpHeaders actualHeaders, ExamplesTable data
if (key.startsWith(HEADER_START) && !key.equals(STATUS_HEADER)) {
String headerKey = key.substring(HEADER_START.length());
String assertionErrorMessage = "Headers don't contain " + headerKey + "\n" + actualResponseMessage;
assertThat(actualHeaders.containsKey(headerKey)).as(assertionErrorMessage).isTrue();

assertThat(actualHeaders.containsHeader(headerKey)).as(assertionErrorMessage).isTrue();
final Verifier verifier = verifierResolver.getVerifierByName(triple.getRight(), equalsVerifier);
verifier.verify(actualHeaders.get(headerKey).get(0), triple.getMiddle());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import static java.lang.Integer.parseInt;
import static java.util.Collections.singletonMap;
import static java.util.Objects.nonNull;
import static org.jbehavesupport.core.ssh.SshSetting.builder;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -122,7 +121,7 @@ public SshTemplate[] sshTemplate() throws IOException {
int port = parseInt(env.getProperty("ssh.port"));
String logPath = env.getProperty("ssh.logPath");

SshSetting passwordSetting = builder()
SshSetting passwordSetting = SshSetting.builder()
.hostname(hostname)
.user(user)
.password(env.getProperty("ssh.credentials.password"))
Expand All @@ -133,7 +132,7 @@ public SshTemplate[] sshTemplate() throws IOException {
String keyPath = resourceLoader.getResource(env.getProperty("ssh.credentials.keyPath"))
.getURL()
.getFile();
SshSetting keySetting = builder()
SshSetting keySetting = SshSetting.builder()
.hostname(hostname)
.user(user)
.keyPath(keyPath)
Expand All @@ -152,7 +151,7 @@ public SshTemplate[] sshTemplate() throws IOException {
@Bean
@Qualifier("LONG_REPORTABLE")
SshTemplate longReportableSshTemplate() throws IOException {
SshSetting sshSetting = builder()
SshSetting sshSetting = SshSetting.builder()
.hostname("fake hostname")
.user("fake user")
.password("asdf5684Daa")
Expand Down
16 changes: 6 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.4.0</version>
<version>4.0.5</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

Expand Down Expand Up @@ -74,19 +74,21 @@
<!-- enable annotation processing for lombok in java 23: https://github.com/projectlombok/lombok/issues/3752 -->
<maven.compiler.proc>full</maven.compiler.proc>

<!-- it needs to be specified due to groovy and java code in one codebase -->
<maven.compiler.target>${java.version}</maven.compiler.target>

<version.jbehave>5.0</version.jbehave>
<version.jbehave-junit-support>5.0.1</version.jbehave-junit-support>
<version.spockframework>2.4-M4-groovy-4.0</version.spockframework>
<version.spockframework>2.4-M7-groovy-5.0</version.spockframework>
<version.sshj>0.39.0</version.sshj>
<version.commons-text>1.12.0</version.commons-text>
<version.commons-collections4>4.4</version.commons-collections4>
<version.moxy>4.0.4</version.moxy>
<version.testcontainers>1.20.4</version.testcontainers>

<!-- remove once boot is on same or newer version -->
<selenium.version>4.13.0</selenium.version>

<plugin.version.gmavenplus-plugin>4.0.1</plugin.version.gmavenplus-plugin>
<plugin.version.gmavenplus-plugin>4.3.1</plugin.version.gmavenplus-plugin>
<plugin.version.maven-release-plugin>3.1.1</plugin.version.maven-release-plugin>
<plugin.version.nexus-staging-maven-plugin>1.6.13</plugin.version.nexus-staging-maven-plugin>
<plugin.version.maven-gpg-plugin>3.2.4</plugin.version.maven-gpg-plugin>
Expand Down Expand Up @@ -198,12 +200,6 @@
<artifactId>org.eclipse.persistence.moxy</artifactId>
<version>${version.moxy}</version>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>${version.testcontainers}</version>
<scope>test</scope>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
Loading