repo
stringlengths
1
191
file
stringlengths
23
351
code
stringlengths
0
5.32M
file_length
int64
0
5.32M
avg_line_length
float64
0
2.9k
max_line_length
int64
0
288k
extension_type
stringclasses
1 value
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/trust/onbehalfof/OnBehalfOfServiceImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.trust.onbehalfof; import org.apache.cxf.Bus; import org.apache.cxf.BusFactory; import org.apache.cxf.annotations.EndpointProperties; import org.apache.cxf.annotations.EndpointProperty; import org.apache.cxf.ws.security.SecurityConstants; import org.apache.cxf.ws.security.trust.STSClient; import org.jboss.as.test.integration.ws.wsse.trust.service.ServiceIface; import jakarta.jws.WebService; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import java.net.MalformedURLException; import java.net.URL; import java.util.Map; /** * User: [email protected] * Date: 1/26/14 */ @WebService ( portName = "OnBehalfOfServicePort", serviceName = "OnBehalfOfService", wsdlLocation = "WEB-INF/wsdl/OnBehalfOfService.wsdl", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/onbehalfofwssecuritypolicy", endpointInterface = "org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfServiceIface" ) @EndpointProperties(value = { @EndpointProperty(key = "ws-security.signature.username", value = "myactaskey"), @EndpointProperty(key = "ws-security.signature.properties", value = "actasKeystore.properties"), @EndpointProperty(key = "ws-security.encryption.properties", value = "actasKeystore.properties"), @EndpointProperty(key = "ws-security.callback-handler", value = "org.jboss.as.test.integration.ws.wsse.trust.onbehalfof.OnBehalfOfCallbackHandler") }) public class OnBehalfOfServiceImpl implements OnBehalfOfServiceIface { public String sayHello(String host, String port) { Bus bus = BusFactory.newInstance().createBus(); try { BusFactory.setThreadDefaultBus(bus); final String serviceURL = "http://" + host + ":" + port + "/jaxws-samples-wsse-policy-trust/SecurityService"; final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "SecurityService"); final URL wsdlURL = new URL(serviceURL + "?wsdl"); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); Map<String, Object> ctx = ((BindingProvider) proxy).getRequestContext(); ctx.put(SecurityConstants.CALLBACK_HANDLER, new OnBehalfOfCallbackHandler()); ctx.put(SecurityConstants.SIGNATURE_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("actasKeystore.properties")); ctx.put(SecurityConstants.SIGNATURE_USERNAME, "myactaskey"); ctx.put(SecurityConstants.ENCRYPT_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("../../META-INF/clientKeystore.properties")); ctx.put(SecurityConstants.ENCRYPT_USERNAME, "myservicekey"); STSClient stsClient = new STSClient(bus); Map<String, Object> props = stsClient.getProperties(); props.put(SecurityConstants.USERNAME, "bob"); //-rls test props.put(SecurityConstants.ENCRYPT_USERNAME, "mystskey"); props.put(SecurityConstants.STS_TOKEN_USERNAME, "myactaskey"); props.put(SecurityConstants.STS_TOKEN_PROPERTIES, Thread.currentThread().getContextClassLoader().getResource("actasKeystore.properties")); props.put(SecurityConstants.STS_TOKEN_USE_CERT_FOR_KEYINFO, "true"); ctx.put(SecurityConstants.STS_CLIENT, stsClient); return "OnBehalfOf " + proxy.sayHello(); } catch (MalformedURLException e) { e.printStackTrace(); return null; } finally { bus.shutdown(true); } } }
4,903
46.153846
155
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/trust/bearer/BearerIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.trust.bearer; import jakarta.jws.WebMethod; import jakarta.jws.WebService; @WebService ( targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/bearerwssecuritypolicy" ) public interface BearerIface { @WebMethod String sayHello(); }
1,360
37.885714
101
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/trust/bearer/BearerImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.trust.bearer; import org.apache.cxf.annotations.EndpointProperties; import org.apache.cxf.annotations.EndpointProperty; import jakarta.jws.WebService; @WebService ( portName = "BearerServicePort", serviceName = "BearerService", wsdlLocation = "WEB-INF/wsdl/BearerService.wsdl", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/bearerwssecuritypolicy", endpointInterface = "org.jboss.as.test.integration.ws.wsse.trust.bearer.BearerIface" ) @EndpointProperties(value = { @EndpointProperty(key = "ws-security.signature.properties", value = "serviceKeystore.properties") }) public class BearerImpl implements BearerIface { public String sayHello() { return "Bearer WS-Trust Hello World!"; } }
1,903
41.311111
105
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/trust/bearer/BearerEJBImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2018, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.trust.bearer; import org.apache.cxf.annotations.EndpointProperties; import org.apache.cxf.annotations.EndpointProperty; import org.jboss.as.test.integration.ws.wsse.trust.ContextProvider; import jakarta.annotation.Resource; import jakarta.ejb.EJB; import jakarta.jws.WebService; import jakarta.xml.ws.WebServiceContext; @WebService ( portName = "BearerServicePort", serviceName = "BearerService", wsdlLocation = "WEB-INF/wsdl/BearerService.wsdl", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/bearerwssecuritypolicy", endpointInterface = "org.jboss.as.test.integration.ws.wsse.trust.bearer.BearerIface" ) @EndpointProperties(value = { @EndpointProperty(key = "ws-security.signature.properties", value = "serviceKeystore.properties"), }) @org.apache.cxf.interceptor.InInterceptors (interceptors = {"org.jboss.as.test.integration.ws.wsse.trust.SamlSecurityContextInInterceptor" }) public class BearerEJBImpl implements BearerIface { @Resource WebServiceContext context; @EJB ContextProvider ejbContext; public String sayHello() { String wsprincipal = context.getUserPrincipal().getName(); return wsprincipal + "&" + ejbContext.getEjbCallerPrincipalName(); } }
2,401
42.672727
141
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/trust/sts/SampleSTS.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.trust.sts; import org.apache.cxf.annotations.EndpointProperties; import org.apache.cxf.annotations.EndpointProperty; import org.apache.cxf.interceptor.InInterceptors; import org.apache.cxf.sts.StaticSTSProperties; import org.apache.cxf.sts.operation.TokenIssueOperation; import org.apache.cxf.sts.operation.TokenValidateOperation; import org.apache.cxf.sts.service.ServiceMBean; import org.apache.cxf.sts.service.StaticService; import org.apache.cxf.sts.token.delegation.UsernameTokenDelegationHandler; import org.apache.cxf.sts.token.provider.SAMLTokenProvider; import org.apache.cxf.sts.token.validator.SAMLTokenValidator; import org.apache.cxf.sts.token.validator.UsernameTokenValidator; import org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider; import org.jboss.as.test.integration.ws.wsse.trust.shared.WSTrustAppUtils; import jakarta.xml.ws.WebServiceProvider; import java.util.Arrays; import java.util.LinkedList; import java.util.List; @WebServiceProvider(serviceName = "SecurityTokenService", portName = "UT_Port", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/", wsdlLocation = "WEB-INF/wsdl/ws-trust-1.4-service.wsdl") //be sure to have dependency on org.apache.cxf module when on AS7, otherwise Apache CXF annotations are ignored @EndpointProperties(value = { @EndpointProperty(key = "ws-security.signature.username", value = "mystskey"), @EndpointProperty(key = "ws-security.signature.properties", value = "stsKeystore.properties"), @EndpointProperty(key = "ws-security.callback-handler", value = "org.jboss.as.test.integration.ws.wsse.trust.sts.STSCallbackHandler"), @EndpointProperty(key = "ws-security.validate.token", value = "false") //to let the JAAS integration deal with validation through the interceptor below }) @InInterceptors(interceptors = {"org.jboss.wsf.stack.cxf.security.authentication.SubjectCreatingPolicyInterceptor"}) public class SampleSTS extends SecurityTokenServiceProvider { public SampleSTS() throws Exception { super(); StaticSTSProperties props = new StaticSTSProperties(); props.setSignatureCryptoProperties("stsKeystore.properties"); props.setSignatureUsername("mystskey"); props.setCallbackHandlerClass(STSCallbackHandler.class.getName()); props.setIssuer("DoubleItSTSIssuer"); List<ServiceMBean> services = new LinkedList<ServiceMBean>(); StaticService service = new StaticService(); String serverHostRegexp = WSTrustAppUtils.getServerHost().replace("[", "\\[").replace("]", "\\]").replace("127.0.0.1", "localhost"); service.setEndpoints(Arrays.asList( "http://" + serverHostRegexp + ":(\\d)*/jaxws-samples-wsse-policy-trust/SecurityService", "http://" + serverHostRegexp + ":(\\d)*/jaxws-samples-wsse-policy-trust-actas/ActAsService", "http://" + serverHostRegexp + ":(\\d)*/jaxws-samples-wsse-policy-trust-onbehalfof/OnBehalfOfService" )); services.add(service); TokenIssueOperation issueOperation = new TokenIssueOperation(); issueOperation.setServices(services); issueOperation.getTokenProviders().add(new SAMLTokenProvider()); // required for OnBehalfOf issueOperation.getTokenValidators().add(new UsernameTokenValidator()); // added for OnBehalfOf and ActAs issueOperation.getDelegationHandlers().add(new UsernameTokenDelegationHandler()); issueOperation.setStsProperties(props); TokenValidateOperation validateOperation = new TokenValidateOperation(); validateOperation.getTokenValidators().add(new SAMLTokenValidator()); validateOperation.setStsProperties(props); this.setIssueOperation(issueOperation); this.setValidateOperation(validateOperation); } }
4,947
52.204301
159
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/trust/sts/STSCallbackHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.trust.sts; import org.jboss.wsf.stack.cxf.extensions.security.PasswordCallbackHandler; import java.util.HashMap; import java.util.Map; public class STSCallbackHandler extends PasswordCallbackHandler { public STSCallbackHandler() { super(getInitMap()); } private static Map<String, String> getInitMap() { Map<String, String> passwords = new HashMap<String, String>(); passwords.put("mystskey", "stskpass"); passwords.put("alice", "clarinet"); return passwords; } }
1,602
38.097561
75
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/trust/stsholderofkey/SampleSTSHolderOfKey.java
/* * JBoss, Home of Professional Open Source. * Copyright 2014, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.trust.stsholderofkey; import org.apache.cxf.annotations.EndpointProperties; import org.apache.cxf.annotations.EndpointProperty; import org.apache.cxf.sts.StaticSTSProperties; import org.apache.cxf.sts.operation.TokenIssueOperation; import org.apache.cxf.sts.service.ServiceMBean; import org.apache.cxf.sts.service.StaticService; import org.apache.cxf.sts.token.provider.SAMLTokenProvider; import org.apache.cxf.ws.security.sts.provider.SecurityTokenServiceProvider; import org.jboss.as.test.integration.ws.wsse.trust.shared.WSTrustAppUtils; import jakarta.xml.ws.WebServiceProvider; import java.util.Arrays; import java.util.LinkedList; import java.util.List; /** * User: rsearls * Date: 3/14/14 */ @WebServiceProvider(serviceName = "SecurityTokenService", portName = "UT_Port", targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/", wsdlLocation = "WEB-INF/wsdl/holderofkey-ws-trust-1.4-service.wsdl") //be sure to have dependency on org.apache.cxf module when on AS7, otherwise Apache CXF annotations are ignored @EndpointProperties(value = { @EndpointProperty(key = "ws-security.signature.properties", value = "stsKeystore.properties"), @EndpointProperty(key = "ws-security.callback-handler", value = "org.jboss.as.test.integration.ws.wsse.trust.stsholderofkey.STSHolderOfKeyCallbackHandler") }) public class SampleSTSHolderOfKey extends SecurityTokenServiceProvider { public SampleSTSHolderOfKey() throws Exception { super(); StaticSTSProperties props = new StaticSTSProperties(); props.setSignatureCryptoProperties("stsKeystore.properties"); props.setSignatureUsername("mystskey"); props.setCallbackHandlerClass(STSHolderOfKeyCallbackHandler.class.getName()); props.setEncryptionCryptoProperties("stsKeystore.properties"); props.setEncryptionUsername("myservicekey"); props.setIssuer("DoubleItSTSIssuer"); List<ServiceMBean> services = new LinkedList<ServiceMBean>(); StaticService service = new StaticService(); String serverHostRegexp = WSTrustAppUtils.getServerHost().replace("[", "\\[").replace("]", "\\]").replace("127.0.0.1", "localhost"); service.setEndpoints(Arrays.asList( "https://" + serverHostRegexp + ":(\\d)*/jaxws-samples-wsse-policy-trust-holderofkey/HolderOfKeyService" )); services.add(service); TokenIssueOperation issueOperation = new TokenIssueOperation(); issueOperation.getTokenProviders().add(new SAMLTokenProvider()); issueOperation.setServices(services); issueOperation.setStsProperties(props); this.setIssueOperation(issueOperation); } }
3,792
45.256098
163
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/trust/stsholderofkey/STSHolderOfKeyCallbackHandler.java
package org.jboss.as.test.integration.ws.wsse.trust.stsholderofkey; import org.jboss.wsf.stack.cxf.extensions.security.PasswordCallbackHandler; import java.util.HashMap; import java.util.Map; /** * User: rsearls * Date: 3/19/14 */ public class STSHolderOfKeyCallbackHandler extends PasswordCallbackHandler { public STSHolderOfKeyCallbackHandler() { super(getInitMap()); } private static Map<String, String> getInitMap() { Map<String, String> passwords = new HashMap<String, String>(); passwords.put("mystskey", "stskpass"); passwords.put("alice", "clarinet"); return passwords; } }
645
25.916667
76
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/crypto/XMLSignatureFactoryTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.crypto; import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.URL; import java.nio.charset.StandardCharsets; import javax.xml.crypto.dsig.XMLSignatureFactory; import org.junit.Assert; 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.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; /** * A testcase for verifying that XMLSignatureFactory can be properly created * * @author [email protected] */ @RunWith(Arquillian.class) @RunAsClient public class XMLSignatureFactoryTestCase { private static Logger log = Logger.getLogger(XMLSignatureFactoryTestCase.class.getName()); @ArquillianResource URL baseUrl; @Deployment public static Archive<?> deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "crypto.war").addClasses(TestServlet.class); return war; } @Test public void signedRequest() throws Exception { XMLSignatureFactory fac = XMLSignatureFactory.getInstance("DOM"); Assert.assertNotNull(fac); BufferedReader br = new BufferedReader(new InputStreamReader(baseUrl.openStream(), StandardCharsets.UTF_8)); try { Assert.assertEquals("OK", br.readLine()); } finally { br.close(); } } }
2,696
34.486842
116
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/crypto/TestServlet.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.crypto; import org.w3c.dom.Document; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebServlet; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import javax.xml.crypto.AlgorithmMethod; import javax.xml.crypto.KeySelector; import javax.xml.crypto.KeySelectorException; import javax.xml.crypto.KeySelectorResult; import javax.xml.crypto.XMLCryptoContext; import javax.xml.crypto.dsig.CanonicalizationMethod; import javax.xml.crypto.dsig.DigestMethod; import javax.xml.crypto.dsig.Reference; import javax.xml.crypto.dsig.SignedInfo; import javax.xml.crypto.dsig.Transform; import javax.xml.crypto.dsig.XMLSignature; import javax.xml.crypto.dsig.XMLSignatureFactory; import javax.xml.crypto.dsig.dom.DOMSignContext; import javax.xml.crypto.dsig.dom.DOMValidateContext; import javax.xml.crypto.dsig.keyinfo.KeyInfo; import javax.xml.crypto.dsig.keyinfo.KeyInfoFactory; import javax.xml.crypto.dsig.spec.C14NMethodParameterSpec; import javax.xml.crypto.dsig.spec.TransformParameterSpec; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import java.io.IOException; import java.io.StringReader; import java.security.Key; import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; import java.security.PrivateKey; import java.security.PublicKey; import java.util.Collections; @WebServlet(name = "TestServlet", urlPatterns = "/*") public class TestServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { try { final Document document = createDocument(); final KeyPair keyPair = createKeyPair(); signDocument(document, keyPair.getPrivate()); if (validateSignature(document, keyPair.getPublic())) { res.getWriter().print("OK"); } else { res.getWriter().print("null"); } } catch (Exception e) { res.getWriter().println(e.getClass() + ": " + e.getMessage()); } } private static boolean validateSignature(final Document document, final PublicKey publicKey) throws Exception { final KeySelector ks = new KeySelector() { @Override public KeySelectorResult select(KeyInfo keyInfo, Purpose purpose, AlgorithmMethod method, XMLCryptoContext context) throws KeySelectorException { return new KeySelectorResult() { public Key getKey() { return publicKey; } }; } }; final DOMValidateContext context = new DOMValidateContext(ks, document.getElementsByTagNameNS(XMLSignature.XMLNS, "Signature").item(0)); return XMLSignatureFactory.getInstance("DOM").unmarshalXMLSignature(context).validate(context); } private static void signDocument(final Document doc, final PrivateKey privateKey) throws Exception { final XMLSignatureFactory xsf = XMLSignatureFactory.getInstance("DOM"); final Reference ref = xsf.newReference( "", xsf.newDigestMethod(DigestMethod.SHA256, null), Collections.singletonList(xsf.newTransform(Transform.ENVELOPED, (TransformParameterSpec) null)), null, null); final SignedInfo si = xsf.newSignedInfo(xsf.newCanonicalizationMethod(CanonicalizationMethod.EXCLUSIVE, (C14NMethodParameterSpec) null), xsf.newSignatureMethod("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256", null), Collections.singletonList(ref)); final KeyInfo ki = KeyInfoFactory.getInstance().newKeyInfo(Collections.singletonList(KeyInfoFactory.getInstance().newKeyName("dummy"))); xsf.newXMLSignature(si, ki).sign(new DOMSignContext(privateKey, doc.getDocumentElement())); } private static Document createDocument() throws IOException, SAXException, ParserConfigurationException { return DocumentBuilderFactory .newInstance() .newDocumentBuilder() .parse(new InputSource(new StringReader("<dummy dummy=\"dummy\"/>"))); } private static KeyPair createKeyPair() throws NoSuchAlgorithmException { return KeyPairGenerator.getInstance("RSA").generateKeyPair(); } }
5,684
42.068182
157
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/signencrypt/EJBSignEncryptMultipleClientsTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.signencrypt; import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import jakarta.xml.ws.soap.SOAPFaultException; import org.apache.cxf.ws.security.SecurityConstants; 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.as.test.integration.ws.wsse.EJBEncryptServiceImpl; import org.jboss.as.test.integration.ws.wsse.KeystorePasswordCallback; import org.jboss.as.test.integration.ws.wsse.ServiceIface; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.wsf.stack.cxf.client.UseNewBusFeature; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Test WS sign + encrypt capability for multiple clients (alice and john) * <p> * Certificates can ge generated using keytool -genkey -keyalg RSA -storetype JKS * Public key can be extracted using keytool -export * Public key can be imported using keytool -import * Keystore can be listed using keytool -list -v * * @author Rostislav Svoboda */ @RunWith(Arquillian.class) @RunAsClient public class EJBSignEncryptMultipleClientsTestCase { @ArquillianResource URL baseUrl; @Deployment public static Archive<?> deployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "jaxws-wsse-sign-encrypt-mc.jar"). addAsManifestResource(new StringAsset("Dependencies: org.jboss.ws.cxf.jbossws-cxf-client\n"), "MANIFEST.MF"). addClasses(ServiceIface.class, EJBEncryptServiceImpl.class, KeystorePasswordCallback.class). addAsResource(ServiceIface.class.getPackage(), "bob.jks", "bob.jks"). addAsResource(ServiceIface.class.getPackage(), "bob.properties", "bob.properties"). addAsManifestResource(ServiceIface.class.getPackage(), "wsdl/SecurityService-ejb-sign-encrypt.wsdl", "wsdl/SecurityService.wsdl"). addAsManifestResource(ServiceIface.class.getPackage(), "wsdl/SecurityService_schema1.xsd", "wsdl/SecurityService_schema1.xsd"). addAsManifestResource(EJBSignEncryptMultipleClientsTestCase.class.getPackage(), "multiple-clients-jaxws-endpoint-config.xml", "jaxws-endpoint-config.xml"); return jar; } @Test public void encryptedAndSignedRequestFromAlice() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "EJBEncryptSecurityService"); URL wsdlURL = new URL(baseUrl, "/jaxws-wsse-sign-encrypt-mc/EJBEncryptSecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); //use a new bus to avoid any possible clash with other tests ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); setupWsse(proxy, "alice"); Assert.assertEquals("Secure Hello World!", proxy.sayHello()); } @Test public void encryptedAndSignedRequestFromJohn() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "EJBEncryptSecurityService"); URL wsdlURL = new URL(baseUrl, "/jaxws-wsse-sign-encrypt-mc/EJBEncryptSecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); //use a new bus to avoid any possible clash with other tests ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); setupWsse(proxy, "john"); Assert.assertEquals("Secure Hello World!", proxy.sayHello()); } /* * Max's public key is not trusted in Bob's keystore * Max's keystore contain's Bob's public key as trusted. */ @Test public void encryptedAndSignedRequestFromUntrustedMax() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "EJBEncryptSecurityService"); URL wsdlURL = new URL(baseUrl, "/jaxws-wsse-sign-encrypt-mc/EJBEncryptSecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); //use a new bus to avoid any possible clash with other tests ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); setupWsse(proxy, "max"); try { proxy.sayHello(); Assert.fail("Max shouldn't invoke this service"); } catch (SOAPFaultException ex) { // expected failure because max isn't trusted } } private void setupWsse(ServiceIface proxy, String clientId) throws MalformedURLException { ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback()); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES, "org/jboss/as/test/integration/ws/wsse/" + clientId + ".properties"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, "org/jboss/as/test/integration/ws/wsse/" + clientId + ".properties"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, clientId); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "bob"); //note, a high timeout can be needed if the target host has low entropy, effectively slowing down initialization of the encryption engine //((BindingProvider) proxy).getRequestContext().put("javax.xml.ws.client.receiveTimeout", 240000); //default is 60000 ms } }
6,974
50.286765
171
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/signencrypt/SignEncryptTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.signencrypt; import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import org.junit.Assert; import org.apache.cxf.ws.security.SecurityConstants; 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.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.wsf.stack.cxf.client.UseNewBusFeature; import org.junit.Test; import org.junit.runner.RunWith; import org.jboss.as.test.integration.ws.wsse.KeystorePasswordCallback; import org.jboss.as.test.integration.ws.wsse.POJOEncryptServiceImpl; import org.jboss.as.test.integration.ws.wsse.ServiceIface; /** * Test WS sign + encrypt capability * <p> * Certificates can ge generated using keytool -genkey -keyalg RSA -storetype JKS * Public key can be extracted using keytool -export * Public key can be imported using keytool -import * Keystore can be listed using keytool -list -v * * @author Rostislav Svoboda */ @RunWith(Arquillian.class) @RunAsClient public class SignEncryptTestCase { private static Logger log = Logger.getLogger(SignEncryptTestCase.class.getName()); @ArquillianResource URL baseUrl; @Deployment public static Archive<?> deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxws-wsse-sign-encrypt.war"). addAsManifestResource(new StringAsset("Dependencies: org.jboss.ws.cxf.jbossws-cxf-client\n"), "MANIFEST.MF"). addClasses(ServiceIface.class, POJOEncryptServiceImpl.class, KeystorePasswordCallback.class). addAsResource(ServiceIface.class.getPackage(), "bob.jks", "bob.jks"). addAsResource(ServiceIface.class.getPackage(), "bob.properties", "bob.properties"). addAsWebInfResource(ServiceIface.class.getPackage(), "wsdl/SecurityService-sign-encrypt.wsdl", "wsdl/SecurityService.wsdl"). addAsWebInfResource(ServiceIface.class.getPackage(), "wsdl/SecurityService_schema1.xsd", "wsdl/SecurityService_schema1.xsd"). addAsWebInfResource(SignEncryptTestCase.class.getPackage(), "jaxws-endpoint-config.xml", "jaxws-endpoint-config.xml"); return war; } @Test public void encryptedAndSignedRequest() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "EncryptSecurityService"); URL wsdlURL = new URL(baseUrl.toString() + "EncryptSecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); //use a new bus to avoid any possible clash with other tests ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); setupWsse(proxy); Assert.assertEquals("Secure Hello World!", proxy.sayHello()); } private void setupWsse(ServiceIface proxy) throws MalformedURLException { ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback()); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES, "org/jboss/as/test/integration/ws/wsse/alice.properties"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, "org/jboss/as/test/integration/ws/wsse/alice.properties"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, "alice"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "bob"); } }
4,986
48.376238
156
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/signencrypt/EJBSignEncryptTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.signencrypt; import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import org.junit.Assert; import org.apache.cxf.ws.security.SecurityConstants; 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.as.test.integration.ws.wsse.EJBEncryptServiceImpl; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.junit.Test; import org.junit.runner.RunWith; import org.jboss.as.test.integration.ws.wsse.KeystorePasswordCallback; import org.jboss.as.test.integration.ws.wsse.ServiceIface; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.wsf.stack.cxf.client.UseNewBusFeature; /** * Test WS sign + encrypt capability * <p> * Certificates can ge generated using keytool -genkey -keyalg RSA -storetype JKS * Public key can be extracted using keytool -export * Public key can be imported using keytool -import * Keystore can be listed using keytool -list -v * * @author Rostislav Svoboda */ @RunWith(Arquillian.class) @RunAsClient public class EJBSignEncryptTestCase { @ArquillianResource URL baseUrl; @Deployment public static Archive<?> deployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "jaxws-wsse-sign-encrypt.jar"). addAsManifestResource(new StringAsset("Dependencies: org.jboss.ws.cxf.jbossws-cxf-client\n"), "MANIFEST.MF"). addClasses(ServiceIface.class, EJBEncryptServiceImpl.class, KeystorePasswordCallback.class). addAsResource(ServiceIface.class.getPackage(), "bob.jks", "bob.jks"). addAsResource(ServiceIface.class.getPackage(), "bob.properties", "bob.properties"). addAsManifestResource(ServiceIface.class.getPackage(), "wsdl/SecurityService-ejb-sign-encrypt.wsdl", "wsdl/SecurityService.wsdl"). addAsManifestResource(ServiceIface.class.getPackage(), "wsdl/SecurityService_schema1.xsd", "wsdl/SecurityService_schema1.xsd"). addAsManifestResource(EJBSignEncryptTestCase.class.getPackage(), "jaxws-endpoint-config.xml", "jaxws-endpoint-config.xml"); return jar; } @Test public void encryptedAndSignedRequest() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "EJBEncryptSecurityService"); URL wsdlURL = new URL(baseUrl, "/jaxws-wsse-sign-encrypt/EJBEncryptSecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); //use a new bus to avoid any possible clash with other tests ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); setupWsse(proxy); Assert.assertEquals("Secure Hello World!", proxy.sayHello()); } private void setupWsse(ServiceIface proxy) throws MalformedURLException { ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback()); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES, "org/jboss/as/test/integration/ws/wsse/alice.properties"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, "org/jboss/as/test/integration/ws/wsse/alice.properties"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, "alice"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "bob"); } }
4,902
48.525253
156
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/signencrypt/SignEncryptMultipleClientsTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsse.signencrypt; import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import jakarta.xml.ws.soap.SOAPFaultException; import org.junit.Assert; import org.apache.cxf.ws.security.SecurityConstants; 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.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.wsf.stack.cxf.client.UseNewBusFeature; import org.junit.Test; import org.junit.runner.RunWith; import org.jboss.as.test.integration.ws.wsse.KeystorePasswordCallback; import org.jboss.as.test.integration.ws.wsse.POJOEncryptServiceImpl; import org.jboss.as.test.integration.ws.wsse.ServiceIface; /** * Test WS sign + encrypt capability for multiple clients (alice and john) * <p> * Certificates can ge generated using keytool -genkey -keyalg RSA -storetype JKS * Public key can be extracted using keytool -export * Public key can be imported using keytool -import * Keystore can be listed using keytool -list -v * * @author Rostislav Svoboda */ @RunWith(Arquillian.class) @RunAsClient public class SignEncryptMultipleClientsTestCase { private static Logger log = Logger.getLogger(SignEncryptMultipleClientsTestCase.class.getName()); @ArquillianResource URL baseUrl; @Deployment public static Archive<?> deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxws-wsse-sign-encrypt-mc.war"). addAsManifestResource(new StringAsset("Dependencies: org.jboss.ws.cxf.jbossws-cxf-client\n"), "MANIFEST.MF"). addClasses(ServiceIface.class, POJOEncryptServiceImpl.class, KeystorePasswordCallback.class). addAsResource(ServiceIface.class.getPackage(), "bob.jks", "bob.jks"). addAsResource(ServiceIface.class.getPackage(), "bob.properties", "bob.properties"). addAsWebInfResource(ServiceIface.class.getPackage(), "wsdl/SecurityService-sign-encrypt.wsdl", "wsdl/SecurityService.wsdl"). addAsWebInfResource(ServiceIface.class.getPackage(), "wsdl/SecurityService_schema1.xsd", "wsdl/SecurityService_schema1.xsd"). addAsWebInfResource(SignEncryptMultipleClientsTestCase.class.getPackage(), "multiple-clients-jaxws-endpoint-config.xml", "jaxws-endpoint-config.xml"); return war; } @Test public void encryptedAndSignedRequestFromAlice() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "EncryptSecurityService"); URL wsdlURL = new URL(baseUrl.toString() + "EncryptSecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); //use a new bus to avoid any possible clash with other tests ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); setupWsse(proxy, "alice"); Assert.assertEquals("Secure Hello World!", proxy.sayHello()); } @Test public void encryptedAndSignedRequestFromJohn() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "EncryptSecurityService"); URL wsdlURL = new URL(baseUrl.toString() + "EncryptSecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); //use a new bus to avoid any possible clash with other tests ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); setupWsse(proxy, "john"); Assert.assertEquals("Secure Hello World!", proxy.sayHello()); } /* * Max's public key is not trusted in Bob's keystore * Max's keystore contain's Bob's public key as trusted. */ @Test public void encryptedAndSignedRequestFromUntrustedMax() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "EncryptSecurityService"); URL wsdlURL = new URL(baseUrl.toString() + "EncryptSecurityService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); //use a new bus to avoid any possible clash with other tests ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); setupWsse(proxy, "max"); try { proxy.sayHello(); Assert.fail("Max shouldn't invoke this service"); } catch (SOAPFaultException ex) { // expected failure because max isn't trusted } } private void setupWsse(ServiceIface proxy, String clientId) throws MalformedURLException { ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.CALLBACK_HANDLER, new KeystorePasswordCallback()); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SIGNATURE_PROPERTIES, "org/jboss/as/test/integration/ws/wsse/" + clientId + ".properties"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.ENCRYPT_PROPERTIES, "org/jboss/as/test/integration/ws/wsse/" + clientId + ".properties"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.SIGNATURE_USERNAME, clientId); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.ENCRYPT_USERNAME, "bob"); } }
6,750
49.007407
167
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsse/usernametoken/UsernameTokenElytronTestCase.java
/* * Copyright 2021 Red Hat, Inc. * * 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 org.jboss.as.test.integration.ws.wsse.usernametoken; import java.net.URL; import java.util.ArrayList; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import jakarta.xml.ws.soap.SOAPFaultException; import org.apache.cxf.rt.security.SecurityConstants; import org.hamcrest.CoreMatchers; import org.hamcrest.MatcherAssert; 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.as.arquillian.api.ServerSetup; import org.jboss.as.arquillian.api.ServerSetupTask; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.integration.security.common.CoreUtils; import org.jboss.as.test.integration.ws.wsse.ElytronUsernameTokenImpl; import org.jboss.as.test.integration.ws.wsse.ServiceIface; import org.jboss.as.test.shared.PermissionUtils; import org.jboss.as.test.shared.ServerReload; import org.jboss.dmr.ModelNode; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.wildfly.security.permission.ElytronPermission; import org.wildfly.test.security.common.AbstractElytronSetupTask; import org.wildfly.test.security.common.elytron.ConfigurableElement; import org.wildfly.test.security.common.elytron.PropertiesRealm; import org.wildfly.test.security.common.elytron.SimpleSecurityDomain; import org.wildfly.test.security.common.elytron.UserWithAttributeValues; import org.wildfly.test.undertow.common.UndertowApplicationSecurityDomain; /** * <p>Test case for SubjectCreatingPolicyInterceptor integrated with elytron * security. The username and password are requested by a UsernameToken * policy.</p> * * @author rmartinc */ @RunWith(Arquillian.class) @RunAsClient @ServerSetup({UsernameTokenElytronTestCase.ElytronDomainSetup.class, UsernameTokenElytronTestCase.EjbElytronDomainSetup.class}) public class UsernameTokenElytronTestCase { @ArquillianResource private URL serviceURL; @Deployment(testable = false) public static WebArchive createDeployment() { WebArchive archive = ShrinkWrap.create(WebArchive.class, UsernameTokenElytronTestCase.class.getSimpleName() + ".war"); archive.setManifest(new StringAsset("Manifest-Version: 1.0\n" + "Dependencies: org.apache.cxf\n")) .addClasses(ServiceIface.class, ElytronUsernameTokenImpl.class) .addAsWebInfResource(UsernameTokenElytronTestCase.class.getPackage(), "jboss-ejb3-elytron-properties.xml", "jboss-ejb3.xml") .addAsWebInfResource(ServiceIface.class.getPackage(), "wsdl/UsernameToken.wsdl", "wsdl/UsernameToken.wsdl") .addAsWebInfResource(ServiceIface.class.getPackage(), "wsdl/UsernameToken_schema1.xsd", "wsdl/UsernameToken_schema1.xsd") .addAsManifestResource(PermissionUtils.createPermissionsXmlAsset(new ElytronPermission("getSecurityDomain")), "permissions.xml"); return archive; } @Test public void testBadPassword() throws Exception { final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "UsernameToken"); final URL wsdlURL = new URL(serviceURL + "UsernameToken/ElytronUsernameTokenImpl?wsdl"); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.USERNAME, "user1"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.PASSWORD, "passwordWrong"); // JBWS024057: Failed Authentication : Subject has not been created SOAPFaultException e = Assert.assertThrows(SOAPFaultException.class, () -> proxy.sayHello()); MatcherAssert.assertThat(e.getMessage(), CoreMatchers.containsString("JBWS024057")); } @Test public void testNoAllowedRole() throws Exception { final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "UsernameToken"); final URL wsdlURL = new URL(serviceURL + "UsernameToken/ElytronUsernameTokenImpl?wsdl"); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.USERNAME, "user2"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.PASSWORD, "password2"); // WFLYEJB0364: Invocation on method: xxx.sayHello() of bean: ElytronUsernameTokenImpl is not allowed SOAPFaultException e = Assert.assertThrows(SOAPFaultException.class, () -> proxy.sayHello()); MatcherAssert.assertThat(e.getMessage(), CoreMatchers.containsString("WFLYEJB0364")); } @Test public void testOk() throws Exception { final QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wssecuritypolicy", "UsernameToken"); final URL wsdlURL = new URL(serviceURL + "UsernameToken/ElytronUsernameTokenImpl?wsdl"); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.USERNAME, "user1"); ((BindingProvider) proxy).getRequestContext().put(SecurityConstants.PASSWORD, "password1"); Assert.assertEquals("Hello user1 with roles and with attributes!", proxy.sayHello()); } /** * Elements needed for the elytron configuration: a properties realm with * a user (user1/password1), the security domain with that realm and * the undertow association. */ public static class ElytronDomainSetup extends AbstractElytronSetupTask { @Override protected ConfigurableElement[] getConfigurableElements() { ArrayList<ConfigurableElement> configurableElements = new ArrayList<>(); // creat a properties builder with users (user1 is allowed and user2 is not) configurableElements.add(PropertiesRealm.builder() .withName("PropertiesRealm") .withUser(UserWithAttributeValues.builder() .withName("user1") .withPassword("password1") .withValues("Users", "Role1") .build()) .withUser(UserWithAttributeValues.builder() .withName("user2") .withPassword("password2") .withValues("Role2") .build()) .build()); // create the domain with the properties realm configurableElements.add(SimpleSecurityDomain.builder() .withName("PropertiesDomain") .withDefaultRealm("PropertiesRealm") .withPermissionMapper("default-permission-mapper") .withRealms(SimpleSecurityDomain.SecurityDomainRealm.builder() .withRealm("PropertiesRealm") .withRoleDecoder("groups-to-roles") .build()) .build()); // undertow domain configurableElements.add(UndertowApplicationSecurityDomain.builder() .withName("PropertiesDomain") .withSecurityDomain("PropertiesDomain") .build()); return configurableElements.toArray(new ConfigurableElement[0]); } } /** * Server task to create the ejb3 domain association. * /subsystem=ejb3/application-security-domain=PropertiesDomain:add(security-domain=PropertiesDomain) */ public static class EjbElytronDomainSetup implements ServerSetupTask { @Override public void setup(ManagementClient managementClient, String containerId) throws Exception { PathAddress ejbDomainAddress = PathAddress.pathAddress() .append(ModelDescriptionConstants.SUBSYSTEM, "ejb3") .append("application-security-domain", "PropertiesDomain"); ModelNode addEjbDomain = Util.createAddOperation(ejbDomainAddress); addEjbDomain.get("security-domain").set("PropertiesDomain"); CoreUtils.applyUpdate(addEjbDomain, managementClient.getControllerClient()); ServerReload.reloadIfRequired(managementClient); } @Override public void tearDown(ManagementClient managementClient, String containerId) throws Exception { PathAddress ejbDomainAddress = PathAddress.pathAddress() .append(ModelDescriptionConstants.SUBSYSTEM, "ejb3") .append("application-security-domain", "PropertiesDomain"); ModelNode addEjbDomain = Util.createRemoveOperation(ejbDomainAddress); CoreUtils.applyUpdate(addEjbDomain, managementClient.getControllerClient()); ServerReload.reloadIfRequired(managementClient); } } }
10,201
50.01
145
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/schemalocations/SchemaLocationsRewriteTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. * */ package org.jboss.as.test.integration.ws.schemalocations; import java.io.ByteArrayInputStream; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; import org.jboss.logging.Logger; import javax.xml.namespace.QName; import javax.xml.stream.XMLEventReader; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamConstants; import javax.xml.stream.events.Attribute; import javax.xml.stream.events.StartElement; import javax.xml.stream.events.XMLEvent; import org.apache.cxf.helpers.IOUtils; 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.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that schema locations are rewritten. * <p> * CXF-6469 * * @author Tomas Hofman ([email protected]) */ @RunWith(Arquillian.class) @RunAsClient public class SchemaLocationsRewriteTestCase { @ArquillianResource URL baseUrl; private static final Logger log = Logger.getLogger(SchemaLocationsRewriteTestCase.class.getName()); @Deployment public static WebArchive createDeployment() { final WebArchive war = ShrinkWrap.create(WebArchive.class, "schema-location-rewrite.war"); war.addPackage(SimpleService.class.getPackage()). addAsWebInfResource(SchemaLocationsRewriteTestCase.class.getPackage(), "SimpleService.wsdl", "wsdl/SimpleService.wsdl"). addAsWebInfResource(SchemaLocationsRewriteTestCase.class.getPackage(), "imported/AnotherService.wsdl", "wsdl/imported/AnotherService.wsdl"). addAsWebInfResource(SchemaLocationsRewriteTestCase.class.getPackage(), "imported/SimpleService.xsd", "wsdl/imported/SimpleService.xsd"). addAsWebInfResource(SchemaLocationsRewriteTestCase.class.getPackage(), "imported/importedschema.xsd", "wsdl/imported/importedschema.xsd"); war.addClass(SimpleService.class); return war; } @Test public void testSchemaLocationsRewritten() throws Exception { // first path: SimpleService.wsdl -> imported/AnotherService.wsdl -> SimpleService.xsd -> importschema.xsd String importedWsdlLocation = getWsdlLocation(new URL(baseUrl, "SimpleService?wsdl"), "AnotherService.wsdl"); verifyLocationRewritten(importedWsdlLocation); String xsdLocation = getSchemaLocation(new URL(importedWsdlLocation), "SimpleService.xsd"); verifyLocationRewritten(xsdLocation); String importedXsdLocation = getSchemaLocation(new URL(xsdLocation), "importedschema.xsd"); verifyLocationRewritten(importedXsdLocation); // second path: SimpleService.wsdl -> imported/SimpleService.xsd -> importedschema.xsd xsdLocation = getSchemaLocation(new URL(baseUrl, "SimpleService?wsdl"), "SimpleService.xsd"); verifyLocationRewritten(xsdLocation); importedXsdLocation = getSchemaLocation(new URL(xsdLocation), "importedschema.xsd"); verifyLocationRewritten(importedXsdLocation); } private String getSchemaLocation(URL url, String locationSuffix) throws Exception { List<String> schemaLocations = getAttributeValues(url, "schemaLocation"); return findLocation(schemaLocations, locationSuffix); } private String getWsdlLocation(URL url, String locationSuffix) throws Exception { List<String> schemaLocations = getAttributeValues(url, "location"); return findLocation(schemaLocations, locationSuffix); } private String findLocation(List<String> values, String locationSuffix) { String result = null; for (String location : values) { if (location.endsWith(locationSuffix)) { if (result == null) { result = location; } else { throw new IllegalStateException("Schema or WSDL location end is not unique for given document."); } } } Assert.assertNotNull(String.format("Location ending with '%s' not found in", locationSuffix), result); return result; } private void verifyLocationRewritten(String schemaLocation) { Assert.assertTrue(String.format("Location was not rewritten: %s", schemaLocation), schemaLocation.contains("?xsd=") || schemaLocation.contains("?wsdl=")); } private List<String> getAttributeValues(URL url, String localPart) throws Exception { String document = IOUtils.toString(url.openStream()); log.trace(document); List<String> values = new ArrayList<>(); XMLInputFactory xmlif = XMLInputFactory.newInstance(); XMLEventReader eventReader = xmlif.createXMLEventReader(new ByteArrayInputStream(document.getBytes(StandardCharsets.UTF_8))); while (eventReader.hasNext()) { XMLEvent xmlEvent = eventReader.nextEvent(); if (xmlEvent.getEventType() == XMLStreamConstants.START_ELEMENT) { StartElement startElement = xmlEvent.asStartElement(); Attribute attribute = startElement.getAttributeByName(new QName("", localPart)); if (attribute != null) { values.add(attribute.getValue()); } } } return values; } }
6,590
41.798701
156
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/schemalocations/SimpleService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.schemalocations; import jakarta.jws.WebService; /** * Simple WS endpoint * * @author Tomas Hofman ([email protected]) */ @WebService( targetNamespace = "http://jbossws.org/SchemaLocationsRewrite", serviceName = "SimpleService", wsdlLocation = "WEB-INF/wsdl/SimpleService.wsdl" ) public class SimpleService { public String echo(final String s) { return s; } }
1,473
32.5
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/ServiceRefTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.serviceref; import java.io.FilePermission; import java.net.SocketPermission; import java.util.Hashtable; import java.util.Properties; import java.util.PropertyPermission; import javax.naming.Context; import javax.naming.InitialContext; 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.as.network.NetworkUtils; import org.jboss.as.test.shared.FileUtils; import org.jboss.as.test.shared.PropertiesValueResolver; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; /** * Serviceref through ejb3 deployment descriptor. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @RunWith(Arquillian.class) @RunAsClient public class ServiceRefTestCase { private static StatelessRemote remote1; private static StatelessRemote remote2; @BeforeClass public static void beforeClass() throws Exception { final Hashtable<String, String> props = new Hashtable<String, String>(); props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); final Context context = new InitialContext(props); remote1 = (StatelessRemote) context.lookup("ejb:/ws-serviceref-example//StatelessBean!" + StatelessRemote.class.getName()); remote2 = (StatelessRemote) context.lookup("ejb:/ws-serviceref-example//StatelessBean2!" + StatelessRemote.class.getName()); } @Deployment public static JavaArchive deployment() { String wsdl = FileUtils.readFile(ServiceRefTestCase.class, "TestService.wsdl"); final Properties properties = new Properties(); properties.putAll(System.getProperties()); final String node0 = NetworkUtils.formatPossibleIpv6Address((String) properties.get("node0")); if (properties.containsKey("node0")) { properties.put("node0", node0); } return ShrinkWrap.create(JavaArchive.class, "ws-serviceref-example.jar") .addClasses(EJB3Bean.class, EndpointInterface.class, EndpointService.class, StatelessBean.class, StatelessRemote.class, CdiBean.class) .addAsManifestResource(ServiceRefTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml") .addAsManifestResource(ServiceRefTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml") .addAsManifestResource(new StringAsset(PropertiesValueResolver.replaceProperties(wsdl, properties)), "wsdl/TestService.wsdl") .addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml") // all the following permissions are needed because EndpointService directly extends jakarta.xml.ws.Service class // and CXF guys are not willing to add more privileged blocks into their code, thus deployments need to have // the following permissions (note that the wsdl.properties permission is needed by wsdl4j) .addAsManifestResource(createPermissionsXmlAsset( new FilePermission("<<ALL FILES>>", "read"), new PropertyPermission("user.dir", "read"), new RuntimePermission("getClassLoader"), new RuntimePermission("org.apache.cxf.permission", "resolveUri"), new RuntimePermission("createClassLoader"), new RuntimePermission("accessDeclaredMembers"), new SocketPermission(node0 + ":8080", "connect,resolve") ), "jboss-permissions.xml"); } @Test public void testEJBRelay1() throws Exception { // test StatelessBean final String result1 = remote1.echo1("Relay1"); Assert.assertEquals("First EJB:Relay1", result1); // test StatelessBean2 final String result2 = remote2.echo1("Relay1"); Assert.assertEquals("Second EJB:Relay1", result2); } @Test public void testEJBRelay2() throws Exception { // test StatelessBean final String result1 = remote1.echo2("Relay2"); Assert.assertEquals("First EJB:Relay2", result1); // test StatelessBean2 final String result2 = remote2.echo2("Relay2"); Assert.assertEquals("Second EJB:Relay2", result2); } @Test public void testEJBRelay3() throws Exception { // test StatelessBean final String result1 = remote1.echo3("Relay3"); Assert.assertEquals("First EJB:Relay3", result1); // test StatelessBean2 final String result2 = remote2.echo3("Relay3"); Assert.assertEquals("Second EJB:Relay3", result2); } @Test public void testEJBRelay4() throws Exception { // test StatelessBean final String result1 = remote1.echo4("Relay4"); Assert.assertEquals("First EJB:Relay4", result1); // test StatelessBean2 final String result2 = remote2.echo4("Relay4"); Assert.assertEquals("Second EJB:Relay4", result2); } @Test public void testCdiBeanRelay() throws Exception { // test StatelessBean final String result1 = remote1.echoCDI("RelayCDI"); Assert.assertEquals("First EJB:RelayCDI", result1); // test StatelessBean2 final String result2 = remote2.echoCDI("RelayCDI"); Assert.assertEquals("Second EJB:RelayCDI", result2); } }
6,830
43.357143
150
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/CdiBean.java
package org.jboss.as.test.integration.ws.serviceref; import jakarta.xml.ws.WebServiceRef; /** * @author Stuart Douglas */ public class CdiBean { @WebServiceRef(value = EndpointService.class, mappedName = "jbossws-client/service/TestService", wsdlLocation = "META-INF/wsdl/TestService.wsdl") EndpointInterface endpoint1; public String echo(String input) { return endpoint1.echo(input); } }
420
22.388889
149
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/EJB3Bean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.serviceref; import jakarta.ejb.Stateless; import jakarta.jws.WebService; /** * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @WebService(targetNamespace = "http://www.openuri.org/2004/04/HelloWorld", serviceName = "EndpointService", endpointInterface = "org.jboss.as.test.integration.ws.serviceref.EndpointInterface") @Stateless public class EJB3Bean implements EndpointInterface { public String echo(final String input) { return input; } }
1,546
39.710526
192
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/StatelessRemote.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.serviceref; /** * @author <a href="mailto:[email protected]">Richard Opalka</a> */ public interface StatelessRemote { String echo1(String string) throws Exception; String echo2(String string) throws Exception; String echo3(String string) throws Exception; String echo4(String string) throws Exception; String echoCDI(String string) throws Exception; }
1,445
36.076923
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/EndpointService.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.serviceref; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.WebEndpoint; import jakarta.xml.ws.WebServiceClient; import jakarta.xml.ws.WebServiceFeature; /** * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @WebServiceClient(name = "EndpointService", targetNamespace = "http://www.openuri.org/2004/04/HelloWorld") public class EndpointService extends jakarta.xml.ws.Service { private static final QName TEST_ENDPOINT_PORT = new QName("http://www.openuri.org/2004/04/HelloWorld", "EJB3BeanPort"); public EndpointService(URL wsdlLocation, QName serviceName) { super(wsdlLocation, serviceName); } public EndpointService(URL wsdlLocation, QName serviceName, WebServiceFeature... features) { super(wsdlLocation, serviceName, features); } @WebEndpoint(name = "EJB3BeanPort") public EndpointInterface getEndpointPort() { return (EndpointInterface) super.getPort(TEST_ENDPOINT_PORT, EndpointInterface.class); } }
2,082
39.057692
123
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/ServletClient.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.serviceref; import java.io.IOException; import javax.naming.InitialContext; import jakarta.servlet.ServletException; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import jakarta.xml.ws.Service; import jakarta.xml.ws.WebServiceRef; import org.jboss.logging.Logger; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ public class ServletClient extends HttpServlet { private static Logger log = Logger.getLogger(ServletClient.class); @WebServiceRef(value = EndpointService.class, mappedName = "jbossws-client/service/TestService", wsdlLocation = "WEB-INF/wsdl/TestService.wsdl") EndpointInterface endpoint1; EndpointInterface _endpoint2; @WebServiceRef(value = EndpointService.class, mappedName = "jbossws-client/service/TestService", wsdlLocation = "WEB-INF/wsdl/TestService.wsdl") public void setEndpoint2(final EndpointInterface endpoint2) { this._endpoint2 = endpoint2; } public String echo1(final String string) throws Exception { if (null == endpoint1) { throw new IllegalArgumentException("Serviceref for property 'endpoint1' not injected"); } return endpoint1.echo(string); } public String echo2(final String string) throws Exception { if (null == _endpoint2) { throw new IllegalArgumentException("Serviceref for property 'endpoint2' not injected"); } return _endpoint2.echo(string); } // service3 and service4 are defined in web.xml public String echo3(final String string) throws Exception { InitialContext iniCtx = new InitialContext(); EndpointInterface endpoint3 = (EndpointInterface) ((Service) iniCtx.lookup("java:comp/env/service3")).getPort(EndpointInterface.class); if (null == endpoint3) { throw new IllegalArgumentException("Serviceref for 'service3' not injected"); } return endpoint3.echo(string); } public String echo4(final String string) throws Exception { InitialContext iniCtx = new InitialContext(); EndpointInterface endpoint4 = ((EndpointService) iniCtx.lookup("java:comp/env/service4")).getEndpointPort(); if (null == endpoint4) { throw new IllegalArgumentException("Serviceref for 'service4' not injected"); } return endpoint4.echo(string); } // service5 is defined in jboss-web.xml public String echo5(final String string) throws Exception { InitialContext iniCtx = new InitialContext(); EndpointInterface endpoint5 = (EndpointInterface) ((Service) iniCtx.lookup("java:comp/env/service5")).getPort(EndpointInterface.class); if (null == endpoint5) { throw new IllegalArgumentException("Serviceref for 'service5' not injected"); } return endpoint5.echo(string); } private void processRequest(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String echoStr = req.getParameter("echo"); String typeStr = req.getParameter("type"); try { if (typeStr.equals("echo1")) { log.trace("Echo1: " + echo1(echoStr)); } else if (typeStr.equals("echo2")) { log.trace("Echo2: " + echo2(echoStr)); } else if (typeStr.equals("echo3")) { log.trace("Echo3: " + echo3(echoStr)); } else if (typeStr.equals("echo4")) { log.trace("Echo4: " + echo4(echoStr)); } else if (typeStr.equals("echo5")) { log.trace("Echo5: " + echo5(echoStr)); } } catch (Exception ex) { resp.getWriter().println(ex.toString()); } resp.getWriter().print(echoStr); } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { processRequest(req, resp); } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { processRequest(req, resp); } }
5,265
40.464567
148
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/StatelessBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.serviceref; import jakarta.annotation.Resource; import jakarta.ejb.Remote; import jakarta.ejb.Stateless; import jakarta.inject.Inject; import jakarta.xml.ws.WebServiceRef; /** * A test bean that delegates to a web service provided through serviceref injection. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @Stateless(name = "StatelessBean") @Remote(StatelessRemote.class) public class StatelessBean implements StatelessRemote { @Inject private CdiBean cdiBean; @WebServiceRef(value = EndpointService.class, mappedName = "jbossws-client/service/TestService", wsdlLocation = "META-INF/wsdl/TestService.wsdl") EndpointInterface endpoint1; EndpointInterface _endpoint2; @WebServiceRef(value = EndpointService.class, mappedName = "jbossws-client/service/TestService", wsdlLocation = "META-INF/wsdl/TestService.wsdl") public void setEndpoint2(final EndpointInterface endpoint2) { this._endpoint2 = endpoint2; } // via XML EndpointInterface endpoint3; // via XML EndpointInterface _endpoint4; @Resource private String id; public void setEndpoint4(final EndpointInterface endpoint4) { this._endpoint4 = endpoint4; } public String echo1(final String string) throws Exception { if (null == endpoint1) { throw new IllegalArgumentException("Serviceref for property 'endpoint1' not injected"); } return endpoint1.echo(id + ":" + string); } public String echo2(final String string) throws Exception { if (null == _endpoint2) { throw new IllegalArgumentException("Serviceref for property 'endpoint2' not injected"); } return _endpoint2.echo(id + ":" + string); } public String echo3(final String string) throws Exception { if (null == endpoint3) { throw new IllegalArgumentException("Serviceref for property 'endpoint3' not injected"); } return endpoint3.echo(id + ":" + string); } public String echo4(final String string) throws Exception { if (null == _endpoint4) { throw new IllegalArgumentException("Serviceref for property 'endpoint4' not injected"); } return _endpoint4.echo(id + ":" + string); } public String echoCDI(final String string) throws Exception { return cdiBean.echo(id + ":" + string); } }
3,399
35.170213
149
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/ServiceRefSevletTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.serviceref; import java.io.BufferedReader; import java.io.FilePermission; import java.io.InputStreamReader; import java.net.SocketPermission; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.Properties; import java.util.PropertyPermission; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.OperateOnDeployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.network.NetworkUtils; import org.jboss.as.test.shared.FileUtils; import org.jboss.as.test.shared.PropertiesValueResolver; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient public class ServiceRefSevletTestCase { @Deployment(name = "main", testable = false) public static JavaArchive mainDeployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ws-serviceref-example.jar") .addClasses(EJB3Bean.class, EndpointInterface.class); return jar; } @Deployment(name = "servletClient", testable = false) public static WebArchive clientDeployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "ws-serviceref-example-servlet-client.war") .addClasses(EndpointInterface.class, EndpointService.class, ServletClient.class) .addAsWebInfResource(ServiceRefSevletTestCase.class.getPackage(), "web.xml", "web.xml") .addAsWebInfResource(ServiceRefSevletTestCase.class.getPackage(), "jboss-web.xml", "jboss-web.xml"); String wsdl = FileUtils.readFile(ServiceRefSevletTestCase.class, "TestService.wsdl"); final Properties properties = new Properties(); properties.putAll(System.getProperties()); final String node0 = NetworkUtils.formatPossibleIpv6Address((String) properties.get("node0")); if (properties.containsKey("node0")) { properties.put("node0", node0); } war.addAsWebInfResource(new StringAsset(PropertiesValueResolver.replaceProperties(wsdl, properties)), "wsdl/TestService.wsdl"); // all the following permissions are needed because EndpointService directly extends jakarta.xml.ws.Service class // and CXF guys are not willing to add more privileged blocks into their code, thus deployments need to have // the following permissions (note that the wsdl.properties permission is needed by wsdl4j) war.addAsManifestResource(createPermissionsXmlAsset( new FilePermission("<<ALL FILES>>", "read"), new PropertyPermission("user.dir", "read"), new RuntimePermission("getClassLoader"), new RuntimePermission("org.apache.cxf.permission", "resolveUri"), new RuntimePermission("createClassLoader"), new RuntimePermission("accessDeclaredMembers"), new SocketPermission(node0 + ":8080", "connect,resolve")), "jboss-permissions.xml"); return war; } @ArquillianResource @OperateOnDeployment("servletClient") URL baseUrl; @Test public void testServletClientEcho1() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo1")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } @Test public void testServletClientEcho2() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo2")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } @Test public void testServletClientEcho3() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo3")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } @Test public void testServletClientEcho4() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo4")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } @Test public void testServletClientEcho5() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo5")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } private String receiveFirstLineFromUrl(URL url) throws Exception { try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) { return br.readLine(); } } }
6,275
45.835821
135
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/ServiceRefEarTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.serviceref; import java.io.BufferedReader; import java.io.FilePermission; import java.io.InputStreamReader; import java.net.SocketPermission; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.Properties; import java.util.PropertyPermission; import org.junit.Assert; 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.as.network.NetworkUtils; import org.jboss.as.test.shared.FileUtils; import org.jboss.as.test.shared.PropertiesValueResolver; import org.jboss.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; /** * Tests for WS ServiceRef from servlet to verify access for <service-ref> in nested war * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient public class ServiceRefEarTestCase { private static final Logger log = Logger.getLogger(ServiceRefEarTestCase.class); @Deployment(testable = false) public static Archive<?> deployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ws-serviceref-example.jar") .addClasses(EJB3Bean.class, EndpointInterface.class); WebArchive war = ShrinkWrap.create(WebArchive.class, "ws-serviceref-example-servlet-client.war") .addClasses(EndpointInterface.class, EndpointService.class, ServletClient.class) .addAsWebInfResource(ServiceRefEarTestCase.class.getPackage(), "web.xml", "web.xml") .addAsWebInfResource(ServiceRefEarTestCase.class.getPackage(), "jboss-web.xml", "jboss-web.xml"); String wsdl = FileUtils.readFile(ServiceRefEarTestCase.class, "TestService.wsdl"); final Properties properties = new Properties(); properties.putAll(System.getProperties()); final String node0 = NetworkUtils.formatPossibleIpv6Address((String) properties.get("node0")); if (properties.containsKey("node0")) { properties.put("node0", node0); } war.addAsWebInfResource(new StringAsset(PropertiesValueResolver.replaceProperties(wsdl, properties)), "wsdl/TestService.wsdl"); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ws-serviceref-example.ear") .addAsModule(jar) .addAsModule(war); // all the following permissions are needed because EndpointService directly extends jakarta.xml.ws.Service class // and CXF guys are not willing to add more privileged blocks into their code, thus deployments need to have // the following permissions (note that the wsdl.properties permission is needed by wsdl4j) ear.addAsManifestResource(createPermissionsXmlAsset( new FilePermission("<<ALL FILES>>", "read"), new PropertyPermission("user.dir", "read"), new RuntimePermission("getClassLoader"), new RuntimePermission("org.apache.cxf.permission", "resolveUri"), new RuntimePermission("createClassLoader"), new RuntimePermission("accessDeclaredMembers"), new SocketPermission(node0 + ":8080", "connect,resolve")), "jboss-permissions.xml"); return ear; } @ArquillianResource(ServletClient.class) URL baseUrl; @Test public void testServletClientEcho1() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo1")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } @Test public void testServletClientEcho2() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo2")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } @Test public void testServletClientEcho3() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo3")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } @Test public void testServletClientEcho4() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo4")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } @Test public void testServletClientEcho5() throws Exception { String retStr = receiveFirstLineFromUrl(new URL(baseUrl.toString() + "?echo=HelloWorld&type=echo5")); Assert.assertEquals("Unexpected output - " + retStr, "HelloWorld", retStr); } private String receiveFirstLineFromUrl(URL url) throws Exception { try (BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream(), StandardCharsets.UTF_8))) { return br.readLine(); } } }
6,504
45.134752
135
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/serviceref/EndpointInterface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.serviceref; import jakarta.ejb.Remote; import jakarta.jws.WebService; import jakarta.jws.soap.SOAPBinding; /** * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @WebService(targetNamespace = "http://www.openuri.org/2004/04/HelloWorld") @SOAPBinding(style = SOAPBinding.Style.RPC) @Remote public interface EndpointInterface { String echo(String input); }
1,445
37.052632
74
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/ejb/SimpleStatelessWebserviceEndpointIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.ejb; import jakarta.ejb.Remote; import jakarta.jws.WebService; import jakarta.jws.soap.SOAPBinding; /** * Webservice endpoint interface. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @Remote @WebService @SOAPBinding public interface SimpleStatelessWebserviceEndpointIface { String echo(String s); }
1,400
32.357143
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/ejb/ContextHandlerEndpointImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.ejb; import jakarta.annotation.Resource; import jakarta.ejb.Stateless; import jakarta.jws.HandlerChain; import jakarta.jws.WebService; import jakarta.xml.ws.WebServiceContext; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @Stateless @WebService( endpointInterface = "org.jboss.as.test.integration.ws.ejb.ContextHandlerEndpointIface", targetNamespace = "org.jboss.as.test.integration.ws.ejb", serviceName = "ContextHandlerService" ) @HandlerChain(file = "handler.xml") public class ContextHandlerEndpointImpl implements ContextHandlerEndpointIface { @Resource WebServiceContext wsCtx; public String doSomething(String msg) { if (!"ContextHandler:handleInbound()".equals(wsCtx.getMessageContext().get("invoked"))) { throw new IllegalArgumentException("Wrong webservice context instance or handler not invoked"); } return msg; } }
2,015
36.333333
107
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/ejb/SimpleStatelessWebserviceEndpointTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.ejb; import java.net.URL; import javax.naming.Context; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; 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.as.test.shared.integration.ejb.security.Util; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests simple stateless web service endpoint invocation. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @RunWith(Arquillian.class) @RunAsClient public class SimpleStatelessWebserviceEndpointTestCase { @ArquillianResource URL baseUrl; @Deployment(testable = false) public static JavaArchive createDeployment() { final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "stateless-ws-endpoint-example.jar"); jar.addClasses(SimpleStatelessWebserviceEndpointIface.class, SimpleStatelessWebserviceEndpointImpl.class); return jar; } @Test public void testSimpleStatelessWebserviceEndpoint() throws Exception { final QName serviceName = new QName("org.jboss.as.test.integration.ws.ejb", "SimpleService"); final URL wsdlURL = new URL(baseUrl, "/stateless-ws-endpoint-example/SimpleService/SimpleStatelessWebserviceEndpointImpl?wsdl"); final Service service = Service.create(wsdlURL, serviceName); final SimpleStatelessWebserviceEndpointIface port = service.getPort(SimpleStatelessWebserviceEndpointIface.class); final String result = port.echo("hello"); Assert.assertEquals("hello", result); } /* * Test for jakarta.ejb.Remote annotation in WS interface */ @Test public void testRemoteAccess() throws Exception { final Context context = Util.createNamingContext(); SimpleStatelessWebserviceEndpointIface ejb3Remote = (SimpleStatelessWebserviceEndpointIface) context.lookup("ejb:/stateless-ws-endpoint-example/SimpleStatelessWebserviceEndpointImpl!" + SimpleStatelessWebserviceEndpointIface.class.getName()); String helloWorld = "Hello world!"; Object retObj = ejb3Remote.echo(helloWorld); Assert.assertEquals(helloWorld, retObj); } }
3,504
39.287356
165
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/ejb/ContextHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.ejb; import jakarta.xml.ws.handler.MessageContext; import org.jboss.ws.api.handler.GenericSOAPHandler; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ public class ContextHandler extends GenericSOAPHandler { @Override protected boolean handleInbound(MessageContext msgContext) { msgContext.put("invoked", "ContextHandler:handleInbound()"); msgContext.setScope("invoked", MessageContext.Scope.APPLICATION); return true; } }
1,566
38.175
73
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/ejb/ContextHandlerEndpointIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.ejb; import jakarta.jws.WebService; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @WebService public interface ContextHandlerEndpointIface { String doSomething(String msg); }
1,286
38
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/ejb/EJBWebServicesTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.ejb; import static java.util.concurrent.TimeUnit.SECONDS; 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.as.test.integration.common.HttpRequest; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Test; import org.junit.runner.RunWith; import java.net.URL; /** * EJB 3.1 FR 3.2.4 Stateless session beans and Singleton session beans may have web service clients. * * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @RunWith(Arquillian.class) @RunAsClient public class EJBWebServicesTestCase { @ArquillianResource URL baseUrl; @Deployment public static JavaArchive deployment() { return ShrinkWrap.create(JavaArchive.class, "ejbws-example.jar") .addClasses(HttpRequest.class, SingletonEndpoint.class); } @Test public void testSingleton() throws Exception { final String message = "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:test=\"http://ejb.ws.integration.test.as.jboss.org/\">" + " <soapenv:Header/>" + " <soapenv:Body>" + " <test:setState>" + " <arg0>Foo</arg0>" + " </test:setState>" + " </soapenv:Body>" + "</soapenv:Envelope>"; URL webRoot = new URL(baseUrl, "/"); String result = HttpRequest.post(webRoot.toString() + "ejbws-example/SingletonEndpoint", message, 10, SECONDS); // TODO: check something } @Test public void testSingletonWSDL() throws Exception { URL webRoot = new URL(baseUrl, "/"); final String wsdl = HttpRequest.get(webRoot.toString() + "ejbws-example/SingletonEndpoint?wsdl", 10, SECONDS); // TODO: check something } }
3,082
38.025316
171
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/ejb/SimpleStatelessWebserviceEndpointImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.ejb; import jakarta.annotation.Resource; import jakarta.ejb.Stateless; import jakarta.jws.WebService; import jakarta.xml.ws.WebServiceContext; /** * Webservice endpoint implementation. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @Stateless @WebService( endpointInterface = "org.jboss.as.test.integration.ws.ejb.SimpleStatelessWebserviceEndpointIface", targetNamespace = "org.jboss.as.test.integration.ws.ejb", serviceName = "SimpleService" ) public class SimpleStatelessWebserviceEndpointImpl implements SimpleStatelessWebserviceEndpointIface { @Resource WebServiceContext ctx; @Override public String echo(final String s) { if (ctx == null) { throw new RuntimeException("@Resource WebServiceContext not injected"); } return s; } }
1,892
34.716981
106
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/ejb/SingletonEndpoint.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.ejb; import jakarta.ejb.Singleton; import jakarta.jws.WebService; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @Singleton @WebService public class SingletonEndpoint { private String state; public String getState() { return state; } public String setState(String s) { String previous = this.state; this.state = s; return previous; } }
1,486
32.044444
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/ejb/ContextHandlerEndpointTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.ejb; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; 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.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests web service context injection into Jakarta XML Web Services handler. * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient public class ContextHandlerEndpointTestCase { @ArquillianResource URL baseUrl; @Deployment(testable = false) public static JavaArchive createDeployment() { JavaArchive ejb3Jar = ShrinkWrap.create(JavaArchive.class, "context-handler-endpoint.jar"); ejb3Jar.addClass(ContextHandler.class); ejb3Jar.addClass(ContextHandlerEndpointIface.class); ejb3Jar.addClass(ContextHandlerEndpointImpl.class); ejb3Jar.addAsResource(ContextHandler.class.getPackage(), "handler.xml", "org/jboss/as/test/integration/ws/ejb/handler.xml"); return ejb3Jar; } @Test public void testHandlerContext() throws Exception { QName serviceName = new QName("org.jboss.as.test.integration.ws.ejb", "ContextHandlerService"); URL wsdlURL = new URL(baseUrl, "/context-handler-endpoint/ContextHandlerService/ContextHandlerEndpointImpl?wsdl"); Service service = Service.create(wsdlURL, serviceName); ContextHandlerEndpointIface port = service.getPort(ContextHandlerEndpointIface.class); String response = port.doSomething("hello"); Assert.assertNotNull("Response is null.", response); } }
2,937
39.805556
132
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsa/WSHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsa; import java.io.ByteArrayOutputStream; import java.util.Set; import javax.xml.namespace.QName; import jakarta.xml.soap.SOAPMessage; import jakarta.xml.ws.handler.MessageContext; import jakarta.xml.ws.handler.soap.SOAPHandler; import jakarta.xml.ws.handler.soap.SOAPMessageContext; import org.jboss.logging.Logger; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ public class WSHandler implements SOAPHandler<SOAPMessageContext> { private static final Logger LOGGER = Logger.getLogger(WSHandler.class); public Set<QName> getHeaders() { return null; } public boolean handleFault(SOAPMessageContext context) { log(context); return true; } public boolean handleMessage(SOAPMessageContext context) { log(context); return true; } private void log(SOAPMessageContext smc) { if (!LOGGER.isTraceEnabled()) { return; } boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); if (outboundProperty) { LOGGER.trace("Outgoing message:"); } else { LOGGER.trace("Incoming message:"); } LOGGER.trace("-----------"); SOAPMessage message = smc.getMessage(); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); message.writeTo(baos); LOGGER.trace(baos.toString()); LOGGER.trace(""); } catch (Exception e) { LOGGER.error("Exception in handler: " + e); } LOGGER.trace("-----------"); } public void close(MessageContext context) { } }
2,750
32.144578
95
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsa/TestOptionalAddressingTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsa; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import org.junit.Assert; 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.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient public class TestOptionalAddressingTestCase { private static Logger log = Logger.getLogger(TestOptionalAddressingTestCase.class.getName()); @ArquillianResource URL baseUrl; private static final String message = "optional-addressing"; private static final String expectedResponse = "Hello optional-addressing!"; @Deployment public static Archive<?> deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxws-wsa.war"). addClasses(ServiceIface.class, ServiceImplAddressingOptional.class, WSHandler.class). addAsResource(WSHandler.class.getPackage(), "ws-handler.xml", "org/jboss/as/test/integration/ws/wsa/ws-handler.xml"); return war; } @Test public void usingLocalWSDLWithoutAddressing() throws Exception { ServiceIface proxy = getServicePortFromWSDL("NoAddressingService.xml"); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); } @Test public void usingLocalWSDLWithOptionalAddressing() throws Exception { ServiceIface proxy = getServicePortFromWSDL("OptionalAddressingService.xml"); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); } @Test public void usingLocalWSDLWithAddressing() throws Exception { ServiceIface proxy = getServicePortFromWSDL("RequiredAddressingService.xml"); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); } @Test public void usingWSDLFromDeployedEndpoint() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService"); URL wsdlURL = new URL(baseUrl, "/jaxws-wsa/AddressingService?wsdl"); File wsdlFile = new File(this.getClass().getSimpleName() + ".wsdl"); TestNoAddressingTestCase.downloadWSDLToFile(wsdlURL, wsdlFile); Service service = Service.create(wsdlFile.toURI().toURL(), serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); wsdlFile.delete(); } private ServiceIface getServicePortFromWSDL(String wsdlFileName) throws MalformedURLException { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService"); File wsdlFile = new File(System.getProperty("jbossas.ts.submodule.dir") + "/src/test/java/org/jboss/as/test/integration/ws/wsa/" + wsdlFileName); URL wsdlURL = wsdlFile.toURI().toURL(); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); BindingProvider bp = (BindingProvider) proxy; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, new URL(baseUrl, "/jaxws-wsa/AddressingService").toString()); return proxy; } }
4,808
40.456897
153
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsa/ServiceImplAddressingOptional.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsa; import jakarta.jws.HandlerChain; import jakarta.jws.WebService; import jakarta.xml.ws.soap.Addressing; @WebService ( portName = "AddressingServicePort", serviceName = "AddressingService", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsaddressing", endpointInterface = "org.jboss.as.test.integration.ws.wsa.ServiceIface" ) @Addressing(enabled = true, required = false) @HandlerChain(file = "ws-handler.xml") public class ServiceImplAddressingOptional implements ServiceIface { public String sayHello(String name) { return "Hello " + name + "!"; } }
1,742
39.534884
92
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsa/ServiceImplAddressingRequired.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsa; import jakarta.jws.HandlerChain; import jakarta.jws.WebService; import jakarta.xml.ws.soap.Addressing; @WebService ( portName = "AddressingServicePort", serviceName = "AddressingService", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsaddressing", endpointInterface = "org.jboss.as.test.integration.ws.wsa.ServiceIface" ) @Addressing(enabled = true, required = true) @HandlerChain(file = "ws-handler.xml") public class ServiceImplAddressingRequired implements ServiceIface { public String sayHello(String name) { return "Hello " + name + "!"; } }
1,741
39.511628
92
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsa/ServiceIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsa; import jakarta.jws.WebService; @WebService(targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsaddressing") public interface ServiceIface { String sayHello(String name); }
1,269
39.967742
88
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsa/TestNoAddressingTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsa; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.nio.file.Files; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import jakarta.xml.ws.WebServiceException; import org.junit.Assert; 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.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient public class TestNoAddressingTestCase { @ArquillianResource URL baseUrl; private static final String message = "no-addressing"; private static final String expectedResponse = "Hello no-addressing!"; @Deployment public static Archive<?> deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxws-wsa.war"). addClasses(ServiceIface.class, ServiceImplNoAddressing.class, WSHandler.class). addAsResource(WSHandler.class.getPackage(), "ws-handler.xml", "org/jboss/as/test/integration/ws/wsa/ws-handler.xml"); return war; } @Test public void usingLocalWSDLWithoutAddressing() throws Exception { ServiceIface proxy = getServicePortFromWSDL("NoAddressingService.xml"); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); } @Test public void usingLocalWSDLWithOptionalAddressing() throws Exception { ServiceIface proxy = getServicePortFromWSDL("OptionalAddressingService.xml"); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); } @Test public void usingLocalWSDLWithAddressing() throws Exception { ServiceIface proxy = getServicePortFromWSDL("RequiredAddressingService.xml"); try { proxy.sayHello(message); Assert.fail("Message Addressing is defined in local wsdl but shouldn't be used on deployed endpoint"); } catch (WebServiceException e) { // Expected, Message Addressing Property is not present } } @Test public void usingWSDLFromDeployedEndpoint() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService"); URL wsdlURL = new URL(baseUrl, "/jaxws-wsa/AddressingService?wsdl"); File wsdlFile = new File(this.getClass().getSimpleName() + ".wsdl"); downloadWSDLToFile(wsdlURL, wsdlFile); Service service = Service.create(wsdlFile.toURI().toURL(), serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); wsdlFile.delete(); } private ServiceIface getServicePortFromWSDL(String wsdlFileName) throws MalformedURLException { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService"); File wsdlFile = new File(System.getProperty("jbossas.ts.submodule.dir") + "/src/test/java/org/jboss/as/test/integration/ws/wsa/" + wsdlFileName); URL wsdlURL = wsdlFile.toURI().toURL(); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); BindingProvider bp = (BindingProvider) proxy; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, new URL(baseUrl, "/jaxws-wsa/AddressingService").toString()); return proxy; } protected static void downloadWSDLToFile(URL wsdlURL, File wsdlFile) throws IOException { Files.copy(wsdlURL.openStream(), wsdlFile.toPath()); } }
5,106
38.589147
153
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsa/ServiceImplNoAddressing.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsa; import jakarta.jws.HandlerChain; import jakarta.jws.WebService; @WebService ( portName = "AddressingServicePort", serviceName = "AddressingService", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsaddressing", endpointInterface = "org.jboss.as.test.integration.ws.wsa.ServiceIface" ) @HandlerChain(file = "ws-handler.xml") public class ServiceImplNoAddressing implements ServiceIface { public String sayHello(String name) { return "Hello " + name + "!"; } }
1,651
39.292683
92
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsa/TestRequiredAddressingTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsa; import java.io.File; import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import jakarta.xml.ws.WebServiceException; import org.junit.Assert; 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.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient public class TestRequiredAddressingTestCase { private static Logger log = Logger.getLogger(TestRequiredAddressingTestCase.class.getName()); @ArquillianResource URL baseUrl; private static final String message = "required-addressing"; private static final String expectedResponse = "Hello required-addressing!"; @Deployment public static Archive<?> deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxws-wsa.war"). addClasses(ServiceIface.class, ServiceImplAddressingRequired.class, WSHandler.class). addAsResource(WSHandler.class.getPackage(), "ws-handler.xml", "org/jboss/as/test/integration/ws/wsa/ws-handler.xml"); return war; } @Test public void usingLocalWSDLWithoutAddressing() throws Exception { ServiceIface proxy = getServicePortFromWSDL("NoAddressingService.xml"); try { proxy.sayHello(message); Assert.fail("Message Addressing is not defined in local wsdl but should be used for deployed endpoint"); } catch (WebServiceException e) { // Expected, Message Addressing Property is not present } } @Test public void usingLocalWSDLWithOptionalAddressing() throws Exception { ServiceIface proxy = getServicePortFromWSDL("OptionalAddressingService.xml"); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); } @Test public void usingLocalWSDLWithAddressing() throws Exception { ServiceIface proxy = getServicePortFromWSDL("RequiredAddressingService.xml"); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); } @Test public void usingWSDLFromDeployedEndpoint() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService"); URL wsdlURL = new URL(baseUrl, "/jaxws-wsa/AddressingService?wsdl"); File wsdlFile = new File(this.getClass().getSimpleName() + ".wsdl"); TestNoAddressingTestCase.downloadWSDLToFile(wsdlURL, wsdlFile); Service service = Service.create(wsdlFile.toURI().toURL(), serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); Assert.assertEquals(expectedResponse, proxy.sayHello(message)); wsdlFile.delete(); } private ServiceIface getServicePortFromWSDL(String wsdlFileName) throws MalformedURLException { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsaddressing", "AddressingService"); File wsdlFile = new File(System.getProperty("jbossas.ts.submodule.dir") + "/src/test/java/org/jboss/as/test/integration/ws/wsa/" + wsdlFileName); URL wsdlURL = wsdlFile.toURI().toURL(); Service service = Service.create(wsdlURL, serviceName); ServiceIface proxy = (ServiceIface) service.getPort(ServiceIface.class); BindingProvider bp = (BindingProvider) proxy; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, new URL(baseUrl, "/jaxws-wsa/AddressingService").toString()); return proxy; } }
5,067
40.540984
153
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/ReliableServiceTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsrm; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.BindingProvider; import jakarta.xml.ws.Service; import org.junit.Assert; 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.as.test.integration.ws.wsrm.generated.ReliableService; import org.jboss.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.wsf.stack.cxf.client.UseNewBusFeature; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient @Ignore("[WFLY-15426] Fix failing ReliableServiceTestCase") public class ReliableServiceTestCase { private static final Logger log = Logger.getLogger(ReliableServiceTestCase.class); @ArquillianResource URL baseUrl; @Deployment(testable = false) public static Archive mainDeployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "ws-reliable-messaging-example.war"). addPackage(ReliableService.class.getPackage()). addClasses(ReliableServiceImpl.class, ReliableCheckHandler.class). addAsWebInfResource(ReliableServiceTestCase.class.getPackage(), "ReliableService.wsdl", "wsdl/ReliableService.wsdl"). addAsResource(ReliableCheckHandler.class.getPackage(), "ws-handler.xml", "org/jboss/as/test/integration/ws/wsrm/ws-handler.xml"); return war; } @Test public void runTests() throws Exception { consumeHelloService(); consumeOneWayService(); } private void consumeOneWayService() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "ReliableService"); URL wsdlURL = new URL(baseUrl, "ReliableService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); ReliableService proxy = (ReliableService) service.getPort(ReliableService.class); BindingProvider bp = (BindingProvider) proxy; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, new URL(baseUrl, "ReliableService").toString()); proxy.writeLogMessage(); } private void consumeHelloService() throws Exception { QName serviceName = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "ReliableService"); URL wsdlURL = new URL(baseUrl, "ReliableService?wsdl"); Service service = Service.create(wsdlURL, serviceName, new UseNewBusFeature()); ReliableService proxy = (ReliableService) service.getPort(ReliableService.class); BindingProvider bp = (BindingProvider) proxy; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, new URL(baseUrl, "ReliableService").toString()); Assert.assertEquals("Hello Rosta!", proxy.sayHello("Rosta")); } }
4,238
43.15625
145
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/ReliableCheckHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsrm; import java.io.IOException; import java.io.OutputStream; import java.nio.charset.StandardCharsets; import java.util.Iterator; import java.util.Set; import javax.xml.namespace.QName; import jakarta.xml.soap.Node; import jakarta.xml.soap.SOAPElement; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPMessage; import jakarta.xml.ws.WebServiceException; import jakarta.xml.ws.handler.MessageContext; import jakarta.xml.ws.handler.soap.SOAPHandler; import jakarta.xml.ws.handler.soap.SOAPMessageContext; import org.jboss.logging.Logger; import org.jboss.logging.Logger.Level; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ public class ReliableCheckHandler implements SOAPHandler<SOAPMessageContext> { /* * 1 -- Body - CreateSequence * 2 -- Body - CreateSequenceResponse * 3 -- Header - wsrm:Sequence * 4 -- Header - wsrm:SequenceAcknowledgement */ int status = 0; private static Logger log = Logger.getLogger(ReliableCheckHandler.class); public Set<QName> getHeaders() { return null; } public boolean handleFault(SOAPMessageContext context) { handleContext(context); return true; } public boolean handleMessage(SOAPMessageContext context) { handleContext(context); return true; } private synchronized void handleContext(SOAPMessageContext smc) { Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY); SOAPMessage message = smc.getMessage(); if (outboundProperty.booleanValue()) { log.debug("Outgoing message:"); } else { log.debug("Incoming message:"); } log.debug("-----------"); try { JBossLoggingOutputStream os = new JBossLoggingOutputStream(log, Level.DEBUG); message.writeTo(os); os.flush(); log.debug(""); } catch (Exception e) { log.debug("Exception in handler: " + e); } log.debug("-----------"); SOAPElement firstBodyElement; try { switch (status % 4) { case 0: @SuppressWarnings("unchecked") Iterator<Node> it = (Iterator<Node>) message.getSOAPBody().getChildElements(); if (it.hasNext()) { firstBodyElement = (SOAPElement) it.next(); final QName createSequenceQName = new QName("http://schemas.xmlsoap.org/ws/2005/02/rm", "CreateSequence"); if (!createSequenceQName.equals(firstBodyElement.getElementQName())) { throw new WebServiceException("CreateSequence in soap body was expected, but it contains '" + firstBodyElement.getElementQName() + "'"); } status++; } else { //we could get multiple acknowledments verifySequenceAcknowledgement(message); } break; case 1: firstBodyElement = (SOAPElement) message.getSOAPBody().getChildElements().next(); final QName createSequenceResponseQName = new QName("http://schemas.xmlsoap.org/ws/2005/02/rm", "CreateSequenceResponse"); if (!createSequenceResponseQName.equals(firstBodyElement.getElementQName())) { throw new WebServiceException("CreateSequenceResponse in soap body was expected, but it contains '" + firstBodyElement.getElementQName() + "'"); } status++; break; case 2: Iterator headerElements = message.getSOAPHeader().getChildElements(); boolean found = false; final QName sequenceQName = new QName("http://schemas.xmlsoap.org/ws/2005/02/rm", "Sequence"); while (headerElements.hasNext()) { SOAPElement soapElement = (SOAPElement) headerElements.next(); if (sequenceQName.equals(soapElement.getElementQName())) { found = true; } } if (!found) { throw new WebServiceException("wsrm:Sequence is not present in soap header"); } status++; break; case 3: if (verifySequenceAcknowledgement(message)) { status++; } break; } } catch (SOAPException ex) { throw new WebServiceException(ex.getMessage(), ex); } } private boolean verifySequenceAcknowledgement(SOAPMessage message) throws SOAPException { Iterator headerElements = message.getSOAPHeader().getChildElements(); boolean found = false; boolean otherRMHeadersFound = false; final QName sequenceAckQName = new QName("http://schemas.xmlsoap.org/ws/2005/02/rm", "SequenceAcknowledgement"); while (headerElements.hasNext()) { SOAPElement soapElement = (SOAPElement) headerElements.next(); if (sequenceAckQName.equals(soapElement.getElementQName())) { found = true; } else if ("http://schemas.xmlsoap.org/ws/2005/02/rm".equals(soapElement.getNamespaceURI())) { otherRMHeadersFound = true; } } //fail if we did not find the sequence ack and the message has other WS-RM headers (hence out of order) or has body contents (hence a non-reliable message is being processed) if (!found && (otherRMHeadersFound || message.getSOAPBody().getChildElements().hasNext())) { throw new WebServiceException("wsrm:SequenceAcknowledgement is not present in soap header"); } return found; } public void close(MessageContext context) { } private class JBossLoggingOutputStream extends OutputStream { public static final int DEFAULT_BUFFER_LENGTH = 2048; protected boolean hasBeenClosed = false; protected byte[] buf; protected int count; private int bufLength; protected Logger logger; protected Level level; JBossLoggingOutputStream(Logger log, Level level) throws IllegalArgumentException { if (log == null) { throw new IllegalArgumentException("Null category!"); } if (level == null) { throw new IllegalArgumentException("Null priority!"); } this.level = level; logger = log; bufLength = DEFAULT_BUFFER_LENGTH; buf = new byte[DEFAULT_BUFFER_LENGTH]; count = 0; } public void close() { flush(); hasBeenClosed = true; } public void write(final int b) throws IOException { if (hasBeenClosed) { throw new IOException("The stream has been closed."); } // would this be writing past the buffer? if (count == bufLength) { // grow the buffer final int newBufLength = bufLength + DEFAULT_BUFFER_LENGTH; final byte[] newBuf = new byte[newBufLength]; System.arraycopy(buf, 0, newBuf, 0, bufLength); buf = newBuf; bufLength = newBufLength; } buf[count] = (byte) b; count++; } public void flush() { if (count == 0) { return; } // don't print out blank lines; flushing from PrintStream puts // out these // For linux system if (count == 1 && ((char) buf[0]) == '\n') { reset(); return; } // For mac system if (count == 1 && ((char) buf[0]) == '\r') { reset(); return; } // On windows system if (count == 2 && (char) buf[0] == '\r' && (char) buf[1] == '\n') { reset(); return; } final byte[] theBytes = new byte[count]; System.arraycopy(buf, 0, theBytes, 0, count); logger.log(level, new String(theBytes, StandardCharsets.UTF_8)); reset(); } private void reset() { // not resetting the buffer -- assuming that if it grew then it // will likely grow similarly again count = 0; } } }
9,902
38.771084
182
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/ReliableServiceImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.wsrm; import jakarta.jws.HandlerChain; import jakarta.jws.Oneway; import jakarta.jws.WebService; import org.jboss.logging.Logger; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @WebService ( name = "ReliableService", serviceName = "ReliableService", portName = "ReliableServicePort", wsdlLocation = "WEB-INF/wsdl/ReliableService.wsdl", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm" ) @HandlerChain(file = "ws-handler.xml") public class ReliableServiceImpl { private static Logger log = Logger.getLogger(ReliableServiceImpl.class); @Oneway public void writeLogMessage() { log.trace("write method was invoked ..."); } public String sayHello(String name) { return "Hello " + name + "!"; } }
1,957
33.964286
83
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/generated/ReliableService_Service.java
package org.jboss.as.test.integration.ws.wsrm.generated; import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.WebEndpoint; import jakarta.xml.ws.WebServiceClient; import jakarta.xml.ws.WebServiceFeature; import jakarta.xml.ws.Service; /** * This class was generated by Apache CXF 2.4.6 * 2012-02-16T17:56:55.263+01:00 * Generated source version: 2.4.6 */ @WebServiceClient(name = "ReliableService", wsdlLocation = "file:/home/rsvoboda/git/jboss-as/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ws/wsrm/ReliableService.wsdl", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm") public class ReliableService_Service extends Service { public static final URL WSDL_LOCATION; public static QName SERVICE = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "ReliableService"); public static final QName ReliableServicePort = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "ReliableServicePort"); static { URL url = null; try { url = new URL("file:/home/rsvoboda/git/jboss-as/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ws/wsrm/ReliableService.wsdl"); } catch (MalformedURLException e) { java.util.logging.Logger.getLogger(ReliableService_Service.class.getName()) .log(java.util.logging.Level.INFO, "Can not initialize the default wsdl from {0}", "file:/home/rsvoboda/git/jboss-as/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ws/wsrm/ReliableService.wsdl"); } WSDL_LOCATION = url; } public ReliableService_Service(URL wsdlLocation) { super(wsdlLocation, SERVICE); } public ReliableService_Service(URL wsdlLocation, QName serviceName) { super(wsdlLocation, serviceName); } public ReliableService_Service() { super(WSDL_LOCATION, SERVICE); } // //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 // //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 // //compliant code instead. // public ReliableService_Service(WebServiceFeature ... features) { // super(WSDL_LOCATION, SERVICE, features); // } // // //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 // //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 // //compliant code instead. // public ReliableService_Service(URL wsdlLocation, WebServiceFeature ... features) { // super(wsdlLocation, SERVICE, features); // } // // //This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2 // //API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1 // //compliant code instead. // public ReliableService_Service(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) { // super(wsdlLocation, serviceName, features); // } /** * @return returns ReliableService */ @WebEndpoint(name = "ReliableServicePort") public ReliableService getReliableServicePort() { return super.getPort(ReliableServicePort, ReliableService.class); } /** * @param features A list of {@link jakarta.xml.ws.WebServiceFeature} to configure on the proxy. Supported features not in the <code>features</code> parameter will have their default values. * @return returns ReliableService */ @WebEndpoint(name = "ReliableServicePort") public ReliableService getReliableServicePort(WebServiceFeature... features) { return super.getPort(ReliableServicePort, ReliableService.class, features); } }
3,790
41.595506
213
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/generated/package-info.java
@jakarta.xml.bind.annotation.XmlSchema(namespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm") package org.jboss.as.test.integration.ws.wsrm.generated;
159
52.333333
101
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/generated/ObjectFactory.java
package org.jboss.as.test.integration.ws.wsrm.generated; import jakarta.xml.bind.JAXBElement; import jakarta.xml.bind.annotation.XmlElementDecl; import jakarta.xml.bind.annotation.XmlRegistry; import javax.xml.namespace.QName; /** * This object contains factory methods for each * Java content interface and Java element interface * generated in the org.jboss.as.test.integration.ws.wsrm.generated package. * <p>An ObjectFactory allows you to programatically * construct new instances of the Java representation * for XML content. The Java representation of XML * content can consist of schema derived interfaces * and classes representing the binding of schema * type definitions, element declarations and model * groups. Factory methods for each of these are * provided in this class. */ @XmlRegistry public class ObjectFactory { private static final QName _WriteLogMessage_QNAME = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "writeLogMessage"); private static final QName _SayHello_QNAME = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "sayHello"); private static final QName _SayHelloResponse_QNAME = new QName("http://www.jboss.org/jbossws/ws-extensions/wsrm", "sayHelloResponse"); /** * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: org.jboss.as.test.integration.ws.wsrm.generated */ public ObjectFactory() { } /** * Create an instance of {@link WriteLogMessage } */ public WriteLogMessage createWriteLogMessage() { return new WriteLogMessage(); } /** * Create an instance of {@link SayHelloResponse } */ public SayHelloResponse createSayHelloResponse() { return new SayHelloResponse(); } /** * Create an instance of {@link SayHello } */ public SayHello createSayHello() { return new SayHello(); } /** * Create an instance of {@link JAXBElement }{@code <}{@link WriteLogMessage }{@code >}} */ @XmlElementDecl(namespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", name = "writeLogMessage") public JAXBElement<WriteLogMessage> createWriteLogMessage(WriteLogMessage value) { return new JAXBElement<WriteLogMessage>(_WriteLogMessage_QNAME, WriteLogMessage.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link SayHello }{@code >}} */ @XmlElementDecl(namespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", name = "sayHello") public JAXBElement<SayHello> createSayHello(SayHello value) { return new JAXBElement<SayHello>(_SayHello_QNAME, SayHello.class, null, value); } /** * Create an instance of {@link JAXBElement }{@code <}{@link SayHelloResponse }{@code >}} */ @XmlElementDecl(namespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", name = "sayHelloResponse") public JAXBElement<SayHelloResponse> createSayHelloResponse(SayHelloResponse value) { return new JAXBElement<SayHelloResponse>(_SayHelloResponse_QNAME, SayHelloResponse.class, null, value); } }
3,161
37.560976
161
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/generated/ReliableService.java
package org.jboss.as.test.integration.ws.wsrm.generated; import jakarta.jws.Oneway; import jakarta.jws.WebMethod; import jakarta.jws.WebParam; import jakarta.jws.WebResult; import jakarta.jws.WebService; import jakarta.xml.bind.annotation.XmlSeeAlso; import jakarta.xml.ws.RequestWrapper; import jakarta.xml.ws.ResponseWrapper; /** * This class was generated by Apache CXF 2.4.6 * 2012-02-16T17:56:55.227+01:00 * Generated source version: 2.4.6 */ @WebService(targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", name = "ReliableService") @XmlSeeAlso({ObjectFactory.class}) public interface ReliableService { @Oneway @RequestWrapper(localName = "writeLogMessage", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", className = "org.jboss.as.test.integration.ws.wsrm.generated.WriteLogMessage") @WebMethod void writeLogMessage(); @WebResult(name = "return", targetNamespace = "") @RequestWrapper(localName = "sayHello", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", className = "org.jboss.as.test.integration.ws.wsrm.generated.SayHello") @WebMethod @ResponseWrapper(localName = "sayHelloResponse", targetNamespace = "http://www.jboss.org/jbossws/ws-extensions/wsrm", className = "org.jboss.as.test.integration.ws.wsrm.generated.SayHelloResponse") java.lang.String sayHello( @WebParam(name = "arg0", targetNamespace = "") java.lang.String arg0 ); }
1,484
41.428571
201
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/generated/WriteLogMessage.java
package org.jboss.as.test.integration.ws.wsrm.generated; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlType; /** * <p>Java class for writeLogMessage complex type. * <p> * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> * &lt;complexType name="writeLogMessage"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "writeLogMessage") public class WriteLogMessage { }
763
23.645161
95
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/generated/SayHelloResponse.java
package org.jboss.as.test.integration.ws.wsrm.generated; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlType; /** * <p>Java class for sayHelloResponse complex type. * <p> * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> * &lt;complexType name="sayHelloResponse"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "sayHelloResponse", propOrder = { "_return" }) public class SayHelloResponse { @XmlElement(name = "return") protected String _return; /** * Gets the value of the return property. * * @return possible object is * {@link String } */ public String getReturn() { return _return; } /** * Sets the value of the return property. * * @param value allowed object is * {@link String } */ public void setReturn(String value) { this._return = value; } }
1,424
24
100
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/wsrm/generated/SayHello.java
package org.jboss.as.test.integration.ws.wsrm.generated; import jakarta.xml.bind.annotation.XmlAccessType; import jakarta.xml.bind.annotation.XmlAccessorType; import jakarta.xml.bind.annotation.XmlType; /** * <p>Java class for sayHello complex type. * <p> * <p>The following schema fragment specifies the expected content contained within this class. * <p> * <pre> * &lt;complexType name="sayHello"> * &lt;complexContent> * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"> * &lt;sequence> * &lt;element name="arg0" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/> * &lt;/sequence> * &lt;/restriction> * &lt;/complexContent> * &lt;/complexType> * </pre> */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "sayHello", propOrder = { "arg0" }) public class SayHello { protected String arg0; /** * Gets the value of the arg0 property. * * @return possible object is * {@link String } */ public String getArg0() { return arg0; } /** * Sets the value of the arg0 property. * * @param value allowed object is * {@link String } */ public void setArg0(String value) { this.arg0 = value; } }
1,290
22.472727
98
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/CdiJsfWebServicesTestCase.java
/* * JBoss, Home of Professional Open Source * Copyright 2021, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi; import java.io.IOException; import java.net.URL; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; 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.as.test.integration.common.HttpRequest; import org.jboss.as.test.shared.TimeoutUtil; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * AS7-1429 * <p/> * Tests that adding a web service does not break CDI + Jakarta Server Faces * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class CdiJsfWebServicesTestCase { @ArquillianResource URL baseUrl; public static final String ARCHIVE_NAME = "testCdiJsfWebServices"; @Deployment public static Archive<?> archive() { WebArchive war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME + ".war"); war.addPackage(CdiJsfWebServicesTestCase.class.getPackage()); war.addAsWebInfResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml"); war.add(new StringAsset("<html><body>#{myBean.message}</body></html>"), "index.xhtml"); war.addAsWebInfResource(new StringAsset(FACES_CONFIG), "faces-config.xml"); return war; } @Test public void testWebServicesDoNotBreakCDI() throws IOException, ExecutionException, TimeoutException { URL webRoot = new URL(baseUrl, "/"); Assert.assertEquals("<html><body>" + MyBean.MESSAGE + "</body></html>", HttpRequest.get(webRoot.toString() + ARCHIVE_NAME + "/index.jsf", TimeoutUtil.adjust(20), TimeUnit.SECONDS)); } private static final String WEB_XML = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" + "<web-app version=\"3.0\" xmlns=\"http://java.sun.com/xml/ns/j2ee\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\">\n" + " <servlet>\n" + " <servlet-name>Faces Servlet</servlet-name>\n" + " <servlet-class>jakarta.faces.webapp.FacesServlet</servlet-class>\n" + " <load-on-startup>1</load-on-startup>\n" + " </servlet>\n" + " <servlet-mapping>\n" + " <servlet-name>Faces Servlet</servlet-name>\n" + " <url-pattern>*.jsf</url-pattern>\n" + " </servlet-mapping>\n" + "</web-app>"; public static final String FACES_CONFIG = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!-- This file is not required if you don't need any extra configuration. -->\n" + "<faces-config version=\"2.0\" xmlns=\"http://java.sun.com/xml/ns/javaee\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"\n" + " http://java.sun.com/xml/ns/javaee\n" + " http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd\">\n" + "</faces-config>"; }
4,560
42.855769
130
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/MyBean.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi; import jakarta.inject.Named; /** * @author Stuart Douglas */ @Named public class MyBean { public static final String MESSAGE = "Hello World"; public String getMessage() { return MESSAGE; } }
1,280
31.846154
73
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/TestService.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi; import jakarta.ejb.Stateless; import jakarta.jws.WebMethod; import jakarta.jws.WebParam; import jakarta.jws.WebService; /** * Simple web service * * @author Stuart Douglas */ @WebService @Stateless public class TestService { @WebMethod public String echo(@WebParam final String toEcho) { return toEcho; } }
1,396
31.488372
73
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/interceptor/EJBInterceptor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi.interceptor; import java.lang.annotation.Retention; import java.lang.annotation.Target; import jakarta.interceptor.InterceptorBinding; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; @InterceptorBinding @Retention(RUNTIME) @Target({METHOD, TYPE}) public @interface EJBInterceptor { }
1,485
38.105263
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/interceptor/EndpointIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi.interceptor; import jakarta.jws.WebService; /** * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @WebService(name = "EndpointIface", targetNamespace = "http://org.jboss.test.ws/jbws3441") public interface EndpointIface { String echo(final String message); }
1,362
40.30303
90
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/interceptor/EJB3EndpointImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi.interceptor; import jakarta.ejb.Stateless; import jakarta.jws.WebService; /** * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @WebService(name = "EJB3Endpoint", serviceName = "EJB3EndpointService", targetNamespace = "http://org.jboss.test.ws/jbws3441") @Stateless public class EJB3EndpointImpl implements EndpointIface { static boolean interceptorCalled; @EJBInterceptor public String echo(final String message) { return interceptorCalled ? message + " (including EJB interceptor)" : message; } }
1,623
39.6
126
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/interceptor/EJBInterceptorImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi.interceptor; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.Interceptor; import jakarta.interceptor.InvocationContext; @EJBInterceptor @Interceptor public class EJBInterceptorImpl { @AroundInvoke public Object intercept(final InvocationContext ic) throws Exception { EJB3EndpointImpl.interceptorCalled = true; return ic.proceed(); } }
1,464
37.552632
74
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/interceptor/POJOInterceptorImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi.interceptor; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.Interceptor; import jakarta.interceptor.InvocationContext; @POJOInterceptor @Interceptor public class POJOInterceptorImpl { @AroundInvoke public Object intercept(final InvocationContext ic) throws Exception { POJOEndpointImpl.interceptorCalled = true; return ic.proceed(); } }
1,466
37.605263
74
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/interceptor/CdiInterceptorTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi.interceptor; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; 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.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * [JBWS-3441] Support CDI interceptors for POJO Jakarta XML Web Services * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @RunWith(Arquillian.class) @RunAsClient public class CdiInterceptorTestCase { @ArquillianResource URL baseUrl; public static final String ARCHIVE_NAME = "jaxws-cdi-interceptors"; @Deployment public static Archive<?> archive() { WebArchive war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME + ".war"); war.addPackage(CdiInterceptorTestCase.class.getPackage()); war.addAsWebInfResource(new StringAsset(BEANS_CONFIG), "beans.xml"); return war; } private EndpointIface getPojo() throws Exception { final URL wsdlURL = new URL(baseUrl + "POJOEndpointService?wsdl"); final QName serviceName = new QName("http://org.jboss.test.ws/jbws3441", "POJOEndpointService"); final Service service = Service.create(wsdlURL, serviceName); return service.getPort(EndpointIface.class); } private EndpointIface getEjb3() throws Exception { final URL wsdlURL = new URL(baseUrl + "EJB3EndpointService/EJB3Endpoint?wsdl"); final QName serviceName = new QName("http://org.jboss.test.ws/jbws3441", "EJB3EndpointService"); final Service service = Service.create(wsdlURL, serviceName); return service.getPort(EndpointIface.class); } @Test public void testPojoCall() throws Exception { String message = "Hi"; String response = getPojo().echo(message); Assert.assertEquals("Hi (including POJO interceptor)", response); } @Test public void testEjb3Call() throws Exception { String message = "Hi"; String response = getEjb3().echo(message); Assert.assertEquals("Hi (including EJB interceptor)", response); } private static final String BEANS_CONFIG = "<beans><interceptors>" + "<class>org.jboss.as.test.integration.ws.cdi.interceptor.POJOInterceptorImpl</class>" + "<class>org.jboss.as.test.integration.ws.cdi.interceptor.EJBInterceptorImpl</class>" + "</interceptors></beans>"; }
3,815
39.168421
127
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/interceptor/POJOEndpointImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi.interceptor; import jakarta.jws.WebService; /** * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @WebService(name = "POJOEndpoint", serviceName = "POJOEndpointService", targetNamespace = "http://org.jboss.test.ws/jbws3441") public class POJOEndpointImpl implements EndpointIface { static boolean interceptorCalled; @POJOInterceptor public String echo(final String message) { return interceptorCalled ? message + " (including POJO interceptor)" : message; } }
1,584
40.710526
126
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/cdi/interceptor/POJOInterceptor.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.cdi.interceptor; import java.lang.annotation.Retention; import java.lang.annotation.Target; import jakarta.interceptor.InterceptorBinding; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; @InterceptorBinding @Retention(RUNTIME) @Target({METHOD, TYPE}) public @interface POJOInterceptor { }
1,486
38.131579
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/as1675/EndpointIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.as1675; import jakarta.jws.WebMethod; import jakarta.jws.WebService; import jakarta.jws.soap.SOAPBinding; /** * An endpoint interface. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @WebService @SOAPBinding(style = SOAPBinding.Style.RPC) public interface EndpointIface { @WebMethod String echo(String s); }
1,429
34.75
71
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/as1675/AS1675TestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.as1675; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; 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.as.test.integration.ws.injection.ejb.as1675.shared.BeanIface; import org.jboss.as.test.integration.ws.injection.ejb.as1675.shared.BeanImpl; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * [AS7-1675] Problem with @Resource lookups on EJBs * <p> * https://issues.jboss.org/browse/AS7-1675 * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @RunWith(Arquillian.class) @RunAsClient public class AS1675TestCase { @ArquillianResource URL baseUrl; @Deployment public static Archive<?> deployment() { // construct shared jar JavaArchive sharedJar = ShrinkWrap.create(JavaArchive.class, "shared.jar"); sharedJar.addClass(BeanIface.class); sharedJar.addClass(BeanImpl.class); sharedJar.addClass(EndpointIface.class); sharedJar.addClass(AbstractEndpointImpl.class); // construct ejb3 jar JavaArchive ejb3Jar = ShrinkWrap.create(JavaArchive.class, "ejb3.jar"); ejb3Jar.addClass(EJB3Bean.class); ejb3Jar.addClass(AS1675TestCase.class); ejb3Jar.addAsManifestResource(new StringAsset(EJB_JAR), "ejb-jar.xml"); // construct ear EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "as1675.ear"); ear.addAsModule(sharedJar); ear.addAsModule(ejb3Jar); // return ear return ear; } @Test public void testEjb3EndpointInjection() throws Exception { QName serviceName = new QName("http://jbossws.org/as1675", "EJB3Service"); URL wsdlURL = new URL(baseUrl + "/as1675/EJB3Service?wsdl"); Service service = Service.create(wsdlURL, serviceName); EndpointIface proxy = (EndpointIface) service.getPort(EndpointIface.class); Assert.assertEquals("Hello World!:EJB3Bean", proxy.echo("Hello World!")); } private static final String EJB_JAR = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<ejb-jar version=\"3.0\" xmlns=\"http://java.sun.com/xml/ns/javaee\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd\">\n" + "\n" + " <enterprise-beans>\n" + " <session>\n" + "\n" + " <ejb-name>EJB3Bean</ejb-name>\n" + " <ejb-class>org.jboss.as.test.integration.ws.injection.ejb.as1675.EJB3Bean</ejb-class>\n" + "\n" + " <env-entry>\n" + " <env-entry-name>boolean1</env-entry-name>\n" + " <env-entry-type>java.lang.Boolean</env-entry-type>\n" + " <env-entry-value>true</env-entry-value>\n" + " </env-entry>\n" + "\n" + " </session>\n" + "\n" + " </enterprise-beans>\n" + "\n" + "</ejb-jar>"; }
4,636
40.035398
127
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/as1675/EJB3Bean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.as1675; import org.jboss.ws.api.annotation.WebContext; import jakarta.ejb.Stateless; import jakarta.jws.WebService; /** * EJB3 bean published as WebService injecting other EJB3 bean and resources. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @Stateless @WebService( name = "EJB3", serviceName = "EJB3Service", targetNamespace = "http://jbossws.org/as1675", endpointInterface = "org.jboss.as.test.integration.ws.injection.ejb.as1675.EndpointIface" ) @WebContext( urlPattern = "/EJB3Service", contextRoot = "/as1675" ) public class EJB3Bean extends AbstractEndpointImpl { public String echo(String msg) { return super.echo(msg) + ":EJB3Bean"; } }
1,826
34.823529
97
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/as1675/AbstractEndpointImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.as1675; import org.jboss.as.test.integration.ws.injection.ejb.as1675.shared.BeanIface; import org.jboss.logging.Logger; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; import jakarta.ejb.EJB; import jakarta.xml.ws.WebServiceException; /** * Abstract endpoint implementation. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ public abstract class AbstractEndpointImpl implements EndpointIface { private static final Logger LOG = Logger.getLogger(AbstractEndpointImpl.class); private boolean correctState; private BeanIface testBean1; @EJB private BeanIface testBean2; private Boolean boolean1; @EJB(name = "as1675/BeanImpl/local-org.jboss.as.test.integration.ws.injection.ejb.as1675.shared.BeanIface") private void setBean(BeanIface bean) { this.testBean1 = bean; } @Resource(name = "boolean1") private void setBoolean1(final Boolean b) { this.boolean1 = b; } public String echo(final String msg) { if (!this.correctState) { throw new WebServiceException("Injection failed"); } LOG.trace("echo: " + msg); return msg; } @PostConstruct private void init() { boolean currentState = true; if (this.testBean1 == null) { LOG.error("Annotation driven initialization for testBean1 failed"); currentState = false; } if (!"Injected hello message".equals(testBean1.printString())) { LOG.error("Annotation driven initialization for testBean1 failed"); currentState = false; } if (this.testBean2 == null) { LOG.error("Annotation driven initialization for testBean2 failed"); currentState = false; } if (!"Injected hello message".equals(testBean2.printString())) { LOG.error("Annotation driven initialization for testBean2 failed"); currentState = false; } if (this.boolean1 == null || this.boolean1 != true) { LOG.error("Annotation driven initialization for boolean1 failed"); currentState = false; } this.correctState = currentState; } }
3,319
34.319149
111
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/as1675/shared/BeanImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.as1675.shared; import jakarta.ejb.Stateless; /** * Shared EJB3 implementation. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @Stateless public class BeanImpl implements BeanIface { public String printString() { return "Injected hello message"; } }
1,379
35.315789
71
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/as1675/shared/BeanIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.as1675.shared; /** * Shared EJB3 interface. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ public interface BeanIface { String printString(); }
1,261
37.242424
71
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/basic/EjbEndpointInsideWarTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.basic; 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.as.test.integration.ws.injection.ejb.basic.shared.BeanIface; import org.jboss.as.test.integration.ws.injection.ejb.basic.shared.BeanImpl; import org.jboss.as.test.integration.ws.injection.ejb.basic.shared.handlers.TestHandler; import org.jboss.as.test.integration.ws.injection.ejb.basic.webservice.AbstractEndpointImpl; import org.jboss.as.test.integration.ws.injection.ejb.basic.webservice.EJB3Bean; import org.jboss.as.test.integration.ws.injection.ejb.basic.webservice.EndpointIface; import org.jboss.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; import java.net.URL; /** * [AS7-3411] Test injection + handlers with EJB3 endpoint packaged inside a WAR. * * @author Robert Reimann * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @RunWith(Arquillian.class) @RunAsClient public class EjbEndpointInsideWarTestCase { private static final Logger log = Logger.getLogger(EjbEndpointInsideWarTestCase.class); @ArquillianResource URL baseUrl; @Deployment public static Archive<?> deployment() { // construct shared jar JavaArchive sharedJar = ShrinkWrap.create(JavaArchive.class, "jaxws-injection.jar"); sharedJar.addClass(BeanIface.class); sharedJar.addClass(BeanImpl.class); // construct ejb3 jar JavaArchive ejb3Jar = ShrinkWrap.create(JavaArchive.class, "jaxws-injection-ejb3.jar"); ejb3Jar.addClass(EJB3Bean.class); ejb3Jar.addClass(TestHandler.class); ejb3Jar.addClass(AbstractEndpointImpl.class); ejb3Jar.addClass(EndpointIface.class); ejb3Jar.addAsResource(EJB3Bean.class.getPackage(), "jaxws-handler.xml", "org/jboss/as/test/integration/ws/injection/ejb/basic/webservice/jaxws-handler.xml"); // construct war containing the ejb3 jar WebArchive ejb3War = ShrinkWrap.create(WebArchive.class, "jaxws-injection-ejb3-inside.war"); ejb3War.addAsLibraries(sharedJar); ejb3War.addAsLibraries(ejb3Jar); ejb3War.addAsWebInfResource(EJB3Bean.class.getPackage(), "ejb-web.xml", "web.xml"); return ejb3War; } @Test public void testEjb3InsideWarEndpoint() throws Exception { QName serviceName = new QName("http://jbossws.org/injection", "EJB3Service"); URL wsdlURL = new URL(baseUrl, "/jaxws-injection-ejb3/EJB3Service?wsdl"); Service service = Service.create(wsdlURL, serviceName); EndpointIface proxy = service.getPort(EndpointIface.class); Assert.assertEquals("Hello World!:Inbound:TestHandler:EJB3Bean:Outbound:TestHandler", proxy.echo("Hello World!")); } }
4,221
43.442105
165
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/basic/InjectionTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.basic; 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.as.test.integration.ws.injection.ejb.basic.shared.BeanIface; import org.jboss.as.test.integration.ws.injection.ejb.basic.shared.BeanImpl; import org.jboss.as.test.integration.ws.injection.ejb.basic.shared.handlers.TestHandler; import org.jboss.as.test.integration.ws.injection.ejb.basic.webservice.AbstractEndpointImpl; import org.jboss.as.test.integration.ws.injection.ejb.basic.webservice.EJB3Bean; import org.jboss.as.test.integration.ws.injection.ejb.basic.webservice.EndpointIface; import org.jboss.as.test.integration.ws.injection.ejb.basic.webservice.POJOBean; import org.jboss.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; import java.net.URL; /** * Migrated testcase from AS6, injection + handlers are tested with POJO and EJB3 endpoint * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient public class InjectionTestCase { private static final Logger log = Logger.getLogger(InjectionTestCase.class); @ArquillianResource URL baseUrl; @Deployment public static Archive<?> deployment() { // construct shared jar JavaArchive sharedJar = ShrinkWrap.create(JavaArchive.class, "jaxws-injection.jar"); sharedJar.addClass(BeanIface.class); sharedJar.addClass(BeanImpl.class); // construct ejb3 jar JavaArchive ejb3Jar = ShrinkWrap.create(JavaArchive.class, "jaxws-injection-ejb3.jar"); ejb3Jar.addClass(EJB3Bean.class); ejb3Jar.addClass(TestHandler.class); ejb3Jar.addClass(AbstractEndpointImpl.class); ejb3Jar.addClass(EndpointIface.class); ejb3Jar.addAsResource(EJB3Bean.class.getPackage(), "jaxws-handler.xml", "org/jboss/as/test/integration/ws/injection/ejb/basic/webservice/jaxws-handler.xml"); ejb3Jar.addAsManifestResource(EJB3Bean.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml"); ejb3Jar.addAsManifestResource(new StringAsset("Dependencies: deployment.jaxws-injection.ear.jaxws-injection.jar"), "MANIFEST.MF"); // construct pojo war WebArchive pojoWar = ShrinkWrap.create(WebArchive.class, "jaxws-injection-pojo.war"); pojoWar.addClass(POJOBean.class); pojoWar.addClass(TestHandler.class); pojoWar.addClass(AbstractEndpointImpl.class); pojoWar.addClass(EndpointIface.class); pojoWar.addAsResource(POJOBean.class.getPackage(), "jaxws-handler.xml", "org/jboss/as/test/integration/ws/injection/ejb/basic/webservice/jaxws-handler.xml"); pojoWar.addAsWebInfResource(POJOBean.class.getPackage(), "web.xml", "web.xml"); pojoWar.addAsManifestResource(new StringAsset("Dependencies: deployment.jaxws-injection.ear.jaxws-injection.jar"), "MANIFEST.MF"); // construct ear EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxws-injection.ear"); ear.addAsModule(sharedJar); ear.addAsModule(ejb3Jar); ear.addAsModule(pojoWar); return ear; } @Test public void testPojoEndpoint() throws Exception { QName serviceName = new QName("http://jbossws.org/injection", "POJOService"); URL wsdlURL = new URL(baseUrl, "/jaxws-injection-pojo/POJOService?wsdl"); Service service = Service.create(wsdlURL, serviceName); EndpointIface proxy = service.getPort(EndpointIface.class); Assert.assertEquals("Hello World!:Inbound:TestHandler:POJOBean:Outbound:TestHandler", proxy.echo("Hello World!")); } @Test public void testEjb3Endpoint() throws Exception { QName serviceName = new QName("http://jbossws.org/injection", "EJB3Service"); URL wsdlURL = new URL(baseUrl, "/jaxws-injection-ejb3/EJB3Service?wsdl"); Service service = Service.create(wsdlURL, serviceName); EndpointIface proxy = service.getPort(EndpointIface.class); Assert.assertEquals("Hello World!:Inbound:TestHandler:EJB3Bean:Outbound:TestHandler", proxy.echo("Hello World!")); } }
5,705
45.390244
165
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/basic/shared/BeanImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.basic.shared; import jakarta.ejb.Stateless; /** * The EJB3 implementation * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @Stateless public class BeanImpl implements BeanIface { public String printString() { return "Injected hello message"; } }
1,371
36.081081
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/basic/shared/BeanIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.basic.shared; /** * The EJB3 interface * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ public interface BeanIface { String printString(); }
1,253
38.1875
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/basic/shared/handlers/TestHandler.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.basic.shared.handlers; import org.jboss.as.test.integration.ws.injection.ejb.basic.shared.BeanIface; import org.jboss.logging.Logger; import org.jboss.ws.api.handler.GenericSOAPHandler; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; import jakarta.ejb.EJB; import jakarta.xml.soap.SOAPElement; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPMessage; import jakarta.xml.ws.WebServiceException; import jakarta.xml.ws.handler.MessageContext; import jakarta.xml.ws.handler.soap.SOAPMessageContext; /** * This handler is initialized via injections. * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ public final class TestHandler extends GenericSOAPHandler { // provide logging private static final Logger log = Logger.getLogger(TestHandler.class); @Resource(name = "boolean1") private Boolean boolean1; @EJB private BeanIface bean1; /** * Indicates whether handler is in correct state. */ private boolean correctState; @PostConstruct private void init() { boolean correctInitialization = true; // verify @EJB annotation driven injection if (this.bean1 == null || !this.bean1.printString().equals("Injected hello message")) { log.error("Annotation driven initialization for bean1 failed"); correctInitialization = false; } else { log.trace("@EJB annotation driven injection OK"); } // verify @Resource annotation driven injection if (this.boolean1 == null || this.boolean1 != true) { log.error("Annotation driven initialization for boolean1 failed -- " + boolean1); correctInitialization = false; } else { log.trace("@Resource annotation driven injection OK"); } this.correctState = correctInitialization; } @Override public boolean handleOutbound(MessageContext msgContext) { return ensureInjectionsAndInitialization(msgContext, "Outbound"); } @Override public boolean handleInbound(MessageContext msgContext) { return ensureInjectionsAndInitialization(msgContext, "Inbound"); } private boolean ensureInjectionsAndInitialization(MessageContext msgContext, String direction) { if (!this.correctState) { throw new WebServiceException("Unfunctional injections"); } try { SOAPMessage soapMessage = ((SOAPMessageContext) msgContext).getMessage(); SOAPElement soapElement = (SOAPElement) soapMessage.getSOAPBody().getChildElements().next(); soapElement = (SOAPElement) soapElement.getChildElements().next(); String oldValue = soapElement.getValue(); String newValue = oldValue + ":" + direction + ":TestHandler"; soapElement.setValue(newValue); log.debug("oldValue: " + oldValue); log.debug("newValue: " + newValue); return true; } catch (SOAPException ex) { throw new WebServiceException(ex); } } }
4,190
35.443478
104
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/basic/webservice/EndpointIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.basic.webservice; import jakarta.jws.WebMethod; import jakarta.jws.WebService; import jakarta.jws.soap.SOAPBinding; /** * An endpoint interface. * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @WebService @SOAPBinding(style = SOAPBinding.Style.DOCUMENT) public interface EndpointIface { @WebMethod String echo(String s); }
1,441
35.974359
72
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/basic/webservice/EJB3Bean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.basic.webservice; import org.jboss.ws.api.annotation.WebContext; import jakarta.ejb.Stateless; import jakarta.jws.HandlerChain; import jakarta.jws.WebService; /** * EJB3 bean published as WebService injecting other EJB3 bean. * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @WebService( name = "EJB3", serviceName = "EJB3Service", targetNamespace = "http://jbossws.org/injection", endpointInterface = "org.jboss.as.test.integration.ws.injection.ejb.basic.webservice.EndpointIface" ) @WebContext( urlPattern = "/EJB3Service", contextRoot = "/jaxws-injection-ejb3" ) @HandlerChain(file = "jaxws-handler.xml") @Stateless public class EJB3Bean extends AbstractEndpointImpl { public String echo(String msg) { return super.echo(msg) + ":EJB3Bean"; } }
1,923
34.62963
107
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/basic/webservice/POJOBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.basic.webservice; import jakarta.jws.HandlerChain; import jakarta.jws.WebService; /** * POJO bean published as WebService injecting other EJB3 bean. * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @WebService( name = "POJO", serviceName = "POJOService", targetNamespace = "http://jbossws.org/injection", endpointInterface = "org.jboss.as.test.integration.ws.injection.ejb.basic.webservice.EndpointIface" ) @HandlerChain(file = "jaxws-handler.xml") public class POJOBean extends AbstractEndpointImpl { public String echo(String msg) { return super.echo(msg) + ":POJOBean"; } }
1,736
36.76087
107
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/injection/ejb/basic/webservice/AbstractEndpointImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.injection.ejb.basic.webservice; import org.jboss.as.test.integration.ws.injection.ejb.basic.shared.BeanIface; import org.jboss.logging.Logger; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; import jakarta.ejb.EJB; import jakarta.xml.ws.WebServiceException; /** * Basic endpoint implementation. * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ public abstract class AbstractEndpointImpl implements EndpointIface { private static final Logger LOG = Logger.getLogger(AbstractEndpointImpl.class); private boolean correctState; @EJB private BeanIface testBean2; private BeanIface testBean1; @EJB private void setBean(BeanIface bean) { this.testBean1 = bean; } private Boolean boolean1; /** * EJB 3.0 16.2.2: "By default, the name of the field is combined with the * name of the class in which the annotation is used and is used directly * as the name in the bean’s naming context */ @Resource(name = "boolean1") private void setBoolean1(Boolean b) { this.boolean1 = b; } public String echo(final String msg) { if (!this.correctState) { throw new WebServiceException("Injection failed"); } LOG.trace("echo: " + msg); return msg; } @PostConstruct private void init() { boolean currentState = true; if (this.testBean1 == null) { LOG.error("Annotation driven initialization for testBean1 failed"); currentState = false; } if (!"Injected hello message".equals(testBean1.printString())) { LOG.error("Annotation driven initialization for testBean1 failed"); currentState = false; } if (this.testBean2 == null) { LOG.error("Annotation driven initialization for testBean2 failed"); currentState = false; } if (!"Injected hello message".equals(testBean2.printString())) { LOG.error("Annotation driven initialization for testBean2 failed"); currentState = false; } if (this.boolean1 == null || this.boolean1 != true) { LOG.error("Annotation driven initialization for boolean1 failed"); currentState = false; } this.correctState = currentState; } }
3,438
32.715686
83
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/application/NotAnnotatedDeployTestCase.java
package org.jboss.as.test.integration.ws.context.application; 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.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.runner.RunWith; @RunWith(Arquillian.class) @RunAsClient public class NotAnnotatedDeployTestCase extends ContextRootTestBase { @Deployment public static EnterpriseArchive createDeployment() { final WebArchive war = createWAR(SampleBean.class, "ws-notannotated-XXX.war"); final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ws-notannotated-XXX.ear"); ear.addAsManifestResource(NotAnnotatedDeployTestCase.class.getPackage(), "application-notannotated.xml", "application.xml"); ear.addAsModule(war); return ear; } }
983
38.36
132
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/application/SampleBean.java
package org.jboss.as.test.integration.ws.context.application; import jakarta.ejb.LocalBean; import jakarta.ejb.Stateless; import jakarta.jws.WebMethod; @Stateless @LocalBean public class SampleBean { @WebMethod public String sayHello(String name) { return "Hello " + name + "."; } }
305
19.4
61
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/application/SampleBeanWebService.java
package org.jboss.as.test.integration.ws.context.application; import jakarta.ejb.LocalBean; import jakarta.ejb.Stateless; import jakarta.jws.WebMethod; import jakarta.jws.WebService; @Stateless @LocalBean @WebService public class SampleBeanWebService { @WebMethod public String sayHello(String name) { return "Hello " + name + "."; } }
358
20.117647
61
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/application/ContextRootTestBase.java
package org.jboss.as.test.integration.ws.context.application; import java.net.URL; import org.junit.Assert; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; /** * Base class for context.application tests. Unit test checks if context-root parameter is honored regardles of deploy content. * * @author baranowb */ public class ContextRootTestBase { protected static final String TEST_PATH = "/test1/"; @ArquillianResource URL baseUrl; protected static WebArchive createWAR(final Class<?> beanClass, final String warDeploymentUnitName) { final WebArchive war = ShrinkWrap.create(WebArchive.class, warDeploymentUnitName); war.addClass(beanClass); war.addAsWebResource(ContextRootTestBase.class.getPackage(), "index.html", "index.html"); war.addAsWebInfResource(ContextRootTestBase.class.getPackage(), "beans.xml", "beans.xml"); war.addAsWebInfResource(ContextRootTestBase.class.getPackage(), "faces-config.xml", "faces-config.xml"); return war; } @Test public void testContextRoot() { Assert.assertEquals("Wrong context root!", TEST_PATH, baseUrl.getPath()); } }
1,286
30.390244
127
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/application/AnnotatedDeployTestCase.java
package org.jboss.as.test.integration.ws.context.application; 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.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.runner.RunWith; @RunWith(Arquillian.class) @RunAsClient public class AnnotatedDeployTestCase extends ContextRootTestBase { @Deployment public static EnterpriseArchive createDeployment() { final WebArchive war = createWAR(SampleBeanWebService.class, "ws-annotated-XXX.war"); final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ws-annotated-XXX.ear"); ear.addAsManifestResource(AnnotatedDeployTestCase.class.getPackage(), "application.xml", "application.xml"); ear.addAsModule(war); return ear; } }
968
37.76
116
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/as1605/BothPojoAndEjbInWarTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.context.as1605; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; 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.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * [AS7-1605] jboss-web.xml ignored for web service root * <p> * This test case tests if both POJO & EJB3 endpoints are in war archive. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @RunWith(Arquillian.class) @RunAsClient public class BothPojoAndEjbInWarTestCase { @ArquillianResource URL baseUrl; @Deployment public static WebArchive createDeployment() { final WebArchive war = ShrinkWrap.create(WebArchive.class, "as1605-usecase1.war"); war.addClass(EndpointIface.class); war.addClass(POJOEndpoint.class); war.addClass(EJB3Endpoint.class); war.addAsWebInfResource(new StringAsset( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<web-app version=\"3.0\"\n" + " xmlns=\"http://java.sun.com/xml/ns/javaee\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd\"\n" + " metadata-complete=\"false\">\n" + " <servlet>\n" + " <servlet-name>POJOService</servlet-name>\n" + " <servlet-class>org.jboss.as.test.integration.ws.context.as1605.POJOEndpoint</servlet-class>\n" + " </servlet>\n" + " <servlet-mapping>\n" + " <servlet-name>POJOService</servlet-name>\n" + " <url-pattern>/POJOEndpoint</url-pattern>\n" + " </servlet-mapping>\n" + "</web-app>\n"), "web.xml"); war.addAsWebInfResource(new StringAsset( "<?xml version='1.0' encoding='UTF-8'?>\n" + "<!DOCTYPE jboss-web PUBLIC \"-//JBoss//DTD Web Application 2.4//EN\" \"http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd\">\n" + "<jboss-web>\n" + "<context-root>/as1605-customized</context-root>\n" + "</jboss-web>\n"), "jboss-web.xml"); return war; } @Test public void testPOJOEndpoint() throws Exception { final QName serviceName = new QName("org.jboss.as.test.integration.ws.context.as1605", "POJOEndpointService"); final URL wsdlURL = new URL(baseUrl, "/as1605-customized/POJOEndpoint?wsdl"); final Service service = Service.create(wsdlURL, serviceName); final EndpointIface port = service.getPort(EndpointIface.class); final String result = port.echo("hello"); Assert.assertEquals("POJO hello", result); } @Test public void testEJB3Endpoint() throws Exception { final QName serviceName = new QName("org.jboss.as.test.integration.ws.context.as1605", "EJB3EndpointService"); final URL wsdlURL = new URL(baseUrl, "/as1605-customized/EJB3Endpoint?wsdl"); final Service service = Service.create(wsdlURL, serviceName); final EndpointIface port = service.getPort(EndpointIface.class); final String result = port.echo("hello"); Assert.assertEquals("EJB3 hello", result); } }
4,906
44.859813
151
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/as1605/EJB3Endpoint.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.context.as1605; import jakarta.ejb.Stateless; import jakarta.jws.WebService; /** * EJB3 endpoint. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @Stateless @WebService( endpointInterface = "org.jboss.as.test.integration.ws.context.as1605.EndpointIface", targetNamespace = "org.jboss.as.test.integration.ws.context.as1605" ) public class EJB3Endpoint { public String echo(final String s) { return "EJB3 " + s; } }
1,541
33.266667
92
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/as1605/EndpointIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.context.as1605; import jakarta.jws.WebService; import jakarta.jws.soap.SOAPBinding; /** * Endpoint interface. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @WebService @SOAPBinding public interface EndpointIface { String echo(String s); }
1,340
32.525
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/as1605/POJOEndpoint.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.context.as1605; import jakarta.jws.WebService; /** * POJO endpoint. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @WebService( endpointInterface = "org.jboss.as.test.integration.ws.context.as1605.EndpointIface", targetNamespace = "org.jboss.as.test.integration.ws.context.as1605" ) public class POJOEndpoint { public String echo(final String s) { return "POJO " + s; } }
1,500
33.906977
92
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/context/as1605/OnlyEjbInWarTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.context.as1605; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; 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.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * [AS7-1605] jboss-web.xml ignored for web service root * <p> * This test case tests if only EJB3 endpoints are in war archive. * * @author <a href="mailto:[email protected]">Richard Opalka</a> */ @RunWith(Arquillian.class) @RunAsClient public class OnlyEjbInWarTestCase { @ArquillianResource URL baseUrl; @Deployment public static WebArchive createDeployment() { final WebArchive war = ShrinkWrap.create(WebArchive.class, "as1605-usecase2.war"); war.addClass(EndpointIface.class); war.addClass(EJB3Endpoint.class); war.addAsWebInfResource(new StringAsset( "<?xml version='1.0' encoding='UTF-8'?>\n" + "<!DOCTYPE jboss-web PUBLIC \"-//JBoss//DTD Web Application 2.4//EN\" \"http://www.jboss.org/j2ee/dtd/jboss-web_4_0.dtd\">\n" + "<jboss-web>\n" + "<context-root>/as1605-customized</context-root>\n" + "</jboss-web>\n"), "jboss-web.xml"); return war; } @Test public void testEJB3Endpoint() throws Exception { final QName serviceName = new QName("org.jboss.as.test.integration.ws.context.as1605", "EJB3EndpointService"); final URL wsdlURL = new URL(baseUrl, "/as1605-customized/EJB3Endpoint?wsdl"); final Service service = Service.create(wsdlURL, serviceName); final EndpointIface port = service.getPort(EndpointIface.class); final String result = port.echo("hello"); Assert.assertEquals("EJB3 hello", result); } }
3,179
38.75
151
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/InstanceCountEndpoint.java
package org.jboss.as.test.integration.ws.basic; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import jakarta.jws.WebMethod; import jakarta.jws.WebService; import jakarta.xml.ws.BindingType; @WebService( serviceName = "SimpleService", targetNamespace = "http://jbossws.org/basic", endpointInterface = "org.jboss.as.test.integration.ws.basic.InstanceCountEndpointIface" ) @BindingType(jakarta.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING) public class InstanceCountEndpoint implements InstanceCountEndpointIface { public static int instanceNum = 0; private Log log = LogFactory.getLog(InstanceCountEndpoint.class); public InstanceCountEndpoint() { instanceNum++; } @WebMethod public int getInstanceCount() { return instanceNum; } @WebMethod public String test(String payload) { log.debug("Start test(). payload=" + payload); return "OK"; } }
982
24.868421
95
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/InstanceCountEndpointTestcase.java
package org.jboss.as.test.integration.ws.basic; 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.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; import java.net.URL; //import org.jboss.shrinkwrap.api.spec.JavaArchive; @RunWith(Arquillian.class) @RunAsClient public class InstanceCountEndpointTestcase { public static final String ARCHIVE_NAME = "instanceCountWebservice"; @ArquillianResource URL baseUrl; @Deployment public static Archive<?> deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME + ".war") .addClasses(InstanceCountEndpoint.class, InstanceCountEndpointIface.class); return war; } @Test public void testforcheckingInstances() throws Exception { final QName serviceName = new QName("http://jbossws.org/basic", "SimpleService"); final URL wsdlURL = new URL(baseUrl, "/instanceCountWebservice/SimpleService?wsdl"); final Service service = Service.create(wsdlURL, serviceName); InstanceCountEndpointIface proxy = service.getPort(InstanceCountEndpointIface.class); Assert.assertEquals("OK", proxy.test("test")); int result = proxy.getInstanceCount(); Assert.assertEquals(1, result); } }
1,664
32.3
93
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/EndpointIface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.basic; import jakarta.jws.WebService; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @WebService public interface EndpointIface { String helloString(String input); HelloObject helloBean(HelloObject input); HelloObject[] helloArray(HelloObject[] input); String helloError(String input); }
1,414
34.375
70
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/EJBEndpointTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.basic; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; import org.apache.commons.lang3.SystemUtils; 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.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Before; import org.junit.runner.RunWith; import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient public class EJBEndpointTestCase extends BasicTests { @ArquillianResource URL baseUrl; @Deployment(testable = false) public static Archive<?> deployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "jaxws-basic-ejb.jar") .addClasses(EndpointIface.class, EJBEndpoint.class, HelloObject.class); if (SystemUtils.JAVA_VENDOR.startsWith("IBM")) { jar.addAsManifestResource(createPermissionsXmlAsset( // With IBM JDK + SecurityManager, EJBEndpoint#helloError needs accessClassInPackage permission for // SOAPFactory.newInstance() invocation to access internal jaxp packages new RuntimePermission("accessClassInPackage.com.sun.org.apache.xerces.internal.jaxp")), "permissions.xml"); } return jar; } @Before public void endpointLookup() throws Exception { QName serviceName = new QName("http://jbossws.org/basic", "EJB3Service"); URL wsdlURL = new URL(baseUrl, "/jaxws-basic-ejb3/EJB3Service?wsdl"); Service service = Service.create(wsdlURL, serviceName); proxy = service.getPort(EndpointIface.class); } }
3,056
40.310811
127
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/EJBEndpoint.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.basic; import jakarta.ejb.Stateless; import jakarta.jws.WebService; import javax.xml.namespace.QName; import jakarta.xml.soap.SOAPConstants; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPFactory; import jakarta.xml.soap.SOAPFault; import jakarta.xml.ws.BindingType; import jakarta.xml.ws.soap.SOAPFaultException; import org.jboss.ws.api.annotation.WebContext; /** * Simple EJB3 endpoint * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @WebService( serviceName = "EJB3Service", targetNamespace = "http://jbossws.org/basic", endpointInterface = "org.jboss.as.test.integration.ws.basic.EndpointIface" ) @WebContext( urlPattern = "/EJB3Service", contextRoot = "/jaxws-basic-ejb3" ) @BindingType(jakarta.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING) @Stateless public class EJBEndpoint implements EndpointIface { public String helloString(String input) { return "Hello " + input + "!"; } public HelloObject helloBean(HelloObject input) { return new HelloObject(helloString(input.getMessage())); } public HelloObject[] helloArray(HelloObject[] input) { HelloObject[] reply = new HelloObject[input.length]; for (int n = 0; n < input.length; n++) { reply[n] = helloBean(input[n]); } return reply; } public String helloError(String input) { try { SOAPFault fault = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createFault(input, SOAPConstants.SOAP_VERSIONMISMATCH_FAULT); fault.setFaultActor("mr.actor"); fault.addDetail().addChildElement("test"); fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "NullPointerException")); fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "OperatorNotFound")); throw new SOAPFaultException(fault); } catch (SOAPException ex) { ex.printStackTrace(); } return "Failure!"; } }
3,137
35.917647
105
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/PojoEndpointTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.basic; import java.net.URL; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; import org.apache.commons.lang3.SystemUtils; 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.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Before; import org.junit.runner.RunWith; import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @RunWith(Arquillian.class) @RunAsClient public class PojoEndpointTestCase extends BasicTests { @ArquillianResource URL baseUrl; @Deployment(testable = false) public static Archive<?> deployment() { WebArchive pojoWar = ShrinkWrap.create(WebArchive.class, "jaxws-basic-pojo.war") .addClasses(EndpointIface.class, PojoEndpoint.class, HelloObject.class); if (SystemUtils.JAVA_VENDOR.startsWith("IBM")) { pojoWar.addAsManifestResource(createPermissionsXmlAsset( // With IBM JDK + SecurityManager, PojoEndpoint#helloError needs accessClassInPackage permission for // SOAPFactory.newInstance() invocation to access internal jaxp packages new RuntimePermission("accessClassInPackage.com.sun.org.apache.xerces.internal.jaxp")), "permissions.xml"); } return pojoWar; } @Before public void endpointLookup() throws Exception { QName serviceName = new QName("http://jbossws.org/basic", "POJOService"); URL wsdlURL = new URL(baseUrl, "/jaxws-basic-pojo/POJOService?wsdl"); Service service = Service.create(wsdlURL, serviceName); proxy = service.getPort(EndpointIface.class); } }
3,068
41.041096
127
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/PojoEndpoint.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.basic; import jakarta.jws.WebService; import javax.xml.namespace.QName; import jakarta.xml.soap.SOAPConstants; import jakarta.xml.soap.SOAPException; import jakarta.xml.soap.SOAPFactory; import jakarta.xml.soap.SOAPFault; import jakarta.xml.ws.BindingType; import jakarta.xml.ws.soap.SOAPFaultException; /** * Simple POJO endpoint * * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ @WebService( serviceName = "POJOService", targetNamespace = "http://jbossws.org/basic", endpointInterface = "org.jboss.as.test.integration.ws.basic.EndpointIface" ) @BindingType(jakarta.xml.ws.soap.SOAPBinding.SOAP12HTTP_BINDING) public class PojoEndpoint implements EndpointIface { public String helloString(String input) { return "Hello " + input + "!"; } public HelloObject helloBean(HelloObject input) { return new HelloObject(helloString(input.getMessage())); } public HelloObject[] helloArray(HelloObject[] input) { HelloObject[] reply = new HelloObject[input.length]; for (int n = 0; n < input.length; n++) { reply[n] = helloBean(input[n]); } return reply; } public String helloError(String input) { try { SOAPFault fault = SOAPFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createFault(input, SOAPConstants.SOAP_VERSIONMISMATCH_FAULT); fault.setFaultActor("mr.actor"); fault.addDetail().addChildElement("test"); fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "NullPointerException")); fault.appendFaultSubcode(new QName("http://ws.gss.redhat.com/", "OperatorNotFound")); throw new SOAPFaultException(fault); } catch (SOAPException ex) { ex.printStackTrace(); } return "Failure!"; } }
2,955
37.38961
105
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/BasicTests.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.basic; import java.util.Iterator; import javax.xml.namespace.QName; import jakarta.xml.soap.SOAPFault; import jakarta.xml.ws.soap.SOAPFaultException; import org.junit.Assert; import org.junit.Test; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ public abstract class BasicTests { protected EndpointIface proxy; @Test public void testHelloString() { Assert.assertEquals("Hello World!", proxy.helloString("World")); } @Test public void testHelloBean() { HelloObject helloObject = new HelloObject("Kermit"); Assert.assertEquals("Hello Kermit!", proxy.helloBean(helloObject).getMessage()); } @Test public void testHelloArray() { HelloObject[] query = new HelloObject[3]; query[0] = new HelloObject("Kermit"); query[1] = new HelloObject("Piggy"); query[2] = new HelloObject("Fozzy"); HelloObject[] reply = proxy.helloArray(query); for (int i = 0; i < reply.length; i++) { Assert.assertEquals("Hello " + query[i].getMessage() + "!", reply[i].getMessage()); } } @Test public void testHelloError() { try { proxy.helloError("Fault for test purpose"); Assert.fail("This should throw a SOAPFaultException"); } catch (SOAPFaultException ex) { SOAPFault fault = ex.getFault(); Assert.assertEquals("Fault for test purpose", fault.getFaultString()); Iterator iter = fault.getFaultSubcodes(); Assert.assertTrue(iter != null); Assert.assertTrue(iter.hasNext()); QName subcode = (QName) iter.next(); Assert.assertEquals(new QName("http://ws.gss.redhat.com/", "NullPointerException"), subcode); Assert.assertTrue(iter.hasNext()); subcode = (QName) iter.next(); Assert.assertEquals(new QName("http://ws.gss.redhat.com/", "OperatorNotFound"), subcode); } } }
3,063
36.365854
105
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/EarLibTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2010, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.basic; import java.net.URL; import java.util.concurrent.TimeUnit; 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.as.test.integration.common.HttpRequest; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.exporter.ZipExporter; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * @author <a href="[email protected]">Kyle Lape</a> * @version $Revision: 1.1 $ */ @RunWith(Arquillian.class) @RunAsClient public class EarLibTestCase { @ArquillianResource private URL url; @Deployment(testable = false) public static Archive<?> getDeployment() { final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ws-app.ear"); final WebArchive war = ShrinkWrap.create(WebArchive.class, "ws-example.war"); final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "endpoint.jar"); jar.addClasses(EndpointIface.class, PojoEndpoint.class, HelloObject.class); war.setWebXML(EarLibTestCase.class.getPackage(), "web.xml"); ear.addAsDirectory("/lib"); ear.add(jar, "/lib", ZipExporter.class); ear.add(war, "/", ZipExporter.class); return ear; } @Test public void testWSDL() throws Exception { String s = performCall("?wsdl"); Assert.assertNotNull(s); Assert.assertTrue(s.contains("wsdl:definitions")); } private String performCall(String params) throws Exception { URL url = new URL(this.url.toExternalForm() + "ws-example/" + params); return HttpRequest.get(url.toExternalForm(), 30, TimeUnit.SECONDS); } }
3,076
38.961039
95
java
null
wildfly-main/testsuite/integration/ws/src/test/java/org/jboss/as/test/integration/ws/basic/HelloObject.java
/* * JBoss, Home of Professional Open Source. * Copyright 2012, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ws.basic; import java.io.Serializable; /** * @author <a href="mailto:[email protected]">Rostislav Svoboda</a> */ public class HelloObject implements Serializable { private String message; public HelloObject() { } public HelloObject(String message) { this.message = message; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } }
1,533
30.958333
70
java