diff --git a/pom.xml b/pom.xml index 531bf90..ba76300 100644 --- a/pom.xml +++ b/pom.xml @@ -57,7 +57,7 @@ 17 UTF-8 UTF-8 - 3.25.8 + 4.33.0 -XX:+EnableDynamicAgentLoading @@ -78,7 +78,8 @@ org.junit junit-bom - 5.13.4 + + 5.14.0 pom import @@ -99,7 +100,7 @@ io.cucumber cucumber-bom - 7.25.0 + 7.30.0 pom import @@ -293,7 +294,7 @@ io.github.ascopes protobuf-maven-plugin - 3.7.0 + 3.10.2 @@ -310,17 +311,13 @@ maven-surefire-plugin - - 3.5.2 + 3.5.4 false - cucumber.junit-platform.naming-strategy=surefire + cucumber.junit-platform.naming-strategy=long diff --git a/src/main/java/org/eclipse/uprotocol/communication/InMemoryRpcClient.java b/src/main/java/org/eclipse/uprotocol/communication/InMemoryRpcClient.java index f589836..cd328f2 100644 --- a/src/main/java/org/eclipse/uprotocol/communication/InMemoryRpcClient.java +++ b/src/main/java/org/eclipse/uprotocol/communication/InMemoryRpcClient.java @@ -91,10 +91,10 @@ public CompletionStage 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); @@ -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 responseFuture = mRequests.remove(responseAttributes.getReqid()); if (responseFuture == null) { diff --git a/src/test/java/org/eclipse/uprotocol/uri/serializer/UriSerializerTest.java b/src/test/java/org/eclipse/uprotocol/uri/serializer/UriSerializerTest.java index 4edde79..ec2d8d9 100644 --- a/src/test/java/org/eclipse/uprotocol/uri/serializer/UriSerializerTest.java +++ b/src/test/java/org/eclipse/uprotocol/uri/serializer/UriSerializerTest.java @@ -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); @@ -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()); + } }