-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[JBWS-4232]:Add testcase to demonstrate how to enable HTTP/2 and HTTP…
…/1.1 support in client side
- Loading branch information
Showing
4 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/http2/HelloWorld.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.jboss.test.ws.jaxws.cxf.http2; | ||
|
||
import jakarta.jws.WebService; | ||
|
||
@WebService(targetNamespace = "http://org.jboss.ws/jaxws/cxf/http2") | ||
public interface HelloWorld | ||
{ | ||
String echo(String input); | ||
} |
35 changes: 35 additions & 0 deletions
35
...s/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/http2/HelloWorldImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.jboss.test.ws.jaxws.cxf.http2; | ||
|
||
import jakarta.jws.WebService; | ||
|
||
@WebService | ||
( | ||
serviceName = "HelloWorldService", | ||
endpointInterface = "org.jboss.test.ws.jaxws.cxf.http2.HelloWorld", | ||
targetNamespace = "http://org.jboss.ws/jaxws/cxf/http2" | ||
) | ||
public class HelloWorldImpl implements HelloWorld | ||
{ | ||
public String echo(String input) | ||
{ | ||
return input; | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
...estsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/http2/Http2EndpointTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you 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 org.jboss.test.ws.jaxws.cxf.http2; | ||
|
||
import jakarta.xml.ws.Service; | ||
import java.io.File; | ||
import java.net.MalformedURLException; | ||
import java.net.URL; | ||
import javax.xml.namespace.QName; | ||
import org.apache.cxf.BusFactory; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.jboss.wsf.test.JBossWSTest; | ||
import org.jboss.wsf.test.JBossWSTestHelper; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
@RunWith(Arquillian.class) | ||
public class Http2EndpointTest extends JBossWSTest { | ||
@ArquillianResource | ||
private URL baseURL; | ||
|
||
|
||
@Deployment(testable = false) | ||
public static WebArchive createDeployment() { | ||
WebArchive archive = ShrinkWrap.create(WebArchive.class, "jaxws-cxf-http2.war"); | ||
archive.setManifest(new StringAsset("Manifest-Version: 1.0\n" | ||
+ "Dependencies: org.apache.cxf\n")) | ||
.addClass(HelloWorld.class) | ||
.addClass(HelloWorldImpl.class) | ||
.setWebXML(new File(JBossWSTestHelper.getTestResourcesDir() + "/jaxws/cxf/http2/WEB-INF/web.xml")); | ||
return archive; | ||
} | ||
@Test | ||
@RunAsClient | ||
public void testHttp11() throws Exception { | ||
BusFactory.getDefaultBus().setProperty("org.apache.cxf.transport.http.forceVersion", "1"); | ||
HelloWorld port = getPort(); | ||
String response = port.echo("hello"); | ||
Assert.assertEquals("hello is expected", "hello", response); | ||
} | ||
|
||
@Test | ||
@RunAsClient | ||
public void testHttp2() throws Exception { | ||
BusFactory.getDefaultBus().setProperty("org.apache.cxf.transport.http.forceVersion", "2"); | ||
HelloWorld port = getPort(); | ||
String response = port.echo("hello"); | ||
Assert.assertEquals("hello is expected", "hello", response); | ||
} | ||
|
||
private HelloWorld getPort() throws MalformedURLException | ||
{ | ||
URL wsdlURL = new URL(baseURL.toString() + "/jaxws-cxf-http2?wsdl"); | ||
QName serviceName = new QName("http://org.jboss.ws/jaxws/cxf/http2", "HelloWorldService"); | ||
Service service = Service.create(wsdlURL, serviceName); | ||
QName portQName = new QName("http://org.jboss.ws/jaxws/cxf/http2", "HelloWorldImplPort"); | ||
HelloWorld port = (HelloWorld) service.getPort(portQName, HelloWorld.class); | ||
return port; | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/http2/WEB-INF/web.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<web-app | ||
version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"> | ||
|
||
<servlet> | ||
<servlet-name>HelloService</servlet-name> | ||
<servlet-class>org.jboss.test.ws.jaxws.cxf.http2.HelloWorldImpl</servlet-class> | ||
</servlet> | ||
|
||
<servlet-mapping> | ||
<servlet-name>HelloService</servlet-name> | ||
<url-pattern>/*</url-pattern> | ||
</servlet-mapping> | ||
</web-app> |