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/basic/src/test/java/org/jboss/as/test/integration/sar/context/classloader/mbean/MBeanInAModuleService.java
package org.jboss.as.test.integration.sar.context.classloader.mbean; import org.jboss.logging.Logger; /** * A MBean class which resides in a JBoss Module. This MBean tests that the TCCL corresponds to the deployment classloader of the deployment through which this MBean was deployed * * @author: Jaikiran Pai */ public class MBeanInAModuleService implements MBeanInAModuleServiceMBean { private static final Logger logger = Logger.getLogger(MBeanInAModuleService.class); static { logger.trace("Static block of " + MBeanInAModuleService.class.getName() + " being loaded"); // test TCCL in static block testClassLoadByTCCL("org.jboss.as.test.integration.sar.context.classloader.ClassAInSarDeployment"); } public MBeanInAModuleService() { logger.trace("Constructing " + this); // test TCCL in constructor testClassLoadByTCCL("org.jboss.as.test.integration.sar.context.classloader.ClassBInSarDeployment"); } @Override public int add(int a, int b) { return a + b; } public void start() { logger.trace("Starting " + this); // test TCCL in lifecycle method testClassLoadByTCCL("org.jboss.as.test.integration.sar.context.classloader.ClassCInSarDeployment"); } public void stop() { logger.trace("Stopping " + this); // test TCCL in lifecycle method testClassLoadByTCCL("org.jboss.as.test.integration.sar.context.classloader.ClassDInSarDeployment"); } private static void testClassLoadByTCCL(final String className) { final ClassLoader tccl = Thread.currentThread().getContextClassLoader(); logger.trace("Trying to load class " + className + " from TCCL " + tccl); try { tccl.loadClass(className); } catch (ClassNotFoundException e) { throw new RuntimeException(e); } logger.trace("Successfully loaded class " + className + " from TCCL " + tccl); } }
1,987
35.814815
178
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/sar/servicembean/TestResultService.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.sar.servicembean; import javax.management.AttributeChangeNotification; import javax.management.Notification; import javax.management.NotificationListener; import org.jboss.logging.Logger; import org.jboss.system.ServiceMBean; /** * An MBean that collects results of life-cycle methods invocations of {@link TestServiceMBean}. * * @author Eduardo Martins */ public class TestResultService implements TestResultServiceMBean, ServiceMBean, NotificationListener { private static Logger logger = Logger.getLogger(TestResultService.class.getName()); private boolean createServiceInvoked; private boolean startServiceInvoked; private boolean stopServiceInvoked; private boolean destroyServiceInvoked; private boolean startingNotificationReceived; private boolean startedNotificationReceived; private boolean stoppingNotificationReceived; private boolean stoppedNotificationReceived; @Override public boolean isCreateServiceInvoked() { return createServiceInvoked; } @Override public boolean isDestroyServiceInvoked() { return destroyServiceInvoked; } @Override public boolean isStartServiceInvoked() { return startServiceInvoked; } @Override public boolean isStopServiceInvoked() { return stopServiceInvoked; } public void setCreateServiceInvoked(boolean createServiceInvoked) { this.createServiceInvoked = createServiceInvoked; } public void setDestroyServiceInvoked(boolean destroyServiceInvoked) { this.destroyServiceInvoked = destroyServiceInvoked; } public void setStartServiceInvoked(boolean startServiceInvoked) { this.startServiceInvoked = startServiceInvoked; } public void setStopServiceInvoked(boolean stopServiceInvoked) { this.stopServiceInvoked = stopServiceInvoked; } @Override public boolean isStartingNotificationReceived() { return startingNotificationReceived; } @Override public boolean isStartedNotificationReceived() { return startedNotificationReceived; } @Override public boolean isStoppingNotificationReceived() { return stoppingNotificationReceived; } @Override public boolean isStoppedNotificationReceived() { return stoppedNotificationReceived; } @Override public void create() throws Exception { // TODO Auto-generated method stub } @Override public void start() throws Exception { // TODO Auto-generated method stub } @Override public void stop() { // TODO Auto-generated method stub } @Override public void destroy() { // TODO Auto-generated method stub } @Override public String getName() { // TODO Auto-generated method stub return null; } @Override public int getState() { // TODO Auto-generated method stub return 0; } @Override public String getStateString() { // TODO Auto-generated method stub return null; } @Override public void jbossInternalLifecycle(String method) throws Exception { // TODO Auto-generated method stub } @Override public void handleNotification(Notification notification, Object handback) { if (notification instanceof AttributeChangeNotification) { AttributeChangeNotification attributeChangeNotification = (AttributeChangeNotification) notification; int oldValue = (Integer) attributeChangeNotification.getOldValue(); int newValue = (Integer) attributeChangeNotification.getNewValue(); logger.trace("Attribute change notification: " + oldValue + "->" + newValue); if (oldValue == STOPPED && newValue == STARTING) { startingNotificationReceived = true; } else if (oldValue == STARTING && newValue == STARTED) { startedNotificationReceived = true; } else if (oldValue == STARTED && newValue == STOPPING) { stoppingNotificationReceived = true; } else if (oldValue == STOPPING && newValue == STOPPED) { stoppedNotificationReceived = true; } } } }
5,332
29.649425
157
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/sar/servicembean/TestResultServiceMBean.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.sar.servicembean; /** * MBean interface for {@link TestResultService}. * * @author Eduardo Martins */ public interface TestResultServiceMBean { boolean isCreateServiceInvoked(); boolean isStartServiceInvoked(); boolean isStopServiceInvoked(); boolean isDestroyServiceInvoked(); void setCreateServiceInvoked(boolean createServiceInvoked); void setDestroyServiceInvoked(boolean destroyServiceInvoked); void setStartServiceInvoked(boolean startServiceInvoked); void setStopServiceInvoked(boolean stopServiceInvoked); boolean isStartingNotificationReceived(); boolean isStartedNotificationReceived(); boolean isStoppingNotificationReceived(); boolean isStoppedNotificationReceived(); }
1,809
31.321429
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/sar/servicembean/ServiceMBeanSupportTestCase.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.sar.servicembean; import javax.management.MBeanPermission; import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import org.jboss.arquillian.container.test.api.Deployer; 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.ContainerResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.test.integration.common.DefaultConfiguration; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.system.ServiceMBean; import org.jboss.system.ServiceMBeanSupport; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.wildfly.naming.java.permission.JndiPermission; import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; /** * Test MBeans which implement {@link ServiceMBean} and extend {@link ServiceMBeanSupport}. * * @author Eduardo Martins */ @RunWith(Arquillian.class) @RunAsClient public class ServiceMBeanSupportTestCase { private static final String UNMANAGED_SAR_DEPLOYMENT_NAME = "service-mbean-support-test"; @ContainerResource private ManagementClient managementClient; @ArquillianResource private Deployer deployer; @Deployment(name = ServiceMBeanSupportTestCase.UNMANAGED_SAR_DEPLOYMENT_NAME, managed = false) public static JavaArchive geTestMBeanSar() { final JavaArchive sar = ShrinkWrap.create(JavaArchive.class, "service-mbean-support-test.sar"); sar.addClasses(TestServiceMBean.class, TestService.class); sar.addAsManifestResource(ServiceMBeanSupportTestCase.class.getPackage(), "jboss-service.xml", "jboss-service.xml"); sar.addAsManifestResource(createPermissionsXmlAsset( new JndiPermission("global/env/foo/legacy", "bind,unbind"), new MBeanPermission(TestResultService.class.getPackage().getName() + ".*", "*")), "permissions.xml"); return sar; } @Deployment public static JavaArchive getTestResultMBeanSar() { final JavaArchive sar = ShrinkWrap.create(JavaArchive.class, "service-mbean-support-test-result.sar"); sar.addClasses(TestResultServiceMBean.class, TestResultService.class); sar.addAsManifestResource(ServiceMBeanSupportTestCase.class.getPackage(), "result-jboss-service.xml", "jboss-service.xml"); return sar; } /** * Tests that invocation on a service deployed within a .sar, inside a .ear without an application.xml, is successful. * * @throws Exception */ @Test public void testSarWithServiceMBeanSupport() throws Exception { // get mbean server final JMXConnector connector = JMXConnectorFactory.connect(managementClient.getRemoteJMXURL(), DefaultConfiguration.credentials()); final MBeanServerConnection mBeanServerConnection = connector.getMBeanServerConnection(); try { // deploy the unmanaged sar deployer.deploy(ServiceMBeanSupportTestCase.UNMANAGED_SAR_DEPLOYMENT_NAME); // check the unmanaged mbean state int state = (Integer) mBeanServerConnection.getAttribute(new ObjectName("jboss:name=service-mbean-support-test"), "State"); Assert.assertEquals("Unexpected return state from Test MBean: " + state, ServiceMBean.STARTED, state); } finally { // undeploy it deployer.undeploy(ServiceMBeanSupportTestCase.UNMANAGED_SAR_DEPLOYMENT_NAME); } // check the result of life-cycle methods invocation, using result mbean // also check that the result mbean received lifecycle notifications String[] expectedAttributes = new String[] {"CreateServiceInvoked", "StartServiceInvoked", "StopServiceInvoked", "DestroyServiceInvoked", "StartingNotificationReceived", "StartedNotificationReceived", "StoppingNotificationReceived", "StoppedNotificationReceived"}; // each of these attributes should be 'true' for(String attribute : expectedAttributes) { Boolean result = (Boolean) mBeanServerConnection.getAttribute(new ObjectName("jboss:name=service-mbean-support-test-result"), attribute); Assert.assertTrue("Unexpected result for " + attribute + ": " + result, result); } } }
5,756
45.427419
145
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/sar/servicembean/TestService.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.sar.servicembean; import javax.management.Attribute; import javax.management.ObjectName; import javax.naming.InitialContext; import org.jboss.system.ServiceMBeanSupport; /** * An MBean that extends legacy {@link ServiceMBeanSupport}. * * @author Eduardo Martins */ public class TestService extends ServiceMBeanSupport implements TestServiceMBean { private static final String NAME = "java:global/env/foo/legacy"; private static final String VALUE = "BAR"; @Override protected void createService() throws Exception { getLog().trace("createService()"); setTestResultMBeanAttribute("CreateServiceInvoked", true); server.addNotificationListener(new ObjectName("jboss:name=service-mbean-support-test"), new ObjectName("jboss:name=service-mbean-support-test-result"), null, new Object()); } @Override protected void startService() throws Exception { getLog().trace("startService()"); new InitialContext().bind(NAME, VALUE); setTestResultMBeanAttribute("StartServiceInvoked", true); } @Override protected void stopService() throws Exception { getLog().trace("stopService()"); new InitialContext().unbind(NAME); setTestResultMBeanAttribute("StopServiceInvoked", true); } @Override protected void destroyService() throws Exception { getLog().trace("destroyService()"); setTestResultMBeanAttribute("DestroyServiceInvoked", true); } private void setTestResultMBeanAttribute(String attributeName, boolean attributeValue) throws Exception { server.setAttribute(new ObjectName("jboss:name=service-mbean-support-test-result"), new Attribute(attributeName, attributeValue)); } }
2,831
36.76
120
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/sar/servicembean/TestServiceMBean.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.sar.servicembean; /** * MBean interface for {@link TestService}. * * @author Eduardo Martins */ public interface TestServiceMBean { int getState(); }
1,222
34.970588
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jmx/ModelControllerMBeanTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, 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.jmx; import java.util.HashMap; import java.util.Map; import java.util.Set; import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; import org.jboss.as.arquillian.api.ContainerResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.jmx.model.ModelControllerMBeanHelper; import org.jboss.as.test.integration.common.DefaultConfiguration; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.xnio.IoUtils; /** * * @author <a href="[email protected]">Kabir Khan</a> */ @RunWith(Arquillian.class) @RunAsClient public class ModelControllerMBeanTestCase { private static final String RESOLVED_DOMAIN = "jboss.as"; static final ObjectName RESOLVED_MODEL_FILTER = createObjectName(RESOLVED_DOMAIN + ":*"); static final ObjectName RESOLVED_ROOT_MODEL_NAME = ModelControllerMBeanHelper.createRootObjectName(RESOLVED_DOMAIN); static JMXConnector connector; static MBeanServerConnection connection; @ContainerResource private ManagementClient managementClient; @Before public void initialize() throws Exception { connection = setupAndGetConnection(); } @After public void closeConnection() throws Exception { IoUtils.safeClose(connector); } /** * Test that all the MBean infos can be read properly */ @Test public void testAllMBeanInfos() throws Exception { Set<ObjectName> names = connection.queryNames(RESOLVED_MODEL_FILTER, null); Map<ObjectName, Exception> failedInfos = new HashMap<ObjectName, Exception>(); for (ObjectName name : names) { try { Assert.assertNotNull(connection.getMBeanInfo(name)); } catch (Exception e) { failedInfos.put(name, e); } } // https://issues.redhat.com/browse/WFLY-13977: // There are some MBeans which only live a short time, such as the active operations. // They may be returned from the original queryNames() call, and then don't exist // in the check so they get added to failedInfos. Remove from failedInfos the ones // which are not there in a fresh queryNames() call Set<ObjectName> currentNames = connection.queryNames(RESOLVED_MODEL_FILTER, null); for (ObjectName name : new HashMap<>(failedInfos).keySet()) { if (!currentNames.contains(name)) { failedInfos.remove(name); } } Assert.assertTrue(failedInfos.toString(), failedInfos.isEmpty()); } private static ObjectName createObjectName(String name) { try { return ObjectName.getInstance(name); } catch (Exception e) { throw new RuntimeException(e); } } private MBeanServerConnection setupAndGetConnection() throws Exception { // Make sure that we can connect to the MBean server String urlString = System .getProperty("jmx.service.url", "service:jmx:remote+http://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort()); JMXServiceURL serviceURL = new JMXServiceURL(urlString); connector = JMXConnectorFactory.connect(serviceURL, DefaultConfiguration.credentials()); return connector.getMBeanServerConnection(); } }
4,717
36.444444
153
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jmx/sar/Test.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, 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.jmx.sar; /** * * @author <a href="[email protected]">Kabir Khan</a> */ public class Test implements TestMBean{ }
1,171
36.806452
69
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jmx/sar/TestMBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, 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.jmx.sar; /** * * @author <a href="[email protected]">Kabir Khan</a> */ public interface TestMBean { }
1,160
36.451613
69
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jmx/full/JMXFilterTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, 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.jmx.full; import java.util.Set; import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; 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.arquillian.api.ContainerResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.test.integration.jmx.sar.TestMBean; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.xnio.IoUtils; /** * @author Kabir Khan */ @RunWith(Arquillian.class) @RunAsClient public class JMXFilterTestCase { static JMXConnector connector; static MBeanServerConnection connection; @Deployment public static Archive<?> createDeployment() { final JavaArchive sar = ShrinkWrap.create(JavaArchive.class, "test-jmx-sar.sar"); sar.addClasses(org.jboss.as.test.integration.jmx.sar.Test.class, TestMBean.class); sar.addAsManifestResource(JMXFilterTestCase.class.getPackage(), "jboss-service.xml", "jboss-service.xml"); return sar; } @ContainerResource private ManagementClient managementClient; @Before public void initialize() throws Exception { connection = setupAndGetConnection(); } @After public void closeConnection() throws Exception { IoUtils.safeClose(connector); } @Test public void testFilter() throws Exception { // Check the non-management JMX domain final ObjectName sarMbeanName = new ObjectName("jboss:name=test-sar-1234567890,type=jmx-sar"); Set<ObjectName> names = connection.queryNames(new ObjectName("*:name=test-sar-1234567890,*"), null); Assert.assertEquals(1, names.size()); Assert.assertTrue(names.contains(sarMbeanName)); // Check that names with no pattern work names = connection.queryNames(sarMbeanName, null); Assert.assertEquals(1, names.size()); Assert.assertTrue(names.contains(sarMbeanName)); // Check getMBeanInfo Assert.assertNotNull(connection.getMBeanInfo(sarMbeanName)); // Check the management JMX domains final ObjectName asMbeanName = new ObjectName("jboss.as:subsystem=sar"); final ObjectName asExprMbeanName = new ObjectName("jboss.as.expr:subsystem=sar"); names = connection.queryNames(new ObjectName("*:subsystem=sar,*"), null); Assert.assertEquals(names.toString(), 4, names.size()); Assert.assertTrue(names.contains(asExprMbeanName)); Assert.assertTrue(names.contains(asMbeanName)); Assert.assertTrue(names.contains(new ObjectName("jboss.as.expr:extension=org.jboss.as.sar,subsystem=sar"))); Assert.assertTrue(names.contains(new ObjectName("jboss.as:extension=org.jboss.as.sar,subsystem=sar"))); // Check that names with no pattern work names = connection.queryNames(asMbeanName, null); Assert.assertEquals(1, names.size()); Assert.assertTrue(names.contains(asMbeanName)); names = connection.queryNames(asExprMbeanName, null); Assert.assertEquals(1, names.size()); Assert.assertTrue(names.contains(asExprMbeanName)); // Check getMBeanInfo Assert.assertNotNull(connection.getMBeanInfo(asMbeanName)); Assert.assertNotNull(connection.getMBeanInfo(asExprMbeanName)); } private MBeanServerConnection setupAndGetConnection() throws Exception { // Make sure that we can connect to the MBean server String urlString = System .getProperty("jmx.service.url", "service:jmx:http-remoting-jmx://" + managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort()); JMXServiceURL serviceURL = new JMXServiceURL(urlString); connector = JMXConnectorFactory.connect(serviceURL, null); return connector.getMBeanServerConnection(); } }
5,342
41.404762
159
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/gzip/BasicGZIPTestCase.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.jaxrs.gzip; import static org.junit.Assert.assertEquals; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; import java.net.URL; import java.util.Properties; import java.util.concurrent.TimeUnit; import java.util.zip.GZIPInputStream; 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.common.HttpRequest; import org.jboss.as.test.integration.jaxrs.packaging.war.WebXml; 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; /** * Tests for RESTEasy @GZIP annotation feature * * @author Pavel Janousek */ @RunWith(Arquillian.class) @RunAsClient public class BasicGZIPTestCase { private static final Properties gzipProp = new Properties(); { gzipProp.setProperty("Accept-Encoding", "gzip,deflate"); } @Deployment public static Archive<?> deploy_true() { return ShrinkWrap .create(WebArchive.class, "gzip.war") .addClasses(BasicGZIPTestCase.class, GZIPResource.class, JaxbModel.class) .setWebXML( WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + "</servlet-mapping>\n" + " <context-param><param-name>resteasy.allowGzip</param-name><param-value>true</param-value></context-param>\n")); } private String read(final InputStream in) throws IOException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); int b; while ((b = in.read()) != -1) { out.write(b); } return out.toString(); } private String getGzipResult(final String url) throws Exception { final HttpURLConnection conn = (HttpURLConnection) (new URL(url)).openConnection(); conn.setRequestProperty("Accept-Encoding", "gzip,deflate"); conn.setDoInput(true); InputStream in = conn.getInputStream(); Assert.assertTrue(conn.getContentEncoding().contains("gzip")); in = new GZIPInputStream(in); String result = read(in); in.close(); Assert.assertEquals(HttpURLConnection.HTTP_OK, conn.getResponseCode()); return result; } @Test public void testPlainString(@ArquillianResource URL url) throws Exception { final String res_string = "Hello World!"; String result = HttpRequest.get(url.toExternalForm() + "myjaxrs/helloworld", 10, TimeUnit.SECONDS); assertEquals(res_string, result); result = getGzipResult(url.toExternalForm() + "myjaxrs/helloworld"); assertEquals(res_string, result); } @Test public void testXml(@ArquillianResource URL url) throws Exception { final String res_string = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><jaxbModel><first>John</first><last>Citizen</last></jaxbModel>"; String result = HttpRequest.get(url.toExternalForm() + "myjaxrs/helloworld/xml", 10, TimeUnit.SECONDS); assertEquals(res_string, result); result = getGzipResult(url.toExternalForm() + "myjaxrs/helloworld/xml"); assertEquals(res_string, result); } }
4,716
37.983471
160
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/gzip/JaxbModel.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.jaxrs.gzip; import jakarta.xml.bind.annotation.XmlRootElement; /** * @author Stuart Douglas */ @XmlRootElement public class JaxbModel { private String first; private String last; public JaxbModel(String first, String last) { this.first = first; this.last = last; } public JaxbModel() { } public String getFirst() { return first; } public String getLast() { return last; } public void setFirst(String first) { this.first = first; } public void setLast(String last) { this.last = last; } }
1,658
26.65
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/gzip/GZIPResource.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.jaxrs.gzip; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import org.jboss.resteasy.annotations.GZIP; @Path("helloworld") public class GZIPResource { @GET @GZIP public String getMessage() { return "Hello World!"; } @GET @GZIP @Path("xml") @Produces({"application/xml"}) public JaxbModel getXml() { return new JaxbModel("John","Citizen"); } }
1,494
31.5
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/BeanValidationConfiguredGloballyTestCase.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, 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.jaxrs.validator; import java.net.URL; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.apache.http.util.EntityUtils; 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.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Test for Jakarta RESTful Web Services taking the global Jakarta Bean Validation configuration into account (META-INF/validation.xml). * * @author Gunnar Morling */ @RunWith(Arquillian.class) @RunAsClient public class BeanValidationConfiguredGloballyTestCase { @ApplicationPath("/myjaxrs") public static class TestApplication extends Application { } @Deployment(testable = false) public static Archive<?> deploy() { return ShrinkWrap.create(WebArchive.class, "jaxrsnoap.war") .addPackage(HttpRequest.class.getPackage()) .addClasses( BeanValidationConfiguredGloballyTestCase.class, ValidatorModel.class, GloballyConfiguredValidatorResource.class ) .addAsManifestResource(new StringAsset( "<validation-config version=\"1.1\" xmlns=\"http://jboss.org/xml/ns/javax/validation/configuration\">\n" + "<executable-validation>\n" + "<default-validated-executable-types>\n" + "<executable-type>NONE</executable-type>\n" + "</default-validated-executable-types>\n" + "</executable-validation>\n" + "</validation-config>"), "validation.xml" ); } @ArquillianResource private URL url; @Test public void testInvalidRequestsAreAcceptedDependingOnGlobalValidationConfiguration() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/globally-configured-validate/3/disabled"); HttpResponse result = client.execute(get); Assert.assertEquals("No constraint violated", 200, result.getStatusLine().getStatusCode()); EntityUtils.consume(result.getEntity()); get = new HttpGet(url + "myjaxrs/globally-configured-validate/3/enabled"); result = client.execute(get); Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode()); } }
4,088
40.72449
136
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/YetAnotherValidatorResource.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, 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.jaxrs.validator; import jakarta.validation.constraints.Min; import jakarta.validation.executable.ExecutableType; import jakarta.validation.executable.ValidateOnExecution; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @Path("yet-another-validate/{id}") @Produces("text/plain") public class YetAnotherValidatorResource { @GET @Path("disabled") @ValidateOnExecution(type = ExecutableType.NONE) public ValidatorModel getWithoutValidation(@PathParam("id") @Min(value = 4) int id) { return new ValidatorModel(id); } @GET @Path("enabled") @ValidateOnExecution(type = ExecutableType.NON_GETTER_METHODS) public ValidatorModel getWithValidation(@PathParam("id") @Min(value = 4) int id) { return new ValidatorModel(id); } }
1,897
36.96
89
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/ValidatorModel.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.jaxrs.validator; import jakarta.validation.constraints.Max; /** * @author Stuart Douglas */ public class ValidatorModel { @Max(10) private int id; public ValidatorModel(final int id) { this.id = id; } public int getId() { return id; } public void setId(final int id) { this.id = id; } @Override public String toString() { return "ValidatorModel{" + "id=" + id + '}'; } }
1,542
28.113208
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/AnotherValidatorResource.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, 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.jaxrs.validator; import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @Path("another-validate/{id}") @Produces("text/plain") public class AnotherValidatorResource { @PathParam("id") @Min(value = 4) private int id; @Valid @GET public ValidatorModel getValidatorModel() { return new ValidatorModel(id); } }
1,538
33.2
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/GloballyConfiguredValidatorResource.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, 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.jaxrs.validator; import jakarta.validation.constraints.Min; import jakarta.validation.executable.ExecutableType; import jakarta.validation.executable.ValidateOnExecution; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @Path("globally-configured-validate/{id}") @Produces("text/plain") public class GloballyConfiguredValidatorResource { @GET @Path("disabled") public ValidatorModel getWithoutValidation(@PathParam("id") @Min(value = 4) int id) { return new ValidatorModel(id); } @GET @Path("enabled") @ValidateOnExecution(type = ExecutableType.NON_GETTER_METHODS) public ValidatorModel getWithValidation(@PathParam("id") @Min(value = 4) int id) { return new ValidatorModel(id); } }
1,860
36.979592
89
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/BeanValidationIntegrationTestCase.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.jaxrs.validator; import java.net.URL; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.apache.http.util.EntityUtils; 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.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Test for the integration of Jakarta RESTful Web Services and Jakarta Bean Validation. * * @author Stuart Douglas * @author Gunnar Morling */ @RunWith(Arquillian.class) @RunAsClient public class BeanValidationIntegrationTestCase { @ApplicationPath("/myjaxrs") public static class TestApplication extends Application { } @Deployment(testable = false) public static Archive<?> deploy() { return ShrinkWrap.create(WebArchive.class, "jaxrsnoap.war") .addPackage(HttpRequest.class.getPackage()) .addClasses( BeanValidationIntegrationTestCase.class, ValidatorModel.class, ValidatorResource.class, AnotherValidatorResource.class, YetAnotherValidatorResource.class ); } @ArquillianResource private URL url; @Test public void testValidRequest() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/validate/5"); HttpResponse result = client.execute(get); Assert.assertEquals(200, result.getStatusLine().getStatusCode()); Assert.assertEquals("ValidatorModel{id=5}", EntityUtils.toString(result.getEntity())); } @Test public void testInvalidRequest() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/validate/3"); HttpResponse result = client.execute(get); Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode()); } @Test public void testInvalidRequestCausingPropertyConstraintViolation() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/another-validate/3"); HttpResponse result = client.execute(get); Assert.assertEquals("Property constraint violated", 400, result.getStatusLine().getStatusCode()); } @Test public void testInvalidRequestsAreAcceptedDependingOnValidationConfiguration() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/yet-another-validate/3/disabled"); HttpResponse result = client.execute(get); Assert.assertEquals("No constraint violated", 200, result.getStatusLine().getStatusCode()); EntityUtils.consume(result.getEntity()); get = new HttpGet(url + "myjaxrs/yet-another-validate/3/enabled"); result = client.execute(get); Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode()); } @Test public void testInvalidResponse() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/validate/11"); HttpResponse result = client.execute(get); Assert.assertEquals("Return value constraint violated", 500, result.getStatusLine().getStatusCode()); } }
5,178
37.93985
109
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/ValidatorResource.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.jaxrs.validator; import jakarta.validation.Valid; import jakarta.validation.constraints.Min; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @Path("validate/{id}") @Produces("text/plain") public class ValidatorResource { @Valid @GET public ValidatorModel get(@PathParam("id") @Min(value=4) int id) { return new ValidatorModel(id); } }
1,484
35.219512
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/cdi/OrderResource.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.jaxrs.validator.cdi; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; @Produces("text/plain") @Path("order/{id}") public class OrderResource { @GET public OrderModel get(@PathParam("id") @CustomMax int id) { return new OrderModel(id); } }
1,383
35.421053
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/cdi/CustomMax.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, 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.jaxrs.validator.cdi; import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.PARAMETER; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.Target; import jakarta.validation.Constraint; import jakarta.validation.Payload; /** * Custom constraint using CDI in its validator class. * * @author Gunnar Morling */ @Constraint(validatedBy = CustomMaxValidator.class) @Documented @Target({ METHOD, FIELD, TYPE, PARAMETER }) @Retention(RUNTIME) public @interface CustomMax { String message() default "my custom constraint"; Class<?>[] groups() default {}; Class<? extends Payload>[] payload() default {}; }
1,943
35.679245
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/cdi/MaximumValueProvider.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, 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.jaxrs.validator.cdi; import jakarta.enterprise.context.ApplicationScoped; /** * A test Jakarta Contexts and Dependency Injection bean. * * @author Gunnar Morling */ @ApplicationScoped public class MaximumValueProvider { public int getMax() { return 10; } }
1,334
34.131579
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/cdi/BeanValidationCdiIntegrationTestCase.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.jaxrs.validator.cdi; import java.net.URL; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; import org.apache.http.HttpResponse; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.impl.conn.PoolingClientConnectionManager; import org.apache.http.util.EntityUtils; 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.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Test for the integration of Jakarta RESTful Web Services, Jakarta Bean Validation and Jakarta Contexts and Dependency Injection. See WFLY-278. * * @author Gunnar Morling */ @RunWith(Arquillian.class) @RunAsClient public class BeanValidationCdiIntegrationTestCase { @ApplicationPath("/myjaxrs") public static class TestApplication extends Application { } @Deployment(testable = false) public static Archive<?> deploy() { return ShrinkWrap.create(WebArchive.class, "jaxrsnoap.war") .addPackage(HttpRequest.class.getPackage()) .addClasses( BeanValidationCdiIntegrationTestCase.class, OrderModel.class, OrderResource.class, CustomMax.class, CustomMaxValidator.class, MaximumValueProvider.class ) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); } @ArquillianResource private URL url; @Test public void testValidRequest() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/order/5"); HttpResponse result = client.execute(get); Assert.assertEquals(200, result.getStatusLine().getStatusCode()); Assert.assertEquals("OrderModel{id=5}", EntityUtils.toString(result.getEntity())); } @Test public void testInvalidRequest() throws Exception { DefaultHttpClient client = new DefaultHttpClient(new PoolingClientConnectionManager()); HttpGet get = new HttpGet(url + "myjaxrs/order/11"); HttpResponse result = client.execute(get); result = client.execute(get); Assert.assertEquals("Parameter constraint violated", 400, result.getStatusLine().getStatusCode()); } }
3,888
37.89
145
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/cdi/OrderModel.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, 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.jaxrs.validator.cdi; /** * An order. * * @author Gunnar Morling */ public class OrderModel { private int id; public OrderModel(final int id) { this.id = id; } public int getId() { return id; } public void setId(final int id) { this.id = id; } @Override public String toString() { return "OrderModel{" + "id=" + id + "}"; } }
1,461
28.24
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/validator/cdi/CustomMaxValidator.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, 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.jaxrs.validator.cdi; import jakarta.inject.Inject; import jakarta.validation.ConstraintValidator; import jakarta.validation.ConstraintValidatorContext; /** * A validator which makes use of constructor injection. * * @author Gunnar Morling */ public class CustomMaxValidator implements ConstraintValidator<CustomMax, Integer> { private final MaximumValueProvider maximumValueProvider; @Inject public CustomMaxValidator(MaximumValueProvider maximumValueProvider) { this.maximumValueProvider = maximumValueProvider; } @Override public void initialize(CustomMax constraintAnnotation) { } @Override public boolean isValid(Integer value, ConstraintValidatorContext context) { return value <= maximumValueProvider.getMax(); } }
1,841
35.117647
84
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/async/JaxrsAsyncTestCase.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.jaxrs.async; 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.as.test.integration.jaxrs.packaging.war.WebXml; 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; import static org.junit.Assert.assertEquals; /** * Tests the Jakarta RESTful Web Services async response functionality * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsAsyncTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.addPackage(JaxrsAsyncTestCase.class.getPackage()); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"),"web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/async/basic"); assertEquals("basic", result); } }
2,870
36.285714
89
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/async/AsyncResource.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.jaxrs.async; import java.util.concurrent.TimeUnit; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.container.AsyncResponse; import jakarta.ws.rs.container.Suspended; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; /** * @author Stuart Douglas */ @Path("/async") public class AsyncResource { @GET @Path("basic") @Produces("text/plain") public void getBasic(@Suspended final AsyncResponse response) throws Exception { response.setTimeout(1, TimeUnit.SECONDS); Thread t = new Thread() { @Override public void run() { try { Response jaxrs = Response.ok("basic").type(MediaType.TEXT_PLAIN).build(); response.resume(jaxrs); } catch (Exception e) { e.printStackTrace(); } } }; t.start(); } }
2,021
34.473684
93
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/decorator/ResourceInterface.java
package org.jboss.as.test.integration.jaxrs.decorator; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; /** * @author Stuart Douglas */ @Path("decorator") @Produces({"text/plain"}) public interface ResourceInterface { @GET String getMessage(); }
295
15.444444
54
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/decorator/CdiDecoratorRootResourceTestCase.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.jaxrs.decorator; import static org.junit.Assert.assertEquals; import java.net.URL; import java.util.concurrent.TimeUnit; import jakarta.ws.rs.core.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.arquillian.test.api.ArquillianResource; import org.jboss.as.test.integration.common.HttpRequest; import org.jboss.as.test.integration.jaxrs.packaging.war.WebXml; 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.Test; import org.junit.runner.RunWith; /** * Tests a Jakarta RESTful Web Services deployment with an application bundled, that has no @ApplicationPath annotation. * <p/> * The container should register a servlet with the name that matches the application name * <p/> * It is the app providers responsibility to provide a mapping for the servlet * <p/> * JAX-RS 1.1 2.3.2 bullet point 3 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class CdiDecoratorRootResourceTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsapp.war"); war.addPackage(HttpRequest.class.getPackage()); war.addPackage(CdiDecoratorRootResourceTestCase.class.getPackage()); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>" + Application.class.getName() + "</servlet-name>\n" + " <url-pattern>/rest/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"), "web.xml"); war.addAsWebInfResource(new StringAsset("<beans bean-discovery-mode=\"all\"><decorators><class>" + ResourceDecorator.class.getName() + "</class></decorators></beans>"), "beans.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithDecoratedResource() throws Exception { String result = performCall("rest/decorator"); assertEquals("DECORATED Hello World!", result); } }
3,481
39.488372
190
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/decorator/ResourceDecorator.java
package org.jboss.as.test.integration.jaxrs.decorator; import jakarta.decorator.Decorator; import jakarta.decorator.Delegate; import jakarta.enterprise.inject.Any; import jakarta.inject.Inject; /** * @author Stuart Douglas */ @Decorator public class ResourceDecorator implements ResourceInterface { @Inject @Delegate @Any private ResourceInterface delegate; @Override public String getMessage() { return "DECORATED " + delegate.getMessage(); } }
488
19.375
61
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/decorator/DecoratedResource.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.jaxrs.decorator; public class DecoratedResource implements ResourceInterface { public String getMessage() { return "Hello World!"; } }
1,207
39.266667
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/atom/Customer.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.jaxrs.atom; import jakarta.xml.bind.annotation.XmlRootElement; /** * @author Stuart Douglas */ @XmlRootElement public class Customer { private String first; private String last; public Customer(String first, String last) { this.first = first; this.last = last; } public Customer() { } public String getFirst() { return first; } public void setFirst(String first) { this.first = first; } public String getLast() { return last; } public void setLast(String last) { this.last = last; } }
1,654
27.050847
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/atom/JaxrsAtomProviderTestCase.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.jaxrs.atom; 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.as.test.integration.jaxrs.packaging.war.WebXml; 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; /** * Tests the resteasy multipart provider * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsAtomProviderTestCase { @Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.addPackage(JaxrsAtomProviderTestCase.class.getPackage()); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"), "web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/atom"); Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><customer><first>John</first><last>Citizen</last></customer>", result); } }
2,932
37.592105
161
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/atom/AtomResource.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.jaxrs.atom; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; /** * @author Stuart Douglas */ @Path("/atom") public class AtomResource { @GET @Produces("application/atom+xml") public Customer get() { return new Customer("John", "Citizen"); } }
1,361
33.05
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/client/ClientThreadContextResource.java
/* * JBoss, Home of Professional Open Source. * * Copyright 2021 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * 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.jaxrs.client; import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletionStage; import java.util.concurrent.ConcurrentSkipListSet; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import jakarta.annotation.Resource; import jakarta.enterprise.concurrent.ManagedExecutorService; import jakarta.enterprise.concurrent.ManagedScheduledExecutorService; import jakarta.enterprise.concurrent.ManagedThreadFactory; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; import jakarta.ws.rs.Produces; import jakarta.ws.rs.WebApplicationException; import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.UriInfo; import org.jboss.as.test.shared.TimeoutUtil; /** * @author <a href="mailto:[email protected]">James R. Perkins</a> */ @Path("/context") public class ClientThreadContextResource { @Resource private ManagedExecutorService executor; @Resource private ManagedScheduledExecutorService scheduledExecutor; @Resource private ManagedThreadFactory threadFactory; @GET @Path("/async") @Produces(MediaType.TEXT_PLAIN) public CompletionStage<String> async(@Context final UriInfo uriInfo) { final CompletableFuture<String> cs = new CompletableFuture<>(); executor.execute(() -> { try { cs.complete(uriInfo.getPath()); } catch (Exception e) { cs.completeExceptionally(e); } }); return cs; } @GET @Path("/async/delayed") @Produces(MediaType.TEXT_PLAIN) @SuppressWarnings("MagicNumber") public CompletionStage<String> delayedAsync(@Context final UriInfo uriInfo) { final CompletableFuture<String> cs = new CompletableFuture<>(); scheduledExecutor.schedule(() -> { try { cs.complete(uriInfo.getPath()); } catch (Exception e) { cs.completeExceptionally(e); } }, 200, TimeUnit.MILLISECONDS); return cs; } @GET @Path("/async/thread-factory") @Produces(MediaType.TEXT_PLAIN) public CompletionStage<String> threadFactory(@Context final UriInfo uriInfo) { final ExecutorService executor = Executors.newSingleThreadExecutor(threadFactory); final CompletableFuture<String> cs = new CompletableFuture<>(); executor.submit(() -> { try { cs.complete(uriInfo.getPath()); } catch (Exception e) { cs.completeExceptionally(e); } finally { executor.shutdownNow(); } }); return cs; } @GET @Path("/async/scheduled/{count}") @Produces(MediaType.APPLICATION_JSON) @SuppressWarnings("MagicNumber") public Set<String> scheduled(@Context final UriInfo uriInfo, @PathParam("count") final int count) throws Exception { final Set<String> collected = new ConcurrentSkipListSet<>(String::compareTo); final ScheduledFuture<?> sf = scheduledExecutor.scheduleAtFixedRate(() -> { final long current = collected.size(); if (current <= count) { collected.add(uriInfo.getPath() + "-" + current); } }, 0L, TimeoutUtil.adjust(600), TimeUnit.MILLISECONDS); try { // Wait no more than 5 seconds long timeout = TimeUnit.SECONDS.toMillis(TimeoutUtil.adjust(5)); while (timeout > 0) { if (collected.size() == 3) { break; } TimeUnit.MILLISECONDS.sleep(100L); timeout -= 100L; } if (timeout < 0) { throw new WebApplicationException("Scheduled tasks did not complete within 5 seconds"); } } finally { sf.cancel(true); } return collected; } }
4,823
33.457143
120
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/client/ClientThreadContextPropagatedTest.java
/* * JBoss, Home of Professional Open Source. * * Copyright 2021 Red Hat, Inc., and individual contributors * as indicated by the @author tags. * * 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.jaxrs.client; import java.net.URL; import java.util.Collection; import java.util.PropertyPermission; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import jakarta.ws.rs.client.Client; import jakarta.ws.rs.client.ClientBuilder; import jakarta.ws.rs.core.MediaType; 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.PermissionUtils; 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.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; /** * @author <a href="mailto:[email protected]">James R. Perkins</a> */ @RunWith(Arquillian.class) @RunAsClient public class ClientThreadContextPropagatedTest { @ArquillianResource private URL url; private Client client; @Before public void setup() { client = ClientBuilder.newClient(); } @After public void tearDown() { if (client != null) { client.close(); } } @Deployment public static Archive<?> deployment() { return ShrinkWrap.create(WebArchive.class, ClientThreadContextPropagatedTest.class.getSimpleName() + ".war") .addClasses(RestActivator.class, ClientThreadContextResource.class, TimeoutUtil.class) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsManifestResource(PermissionUtils.createPermissionsXmlAsset( new PropertyPermission("ts.timeout.factor", "read")) , "permissions.xml"); } @Test public void async() throws Exception { final Future<String> future = client.target(url + "context/async") .request(MediaType.TEXT_PLAIN_TYPE) .async() .get(String.class); final String value = future.get(2, TimeUnit.SECONDS); Assert.assertEquals("/context/async", value); } @Test public void delayed() throws Exception { final Future<String> future = client.target(url + "context/async/delayed") .request(MediaType.TEXT_PLAIN_TYPE) .async() .get(String.class); final String value = future.get(2, TimeUnit.SECONDS); Assert.assertEquals("/context/async/delayed", value); } @Test public void managedThreadFactory() throws Exception { final Future<String> future = client.target(url + "context/async/thread-factory") .request(MediaType.TEXT_PLAIN_TYPE) .async() .get(String.class); final String value = future.get(2, TimeUnit.SECONDS); Assert.assertEquals("/context/async/thread-factory", value); } @Test public void scheduled() throws Exception { @SuppressWarnings("unchecked") final Collection<String> results = client.target(url + "context/async/scheduled/3") .request(MediaType.APPLICATION_JSON_TYPE) .get(Collection.class); // We should end up with 3 results Assert.assertEquals(String.format("Expected 3 entries found: %d - %s", results.size(), results), 3, results.size()); // Compare the results int index = 0; for (String found : results) { Assert.assertEquals("/context/async/scheduled/3-" + index++, found); } } }
4,474
34.515873
124
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/client/RestActivator.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.jaxrs.client; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; /** * @author <a href="mailto:[email protected]">James R. Perkins</a> */ @ApplicationPath("/") public class RestActivator extends Application { }
877
30.357143
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/client/ClientResource.java
/* * JBoss, Home of Professional Open Source * Copyright 2015, 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.jaxrs.client; import jakarta.ws.rs.Consumes; import jakarta.ws.rs.DELETE; import jakarta.ws.rs.GET; import jakarta.ws.rs.POST; import jakarta.ws.rs.PUT; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; /** * @author <a href="mailto:[email protected]">Katerina Novotna</a> */ @Path("/client") public class ClientResource { @GET @Produces("text/plain") public String get() { return "GET: Hello World!"; } @POST @Consumes("text/plain") public String post(String str) { return "POST: " + str; } @PUT @Consumes("text/plain") public String put(String str) { return "PUT: " + str; } @DELETE @Produces("text/plain") public String delete() { return "DELETE:"; } }
1,827
27.123077
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/client/BasicClientTestCase.java
/* * JBoss, Home of Professional Open Source * Copyright 2015, 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.jaxrs.client; import java.net.URL; import jakarta.ws.rs.client.Client; import jakarta.ws.rs.client.ClientBuilder; import jakarta.ws.rs.client.Entity; 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.jaxrs.packaging.war.WebXml; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; /** * Use jaxrs client to send http requests to the server. * * @author <a href="mailto:[email protected]">Katerina Novotna</a> */ @RunWith(Arquillian.class) @RunAsClient public class BasicClientTestCase { @Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsapp.war"); war.addClasses(BasicClientTestCase.class, ClientResource.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"), "web.xml"); return war; } @ArquillianResource private URL url; static Client client; @BeforeClass public static void setUpClient() { client = ClientBuilder.newClient(); } @AfterClass public static void close() { client.close(); } @Test public void testGet() throws Exception { String result = client.target(url.toExternalForm() + "myjaxrs/client") .request("text/plain").get(String.class); Assert.assertEquals("GET: Hello World!", result); } @Test public void testPost() throws Exception { String result = client.target(url.toExternalForm() + "myjaxrs/client") .request("text/plain").post(Entity.text("David"), String.class); Assert.assertEquals("POST: David", result); } @Test public void testPut() throws Exception { String result = client.target(url.toExternalForm() + "myjaxrs/client") .request("text/plain").put(Entity.text("Michael"), String.class); Assert.assertEquals("PUT: Michael", result); } @Test public void testDelete() throws Exception { String result = client.target(url.toExternalForm() + "myjaxrs/client") .request("text/plain").delete(String.class); Assert.assertEquals("DELETE:", result); } }
3,843
34.592593
89
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/exception/NPExceptionMapper.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.jaxrs.exception; import jakarta.servlet.http.HttpServletResponse; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.ext.ExceptionMapper; import jakarta.ws.rs.ext.Provider; /** * Exception mapper - occurred NPE exception remaps to HTTP 404 Error code * * @author Pavel Janousek */ @Provider public class NPExceptionMapper implements ExceptionMapper<NullPointerException> { public Response toResponse(NullPointerException ex) { return Response.status(HttpServletResponse.SC_NOT_FOUND).build(); } }
1,579
38.5
81
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/exception/ExceptionHandlingTestCase.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.jaxrs.exception; import static org.junit.Assert.assertEquals; import java.net.URL; import java.util.concurrent.TimeUnit; 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.common.HttpRequest; import org.jboss.as.test.integration.jaxrs.packaging.war.WebXml; 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; /** * Tests the RESTEasy exception handling * * @author Pavel Janousek */ @RunWith(Arquillian.class) @RunAsClient public class ExceptionHandlingTestCase { @Deployment public static Archive<?> deploy_true() { return ShrinkWrap .create(WebArchive.class, "exception.war") .addClasses(ExceptionHandlingTestCase.class, HelloWorldResource.class, NPExceptionMapper.class) .setWebXML( WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + "</servlet-mapping>\n")); } @Test public void testResource(@ArquillianResource URL url) throws Exception { String result = HttpRequest.get(url.toExternalForm() + "myjaxrs/helloworld", 10, TimeUnit.SECONDS); assertEquals("Hello World!", result); } @Test public void testNullPointerException(@ArquillianResource URL url) throws Exception { try { @SuppressWarnings("unused") String result = HttpRequest.get(url.toExternalForm() + "myjaxrs/helloworld/ex1", 10, TimeUnit.SECONDS); Assert.fail("Should not go there - NullPointerException must occurred!"); } catch (Exception e) { Assert.assertTrue(e.toString().contains("HTTP Status 404")); } } @Test public void testArrayIndexOutOfBoundsException(@ArquillianResource URL url) throws Exception { try { @SuppressWarnings("unused") String result = HttpRequest.get(url.toExternalForm() + "myjaxrs/helloworld/ex2", 10, TimeUnit.SECONDS); Assert.fail("Should not go there - ArrayIndexOutOfBoundsException must occurred!"); } catch (Exception e) { Assert.assertFalse(e.toString().contains("HTTP Status 404")); Assert.assertTrue(e.toString().contains("HTTP Status 500")); } } }
3,764
39.923913
115
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/exception/HelloWorldResource.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.jaxrs.exception; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; /** * Simple resource + produces exception * * @author Pavel Janousek */ @Path("helloworld") @Produces({"text/plain"}) public class HelloWorldResource { @GET public String getMessage() { return "Hello World!"; } @GET @Path("ex1") @SuppressWarnings("null") public String getNullPointerException() { String a = null; return a.toString(); } @GET @Path("ex2") public String getArrayIndexOutOfBoundsException() { String[] a = new String[1]; return a[5]; } }
1,704
29.446429
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/deployment/DupliciteApplicationOne.java
package org.jboss.as.test.integration.jaxrs.deployment; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; @ApplicationPath("a") public class DupliciteApplicationOne extends Application { }
219
21
58
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/deployment/DupliciteApplicationPathTestCase.java
package org.jboss.as.test.integration.jaxrs.deployment; 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.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 java.io.File; import java.io.IOException; import java.nio.charset.MalformedInputException; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @RunWith(Arquillian.class) @RunAsClient public class DupliciteApplicationPathTestCase { static int initWarningsCount; @Deployment public static Archive<?> deploy_true() { initWarningsCount = getWarningCount("WFLYUT0101"); WebArchive war = ShrinkWrap.create(WebArchive.class, DupliciteApplicationPathTestCase.class.getSimpleName() + ".war"); war.addClass(DupliciteApplicationOne.class); war.addClass(DupliciteApplicationTwo.class); return war; } @Test public void testDuplicationTwoAppTwoResourceSameMethodPath() throws Exception { int resultWarningsCount = getWarningCount("WFLYUT0101"); Assert.assertEquals("Expected warning 'WFLYUT0101' not found.", 1, resultWarningsCount - initWarningsCount); } /** * Get count of lines with specific string in log */ private static int getWarningCount(String findedString) { int count = 0; List<String> lines = readServerLogLines(); for (String line : lines) { if (line.contains(findedString)) { count++; } } return count; } private static List<String> readServerLogLines() { String jbossHome = System.getProperty("jboss.home"); String logPath = String.format("%s%sstandalone%slog%sserver.log", jbossHome, (jbossHome.endsWith(File.separator) || jbossHome.endsWith("/")) ? "" : File.separator, File.separator, File.separator); logPath = logPath.replace('/', File.separatorChar); try { return Files.readAllLines(Paths.get(logPath)); // UTF8 is used by default } catch (MalformedInputException e1) { // some windows machines could accept only StandardCharsets.ISO_8859_1 encoding try { return Files.readAllLines(Paths.get(logPath), StandardCharsets.ISO_8859_1); } catch (IOException e4) { throw new RuntimeException("Server logs has not standard Charsets (UTF8 or ISO_8859_1)"); } } catch (IOException e) { // server.log file is not created, it is the same as server.log is empty } return new ArrayList<>(); } }
2,948
36.329114
126
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/deployment/DupliciteApplicationTwo.java
package org.jboss.as.test.integration.jaxrs.deployment; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; @ApplicationPath("a") public class DupliciteApplicationTwo extends Application { }
219
21
58
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/subresource/SubResourceTestCase.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.jaxrs.subresource; import static org.junit.Assert.assertEquals; 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.integration.jaxrs.packaging.war.WebXml; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import java.net.URL; import java.util.concurrent.TimeUnit; /** * Tests Jakarta RESTful Web Services subresources. * <p> * AS7-1349 * * @author Jozef Hartinger */ @RunWith(Arquillian.class) @RunAsClient public class SubResourceTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, "subresource.war"); war.addPackage(HttpRequest.class.getPackage()); war.add(EmptyAsset.INSTANCE, "WEB-INF/beans.xml"); war.addClasses(SubResourceTestCase.class, PeopleResource.class, PersonResource.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/api/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"), "web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testSubResource() throws Exception { assertEquals("Jozef", performCall("api/person/Jozef")); assertEquals("Jozef's address is unknown.", performCall("api/person/Jozef/address")); } }
3,069
35.987952
94
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/subresource/PersonResource.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.jaxrs.subresource; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; public class PersonResource { private String name; public PersonResource(String name) { this.name = name; } @GET public String getName() { return name; } @GET @Path("/address") public String getClassName() { return name + "'s address is unknown."; } }
1,448
30.5
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/subresource/PeopleResource.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.jaxrs.subresource; import jakarta.ws.rs.Path; import jakarta.ws.rs.PathParam; @Path("person") public class PeopleResource { @Path("{name}") public PersonResource findPerson(@PathParam("name") String name) { return new PersonResource(name); } }
1,321
36.771429
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jackson/JacksonProducer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2016, 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 * 2110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.jaxrs.jackson; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.ext.ContextResolver; import jakarta.ws.rs.ext.Provider; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; @Provider @Produces(MediaType.APPLICATION_JSON) public class JacksonProducer implements ContextResolver<ObjectMapper> { private final ObjectMapper json; public JacksonProducer() throws Exception { this.json = new ObjectMapper() .findAndRegisterModules() .configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false) .configure(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS, false) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); } @Override public ObjectMapper getContext(Class<?> objectType) { return json; } }
2,051
35.642857
85
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jackson/JacksonResource.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.jaxrs.jackson; import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.Optional; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.MediaType; /** * @author Stuart Douglas */ @Path("/jackson") public class JacksonResource { @GET @Produces("application/vnd.customer+json") public Customer get() { return new Customer("John", "Citizen"); } @Path("/duration") @GET @Produces(MediaType.APPLICATION_JSON) public Duration duration() { return Duration.of(1, ChronoUnit.SECONDS); } @Path("/optional") @GET @Produces(MediaType.APPLICATION_JSON) public Optional<String> optional() { return Optional.of("optional string"); } }
1,844
29.75
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jackson/JaxrsJacksonProviderTestCase.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.jaxrs.jackson; 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.as.test.integration.jaxrs.packaging.war.WebXml; import org.jboss.as.test.shared.SecurityManagerFailure; 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.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests the resteasy multipart provider * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsJacksonProviderTestCase { @Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.addPackage(JaxrsJacksonProviderTestCase.class.getPackage()); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"), "web.xml"); return war; } @ArquillianResource private URL url; @BeforeClass public static void beforeClass() { SecurityManagerFailure.thisTestIsFailingUnderSM("https://github.com/FasterXML/jackson-databind/pull/1585"); } private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testSimpleJacksonResource() throws Exception { String result = performCall("myjaxrs/jackson"); Assert.assertEquals("{\"first\":\"John\",\"last\":\"Citizen\"}", result); } @Test public void testDurationJsr310() throws Exception { String result = performCall("myjaxrs/jackson/duration"); Assert.assertEquals("\"PT1S\"", result); } @Test public void testDurationJsrjdk8() throws Exception { String result = performCall("myjaxrs/jackson/optional"); Assert.assertEquals("\"optional string\"", result); } /** * AS7-1276 */ @Test public void testJacksonWithJsonIgnore() throws Exception { String result = performCall("myjaxrs/country"); Assert.assertEquals("{\"name\":\"Australia\",\"temperature\":\"Hot\"}", result); } }
3,771
35.269231
115
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jackson/JacksonCountryResource.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.jaxrs.jackson; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; /** * @author Stuart Douglas */ @Path("/country") public class JacksonCountryResource { @GET @Produces("application/vnd.customer+json") public Country get() { return new Country(3, "Australia", "Hot"); } }
1,388
33.725
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jackson/Customer.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.jaxrs.jackson; import jakarta.xml.bind.annotation.XmlRootElement; import com.fasterxml.jackson.annotation.JsonPropertyOrder; /** * @author Stuart Douglas */ @XmlRootElement @JsonPropertyOrder({"first", "last"}) public class Customer { private String first; private String last; public Customer() { } public Customer(String first, String last) { this.first = first; this.last = last; } public String getFirst() { return first; } public void setFirst(String first) { this.first = first; } public String getLast() { return last; } public void setLast(String last) { this.last = last; } }
1,756
26.888889
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jackson/Country.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.jaxrs.jackson; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; import jakarta.xml.bind.annotation.XmlElement; import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlTransient; import jakarta.xml.bind.annotation.XmlType; import java.io.Serializable; @XmlRootElement(name = "Country") @XmlType(name = "Country", propOrder = {"name", "awesomeness"}) @JsonPropertyOrder({"name", "temperature"}) public class Country implements Serializable { private Integer id; private String name; private String temperature; public Country(final Integer id, final String name, final String temperature) { this.id = id; this.name = name; this.temperature = temperature; } @XmlTransient @JsonIgnore public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } @XmlElement(name = "name", required = true) @JsonProperty public String getName() { return name; } public void setName(String name) { this.name = name; } public void setTemperature(final String temperature) { this.temperature = temperature; } @XmlElement(name = "temperature", required = true) @JsonProperty public String getTemperature() { return temperature; } }
2,511
30.4
83
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/ejb/EJBResource.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.jaxrs.integration.ejb; import jakarta.annotation.Resource; import jakarta.ejb.Stateless; import jakarta.interceptor.Interceptors; import jakarta.transaction.Status; import jakarta.transaction.SystemException; import jakarta.transaction.TransactionSynchronizationRegistry; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; @Path("ejbInterceptor") @Produces({"text/plain"}) @Stateless(name = "CustomName") @Interceptors(EjbInterceptor.class) public class EJBResource implements EjbInterface { @Resource private TransactionSynchronizationRegistry transactionSynchronizationRegistry; @GET public String getMessage() throws SystemException { if(transactionSynchronizationRegistry.getTransactionStatus() != Status.STATUS_ACTIVE) { throw new RuntimeException("Transaction not active, not an EJB invocation"); } return "Hello"; } }
1,972
37.686275
95
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/ejb/EjbInterceptor.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.jaxrs.integration.ejb; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.InvocationContext; /** * @author Stuart Douglas */ public class EjbInterceptor { @AroundInvoke public Object intercept(final InvocationContext invocationContext) throws Exception { return invocationContext.proceed().toString() + " World"; } }
1,414
36.236842
89
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/ejb/EjbInterface.java
package org.jboss.as.test.integration.jaxrs.integration.ejb; import jakarta.transaction.SystemException; /** * @author Stuart Douglas */ public interface EjbInterface { String getMessage() throws SystemException; }
223
19.363636
60
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/ejb/JaxrsEjbInterceptorsTestCase.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.jaxrs.integration.ejb; 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.as.test.integration.jaxrs.packaging.war.WebXml; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Tests injections of Jakarta Contexts and Dependency Injection beans into Jakarta RESTful Web Services resources * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsEjbInterceptorsTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.add(EmptyAsset.INSTANCE, "WEB-INF/beans.xml"); war.addClasses(EJBResource.class, EjbInterceptor.class, EjbInterface.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"),"web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/ejbInterceptor"); assertEquals("Hello World", result); } }
3,074
37.924051
114
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/ejb/JaxrsEjbInterceptorsEarTestCase.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.jaxrs.integration.ejb; 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.as.test.integration.jaxrs.packaging.war.WebXml; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; 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.junit.Assert.assertEquals; /** * Tests injections of Jakarta Contexts and Dependency Injection beans into Jakarta RESTful Web Services resources with an EAR based deployment structure * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsEjbInterceptorsEarTestCase { @Deployment(testable = false) public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxrsnoap.ear"); final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejbjar.jar"); ejbJar.addClasses(EJBResource.class, EjbInterceptor.class, EjbInterface.class); ear.addAsModule(ejbJar); WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"),"web.xml"); ear.addAsModule(war); return ear; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/ejbInterceptor"); assertEquals("Hello World", result); } }
3,364
37.238636
153
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/cdi/CDIPathApplication.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.jaxrs.integration.cdi; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; /** * Application with a predefined path *@author Stuart Douglas */ @ApplicationPath("/cdipath") public class CDIPathApplication extends Application { }
1,312
37.617647
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/cdi/CDIBean.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.jaxrs.integration.cdi; /** * @author Stuart Douglas */ public class CDIBean { public String message() { return "Hello World!"; } }
1,206
34.5
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/cdi/CDIResourceInjectionTestCase.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.jaxrs.integration.cdi; 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.as.test.integration.jaxrs.packaging.war.WebXml; 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.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Tests injections of CDI beans into Jakarta RESTful Web Services resources * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class CDIResourceInjectionTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.add(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "WEB-INF/beans.xml"); war.addClasses(CDIResourceInjectionTestCase.class, CDIResource.class, CDIBean.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"),"web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/cdiInject"); assertEquals("Hello World!", result); } }
3,086
37.5875
101
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/cdi/CDIResourceInjectionEarTestCase.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.jaxrs.integration.cdi; 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.as.test.integration.jaxrs.packaging.war.WebXml; 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.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Tests injections of CDI beans into Jakarta RESTful Web Services resources with an EAR based deployment structure * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class CDIResourceInjectionEarTestCase { @Deployment(testable = false) public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxrsnoap.ear"); WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.add(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "WEB-INF/beans.xml"); war.addClasses(CDIResourceInjectionEarTestCase.class, CDIResource.class, CDIBean.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"),"web.xml"); ear.addAsModule(war); return ear; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/cdiInject"); assertEquals("Hello World!", result); } }
3,316
36.269663
115
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/cdi/CDIResource.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.jaxrs.integration.cdi; import jakarta.inject.Inject; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; @Path("cdiInject") @Produces({"text/plain"}) public class CDIResource { @Inject CDIBean bean; @GET public String getMessage() { return bean.message(); } }
1,378
32.634146
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/cdi/JaxrsComponentBeanDefinitionTestCase.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, 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.jaxrs.integration.cdi; import static org.junit.Assert.assertEquals; import java.util.Set; import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.context.RequestScoped; import jakarta.enterprise.inject.spi.Bean; import jakarta.enterprise.inject.spi.BeanManager; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; 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.Test; import org.junit.runner.RunWith; /** * * @author Martin Kouba */ @RunWith(Arquillian.class) public class JaxrsComponentBeanDefinitionTestCase { @Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class); war.add(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "WEB-INF/beans.xml"); war.addClasses(JaxrsComponentBeanDefinitionTestCase.class, CDIBean.class, CDIResource.class, CDIApplication.class, CDIProvider.class); return war; } @Inject BeanManager beanManager; @Test public void testResource() throws Exception { // There's one bean of type CDIResource and it's scope is @RequestScoped (this is resteasy-cdi specific) Set<Bean<?>> beans = beanManager.getBeans(CDIResource.class); assertEquals(1, beans.size()); assertEquals(RequestScoped.class, beans.iterator().next().getScope()); } @Test public void testApplication() throws Exception { // There's one bean of type CDIApplication and it's scope is @ApplicationScoped Set<Bean<?>> beans = beanManager.getBeans(CDIApplication.class); assertEquals(1, beans.size()); assertEquals(ApplicationScoped.class, beans.iterator().next().getScope()); } @Test public void testProvider() throws Exception { // There's one bean of type CDIProvider and it's scope is @ApplicationScoped Set<Bean<?>> beans = beanManager.getBeans(CDIProvider.class); assertEquals(1, beans.size()); assertEquals(ApplicationScoped.class, beans.iterator().next().getScope()); } }
3,334
37.77907
142
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/cdi/CDIApplicationPathIntegrationTestCase.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.jaxrs.integration.cdi; 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.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Tests that Jakarta RESTful Web Services + CDI work together when using @ApplicationPath * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class CDIApplicationPathIntegrationTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsapp.war"); war.addPackage(HttpRequest.class.getPackage()); war.addClasses(CDIApplicationPathIntegrationTestCase.class, CDIBean.class, CDIPathApplication.class, CDIResource.class); war.add(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "WEB-INF/beans.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("cdipath/cdiInject"); assertEquals("Hello World!", result); } }
2,774
36.5
128
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/cdi/CDIApplication.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.jaxrs.integration.cdi; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; @ApplicationPath("/rest") public class CDIApplication extends Application { }
1,235
38.870968
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/integration/cdi/CDIProvider.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.jaxrs.integration.cdi; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.ext.ExceptionMapper; import jakarta.ws.rs.ext.Provider; @Provider public class CDIProvider implements ExceptionMapper<NullPointerException> { @Override public Response toResponse(NullPointerException exception) { return Response.ok().build(); } }
1,405
37
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jaxb/JaxbProviderTestCase.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.jaxrs.jaxb; 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.as.test.integration.jaxrs.packaging.war.WebXml; 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; /** * Tests a Jakarta RESTful Web Services deployment without an application bundled. * * The container should register a servlet with the name * * jakarta.ws.rs.core.Application * * It is the app providers responsibility to provide a mapping for the servlet * * JAX-RS 1.1 2.3.2 bullet point 1 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class JaxbProviderTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.addClasses(JaxbProviderTestCase.class, JaxbModel.class, JaxbResource.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"),"web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/jaxb"); //TDOO: this is fragile Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><jaxbModel><first>John</first><last>Citizen</last></jaxbModel>", result); } }
3,256
36.872093
163
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jaxb/JaxbResource.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.jaxrs.jaxb; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; @Path("jaxb") @Produces({"application/xml"}) public class JaxbResource { @GET public JaxbModel get() { return new JaxbModel("John","Citizen"); } }
1,319
35.666667
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jaxb/JaxbModel.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.jaxrs.jaxb; import jakarta.xml.bind.annotation.XmlRootElement; /** * @author Stuart Douglas */ @XmlRootElement public class JaxbModel { private String first; private String last; public JaxbModel(String first, String last) { this.first = first; this.last = last; } public JaxbModel() { } public String getFirst() { return first; } public String getLast() { return last; } public void setFirst(String first) { this.first = first; } public void setLast(String last) { this.last = last; } }
1,658
26.65
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/HelloRestResource.java
package org.jboss.as.test.integration.jaxrs.packaging.ear; import jakarta.ejb.Stateless; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; @Path("hellorest") @Stateless public class HelloRestResource { @GET @Produces({ "text/plain" }) public String getMessage() { return "Hello Rest"; } }
339
16.894737
58
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/SimpleEjb.java
package org.jboss.as.test.integration.jaxrs.packaging.ear; import jakarta.ejb.Stateless; /** * @author Stuart Douglas */ @Stateless public class SimpleEjb { }
163
13.909091
58
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/ApplicationIntegrationTestCase.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.jaxrs.packaging.ear; 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.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.junit.Assert.assertEquals; /** * Tests a Jakarta RESTful Web Services deployment with an application bundled, that has no @ApplicationPath annotation. * * The container should register a servlet with the name that matches the application name * * It is the app providers responsibility to provide a mapping for the servlet * * JAX-RS 1.1 2.3.2 bullet point 3 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class ApplicationIntegrationTestCase { @Deployment(testable = false) public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class,"jaxrsapp.ear"); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb.jar"); jar.addPackage(HttpRequest.class.getPackage()); jar.addClasses(ApplicationIntegrationTestCase.class, HelloWorldResource.class,HelloWorldApplication.class); ear.addAsModule(jar); WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsapp.war"); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>" + HelloWorldApplication.class.getName() + "</servlet-name>\n" + " <url-pattern>/hello/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"),"web.xml"); ear.addAsModule(war); return ear; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("hello/helloworld"); assertEquals("Hello World!", result); } }
3,493
37.395604
120
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/WebXml.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.jaxrs.packaging.ear; import org.jboss.shrinkwrap.api.asset.StringAsset; /** * Utility class that generates a web.xml file * * TODO: replace with the SW descriptors project when it becomes available * @author Stuart Douglas */ public class WebXml { public static StringAsset get(String contents) { return new StringAsset("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "\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" + contents + "</web-app>"); } }
1,940
40.297872
137
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/EarApplicationPathIntegrationTestCase.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.jaxrs.packaging.ear; 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.arquillian.api.ContainerResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.test.integration.common.HttpRequest; import org.jboss.dmr.ModelNode; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; 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.junit.Assert.assertEquals; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; /** * Tests a Jakarta RESTful Web Services deployment with an application bundled, that has no @ApplicationPath annotation. * <p/> * The container should register a servlet with the name that matches the application name * <p/> * It is the app providers responsibility to provide a mapping for the servlet * <p/> * JAX-RS 1.1 2.3.2 bullet point 3 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class EarApplicationPathIntegrationTestCase { @Deployment(testable = false) public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxrsapp.ear"); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb.jar"); jar.addPackage(HttpRequest.class.getPackage()); jar.addClasses(EarApplicationPathIntegrationTestCase.class, HelloWorldResource.class, HelloWorldPathApplication.class); ear.addAsModule(jar); JavaArchive jar2 = ShrinkWrap.create(JavaArchive.class, "ejb2.jar"); jar2.addClass(SimpleEjb.class); ear.addAsModule(jar2); WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsapp.war"); war.addAsWebInfResource(WebXml.get(""), "web.xml"); ear.addAsModule(war); return ear; } @ArquillianResource private URL url; @ContainerResource private ManagementClient managementClient; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("hellopath/helloworld"); assertEquals("Hello World!", result); } @Test public void testReadRestResources() throws Exception { ModelNode addr = new ModelNode().add("deployment", "jaxrsapp.ear").add("subdeployment", "jaxrsapp.war") .add("subsystem", "jaxrs").add("rest-resource", HelloWorldResource.class.getName()); ModelNode operation = new ModelNode(); operation.get(OP).set("read-resource"); operation.get(OP_ADDR).set(addr); operation.get("include-runtime").set(true); ModelNode result = managementClient.getControllerClient().execute(operation).get("result"); assertEquals(HelloWorldResource.class.getName(), result.get("resource-class").asString()); ModelNode restResPath = result.get("rest-resource-paths").asList().get(0); assertEquals("helloworld", restResPath.get("resource-path").asString()); assertEquals("java.lang.String " + HelloWorldResource.class.getName() + ".getMessage()", restResPath.get("java-method").asString()); assertEquals("GET /jaxrsapp/hellopath/helloworld", restResPath.get("resource-methods").asList().get(0).asString()); } }
4,946
41.282051
127
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/NoApplicationIntegrationTestCase.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.jaxrs.packaging.ear; 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.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.junit.Assert.assertEquals; /** * Tests a JAX-RS deployment without an application bundled. * <p/> * The container should register a servlet with the name * <p/> * jakarta.ws.rs.core.Application * <p/> * It is the app providers responsibility to provide a mapping for the servlet * <p/> * JAX-RS 1.1 2.3.2 bullet point 1 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class NoApplicationIntegrationTestCase { @Deployment(testable = false) public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxrsapp.ear"); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb.jar"); jar.addPackage(HttpRequest.class.getPackage()); jar.addClasses(NoApplicationIntegrationTestCase.class, HelloWorldResource.class); ear.addAsModule(jar); WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsnoap.war"); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"), "web.xml"); ear.addAsModule(war); return ear; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/helloworld"); assertEquals("Hello World!", result); } }
3,430
35.5
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/HelloWorldPathApplication.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.jaxrs.packaging.ear; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; /** * Application with a predefined path *@author Stuart Douglas */ @ApplicationPath("/hellopath") public class HelloWorldPathApplication extends Application { }
1,319
37.823529
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/ApplicationPathOverrideIntegrationTestCase.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.jaxrs.packaging.ear; 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.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.junit.Assert.assertEquals; /** * Tests a JAX-RS deployment with an application bundled, that has an @ApplicationPath annotation. * <p/> * This annotation is overridden by a mapping in web.xml * <p/> * JAX-RS 1.1 2.3.2 bullet point 3 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class ApplicationPathOverrideIntegrationTestCase { @Deployment(testable = false) public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxrsapp.ear"); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb.jar"); jar.addPackage(HttpRequest.class.getPackage()); jar.addClasses(ApplicationPathOverrideIntegrationTestCase.class, HelloWorldResource.class, HelloWorldPathApplication.class); ear.addAsModule(jar); WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsapp.war"); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>" + HelloWorldPathApplication.class.getName() + "</servlet-name>\n" + " <url-pattern>/override/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"), "web.xml"); ear.addAsModule(war); return ear; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("override/helloworld"); assertEquals("Hello World!", result); } }
3,409
36.472527
132
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/EarApplicationRESTInEJBIsolatedTestCase.java
/* * JBoss, Home of Professional Open Source * Copyright 2019, 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.jaxrs.packaging.ear; 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.arquillian.api.ContainerResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.test.integration.common.HttpRequest; import org.jboss.dmr.ModelNode; 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.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; /** * Use Case: 2 ejb modules, 2 web modules, isolated via jboss-deployment-structure.xml. * * REST Endpoints are defined in ejb module. * Application is defined in web module. * * web1 depends on ejb1 only, web2 can access ejb1 and ejb2 * * @author Lin Gao */ @RunWith(Arquillian.class) @RunAsClient public class EarApplicationRESTInEJBIsolatedTestCase { @Deployment(testable = false) public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxrsapp-isolated.ear"); ear.addAsManifestResource(new StringAsset( "<jboss-deployment-structure>" + " <ear-subdeployments-isolated>true</ear-subdeployments-isolated>" + " <sub-deployment name=\"web1.war\">" + " <dependencies>" + " <module name=\"deployment.jaxrsapp-isolated.ear.ejb1.jar\" />" + " </dependencies>" + " </sub-deployment>" + " <sub-deployment name=\"web2.war\">" + " <dependencies>" + " <module name=\"deployment.jaxrsapp-isolated.ear.ejb1.jar\" />" + " <module name=\"deployment.jaxrsapp-isolated.ear.ejb2.jar\" />" + " </dependencies>" + " </sub-deployment>" + "</jboss-deployment-structure>"), "jboss-deployment-structure.xml"); JavaArchive ejb1 = ShrinkWrap.create(JavaArchive.class, "ejb1.jar"); ejb1.addPackage(HttpRequest.class.getPackage()); ejb1.addClasses(EarApplicationRESTInEJBIsolatedTestCase.class, HelloWorldResource.class); ear.addAsModule(ejb1); JavaArchive ejb2 = ShrinkWrap.create(JavaArchive.class, "ejb2.jar"); ejb2.addPackage(HttpRequest.class.getPackage()); ejb2.addClasses(EarApplicationRESTInEJBIsolatedTestCase.class, HelloRestResource.class); ear.addAsModule(ejb2); // define a REST inside the WAR ? WebArchive war1 = ShrinkWrap.create(WebArchive.class, "web1.war"); war1.addClasses(HelloWorldPathApplication.class); war1.addAsWebInfResource(WebXml.get(""), "web.xml"); ear.addAsModule(war1); WebArchive war2 = ShrinkWrap.create(WebArchive.class, "web2.war"); war2.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/api/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"), "web.xml"); ear.addAsModule(war2); return ear; } @ArquillianResource private URL url; @ContainerResource private ManagementClient managementClient; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRs() throws Exception { String result = performCall("/web1/hellopath/helloworld"); assertEquals("Hello World!", result); result = performCall("/web2/api/helloworld"); assertEquals("Hello World!", result); result = performCall("/web2/api/hellorest"); assertEquals("Hello Rest", result); } @Test(expected = java.io.IOException.class) public void testRESTNotAvailable() throws Exception { performCall("/web1/hellopath/hellorest"); } @Test public void testReadRestResources() throws Exception { testRestReadHelloWorldResource("web1", "hellopath"); testRestReadHelloWorldResource("web2", "api"); testRestReadHelloRestResourceOnWeb1(); testRestReadHelloRestResourceOnWeb2(); } // HelloWorldResource is visible to web1 and web2 private void testRestReadHelloWorldResource(String web, String appPath) throws Exception { ModelNode addr = new ModelNode().add("deployment", "jaxrsapp-isolated.ear").add("subdeployment", web + ".war") .add("subsystem", "jaxrs").add("rest-resource", HelloWorldResource.class.getName()); ModelNode operation = new ModelNode(); operation.get(OP).set("read-resource"); operation.get(OP_ADDR).set(addr); operation.get("include-runtime").set(true); ModelNode result = managementClient.getControllerClient().execute(operation).get("result"); assertEquals(HelloWorldResource.class.getName(), result.get("resource-class").asString()); ModelNode restResPath = result.get("rest-resource-paths").asList().get(0); assertEquals("helloworld", restResPath.get("resource-path").asString()); assertEquals("java.lang.String " + HelloWorldResource.class.getName() + ".getMessage()", restResPath.get("java-method").asString()); assertEquals("GET /" + web + "/" + appPath + "/helloworld", restResPath.get("resource-methods").asList().get(0).asString()); } // HelloRestResource is not visible to web1 private void testRestReadHelloRestResourceOnWeb1() throws Exception { ModelNode addr = new ModelNode().add("deployment", "jaxrsapp-isolated.ear").add("subdeployment", "web1.war") .add("subsystem", "jaxrs").add("rest-resource", HelloRestResource.class.getName()); ModelNode operation = new ModelNode(); operation.get(OP).set("read-resource"); operation.get(OP_ADDR).set(addr); operation.get("include-runtime").set(true); ModelNode result = managementClient.getControllerClient().execute(operation); assertEquals("failed", result.get("outcome").asString()); String failureDescription = result.get("failure-description").asString(); assertTrue(failureDescription.contains("WFLYCTL0216")); assertTrue(failureDescription.contains("org.jboss.as.test.integration.jaxrs.packaging.ear.HelloRestResource")); assertTrue(failureDescription.contains("not found")); } // HelloRestResource is visible to web2 private void testRestReadHelloRestResourceOnWeb2() throws Exception { ModelNode addr = new ModelNode().add("deployment", "jaxrsapp-isolated.ear").add("subdeployment", "web2.war") .add("subsystem", "jaxrs").add("rest-resource", HelloRestResource.class.getName()); ModelNode operation = new ModelNode(); operation.get(OP).set("read-resource"); operation.get(OP_ADDR).set(addr); operation.get("include-runtime").set(true); ModelNode result = managementClient.getControllerClient().execute(operation).get("result"); assertEquals(HelloRestResource.class.getName(), result.get("resource-class").asString()); ModelNode restResPath = result.get("rest-resource-paths").asList().get(0); assertEquals("hellorest", restResPath.get("resource-path").asString()); assertEquals("java.lang.String " + HelloRestResource.class.getName() + ".getMessage()", restResPath.get("java-method").asString()); assertEquals("GET /web2/api/hellorest", restResPath.get("resource-methods").asList().get(0).asString()); } }
9,431
45.925373
132
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/EarApplicationRESTInEJBTestCase.java
/* * JBoss, Home of Professional Open Source * Copyright 2019, 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.jaxrs.packaging.ear; 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.arquillian.api.ContainerResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.test.integration.common.HttpRequest; import org.jboss.dmr.ModelNode; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; 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.junit.Assert.assertEquals; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.OP_ADDR; /** * Use Case: one ejb module, 2 web modules, not isolated. * * REST Endpoints are defined in ejb module. * Application class is defined in ejb module. * * @author Lin Gao */ @RunWith(Arquillian.class) @RunAsClient public class EarApplicationRESTInEJBTestCase { @Deployment(testable = false) public static Archive<?> deploy() { EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "jaxrsapp.ear"); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb.jar"); jar.addPackage(HttpRequest.class.getPackage()); jar.addClasses(EarApplicationRESTInEJBTestCase.class, HelloWorldResource.class, HelloWorldPathApplication.class); ear.addAsModule(jar); WebArchive war1 = ShrinkWrap.create(WebArchive.class, "web1.war"); war1.addAsWebInfResource(WebXml.get(""), "web.xml"); ear.addAsModule(war1); WebArchive war2 = ShrinkWrap.create(WebArchive.class, "web2.war"); war2.addAsWebInfResource(WebXml.get(""), "web.xml"); ear.addAsModule(war2); return ear; } @ArquillianResource private URL url; @ContainerResource private ManagementClient managementClient; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRs() throws Exception { String result = performCall("/web1/hellopath/helloworld"); assertEquals("Hello World!", result); result = performCall("/web2/hellopath/helloworld"); assertEquals("Hello World!", result); } @Test public void testReadRestResources() throws Exception { testReadResetOnWebModule("web1"); testReadResetOnWebModule("web2"); } private void testReadResetOnWebModule(String web) throws Exception { ModelNode addr = new ModelNode().add("deployment", "jaxrsapp.ear").add("subdeployment", web + ".war") .add("subsystem", "jaxrs").add("rest-resource", HelloWorldResource.class.getName()); ModelNode operation = new ModelNode(); operation.get(OP).set("read-resource"); operation.get(OP_ADDR).set(addr); operation.get("include-runtime").set(true); ModelNode result = managementClient.getControllerClient().execute(operation).get("result"); assertEquals(HelloWorldResource.class.getName(), result.get("resource-class").asString()); ModelNode restResPath = result.get("rest-resource-paths").asList().get(0); assertEquals("helloworld", restResPath.get("resource-path").asString()); assertEquals("java.lang.String " + HelloWorldResource.class.getName() + ".getMessage()", restResPath.get("java-method").asString()); assertEquals("GET /" + web + "/hellopath/helloworld", restResPath.get("resource-methods").asList().get(0).asString()); } }
5,008
40.396694
126
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/HelloWorldResource.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.jaxrs.packaging.ear; import jakarta.annotation.PostConstruct; import jakarta.ejb.Stateless; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; @Path("helloworld") @Produces({"text/plain"}) @Stateless public class HelloWorldResource { private String message; @PostConstruct public void postConstruct() { message = "Hello World!"; } @GET public String getMessage() { return message; } }
1,522
30.729167
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/ear/HelloWorldApplication.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.jaxrs.packaging.ear; import jakarta.ws.rs.core.Application; /** * Application with no path *@author Stuart Douglas */ public class HelloWorldApplication extends Application { }
1,236
37.65625
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/war/ApplicationPathIntegrationTestCase.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.jaxrs.packaging.war; 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.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Tests a JAX-RS deployment with an application bundled, that has no @ApplicationPath annotation. * * The container should register a servlet with the name that matches the application name * * It is the app providers responsibility to provide a mapping for the servlet * * JAX-RS 1.1 2.3.2 bullet point 3 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class ApplicationPathIntegrationTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsapp.war"); war.addPackage(HttpRequest.class.getPackage()); war.addClasses(ApplicationPathIntegrationTestCase.class, HelloWorldResource.class,HelloWorldPathApplication.class); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("hellopath/helloworld"); assertEquals("Hello World!", result); } }
2,837
34.924051
123
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/war/ApplicationIntegrationTestCase.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.jaxrs.packaging.war; 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.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Tests a Jakarta RESTful Web Services deployment with an application bundled, that has no @ApplicationPath annotation. * <p/> * The container should register a servlet with the name that matches the application name * <p/> * It is the app providers responsibility to provide a mapping for the servlet * <p/> * JAX-RS 1.1 2.3.2 bullet point 3 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class ApplicationIntegrationTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsapp.war"); war.addPackage(HttpRequest.class.getPackage()); war.addClasses(ApplicationIntegrationTestCase.class, HelloWorldResource.class, HelloWorldApplication.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>" + HelloWorldApplication.class.getName() + "</servlet-name>\n" + " <url-pattern>/hello/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"), "web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("hello/helloworld"); assertEquals("Hello World!", result); } }
3,177
37.289157
120
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/war/WebXml.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.jaxrs.packaging.war; import org.jboss.shrinkwrap.api.asset.StringAsset; /** * Utility class that generates a web.xml file * * TODO: replace with the SW descriptors project when it becomes available * @author Stuart Douglas */ public class WebXml { public static StringAsset get(String contents) { return new StringAsset("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "\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" + contents + "</web-app>"); } }
1,940
40.297872
137
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/war/NoApplicationIntegrationTestCase.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.jaxrs.packaging.war; 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.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Tests a JAX-RS deployment without an application bundled. * * The container should register a servlet with the name * * jakarta.ws.rs.core.Application * * It is the app providers responsibility to provide a mapping for the servlet * * JAX-RS 1.1 2.3.2 bullet point 1 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class NoApplicationIntegrationTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.addClasses(NoApplicationIntegrationTestCase.class, HelloWorldResource.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"),"web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/helloworld"); assertEquals("Hello World!", result); } }
3,068
35.105882
89
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/war/HelloWorldPathApplication.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.jaxrs.packaging.war; import jakarta.ws.rs.ApplicationPath; import jakarta.ws.rs.core.Application; /** * Application with a predefined path *@author Stuart Douglas */ @ApplicationPath("/hellopath") public class HelloWorldPathApplication extends Application { }
1,319
37.823529
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/war/ResteasyScanTestCase.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.jaxrs.packaging.war; 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.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Tests a Jakarta RESTful Web Services deployment without an application bundled and resteasy.scan specified will * ignore the resteasy.scan property and still work. * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class ResteasyScanTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.addClasses(ResteasyScanTestCase.class, HelloWorldResource.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + " </servlet-mapping>\n" + "<context-param> <param-name>resteasy.scan</param-name> <param-value>true</param-value> </context-param>" + "\n"),"web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/helloworld"); assertEquals("Hello World!", result); } }
3,058
37.721519
123
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/war/ApplicationPathOverrideIntegrationTestCase.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.jaxrs.packaging.war; 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.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; import static org.junit.Assert.assertEquals; /** * Tests a Jakarta RESTful Web Services deployment with an application bundled, that has an @ApplicationPath annotation. * * This annotation is overridden by a mapping in web.xml * * JAX-RS 1.1 2.3.2 bullet point 3 * * @author Stuart Douglas */ @RunWith(Arquillian.class) @RunAsClient public class ApplicationPathOverrideIntegrationTestCase { @Deployment(testable = false) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class,"jaxrsapp.war"); war.addPackage(HttpRequest.class.getPackage()); war.addClasses(ApplicationPathOverrideIntegrationTestCase.class, HelloWorldResource.class,HelloWorldPathApplication.class); war.addAsWebInfResource(WebXml.get("<servlet-mapping>\n" + " <servlet-name>" + HelloWorldPathApplication.class.getName() + "</servlet-name>\n" + " <url-pattern>/override/*</url-pattern>\n" + " </servlet-mapping>\n" + "\n"),"web.xml"); return war; } @ArquillianResource private URL url; private String performCall(String urlPattern) throws Exception { return HttpRequest.get(url + urlPattern, 10, TimeUnit.SECONDS); } @Test public void testJaxRsWithNoApplication() throws Exception { String result = performCall("override/helloworld"); assertEquals("Hello World!", result); } }
3,081
37.049383
131
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/war/HelloWorldResource.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.jaxrs.packaging.war; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; @Path("helloworld") @Produces({"text/plain"}) public class HelloWorldResource { @GET public String getMessage() { return "Hello World!"; } }
1,322
35.75
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/packaging/war/HelloWorldApplication.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.jaxrs.packaging.war; import jakarta.ws.rs.core.Application; /** * Application with no path *@author Stuart Douglas */ public class HelloWorldApplication extends Application { }
1,236
37.65625
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jsapi/JaxrsJSApiTestCase.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.jaxrs.jsapi; import java.net.URL; import java.util.concurrent.TimeUnit; 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.junit.InSequence; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.integration.common.HttpRequest; import org.jboss.as.test.integration.jaxrs.packaging.war.WebXml; 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; /** * Tests the resteasy JavaScript API * * @author Pavel Janousek */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsJSApiTestCase { private static final String depName = "jsapi"; @Deployment(name = depName) public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, "jaxrsnoap.war"); war.addPackage(HttpRequest.class.getPackage()); war.addPackage(JaxrsJSApiTestCase.class.getPackage()); war.addAsWebInfResource(WebXml.get( "<servlet-mapping>\n" + " <servlet-name>jakarta.ws.rs.core.Application</servlet-name>\n" + " <url-pattern>/myjaxrs/*</url-pattern>\n" + "</servlet-mapping>\n" + "\n" + "<servlet>\n" + " <servlet-name>RESTEasy JSAPI</servlet-name>\n" + " <servlet-class>org.jboss.resteasy.jsapi.JSAPIServlet</servlet-class>\n" + "</servlet>\n" + "\n" + "<servlet-mapping>" + " <servlet-name>RESTEasy JSAPI</servlet-name>\n" + " <url-pattern>/rest-JS</url-pattern>\n" + "</servlet-mapping>\n" + "\n"), "web.xml"); return war; } @ArquillianResource @OperateOnDeployment(depName) static URL url; private static String performCall(String urlPattern) throws Exception { return HttpRequest.get(url.toString() + urlPattern, 5, TimeUnit.SECONDS); } @Test @InSequence(1) public void testJaxRsWithNoApplication() throws Exception { String result = performCall("myjaxrs/jsapi"); Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><customer><first>John</first><last>Citizen</last></customer>", result); } @Test @InSequence(2) public void testJaxRsJSApis() throws Exception { String result = performCall("/rest-JS"); Assert.assertTrue(result.contains("var CustomerResource")); } }
4,001
39.02
161
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jsapi/Customer.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.jaxrs.jsapi; import jakarta.xml.bind.annotation.XmlRootElement; /** * @author Stuart Douglas */ @XmlRootElement public class Customer { private String first; private String last; public Customer(String first, String last) { this.first = first; this.last = last; } public Customer() { } public String getFirst() { return first; } public void setFirst(String first) { this.first = first; } public String getLast() { return last; } public void setLast(String last) { this.last = last; } }
1,655
27.067797
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/jsapi/CustomerResource.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.jaxrs.jsapi; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; /** * @author Pavel Janousek */ @Path("jsapi") public class CustomerResource { @GET @Produces({"application/xml"}) public Customer get() { return new Customer("John", "Citizen"); } }
1,363
33.1
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/spec/basic/JaxrsAppTestCase.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.jaxrs.spec.basic; import java.net.URL; 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.jaxrs.spec.basic.resource.JaxrsApp; import org.jboss.as.test.integration.jaxrs.spec.basic.resource.JaxrsAppResource; 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 jakarta.ws.rs.client.Client; import jakarta.ws.rs.client.ClientBuilder; import jakarta.ws.rs.client.WebTarget; /** */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsAppTestCase { @ArquillianResource URL baseUrl; private static final String CONTENT_ERROR_MESSAGE = "Wrong content of response"; @Deployment public static Archive<?> deploySimpleResource() { WebArchive war = ShrinkWrap.create(WebArchive.class, JaxrsAppTestCase.class.getSimpleName() + ".war"); war.addAsWebInfResource(JaxrsAppTestCase.class.getPackage(), "JaxrsAppWeb.xml", "web.xml"); war.addClasses(JaxrsAppResource.class, JaxrsApp.class); return war; } /** * The jaxrs 2.0 spec says that when a Application subclass returns * empty collections for getClasses and getSingletons methods the * resource and provider classes should be dynamically found. * This test shows that the server deployment processing code performs * the required scanning. */ @Test public void testDemo() throws Exception { Client client = ClientBuilder.newClient(); try { String url = baseUrl.toString() + "resources"; WebTarget base = client.target(url); String value = base.path("example").request().get(String.class); Assert.assertEquals(CONTENT_ERROR_MESSAGE, "Hello world!", value); } finally { client.close(); } } }
3,194
37.963415
110
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/spec/basic/JaxrsInitParamMgtApiTestCase.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.jaxrs.spec.basic; import java.io.IOException; 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.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.integration.jaxrs.spec.basic.resource.JaxrsAppResource; import org.jboss.as.test.integration.jaxrs.spec.basic.resource.JaxrsAppTwo; import org.jboss.as.test.integration.management.base.ContainerResourceMgmtTestBase; import org.jboss.as.test.integration.management.util.MgmtOperationException; import org.jboss.dmr.ModelNode; 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; import org.junit.Assert; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEPLOYMENT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_OPERATION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; /** */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsInitParamMgtApiTestCase extends ContainerResourceMgmtTestBase { @Deployment public static Archive<?> deploySimpleResource() { WebArchive war = ShrinkWrap.create(WebArchive.class, JaxrsInitParamMgtApiTestCase.class.getSimpleName() + ".war"); war.addAsWebInfResource(JaxrsInitParamMgtApiTestCase.class.getPackage(), "JaxrsInitParamWeb.xml", "web.xml"); war.addClasses(JaxrsAppResource.class, JaxrsAppTwo.class); return war; } /** * When web.xml is present in the archive and the Application subclass is * declared only in the init-param element. The subclass must provide a * list of classes to use in the getClasses or getSingletons method. * confirm resource class is registered in the (CLI) management model * Corresponding CLI cmd: * ./jboss-cli.sh -c --command="/deployment=JaxrsInitParamMgtApiTestCase.war/subsystem=jaxrs:read-resource(include-runtime=true,recursive=true)" * */ @Test public void testInitParam() throws IOException, MgmtOperationException { ModelNode op = Util.createOperation(READ_RESOURCE_OPERATION, PathAddress.pathAddress(DEPLOYMENT, JaxrsInitParamMgtApiTestCase.class.getSimpleName() + ".war") .append(SUBSYSTEM, "jaxrs") .append("rest-resource", JaxrsAppResource.class.getCanonicalName())); op.get(ModelDescriptionConstants.INCLUDE_RUNTIME).set(true); ModelNode result = executeOperation(op); Assert.assertFalse("Subsystem is empty.", result.keys().size() == 0); ModelNode resClass = result.get("resource-class"); Assert.assertNotNull("No resource-class present.", resClass); Assert.assertTrue("Expected resource-class not found.", resClass.toString().contains(JaxrsAppResource.class.getSimpleName())); } }
4,217
47.482759
148
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/spec/basic/JaxrsNoXmlMgtApiTestCase.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.jaxrs.spec.basic; import java.io.IOException; 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.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.integration.jaxrs.spec.basic.resource.JaxrsApp; import org.jboss.as.test.integration.jaxrs.spec.basic.resource.JaxrsAppResource; import org.jboss.as.test.integration.management.base.ContainerResourceMgmtTestBase; import org.jboss.as.test.integration.management.util.MgmtOperationException; import org.jboss.dmr.ModelNode; 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; import org.junit.Assert; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEPLOYMENT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_OPERATION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; /** */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsNoXmlMgtApiTestCase extends ContainerResourceMgmtTestBase { @Deployment public static Archive<?> deploySimpleResource() { WebArchive war = ShrinkWrap.create(WebArchive.class, JaxrsNoXmlMgtApiTestCase.class.getSimpleName() + ".war"); war.addClasses(JaxrsAppResource.class, JaxrsApp.class); return war; } /** * When no web.xml file present in archive auto-scan should fine and register * the resource class in the management model. * Confirm resource class is registered in the (CLI) management model * Corresponding CLI cmd: * ./jboss-cli.sh -c --command="/deployment=JaxrsNoXmlMgtApiTestCase.war/subsystem=jaxrs:read-resource(include-runtime=true,recursive=true)" * */ @Test public void testNoXml() throws IOException, MgmtOperationException { ModelNode op = Util.createOperation(READ_RESOURCE_OPERATION, PathAddress.pathAddress(DEPLOYMENT, JaxrsNoXmlMgtApiTestCase.class.getSimpleName() + ".war") .append(SUBSYSTEM, "jaxrs") .append("rest-resource", JaxrsAppResource.class.getCanonicalName())); op.get(ModelDescriptionConstants.INCLUDE_RUNTIME).set(true); ModelNode result = executeOperation(op); Assert.assertFalse("Subsystem is empty.", result.keys().size() == 0); ModelNode resClass = result.get("resource-class"); Assert.assertNotNull("No resource-class present.", resClass); Assert.assertTrue("Expected resource-class not found.", resClass.toString().contains(JaxrsAppResource.class.getSimpleName())); } }
3,969
45.705882
144
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/jaxrs/spec/basic/JaxrsContextParamMgtApiTestCase.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.jaxrs.spec.basic; import java.io.IOException; 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.controller.PathAddress; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.integration.jaxrs.spec.basic.resource.JaxrsAppResource; import org.jboss.as.test.integration.jaxrs.spec.basic.resource.JaxrsAppTwo; import org.jboss.as.test.integration.management.base.ContainerResourceMgmtTestBase; import org.jboss.as.test.integration.management.util.MgmtOperationException; import org.jboss.dmr.ModelNode; 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; import org.junit.Assert; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.DEPLOYMENT; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.READ_RESOURCE_OPERATION; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; /** */ @RunWith(Arquillian.class) @RunAsClient public class JaxrsContextParamMgtApiTestCase extends ContainerResourceMgmtTestBase { @Deployment public static Archive<?> deploySimpleResource() { WebArchive war = ShrinkWrap.create(WebArchive.class, JaxrsContextParamMgtApiTestCase.class.getSimpleName() + ".war"); war.addAsWebInfResource(JaxrsContextParamMgtApiTestCase.class.getPackage(), "JaxrsContextParamWeb.xml", "web.xml"); war.addClasses(JaxrsAppResource.class, JaxrsAppTwo.class); return war; } /** * When web.xml is present in the archive and the Application subclass is * declared only in the context-param element. The subclass must provide a * list of classes to use in the getClasses or getSingletons method. * confirm resource class is registered in the (CLI) management model * Corresponding CLI cmd: * ./jboss-cli.sh -c --command="/deployment=JaxrsContextParamMgtApiTestCase.war/subsystem=jaxrs:read-resource(include-runtime=true,recursive=true)" * */ @Test public void testContextParam() throws IOException, MgmtOperationException { ModelNode op = Util.createOperation(READ_RESOURCE_OPERATION, PathAddress.pathAddress(DEPLOYMENT, JaxrsContextParamMgtApiTestCase.class.getSimpleName() + ".war") .append(SUBSYSTEM, "jaxrs") .append("rest-resource", JaxrsAppResource.class.getCanonicalName())); op.get(ModelDescriptionConstants.INCLUDE_RUNTIME).set(true); ModelNode result = executeOperation(op); Assert.assertFalse("Subsystem is empty.", result.keys().size() == 0); ModelNode resClass = result.get("resource-class"); Assert.assertNotNull("No resource-class present.", resClass); Assert.assertTrue("Expected resource-class not found.", resClass.toString().contains(JaxrsAppResource.class.getSimpleName())); } }
4,241
47.758621
151
java