Skip to content

Commit

Permalink
Revisit logging configuration fix #1162
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Dec 29, 2023
1 parent 3ca46ee commit 749dac0
Show file tree
Hide file tree
Showing 14 changed files with 877 additions and 294 deletions.
180 changes: 91 additions & 89 deletions docs/modules/ROOT/pages/includes/quarkus-cxf.adoc

Large diffs are not rendered by default.

23 changes: 19 additions & 4 deletions docs/modules/ROOT/pages/reference/extensions/quarkus-cxf.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,26 @@ endif::[]
[id="quarkus-cxf-usage"]
== Usage

Check the following chapters of xref:user-guide/index.adoc[User guide]:
There are several chapters in the xref:user-guide/index.adoc[User guide] covering the usage of this extension:

** xref:user-guide/first-soap-web-service.adoc[Your first SOAP Web service]
** xref:user-guide/first-soap-client.adoc[Your first SOAP Client]
** xref:user-guide/payload-logging.adoc[Payload logging]
* xref:user-guide/first-soap-web-service.adoc[Your first SOAP Web service]
* xref:user-guide/first-soap-client.adoc[Your first SOAP Client]
* xref:user-guide/configuration.adoc[Configuration]
* xref:user-guide/package-for-jvm-and-native.adoc[Package for JVM and native]
* xref:user-guide/payload-logging.adoc[Logging]
* xref:user-guide/ssl.adoc[SSL]
* xref:user-guide/auth.adoc[Authentication and authorization]
* xref:user-guide/advanced-soap-client-topics.adoc[Advanced SOAP client topics]
* xref:user-guide/advanced-soap-server-topics.adoc[Advanced SOAP server topics]
* xref:user-guide/generate-java-from-wsdl.adoc[Generate Java from WSDL]
* xref:user-guide/generate-wsdl-from-java.adoc[Generate WSDL from Java]
* xref:user-guide/contract-first-code-first.adoc[Contract first and code first]
* xref:user-guide/cxf-interceptors-and-features.adoc[CXF Interceptors and Features]
* xref:user-guide/jax-ws-handlers.adoc[JAX-WS Handlers]
* xref:user-guide/jax-ws-providers.adoc[JAX-WS Providers]
* xref:user-guide/supported-soap-binding.adoc[Supported SOAP Bindings]
* xref:user-guide/examples.adoc[Examples]
* xref:user-guide/common-problems-troubleshooting.adoc[Common problems and troubleshooting]


[id="quarkus-cxf-configuration"]
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/user-guide/payload-logging.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ The global settings can be xref:#per-client-or-service-endpoind-payload-logging[
.application.properties
[source,properties,subs=attributes+]
----
# For a service:
# Global settings
quarkus.cxf.logging.enabled = true
quarkus.cxf.logging.pretty = true
----
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package io.quarkiverse.cxf.deployment.logging;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.util.logging.LogRecord;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkiverse.cxf.annotation.CXFClient;
import io.quarkus.test.QuarkusUnitTest;

