Skip to content

Commit 233f5b5

Browse files
committed
Hacking
1 parent 4a3bab5 commit 233f5b5

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

spring-ws-core/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ dependencies {
5555

5656
testImplementation("com.fasterxml.woodstox:woodstox-core")
5757
testImplementation("commons-io:commons-io")
58+
testImplementation("io.micrometer:micrometer-observation-test")
5859
testImplementation("net.minidev:json-smart:jar")
5960
testImplementation("org.apache.logging.log4j:log4j-core")
6061
testImplementation("org.apache.logging.log4j:log4j-slf4j2-impl")

spring-ws-core/src/main/java/org/springframework/ws/client/core/WebServiceTemplate.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,11 +736,13 @@ public boolean sendAndReceive(String uri, WebServiceMessageCallback requestCallb
736736
}
737737
catch (TransformerException ex) {
738738
triggerAfterCompletion(interceptorIndex, messageContext, ex);
739+
observation.error(ex);
739740
throw new WebServiceTransformerException("Transformation error: " + ex.getMessage(), ex);
740741
}
741742
catch (RuntimeException | IOException ex) {
742743
// Trigger after-completion for thrown exception.
743744
triggerAfterCompletion(interceptorIndex, messageContext, ex);
745+
observation.error(ex);
744746
throw ex;
745747
}
746748
finally {

spring-ws-core/src/main/java/org/springframework/ws/client/core/observation/ClientWebServiceObservationDocumentation.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
import io.micrometer.observation.ObservationConvention;
2222
import io.micrometer.observation.docs.ObservationDocumentation;
2323

24-
import org.springframework.http.client.ClientHttpRequestFactory;
24+
import org.springframework.ws.WebServiceMessage;
2525

2626
/**
27-
* Documented {@link io.micrometer.common.KeyValue KeyValues} for
28-
* {@link ClientHttpRequestFactory web service client} observations.
27+
* Documented {@link io.micrometer.common.KeyValue KeyValues} for {@link WebServiceMessage
28+
* web service client} observations.
2929
* <p>
3030
* This class is used by automated tools to document KeyValues attached to the web service
3131
* client observations.

spring-ws-core/src/test/java/org/springframework/ws/client/core/WebServiceTemplateTests.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import javax.xml.transform.Source;
2424
import javax.xml.transform.TransformerException;
2525

26+
import io.micrometer.observation.tck.TestObservationRegistry;
2627
import org.assertj.core.api.AbstractObjectAssert;
2728
import org.assertj.core.api.AbstractThrowableAssert;
2829
import org.assertj.core.api.AssertProvider;
@@ -62,6 +63,8 @@
6263
@SuppressWarnings("unchecked")
6364
class WebServiceTemplateTests {
6465

66+
private static final URI CONNECTION_URI = URI.create("http://www.springframework.org/spring-ws");
67+
6568
private WebServiceTemplate template;
6669

6770
private FaultAwareWebServiceConnection connectionMock;
@@ -74,8 +77,7 @@ void setUp() throws Exception {
7477
this.messageFactory = new MockWebServiceMessageFactory();
7578
this.template = new WebServiceTemplate(this.messageFactory);
7679
this.connectionMock = mock(FaultAwareWebServiceConnection.class);
77-
final URI expectedUri = new URI("http://www.springframework.org/spring-ws");
78-
when(this.connectionMock.getUri()).thenReturn(expectedUri);
80+
when(this.connectionMock.getUri()).thenReturn(CONNECTION_URI);
7981
this.template.setMessageSender(new WebServiceMessageSender() {
8082

8183
@Override
@@ -86,12 +88,12 @@ public WebServiceConnection createConnection(URI uri) {
8688
@Override
8789
public boolean supports(URI uri) {
8890

89-
assertThat(uri).isEqualTo(expectedUri);
91+
assertThat(uri).isEqualTo(CONNECTION_URI);
9092
return true;
9193
}
9294
});
9395

94-
this.template.setDefaultUri(expectedUri.toString());
96+
this.template.setDefaultUri(CONNECTION_URI.toString());
9597
}
9698

9799
@Test
@@ -619,6 +621,20 @@ public boolean supports(URI uri) {
619621
assertThat(result).isNull();
620622
}
621623

624+
@Test
625+
void testObservationWithSendAndReceiveResultResponse() throws Exception {
626+
TestObservationRegistry observationRegistry = TestObservationRegistry.create();
627+
this.template.setObservationRegistry(observationRegistry);
628+
Object unmarshalled = new Object();
629+
setupMarshallerAndUnmarshaller(unmarshalled);
630+
this.template.marshalSendAndReceive(new Object());
631+
assertThat(observationRegistry).hasObservationWithNameEqualTo("soap.client")
632+
.that()
633+
.hasLowCardinalityKeyValue("protocol", "http")
634+
.hasHighCardinalityKeyValue("uri", CONNECTION_URI.toString());
635+
636+
}
637+
622638
private static WebServiceMessageExtractor<Object> mockWebServiceMessageExtractor() {
623639
return mock(WebServiceMessageExtractor.class);
624640
}

spring-ws-platform/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ javaPlatform {
2323
}
2424

2525
dependencies {
26+
api(platform("io.micrometer:micrometer-bom:1.16.1"))
2627
api(platform("org.apache.logging.log4j:log4j-bom:2.25.2"))
2728
api(platform("org.apache.activemq:activemq-bom:6.1.8"))
2829
api(platform("org.eclipse.jetty:jetty-bom:12.1.4"))

0 commit comments

Comments
 (0)