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
17 changes: 7 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<java.version>17</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<protobuf.version>3.25.8</protobuf.version>
<protobuf.version>4.33.0</protobuf.version>
<!-- allow dynamic loading of the Mockito Mock agent -->
<!-- see https://www.jacoco.org/jacoco/trunk/doc/prepare-agent-mojo.html -->
<argLine>-XX:+EnableDynamicAgentLoading</argLine>
Expand All @@ -78,7 +78,8 @@
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.13.4</version>
<!-- this version must match the version of junit used by Cucumber JVM -->
<version>5.14.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand All @@ -99,7 +100,7 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-bom</artifactId>
<version>7.25.0</version>
<version>7.30.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
Expand Down Expand Up @@ -293,7 +294,7 @@
<plugin>
<groupId>io.github.ascopes</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>3.7.0</version>
<version>3.10.2</version>
<executions>
<execution>
<goals>
Expand All @@ -310,17 +311,13 @@
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<!--
do NOT use 3.5.3 as it is incompatible with Cucumber
https://github.com/cucumber/cucumber-jvm/issues/2984
-->
<version>3.5.2</version>
<version>3.5.4</version>
<configuration>
<!-- allow to use unnamed modules -->
<useModulePath>false</useModulePath>
<properties>
<configurationParameters>
cucumber.junit-platform.naming-strategy=surefire
cucumber.junit-platform.naming-strategy=long
</configurationParameters>
</properties>
</configuration>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,10 @@ public CompletionStage<UPayload> invokeMethod(UUri methodUri, UPayload requestPa
Objects.requireNonNull(options, "Call options cannot be null");

UMessageBuilder builder = UMessageBuilder.request(getUriProvider().getSource(), methodUri, options.timeout());
Optional.ofNullable(options.priority()).ifPresent(priority -> builder.withPriority(priority));
Optional.ofNullable(options.priority()).ifPresent(builder::withPriority);
Optional.ofNullable(options.token())
.filter(s -> !s.isBlank())
.ifPresent(token -> builder.withToken(token));
.ifPresent(builder::withToken);

// Build the request message
final UMessage request = builder.build(requestPayload);
Expand Down Expand Up @@ -132,14 +132,13 @@ public void close() {
}

private void handleResponse(UMessage message) {
final UAttributes responseAttributes = message.getAttributes();
// Only handle responses messages
if (message.getAttributes().getType() != UMessageType.UMESSAGE_TYPE_RESPONSE) {
if (responseAttributes.getType() != UMessageType.UMESSAGE_TYPE_RESPONSE) {
Optional.ofNullable(unexpectedMessageHandler).ifPresent(handler -> handler.accept(message));
return;
}

final UAttributes responseAttributes = message.getAttributes();


// Check if the response is for a request we made, if not then ignore it
final CompletableFuture<UMessage> responseFuture = mRequests.remove(responseAttributes.getReqid());
if (responseFuture == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ void testSerializingANullUuri() {
}

@Test
@DisplayName("Test deserializing a null UUri fails")
void testDeserializingANullUuriFails() {
@DisplayName("Test deserializing a null URI fails")
void testDeserializingANullUriFails() {
assertThrows(NullPointerException.class, () -> UriSerializer.deserialize((String) null));
assertThrows(NullPointerException.class, () -> UriSerializer.deserialize((URI) null));
}

@Test
@DisplayName("Test deserializing a UUri with authority name exceeding max length fails")
@DisplayName("Test deserializing a URI with authority name exceeding max length fails")
// [utest->dsn~uri-authority-name-length~1]
void testDeserializeRejectsAuthorityNameExceedingMaxLength() {
String authority = "a".repeat(UriValidator.AUTHORITY_NAME_MAX_LENGTH);
Expand All @@ -48,4 +48,14 @@ void testDeserializeRejectsAuthorityNameExceedingMaxLength() {
var invalidUri = "up://%s/ABCD/1/1001".formatted(authority);
assertThrows(IllegalArgumentException.class, () -> UriSerializer.deserialize(invalidUri));
}

@Test
@DisplayName("Test deserializing URI that contains lower case hex-encoded values succeeds")
// [utest->dsn~uri-path-mapping~2]
void testDeserializingLowerCaseHexEncodingSuccceeds() {
var uuri = UriSerializer.deserialize("up://example.com/abcd/a1/ef01");
assertEquals(0xabcd, uuri.getUeId());
assertEquals(0xa1, uuri.getUeVersionMajor());
assertEquals(0xef01, uuri.getResourceId());
}
}