/**
* {@code LoggingFeature} set in {@code application.properties} and a named bean is produced via
* {@link NamedLoggingFeatureProducer}
*/
public class EnabledPrettyLoggingFeatureTest {

@RegisterExtension
static final QuarkusUnitTest TEST = new QuarkusUnitTest()
.withApplicationRoot(
root -> root.addClasses(HelloService.class, HelloServiceImpl.class))
.overrideConfigKey("quarkus.cxf.endpoint.\"/hello\".implementor", HelloServiceImpl.class.getName())
.overrideConfigKey("quarkus.cxf.endpoint.\"/hello\".logging.enabled", "true")
.overrideConfigKey("quarkus.cxf.endpoint.\"/hello\".logging.pretty", "false")
.overrideConfigKey("quarkus.cxf.client.hello.service-interface", HelloService.class.getName())
.overrideConfigKey("quarkus.cxf.client.hello.client-endpoint-url", "http://localhost:8081/services/hello")
.overrideConfigKey("quarkus.cxf.client.hello.logging.enabled", "pretty")
.setLogRecordPredicate(logRecord -> logRecord.getLoggerName().contains("org.apache.cxf.services.HelloService.RE")) // REQ_IN or RESP_OUT
.assertLogRecords(records -> assertThat(records)
.extracting(LogRecord::getMessage)
.anyMatch(msg -> msg.contains(
/* The service in message is not pretty */
"Payload: <soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:hello xmlns:ns2=\"http://deployment.logging.features.cxf.quarkiverse.io/\"><arg0>Dolly</arg0></ns2:hello></soap:Body></soap:Envelope>"))
.anyMatch(msg -> msg.contains(
/* The service out message is not pretty */
"Payload: <soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ns2:helloResponse xmlns:ns2=\"http://deployment.logging.features.cxf.quarkiverse.io/\"><return>Hello Dolly!</return></ns2:helloResponse></soap:Body></soap:Envelope>"))
.anyMatch(msg -> msg.contains(
"Payload: <soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
+ " <soap:Body>\n"
+ " <ns2:hello xmlns:ns2=\"http://deployment.logging.features.cxf.quarkiverse.io/\">\n"
+ " <arg0>Dolly</arg0>\n"
+ " </ns2:hello>\n"
+ " </soap:Body>\n"
+ "</soap:Envelope>"))
.anyMatch(msg -> msg.contains(
"Payload: <soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
+ " <soap:Body>\n"
+ " <ns2:helloResponse xmlns:ns2=\"http://deployment.logging.features.cxf.quarkiverse.io/\">\n"
+ " <return>Hello Dolly!</return>\n"
+ " </ns2:helloResponse>\n"
+ " </soap:Body>\n"
+ "</soap:Envelope>"))
.hasSize(4));

@CXFClient("hello")
HelloService helloService;

@Test
void payloadPrettyLogged() throws IOException {

helloService.hello("Dolly");

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.quarkiverse.cxf.deployment.logging;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.util.logging.LogRecord;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import io.quarkiverse.cxf.annotation.CXFClient;
import io.quarkiverse.cxf.test.QuarkusCxfClientTestUtil;
import io.quarkus.test.QuarkusUnitTest;

/**
* A global logging feature configured in {@code application.properties}.
*/
public class GlobalClientsLoggingConfigurationTest {

@RegisterExtension
static final QuarkusUnitTest TEST = new QuarkusUnitTest()
.withApplicationRoot(
root -> root.addClasses(HelloService.class, HelloServiceImpl.class))
.overrideConfigKey("quarkus.cxf.logging.enabled-for", "clients")
.overrideConfigKey("quarkus.cxf.logging.pretty", "true")
.overrideConfigKey("quarkus.cxf.endpoint.\"/hello\".implementor", HelloServiceImpl.class.getName())
.overrideConfigKey("quarkus.cxf.client.hello.service-interface", HelloService.class.getName())
.overrideConfigKey("quarkus.cxf.client.hello.client-endpoint-url", "http://localhost:8081/services/hello")

.setLogRecordPredicate(logRecord -> logRecord.getLoggerName().contains("org.apache.cxf.services.HelloService.RE")) // REQ_IN or RESP_OUT
.assertLogRecords(records -> assertThat(records)
.extracting(LogRecord::getMessage)
.anyMatch(QuarkusCxfClientTestUtil.messageExists("REQ_OUT",
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
+ " <soap:Body>\n"
+ " <ns2:hello xmlns:ns2=\"http://deployment.logging.features.cxf.quarkiverse.io/\">\n"
+ " <arg0>Dolly</arg0>\n"
+ " </ns2:hello>\n"
+ " </soap:Body>\n"
+ "</soap:Envelope>\n"))
.anyMatch(QuarkusCxfClientTestUtil.messageExists("RESP_IN",
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
+ " <soap:Body>\n"
+ " <ns2:helloResponse xmlns:ns2=\"http://deployment.logging.features.cxf.quarkiverse.io/\">\n"
+ " <return>Hello Dolly!</return>\n"
+ " </ns2:helloResponse>\n"
+ " </soap:Body>\n"
+ "</soap:Envelope>\n"))
.hasSize(2));

@CXFClient("hello")
HelloService helloService;

@Test
void payloadPrettyLogged() throws IOException {

helloService.hello("Dolly");

}

}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

package io.quarkiverse.cxf.deployment.logging;

import static org.assertj.core.api.Assertions.assertThat;
Expand Down
13 changes: 13 additions & 0 deletions extensions/core/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@
<artifactId>graal-sdk</artifactId>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
23 changes: 19 additions & 4 deletions extensions/core/runtime/src/main/doc/usage.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
Check the following chapters of xref:user-guide/index.adoc[User guide]:
There are several chapters in the xref:user-guide/index.adoc[User guide] covering the usage of this extension:

** xref:user-guide/first-soap-web-service.adoc[Your first SOAP Web service]
** xref:user-guide/first-soap-client.adoc[Your first SOAP Client]
** xref:user-guide/payload-logging.adoc[Payload logging]
* xref:user-guide/first-soap-web-service.adoc[Your first SOAP Web service]
* xref:user-guide/first-soap-client.adoc[Your first SOAP Client]
* xref:user-guide/configuration.adoc[Configuration]
* xref:user-guide/package-for-jvm-and-native.adoc[Package for JVM and native]
* xref:user-guide/payload-logging.adoc[Logging]
* xref:user-guide/ssl.adoc[SSL]
* xref:user-guide/auth.adoc[Authentication and authorization]
* xref:user-guide/advanced-soap-client-topics.adoc[Advanced SOAP client topics]
* xref:user-guide/advanced-soap-server-topics.adoc[Advanced SOAP server topics]
* xref:user-guide/generate-java-from-wsdl.adoc[Generate Java from WSDL]
* xref:user-guide/generate-wsdl-from-java.adoc[Generate WSDL from Java]
* xref:user-guide/contract-first-code-first.adoc[Contract first and code first]
* xref:user-guide/cxf-interceptors-and-features.adoc[CXF Interceptors and Features]
* xref:user-guide/jax-ws-handlers.adoc[JAX-WS Handlers]
* xref:user-guide/jax-ws-providers.adoc[JAX-WS Providers]
* xref:user-guide/supported-soap-binding.adoc[Supported SOAP Bindings]
* xref:user-guide/examples.adoc[Examples]
* xref:user-guide/common-problems-troubleshooting.adoc[Common problems and troubleshooting]
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import io.smallrye.config.WithDefaults;
import io.smallrye.config.WithName;

@ConfigMapping(prefix = "quarkus.cxf")
Expand All @@ -18,12 +19,14 @@ public interface CxfConfig {
* Choose the path of each web services.
*/
@WithName("endpoint")
@WithDefaults
public Map<String, CxfEndpointConfig> endpoints();

/**
* Configure client proxies.
*/
@WithName("client")
@WithDefaults
public Map<String, CxfClientConfig> clients();

/**
Expand Down
Loading

0 comments on commit 749dac0

Please sign in to comment.