Skip to content

Commit

Permalink
Move code-first ClientGreetingClientTest to the client test module
Browse files Browse the repository at this point in the history
  • Loading branch information
ppalaga committed Aug 15, 2022
1 parent 85bece2 commit 6fcf219
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 112 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* JBoss, Home of Professional Open Source
* Copyright 2015, Red Hat, Inc. and/or its affiliates, and individual
* contributors by the @authors tag. See the copyright.txt in the
* distribution for a full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.quarkiverse.cxf.client.it;

import javax.jws.WebMethod;
import javax.jws.WebService;

/**
* An incomplete copy of
* https://github.com/l2x6/calculator-ws/blob/1.0/src/main/java/org/jboss/as/quickstarts/wscalculator/CalculatorService.java
* CXF should be able to use this to produce a partial client communicating with a compatible service endpoint.
*/
@WebService(targetNamespace = CodeFirstClient.TARGET_NS, name = "CalculatorService")
public interface CodeFirstClient {

public static final String TARGET_NS = "http://www.jboss.org/eap/quickstarts/wscalculator/Calculator";

@WebMethod
public int multiply(int intA, int intB);
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public class CxfClientResource {
@CXFClient("mySkewedCalculator") // name used in application.properties
CalculatorService mySkewedCalculator;

@Inject
@CXFClient("codeFirstClient") // name used in application.properties
CodeFirstClient codeFirstClient;

@Inject
@CXFClient("myFaultyCalculator") // name used in application.properties
CalculatorService myFaultyCalculator;
Expand All @@ -50,6 +54,13 @@ public Response multiplyDefault(@PathParam("client") String client, @QueryParam(
}
}

@GET
@Path("/codeFirstClient/multiply")
@Produces(MediaType.TEXT_PLAIN)
public int codeFirstClient(@PathParam("client") String client, @QueryParam("a") int a, @QueryParam("b") int b) {
return codeFirstClient.multiply(a, b);
}

@GET
@Path("/calculator/{client}/addOperands")
@Produces(MediaType.TEXT_PLAIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ quarkus.cxf.client.mySkewedCalculator.wsdl=${cxf.it.skewed-calculator.baseUri}/c
quarkus.cxf.client.mySkewedCalculator.client-endpoint-url=${cxf.it.skewed-calculator.baseUri}/calculator-ws/CalculatorService
quarkus.cxf.client.mySkewedCalculator.endpoint-namespace=http://www.jboss.org/eap/quickstarts/wscalculator/Calculator
quarkus.cxf.client.mySkewedCalculator.endpoint-name=Calculator

#quarkus.cxf.client.codeFirstClient.wsdl=${cxf.it.calculator.baseUri}/calculator-ws/CalculatorService?wsdl
quarkus.cxf.client.codeFirstClient.client-endpoint-url=${cxf.it.calculator.baseUri}/calculator-ws/CalculatorService
quarkus.cxf.client.codeFirstClient.service-interface=io.quarkiverse.cxf.client.it.CodeFirstClient
quarkus.cxf.client.codeFirstClient.endpoint-namespace=http://www.jboss.org/eap/quickstarts/wscalculator/Calculatorrr
quarkus.cxf.client.codeFirstClient.endpoint-name=CalculatorService
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,20 @@ void outInterceptor() {
.body(is("No luck at this time, Luke!"));
}

/**
* Test whether a code-first client (without WSDL) works properly.
*/
@Test
void codeFirstClient() {
RestAssured.given()
.queryParam("a", 3)
.queryParam("b", 4)
.get("/cxf/client/codeFirstClient/multiply")
.then()
.statusCode(200)
.body(is("12"));
}

/**
* Check whether we can get the WSDL URL configured in application.properties from the application code via
* {@link CXFClientInfo}.
Expand Down Expand Up @@ -123,6 +137,7 @@ void wsdlUpToDate() throws IOException {
.getValue("quarkus.cxf.client.myCalculator.wsdl", String.class);

final String staticCopyPath = "src/main/cxf-codegen-resources/wsdl/CalculatorService.wsdl";
/* The changing Docker IP address in the WSDL should not matter */
final String sanitizerRegex = "<soap:address location=\"http://[^/]*/calculator-ws/CalculatorService\"></soap:address>";
final String staticCopyContent = Files
.readString(Paths.get(staticCopyPath), StandardCharsets.UTF_8)
Expand Down

0 comments on commit 6fcf219

Please sign in to comment.