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/ejb/remote/jndi/RemoteEJBJndiBasedInvocationTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.remote.jndi; import javax.naming.Context; import javax.naming.InitialContext; import java.util.Hashtable; 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.JavaArchive; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; /** * @author Jaikiran Pai */ @RunWith(Arquillian.class) @RunAsClient public class RemoteEJBJndiBasedInvocationTestCase { private static final String APP_NAME = ""; private static final String DISTINCT_NAME = ""; private static final String MODULE_NAME = "remote-ejb-jndi-test-case"; private static Context context; @Deployment(testable = false) // the incorrectly named "testable" attribute tells Arquillian whether or not // it should add Arquillian specific metadata to the archive (which ultimately transforms it to a WebArchive). // We don't want that, so set that flag to false public static Archive createDeployment() { final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar"); jar.addPackage(RemoteCounter.class.getPackage()); return jar; } @BeforeClass public static void beforeClass() throws Exception { final Hashtable props = new Hashtable(); props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); context = new InitialContext(props); } @Test public void testRemoteSLSBInvocation() throws Exception { final RemoteEcho remoteEcho = (RemoteEcho) context.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + EchoBean.class.getSimpleName() + "!" + RemoteEcho.class.getName()); Assert.assertNotNull("Lookup returned a null bean proxy", remoteEcho); final String msg = "Hello world from a really remote client!!!"; final String echo = remoteEcho.echo(msg); Assert.assertEquals("Unexpected echo returned from remote bean", msg, echo); } @Test public void testRemoteSFSBInvocation() throws Exception { final RemoteCounter remoteCounter = (RemoteCounter) context.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + CounterBean.class.getSimpleName() + "!" + RemoteCounter.class.getName() + "?stateful"); Assert.assertNotNull("Lookup returned a null bean proxy", remoteCounter); Assert.assertEquals("Unexpected initial count returned by bean", 0, remoteCounter.getCount()); final int NUM_TIMES = 25; // test increment for (int i = 0; i < NUM_TIMES; i++) { remoteCounter.incrementCount(); final int currentCount = remoteCounter.getCount(); Assert.assertEquals("Unexpected count after increment", i + 1, currentCount); } Assert.assertEquals("Unexpected total count after increment", NUM_TIMES, remoteCounter.getCount()); // test decrement for (int i = NUM_TIMES; i > 0; i--) { remoteCounter.decrementCount(); final int currentCount = remoteCounter.getCount(); Assert.assertEquals("Unexpected count after decrement", i - 1, currentCount); } Assert.assertEquals("Unexpected total count after decrement", 0, remoteCounter.getCount()); } }
4,576
42.590476
134
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/jndi/EchoBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.remote.jndi; import jakarta.ejb.Remote; import jakarta.ejb.Stateless; /** * @author Jaikiran Pai */ @Stateless @Remote(RemoteEcho.class) public class EchoBean implements RemoteEcho { @Override public String echo(String msg) { return msg; } @Override public EchoMessage echo(final EchoMessage message) { final EchoMessage echo = new EchoMessage(); if (message != null) { echo.setMessage(message.getMessage()); } return echo; } }
1,576
31.183673
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/ejbnamespace/SimpleEjb.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.ejb.remote.ejbnamespace; import jakarta.ejb.EJB; import jakarta.ejb.Stateless; /** * @author Stuart Douglas */ @Stateless public class SimpleEjb { @EJB(lookup="ejb:/RemoteInvocationTest//StatelessRemoteBean!org.jboss.as.test.integration.ejb.remote.ejbnamespace.RemoteInterface") RemoteInterface ejb; public String hello() { return ejb.hello(); } }
1,435
32.395349
135
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/ejbnamespace/EjbNamespaceInvocationTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.remote.ejbnamespace; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import javax.naming.InitialContext; import javax.naming.NamingException; /** * Simple remote ejb tests * * @author Stuart Douglas */ @RunWith(Arquillian.class) public class EjbNamespaceInvocationTestCase { private static final String APP_NAME = ""; private static final String MODULE_NAME = "RemoteInvocationTest"; @Deployment public static Archive<?> deploy() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar"); jar.addPackage(EjbNamespaceInvocationTestCase.class.getPackage()); return jar; } @ArquillianResource private InitialContext iniCtx; @Test public void testDirectLookup() throws Exception { RemoteInterface bean = lookupEjb(StatelessRemoteBean.class.getSimpleName(), RemoteInterface.class); Assert.assertEquals("hello", bean.hello()); } @Test public void testAnnotationInjection() throws Exception { SimpleEjb bean = lookup(SimpleEjb.class.getSimpleName(), SimpleEjb.class); Assert.assertEquals("hello", bean.hello()); } protected <T> T lookupEjb(String beanName, Class<T> interfaceType) throws NamingException { return interfaceType.cast(iniCtx.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "//" + beanName + "!" + interfaceType.getName())); } protected <T> T lookup(String beanName, Class<T> interfaceType) throws NamingException { return interfaceType.cast(iniCtx.lookup("java:global/" + MODULE_NAME + "/" + beanName + "!" + interfaceType.getName())); } }
3,020
35.841463
138
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/ejbnamespace/RemoteInterface.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.ejb.remote.ejbnamespace; import jakarta.ejb.Remote; /** * @author Stuart Douglas */ @Remote public interface RemoteInterface { String hello(); }
1,209
33.571429
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/ejbnamespace/StatelessRemoteBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.remote.ejbnamespace; import jakarta.ejb.Stateless; /** * */ @Stateless public class StatelessRemoteBean implements RemoteInterface { @Override public String hello() { return "hello"; } }
1,280
31.846154
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/httpobfuscatedroute/HttpObfuscatedRouteTestSuite.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 2110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.remote.httpobfuscatedroute; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.as.arquillian.api.ServerSetup; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.runners.Suite; /** * Test suite for running some http invocation tests with Undertow obfuscated-session-route set to true. * * @author Flavia Rainone */ @RunAsClient @Suite.SuiteClasses({HttpObfuscatedRouteTestSuite.HttpRemoteEJBJndiBasedInvocationTest.class, HttpObfuscatedRouteTestSuite.HttpRemoteIdentityTestCase.class}) public class HttpObfuscatedRouteTestSuite { private static Throwable failure = null; @ServerSetup(UndertowObfuscatedSessionRouteServerSetup.class) public static class HttpRemoteEJBJndiBasedInvocationTest extends org.jboss.as.test.integration.ejb.remote.jndi.HttpRemoteEJBJndiBasedInvocationTestCase { @BeforeClass @AfterClass public static void checkFailure() throws Throwable { if (failure != null) { throw failure; } } } @ServerSetup(UndertowObfuscatedSessionRouteServerSetup.class) public static class HttpRemoteIdentityTestCase extends org.jboss.as.test.integration.ejb.remote.security.HttpRemoteIdentityTestCase { @BeforeClass @AfterClass public static void checkFailure() throws Throwable { if (failure != null) { throw failure; } } } }
2,546
38.184615
157
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/httpobfuscatedroute/UndertowObfuscatedSessionRouteServerSetup.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.ejb.remote.httpobfuscatedroute; import org.jboss.as.arquillian.api.ServerSetupTask; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.shared.ServerReload; import org.jboss.dmr.ModelNode; import static org.jboss.as.controller.client.helpers.ClientConstants.FAILURE_DESCRIPTION; import static org.jboss.as.controller.client.helpers.ClientConstants.OUTCOME; import static org.jboss.as.controller.client.helpers.ClientConstants.SUCCESS; import static org.jboss.as.controller.descriptions.ModelDescriptionConstants.SUBSYSTEM; import org.wildfly.extension.undertow.UndertowExtension; import static org.wildfly.extension.undertow.Constants.OBFUSCATE_SESSION_ROUTE; /** * ServerSetupTask that sets Undertow subsystem obfuscate-session-route attribute to true * and reloads the server. * * @author Flavia Rainone */ public class UndertowObfuscatedSessionRouteServerSetup implements ServerSetupTask { private static Exception failure; @Override public void setup(ManagementClient managementClient, String containerId) throws Exception { failure = null; try { final ModelNode op = Util.getWriteAttributeOperation( PathAddress.pathAddress(SUBSYSTEM, UndertowExtension.SUBSYSTEM_NAME), OBFUSCATE_SESSION_ROUTE, true); runOperationAndReload(op, managementClient); } catch (Exception e) { failure = e; throw e; } } @Override public void tearDown(ManagementClient managementClient, String containerId) throws Exception { if (failure != null) return; try { final ModelNode op = Util.getUndefineAttributeOperation( PathAddress.pathAddress(SUBSYSTEM, UndertowExtension.SUBSYSTEM_NAME), OBFUSCATE_SESSION_ROUTE); runOperationAndReload(op, managementClient); } catch (Exception e) { failure = e; throw e; } } private void runOperationAndReload(ModelNode operation, ManagementClient client) throws Exception { final ModelNode result = client.getControllerClient().execute(operation); if (result.hasDefined(FAILURE_DESCRIPTION)) { final String failureDesc = result.get(FAILURE_DESCRIPTION).toString(); throw new RuntimeException(failureDesc); } if (!result.hasDefined(OUTCOME) || !SUCCESS.equals(result.get(OUTCOME).asString())) { throw new RuntimeException("Operation not successful; outcome = " + result.get(OUTCOME)); } ServerReload.reloadIfRequired(client); } public static Exception getFailure() { return failure; } }
3,449
38.204545
115
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/httpobfuscatedroute/HttpObfuscatedRouteInvocationInContainerTestCase.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.ejb.remote.httpobfuscatedroute; import java.net.SocketPermission; import java.net.URL; import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.arquillian.api.ServerSetup; import org.jboss.as.test.integration.ejb.remote.http.EchoRemote; import org.jboss.as.test.integration.ejb.remote.http.HttpInvocationInContainerTestCase; import org.jboss.as.test.shared.TestSuiteEnvironment; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import static org.jboss.as.test.shared.PermissionUtils.createPermissionsXmlAsset; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; /** * Copy of {@link HttpInvocationInContainerTestCase} (cannot be extended because of class * finding issues with deployment classpath. * * @author Flavia Rainone */ @RunWith(Arquillian.class) @ServerSetup(UndertowObfuscatedSessionRouteServerSetup.class) public class HttpObfuscatedRouteInvocationInContainerTestCase { @BeforeClass @AfterClass public static void checkFailure() throws Throwable { if (UndertowObfuscatedSessionRouteServerSetup.getFailure() != null) { throw UndertowObfuscatedSessionRouteServerSetup.getFailure(); } } @ArquillianResource private URL url; @Deployment public static WebArchive deployment() { String SERVER_HOST_PORT = TestSuiteEnvironment.getHttpAddress() + ":" + TestSuiteEnvironment.getHttpPort(); return ShrinkWrap.create(WebArchive.class, "http-test.war") .addPackage(EchoRemote.class.getPackage()) .addPackage(UndertowObfuscatedSessionRouteServerSetup.class.getPackage()) .addAsManifestResource(createPermissionsXmlAsset( new SocketPermission(SERVER_HOST_PORT, "connect,resolve") ), "permissions.xml"); } @Test public void invokeEjb() throws NamingException { Hashtable table = new Hashtable(); table.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory"); table.put(Context.PROVIDER_URL, "http://" + url.getHost() + ":" + url.getPort() + "/wildfly-services"); table.put(Context.SECURITY_PRINCIPAL, "user1"); table.put(Context.SECURITY_CREDENTIALS, "password1"); InitialContext ic = new InitialContext(table); EchoRemote echo = (EchoRemote) ic.lookup("http-test/EchoBean!org.jboss.as.test.integration.ejb.remote.http.EchoRemote"); Assert.assertEquals("hello", echo.echo("hello")); } }
3,503
38.818182
128
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/http/EchoRemote.java
package org.jboss.as.test.integration.ejb.remote.http; public interface EchoRemote { String echo(String arg); }
118
16
54
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/http/HttpInvocationInContainerTestCase.java
package org.jboss.as.test.integration.ejb.remote.http; import static org.jboss.as.test.shared.PermissionUtils.createPermissionsXmlAsset; import java.net.SocketPermission; import java.net.URL; import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.shared.TestSuiteEnvironment; 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; @RunWith(Arquillian.class) public class HttpInvocationInContainerTestCase { @ArquillianResource private URL url; @Deployment public static WebArchive deployment() { String SERVER_HOST_PORT = TestSuiteEnvironment.getHttpAddress() + ":" + TestSuiteEnvironment.getHttpPort(); return ShrinkWrap.create(WebArchive.class, "http-test.war") .addPackage(HttpInvocationInContainerTestCase.class.getPackage()) .addAsManifestResource(createPermissionsXmlAsset( new SocketPermission(SERVER_HOST_PORT, "connect,resolve") ), "permissions.xml"); } @Test public void invokeEjb() throws NamingException { Hashtable table = new Hashtable(); table.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory"); table.put(Context.PROVIDER_URL, "http://" + url.getHost() + ":" + url.getPort() + "/wildfly-services"); table.put(Context.SECURITY_PRINCIPAL, "user1"); table.put(Context.SECURITY_CREDENTIALS, "password1"); InitialContext ic = new InitialContext(table); EchoRemote echo = (EchoRemote) ic.lookup("http-test/EchoBean!org.jboss.as.test.integration.ejb.remote.http.EchoRemote"); Assert.assertEquals("hello", echo.echo("hello")); } }
2,057
38.576923
128
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/http/EchoBean.java
package org.jboss.as.test.integration.ejb.remote.http; import jakarta.ejb.Remote; import jakarta.ejb.Stateless; @Stateless @Remote(EchoRemote.class) public class EchoBean implements EchoRemote { @Override public String echo(String arg) { return arg; } }
276
18.785714
54
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/view/StatelessEcho.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.ejb.remote.view; import jakarta.ejb.Local; import jakarta.ejb.Stateless; /** * @author Jaikiran Pai */ @Stateless @Local(LocalEcho.class) public class StatelessEcho extends CommonEcho { }
1,254
34.857143
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/view/SingletonEcho.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.ejb.remote.view; import jakarta.ejb.Local; import jakarta.ejb.Singleton; /** * @author Jaikiran Pai */ @Singleton @Local(LocalEcho.class) public class SingletonEcho extends CommonEcho { }
1,254
34.857143
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/view/LocalViewRemoteInvocationTestCase.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.ejb.remote.view; import java.util.Hashtable; import jakarta.ejb.EJBException; import javax.naming.Context; import javax.naming.InitialContext; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; import org.jboss.logging.Logger; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that a local view exposed by an EJB is <b>not</b> invokable remotely. * * @author Jaikiran Pai * @see https://issues.jboss.org/browse/AS7-3939 */ @RunWith(Arquillian.class) public class LocalViewRemoteInvocationTestCase { private static final Logger logger = Logger.getLogger(LocalViewRemoteInvocationTestCase.class); private static final String APP_NAME = ""; private static final String DISTINCT_NAME = ""; private static final String MODULE_NAME = "local-view-remote-invocation-test"; private static Context context; @Deployment public static Archive createDeployment() { final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar"); ejbJar.addPackage(LocalViewRemoteInvocationTestCase.class.getPackage()); return ejbJar; } @BeforeClass public static void beforeClass() throws Exception { final Hashtable props = new Hashtable(); props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); context = new InitialContext(props); } /** * Test that remote invocation on a local view of a stateless bean isn't allowed * * @throws Exception */ @Test @RunAsClient public void testLocalViewInvocationRemotelyOnSLSB() throws Exception { final LocalEcho localEcho = (LocalEcho) context.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + StatelessEcho.class.getSimpleName() + "!" + LocalEcho.class.getName()); final String message = "Silence!"; try { final String echo = localEcho.echo(message); Assert.fail("Remote invocation on a local view " + LocalEcho.class.getName() + " was expected to fail"); } catch (EJBException nsee) { // expected logger.trace("Got the expected exception on invoking on a local view, remotely", nsee); } } /** * Test that remote invocation on a local view of a stateful bean isn't allowed * * @throws Exception */ @Test @RunAsClient public void testLocalViewInvocationRemotelyOnSFSB() throws Exception { final LocalEcho localEcho = (LocalEcho) context.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + StatefulEcho.class.getSimpleName() + "!" + LocalEcho.class.getName() + "?stateful"); final String message = "Silence!"; try { final String echo = localEcho.echo(message); Assert.fail("Remote invocation on a local view " + LocalEcho.class.getName() + " was expected to fail"); } catch (EJBException nsee) { // expected logger.trace("Got the expected exception on invoking on a local view, remotely", nsee); } } /** * Test that remote invocation on a local view of a singleton bean isn't allowed * * @throws Exception */ @Test @RunAsClient public void testLocalViewInvocationRemotelyOnSingleton() throws Exception { final LocalEcho localEcho = (LocalEcho) context.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + SingletonEcho.class.getSimpleName() + "!" + LocalEcho.class.getName()); final String message = "Silence!"; try { final String echo = localEcho.echo(message); Assert.fail("Remote invocation on a local view " + LocalEcho.class.getName() + " was expected to fail"); } catch (EJBException nsee) { // expected logger.trace("Got the expected exception on invoking on a local view, remotely", nsee); } } /** * Test that an in-vm invocation on a local business interface, of a SLSB, using the ejb: namespace fails, since only * remote view invocations are allowed for ejb: namespace * * @throws Exception */ @Test public void testServerInVMInvocationOnLocalViewOfSLSB() throws Exception { final Context jndiContext = new InitialContext(); final LocalEcho localEcho = (LocalEcho) jndiContext.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + StatelessEcho.class.getSimpleName() + "!" + LocalEcho.class.getName()); final String message = "Silence!"; try { final String echo = localEcho.echo(message); Assert.fail("Remote invocation on a local view " + LocalEcho.class.getName() + " was expected to fail"); } catch (IllegalStateException nsee) { // expected logger.trace("Got the expected exception on invoking on a local view, remotely", nsee); } } /** * Test that an in-vm invocation on a local business interface, of a SFSB, using the ejb: namespace fails, since only * remote view invocations are allowed for ejb: namespace * * @throws Exception */ @Test public void testServerInVMInvocationOnLocalViewOfSFSB() throws Exception { final Context jndiContext = new InitialContext(); final LocalEcho localEcho = (LocalEcho) jndiContext.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + StatefulEcho.class.getSimpleName() + "!" + LocalEcho.class.getName() + "?stateful"); final String message = "Silence!"; try { final String echo = localEcho.echo(message); Assert.fail("Remote invocation on a local view " + LocalEcho.class.getName() + " was expected to fail"); } catch (IllegalStateException nsee) { // expected logger.trace("Got the expected exception on invoking on a local view, remotely", nsee); } } /** * Test that an in-vm invocation on a local business interface, of a singleton bean, using the ejb: namespace fails, since only * remote view invocations are allowed for ejb: namespace * * @throws Exception */ @Test public void testServerInVMInvocationOnLocalViewOfSingleton() throws Exception { final Context jndiContext = new InitialContext(); final LocalEcho localEcho = (LocalEcho) jndiContext.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + SingletonEcho.class.getSimpleName() + "!" + LocalEcho.class.getName()); final String message = "Silence!"; try { final String echo = localEcho.echo(message); Assert.fail("Remote invocation on a local view " + LocalEcho.class.getName() + " was expected to fail"); } catch (IllegalStateException nsee) { // expected logger.trace("Got the expected exception on invoking on a local view, remotely", nsee); } } }
8,340
42.217617
219
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/view/CommonEcho.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.ejb.remote.view; /** * @author Jaikiran Pai */ abstract class CommonEcho implements LocalEcho { @Override public String echo(String message) { return message; } }
1,249
34.714286
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/view/LocalEcho.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.ejb.remote.view; import jakarta.ejb.Local; /** * @author Jaikiran Pai */ @Local public interface LocalEcho { String echo(String message); }
1,211
33.628571
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/view/StatefulEcho.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.ejb.remote.view; import jakarta.ejb.Local; import jakarta.ejb.Stateful; /** * @author Jaikiran Pai */ @Stateful @Local(LocalEcho.class) public class StatefulEcho extends CommonEcho { }
1,251
34.771429
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/suspend/Echo.java
package org.jboss.as.test.integration.ejb.remote.suspend; import jakarta.ejb.Remote; /** * @author Stuart Douglas */ @Remote public interface Echo { String echo(String val); }
186
12.357143
57
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/suspend/PauseEchoBean.java
package org.jboss.as.test.integration.ejb.remote.suspend; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import jakarta.ejb.Lock; import jakarta.ejb.LockType; import jakarta.ejb.Singleton; /** * @author Stuart Douglas */ @Singleton @Lock(LockType.READ) public class PauseEchoBean implements Echo { private volatile CountDownLatch latch = null; @Override public String echo(String val) { if(latch == null) { latch = new CountDownLatch(1); try { latch.await(2, TimeUnit.MINUTES); } catch (InterruptedException e) { throw new RuntimeException(e); } } else { CountDownLatch l = latch; latch = null; l.countDown(); } return val; } }
834
22.194444
57
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/suspend/EjbRemoteSuspendTestCase.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.ejb.remote.suspend; import java.util.Hashtable; import jakarta.ejb.NoSuchEJBException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; 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.junit.InSequence; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.controller.descriptions.ModelDescriptionConstants; import org.jboss.as.test.shared.TimeoutUtil; import org.jboss.dmr.ModelNode; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that remote EJB requests are rejected when the container is suspended. */ @RunWith(Arquillian.class) @RunAsClient public class EjbRemoteSuspendTestCase { private static final String APP_NAME = ""; private static final String DISTINCT_NAME = ""; private static final String MODULE_NAME = "ejb-suspend-test-case"; private static Context context; @ArquillianResource private ManagementClient managementClient; @Deployment public static Archive createDeployment() { final JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, MODULE_NAME + ".jar"); ejbJar.addPackage(EjbRemoteSuspendTestCase.class.getPackage()); return ejbJar; } @BeforeClass public static void beforeClass() throws Exception { final Hashtable props = new Hashtable(); props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); context = new InitialContext(props); } @Test @InSequence(1) public void testSuspendedCallRejected() throws Exception { final Echo localEcho = (Echo) context.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + EchoBean.class.getSimpleName() + "!" + Echo.class.getName() + "?stateful"); final String message = "Silence!"; String echo = localEcho.echo(message); Assert.assertEquals(message, echo); ModelNode op = new ModelNode(); op.get(ModelDescriptionConstants.OP).set("suspend"); managementClient.getControllerClient().execute(op); try { long fin = System.currentTimeMillis() + TimeoutUtil.adjust(5000); while (true) { echo = localEcho.echo(message); if (System.currentTimeMillis() > fin) Assert.fail("call should have been rejected"); Thread.sleep(300); } } catch (NoSuchEJBException expected) { } catch (Exception e) { Assert.fail(e.getMessage() + " thrown but NoSuchEJBException was expected"); } finally { op = new ModelNode(); op.get(ModelDescriptionConstants.OP).set("resume"); managementClient.getControllerClient().execute(op); //we need to make sure the module availbility message has been recieved //(this is why we have InSequence, so avoid two sleep() calls) //otherwise the test might fail intermittently if the message has not been recieved when the //next test is started //this is a somewhat weird construct, basically we just wait up to 5 seconds for the connection //to become usable again long fin = System.currentTimeMillis() + 5000; while (true) { try { localEcho.echo(message); break; } catch (Exception e) { if (System.currentTimeMillis() > fin) { throw e; } } Thread.sleep(300); } } } @Test @InSequence(2) public void testStatefulEjbCreationRejected() throws Exception { ModelNode op = new ModelNode(); op.get(ModelDescriptionConstants.OP).set("suspend"); managementClient.getControllerClient().execute(op); try { long fin = System.currentTimeMillis() + TimeoutUtil.adjust(5000); while (true) { Echo localEcho = (Echo) context.lookup("ejb:" + APP_NAME + "/" + MODULE_NAME + "/" + DISTINCT_NAME + "/" + EchoBean.class.getSimpleName() + "!" + Echo.class.getName() + "?stateful"); if (System.currentTimeMillis() > fin) Assert.fail("call should have been rejected"); Thread.sleep(300); } } catch (NamingException expected) { } finally { op = new ModelNode(); op.get(ModelDescriptionConstants.OP).set("resume"); managementClient.getControllerClient().execute(op); } } }
6,078
37.719745
198
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/suspend/EchoBean.java
package org.jboss.as.test.integration.ejb.remote.suspend; import jakarta.ejb.Stateful; /** * @author Stuart Douglas */ @Stateful public class EchoBean implements Echo { @Override public String echo(String val) { return val; } }
252
15.866667
57
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/requestdeserialization/HelloRemote.java
package org.jboss.as.test.integration.ejb.remote.requestdeserialization; import jakarta.ejb.Remote; @Remote public interface HelloRemote { Response sayHello(Request request); }
185
15.909091
72
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/requestdeserialization/HelloBean.java
package org.jboss.as.test.integration.ejb.remote.requestdeserialization; import jakarta.ejb.Stateless; @Stateless public class HelloBean implements HelloRemote { @Override public Response sayHello(Request request) { // relay the TCCL that was set during request unmarshalling return new Response(request.getGreeting(), request.getTccl().toString()); } }
384
28.615385
81
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/requestdeserialization/RequestDeserializationTestCase.java
package org.jboss.as.test.integration.ejb.remote.requestdeserialization; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.not; import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.hamcrest.MatcherAssert; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(Arquillian.class) public class RequestDeserializationTestCase { @Deployment public static Archive<?> createDeployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, RequestDeserializationTestCase.class.getSimpleName() + ".jar"); jar.addPackage(RequestDeserializationTestCase.class.getPackage()); return jar; } protected <T> T lookup(String beanName, Class<T> interfaceType) throws NamingException { final Hashtable<String, String> props = new Hashtable<>(); // props.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); props.put("java.naming.factory.initial","org.wildfly.naming.client.WildFlyInitialContextFactory"); final Context jndiContext = new InitialContext(props); return interfaceType.cast(jndiContext.lookup(String.format("ejb:/%s/%s!%s", getClass().getSimpleName(), beanName, interfaceType.getName()))); } @Test @RunAsClient public void test() throws NamingException { HelloRemote bean = lookup(HelloBean.class.getSimpleName(), HelloRemote.class); Response response = bean.sayHello(new Request("Cheers")); // check the TCCL used during unmarshalling of parameters on the server side, it should be the deployment // classloader, not the "org.wildfly.extension.io" module classloader MatcherAssert.assertThat(response.getTccl(), not(containsString("org.wildfly.extension.io"))); MatcherAssert.assertThat(response.getTccl(), containsString(getClass().getSimpleName())); } }
2,280
42.037736
126
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/requestdeserialization/UnmarshallingFilterTestCase.java
/* * Copyright (c) 2020. 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.ejb.remote.requestdeserialization; import java.io.Serializable; import java.util.HashSet; import jakarta.ejb.EJBException; import javax.naming.NamingException; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.as.arquillian.api.ServerSetup; import org.jboss.as.arquillian.api.ServerSetupTask; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.integration.security.common.CoreUtils; import org.jboss.as.test.shared.ServerReload; import org.jboss.as.test.shared.util.AssumeTestGroupUtil; import org.jboss.dmr.ModelNode; import org.jboss.shrinkwrap.api.Archive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(Arquillian.class) @ServerSetup(UnmarshallingFilterTestCase.ServerSetup.class) public class UnmarshallingFilterTestCase extends AbstactUnmarshallingFilterTestCase { public static class ServerSetup implements ServerSetupTask { private static final PathAddress DESERIALTEMPLATE_ADDRESS = PathAddress.pathAddress("system-property", "jdk.xml.enableTemplatesImplDeserialization"); @Override public void setup(ManagementClient managementClient, String s) throws Exception { if (AssumeTestGroupUtil.isSecurityManagerEnabled()) { //When SM is enabled, deserializing TemplatesImpl in JDK is disabled and //set the jdk.xml.enableTemplatesImplDeserialization system property //to enable it, then we can test if the blockerlist works ModelNode templateOp = Util.createAddOperation(DESERIALTEMPLATE_ADDRESS); templateOp.get("value").set("true"); CoreUtils.applyUpdate(templateOp, managementClient.getControllerClient()); } } @Override public void tearDown(ManagementClient managementClient, String s) throws Exception { if (AssumeTestGroupUtil.isSecurityManagerEnabled()) { ModelNode removeOp = Util.createRemoveOperation(DESERIALTEMPLATE_ADDRESS); CoreUtils.applyUpdate(removeOp, managementClient.getControllerClient()); } // This test results in construction of a org.jboss.ejb.protocol.remote.EJBClientChannel // in the server which affects the behavior of later tests. So reload to clear it out. ServerReload.executeReloadAndWaitForCompletion(managementClient); } } @Deployment public static Archive<?> createDeployment() { return createDeployment(UnmarshallingFilterTestCase.class); } @Test public void testRemotingBlocklist() throws NamingException { testBlocklist(false); } @Test public void testHttpBlocklist() throws NamingException { testBlocklist(true); } private void testBlocklist(boolean http) throws NamingException { HelloRemote bean = lookup(HelloBean.class.getSimpleName(), HelloRemote.class, http); Serializable blocklisted = getTemplatesImpl(); try { Response response = bean.sayHello(new Request(blocklisted)); Assert.fail(response.getGreeting()); } catch (EJBException good) { // } try { HashSet<Serializable> set = new HashSet<>(); set.add(blocklisted); Response response = bean.sayHello(new Request(set)); Assert.fail(response.getGreeting()); } catch (EJBException good) { // } } }
4,315
39.716981
105
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/requestdeserialization/Request.java
package org.jboss.as.test.integration.ejb.remote.requestdeserialization; import java.io.Externalizable; import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; import java.io.Serializable; public class Request implements Externalizable { private Serializable greeting; private transient ClassLoader tccl; public Request() { } public Request(Serializable greeting) { this.greeting = greeting; } public String getGreeting() { return greeting == null ? null : greeting.toString(); } public ClassLoader getTccl() { return tccl; } @Override public void writeExternal(ObjectOutput out) throws IOException { out.writeObject(greeting); } @Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { greeting = (Serializable) in.readObject(); tccl = Thread.currentThread().getContextClassLoader(); // save a reference to current TCCL } }
1,014
24.375
98
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/requestdeserialization/AbstactUnmarshallingFilterTestCase.java
/* * Copyright (c) 2020. 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.ejb.remote.requestdeserialization; import static org.jboss.as.test.shared.PermissionUtils.createPermissionsXmlAsset; import java.io.Serializable; import java.net.SocketPermission; import java.net.URL; import java.util.Hashtable; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.shared.TestSuiteEnvironment; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; public class AbstactUnmarshallingFilterTestCase { static Archive<?> createDeployment(Class clazz) { String SERVER_HOST_PORT = TestSuiteEnvironment.getHttpAddress() + ":" + TestSuiteEnvironment.getHttpPort(); return ShrinkWrap.create(JavaArchive.class, clazz.getSimpleName() + ".jar") .addPackage(AbstactUnmarshallingFilterTestCase.class.getPackage()) .addAsManifestResource(createPermissionsXmlAsset( new SocketPermission(SERVER_HOST_PORT, "connect,resolve"), new RuntimePermission("accessClassInPackage.com.sun.org.apache.xalan.internal.xsltc.trax") ), "permissions.xml"); } @ArquillianResource private URL url; <T> T lookup(String beanName, Class<T> interfaceType, boolean http) throws NamingException { final Context jndiContext = getContext(http); return interfaceType.cast(jndiContext.lookup(String.format("ejb:/%s/%s!%s", getClass().getSimpleName(), beanName, interfaceType.getName()))); } private Context getContext(boolean http) throws NamingException { final Hashtable<String, String> jndiProperties = new Hashtable<>(); jndiProperties.put(Context.INITIAL_CONTEXT_FACTORY, "org.wildfly.naming.client.WildFlyInitialContextFactory"); jndiProperties.put(Context.SECURITY_PRINCIPAL, "user1"); jndiProperties.put(Context.SECURITY_CREDENTIALS, "password1"); String addressPort = url.getHost() + ":" + url.getPort(); if (http) { // use HTTP based invocation. Each invocation will be a HTTP request jndiProperties.put(Context.PROVIDER_URL, "http://" + addressPort + "/wildfly-services"); } else { // use HTTP upgrade, an initial upgrade requests is sent to upgrade to the // remoting protocol jndiProperties.put(Context.PROVIDER_URL, "remote+http://" + addressPort); } return new InitialContext(jndiProperties); } static Serializable getTemplatesImpl() { // Use reflection so we don't need this class on the compilation classpath // This call executes in the server in a deployment that has this class's module // configured as a dependency try { return (Serializable) Class.forName("com.sun.org.apache.xalan.internal.xsltc.trax.TemplatesImpl").newInstance(); } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) { throw new RuntimeException(e); } } }
3,805
41.764045
124
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/requestdeserialization/UnmarshallingFilterDisabledTestCase.java
/* * Copyright (c) 2020. 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.ejb.remote.requestdeserialization; import java.io.Serializable; import javax.naming.NamingException; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.as.arquillian.api.ServerSetup; import org.jboss.as.arquillian.api.ServerSetupTask; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.integration.security.common.CoreUtils; import org.jboss.as.test.shared.ServerReload; import org.jboss.as.test.shared.util.AssumeTestGroupUtil; import org.jboss.dmr.ModelNode; import org.jboss.shrinkwrap.api.Archive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(Arquillian.class) @ServerSetup(UnmarshallingFilterDisabledTestCase.ServerSetup.class) public class UnmarshallingFilterDisabledTestCase extends AbstactUnmarshallingFilterTestCase { // Disables unmarshalling blocklisting. public static class ServerSetup implements ServerSetupTask { private static final PathAddress DESERIALTEMPLATE_ADDRESS = PathAddress.pathAddress("system-property", "jdk.xml.enableTemplatesImplDeserialization"); private static final PathAddress PROP_ADDRESS = PathAddress.pathAddress("system-property", "jboss.ejb.unmarshalling.filter.disabled"); @Override public void setup(ManagementClient managementClient, String s) throws Exception { if (AssumeTestGroupUtil.isSecurityManagerEnabled()) { //When SM is enabled, deserializing TemplatesImpl in JDK is disabled and //set the jdk.xml.enableTemplatesImplDeserialization system property //to enable it ModelNode templateOp = Util.createAddOperation(DESERIALTEMPLATE_ADDRESS); templateOp.get("value").set("true"); CoreUtils.applyUpdate(templateOp, managementClient.getControllerClient()); } ModelNode op = Util.createAddOperation(PROP_ADDRESS); op.get("value").set("true"); CoreUtils.applyUpdate(op, managementClient.getControllerClient()); ServerReload.executeReloadAndWaitForCompletion(managementClient); } @Override public void tearDown(ManagementClient managementClient, String s) throws Exception { if (AssumeTestGroupUtil.isSecurityManagerEnabled()) { CoreUtils.applyUpdate(Util.createRemoveOperation(DESERIALTEMPLATE_ADDRESS), managementClient.getControllerClient()); } ModelNode removeOp = Util.createRemoveOperation(PROP_ADDRESS); CoreUtils.applyUpdate(removeOp, managementClient.getControllerClient()); ServerReload.executeReloadAndWaitForCompletion(managementClient); } } @Deployment public static Archive<?> createDeployment() { return createDeployment(UnmarshallingFilterDisabledTestCase.class); } @Test public void testRemoting() throws NamingException { testBlocklistDisabled(false); } @Test public void testHttp() throws NamingException { testBlocklistDisabled(true); } private void testBlocklistDisabled(boolean http) throws NamingException { HelloRemote bean = lookup(HelloBean.class.getSimpleName(), HelloRemote.class, http); Serializable blocklisted = getTemplatesImpl(); Response response = bean.sayHello(new Request(blocklisted)); Assert.assertTrue(response.getGreeting(), response.getGreeting().contains("TemplatesImpl")); } }
4,307
42.515152
158
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/requestdeserialization/Response.java
package org.jboss.as.test.integration.ejb.remote.requestdeserialization; import java.io.Serializable; public class Response implements Serializable { private Serializable greeting; private String tccl; public Response() { } public Response(String greeting, String tccl) { this.greeting = greeting; this.tccl = tccl; } public String getGreeting() { return greeting == null ? null : greeting.toString(); } public String getTccl() { return tccl; } }
527
18.555556
72
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/RemoteByReferenceException.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; public class RemoteByReferenceException extends Exception { private NonSerializableObject nonSerializableObject; public RemoteByReferenceException() { super(); nonSerializableObject = new NonSerializableObject("null"); } public RemoteByReferenceException(String msg) { super(msg); nonSerializableObject = new NonSerializableObject(msg); } }
1,484
36.125
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/HelloRemote.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; import jakarta.ejb.Remote; @Remote public interface HelloRemote { public TransferReturnValue hello ( TransferParameter param ) throws RemoteByReferenceException; public SerializableObject helloSerializable ( SerializableObject param ) throws RemoteByReferenceException; public NonSerializableObject helloNonSerializable(NonSerializableObject param) throws RemoteByReferenceException; public SerializableObject helloNonSerializableToSerializable(NonSerializableObject param) throws RemoteByReferenceException; public NonSerializableObject helloSerializableToNonSerializable(SerializableObject param) throws RemoteByReferenceException; }
1,749
42.75
128
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/HelloBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; import jakarta.ejb.Stateless; import org.jboss.logging.Logger; @Stateless public class HelloBean implements HelloRemote { private final Logger log = Logger.getLogger(this.getClass()); public TransferReturnValue hello ( TransferParameter param ) throws RemoteByReferenceException { log.debug("hello("+ param +") = Hello " + param ); if(param == null) throw new RemoteByReferenceException("Param was null"); return new TransferReturnValue ( "Hello " + param ); } @Override public SerializableObject helloSerializable(SerializableObject param) throws RemoteByReferenceException { log.debug("helloserializable("+ param +") = Hello " + param ); if(param == null) throw new RemoteByReferenceException("Param was null"); param.setValue("Bye"); return param; } @Override public NonSerializableObject helloNonSerializable(NonSerializableObject param) throws RemoteByReferenceException { log.debug("helloserializable("+ param +") = Hello " + param ); if(param == null) throw new RemoteByReferenceException("Param was null"); param.setValue("Bye"); return param; } @Override public SerializableObject helloNonSerializableToSerializable(NonSerializableObject param) throws RemoteByReferenceException { log.debug("helloserializable("+ param +") = Hello " + param ); if(param == null) throw new RemoteByReferenceException("Param was null"); param.setValue("Bye"); return new SerializableObject(param.getValue()); } @Override public NonSerializableObject helloSerializableToNonSerializable(SerializableObject param) throws RemoteByReferenceException { log.debug("helloserializable("+ param +") = Hello " + param ); if(param == null) throw new RemoteByReferenceException("Param was null"); param.setValue("Bye"); return new NonSerializableObject(param.getValue()); } }
3,154
34.449438
118
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/SerializableObject.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; import java.io.Serializable; public class SerializableObject implements Serializable { private String value; public SerializableObject() { } public SerializableObject(String value) { this.value = value; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public String toString() { return value; } }
1,522
29.46
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/TransferReturnValue.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; /** * A return value class that does not implement serializable */ public class TransferReturnValue { private String value; public TransferReturnValue() { } public TransferReturnValue( String value ) { this.value = value; } public String getValue() { return value; } public void setValue ( String value ) { this.value = value; } public String getString() { return value; } }
1,545
29.92
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/RemoteInvocationByReferenceTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; import javax.naming.InitialContext; import javax.naming.NamingException; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.arquillian.api.ServerSetup; import org.jboss.as.arquillian.api.ServerSetupTask; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.test.integration.ejb.remote.common.EJBManagementUtil; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that the EJB subsystem can be configured for pass-by-reference semantics for in-vm invocations on * remote interfaces of EJBs * * @author Jaikiran Pai */ @RunWith(Arquillian.class) @ServerSetup(RemoteInvocationByReferenceTestCase.RemoteInvocationByReferenceTestCaseSetup.class) public class RemoteInvocationByReferenceTestCase { private static final String ARCHIVE_NAME = "in-vm-remote-interface-pass-by-reference-test"; static class RemoteInvocationByReferenceTestCaseSetup implements ServerSetupTask { @Override public void setup(final ManagementClient managementClient, final String containerId) throws Exception { // setup pass-by-reference semantics // we do this here instead of a separate @BeforeClass method because of some weirdness // with the ordering of the @BeforeClass execution and deploying the deployment by Arquillian EJBManagementUtil.disablePassByValueForRemoteInterfaceInvocations(managementClient); } @Override public void tearDown(final ManagementClient managementClient, final String containerId) throws Exception { // switch back to the default pass-by-value semantics EJBManagementUtil.undefinePassByValueForRemoteInterfaceInvocations(managementClient); } } @ArquillianResource private InitialContext iniCtx; @Deployment public static Archive<?> createDeployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, ARCHIVE_NAME + ".jar"); jar.addClasses(StatelessRemoteBean.class, RemoteInterface.class, RemoteInvocationByReferenceTestCaseSetup.class, RemoteByReferenceException.class, NonSerializableObject.class, HelloBean.class, HelloRemote.class, TransferParameter.class, TransferReturnValue.class, SerializableObject.class); return jar; } protected <T> T lookup(String beanName, Class<T> interfaceType) throws NamingException { return interfaceType.cast(iniCtx.lookup("java:global/" + ARCHIVE_NAME + "/" + beanName + "!" + interfaceType.getName())); } /** * Test that invocation on a remote interface of an EJB uses pass-by-reference semantics * * @throws Exception */ @Test public void testPassByReferenceSemanticsOnRemoteInterface() throws Exception { final String[] array = {"hello"}; final RemoteInterface remote = lookup(StatelessRemoteBean.class.getSimpleName(), RemoteInterface.class); final String newValue = "foo"; // invoke on the remote interface remote.modifyFirstElementOfArray(array, newValue); Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference semantics", newValue, array[0]); } /** * Test that invocation on a remote interface of an EJB uses pass-by-reference semantics and the Exception also is pass-by-reference * @throws Exception */ @Test public void testPassByReferenceObjectAndException() throws Exception { final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class); // invoke on the remote interface TransferReturnValue ret = remote.hello(new TransferParameter(this.getClass().getSimpleName())); Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Hello " + this.getClass().getSimpleName()); try { remote.hello(null); } catch(RemoteByReferenceException he) { Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null"); } } @Test public void testPassByReferenceNonSerializableAndException() throws Exception { final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class); // invoke on the remote interface NonSerializableObject ret = remote.helloNonSerializable(new NonSerializableObject("Hello")); Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Bye"); try { remote.helloNonSerializable(null); } catch(RemoteByReferenceException he) { Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null"); } } @Test public void testPassByReferenceSerializable() throws Exception { final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class); // invoke on the remote interface SerializableObject ret = remote.helloSerializable(new SerializableObject("Hello")); Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Bye"); try { remote.helloSerializable(null); } catch(RemoteByReferenceException he) { Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null"); } } @Test public void testPassByReferenceSerializableToNonSerializable() throws Exception { final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class); // invoke on the remote interface NonSerializableObject ret = remote.helloSerializableToNonSerializable(new SerializableObject("Hello")); Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Bye"); try { remote.helloSerializableToNonSerializable(null); } catch(RemoteByReferenceException he) { Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null"); } } @Test public void testPassByReferenceNonSerializableToSerializable() throws Exception { final HelloRemote remote = lookup(HelloBean.class.getSimpleName(), HelloRemote.class); // invoke on the remote interface SerializableObject ret = remote.helloNonSerializableToSerializable(new NonSerializableObject("Hello")); Assert.assertEquals("Invocation on remote interface of Hello did *not* use pass-by-reference semantics", ret.getValue(), "Bye"); try { remote.helloNonSerializableToSerializable(null); } catch(RemoteByReferenceException he) { Assert.assertEquals("Invocation on remote interface of an EJB did *not* use pass-by-reference in exception", he.getMessage(), "Param was null"); } } }
8,559
47.914286
183
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/NonSerializableObject.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; public class NonSerializableObject { private String value; public NonSerializableObject() { } public NonSerializableObject(String value) { this.value = value; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } public String toString() { return value; } }
1,477
29.791667
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/RemoteInterface.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; /** * @author Jaikiran Pai */ public interface RemoteInterface { void modifyFirstElementOfArray(final String[] array, final String newValue); }
1,238
37.71875
80
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/StatelessRemoteBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; import jakarta.ejb.Remote; import jakarta.ejb.Stateless; /** * @author Jaikiran Pai */ @Stateless @Remote(RemoteInterface.class) public class StatelessRemoteBean implements RemoteInterface { @Override public void modifyFirstElementOfArray(String[] array, String newValue) { array[0] = newValue; } }
1,411
33.439024
76
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/remote/byreference/TransferParameter.java
/* * JBoss, Home of Professional Open Source. * Copyright 2019, 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.ejb.remote.byreference; /** * A class that does not implement serializable used in pass-by-reference */ public class TransferParameter { private String value; public TransferParameter() { } public TransferParameter( String value ) { this.value = value; } public String getValue() { return value; } public void setValue ( String value ) { this.value = value; } public String toString() { return value; } }
1,552
29.45098
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/threadpool/ScheduleSingletonOneTimer.java
/* * JBoss, Home of Professional Open Source. * Copyright 2010, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.threadpool; import jakarta.ejb.Schedule; import jakarta.ejb.Singleton; import jakarta.ejb.Startup; import jakarta.ejb.Timer; import java.util.Collections; import java.util.Set; import java.util.concurrent.ConcurrentSkipListSet; @Startup @Singleton public class ScheduleSingletonOneTimer { private final ConcurrentSkipListSet<String> threadNames = new ConcurrentSkipListSet<String>(); @Schedule(second="*/1", minute="*", hour="*", persistent=false) public void timeout(Timer t) { threadNames.add(Thread.currentThread().getName()); } public Set<String> getThreadNames() { return Collections.unmodifiableSet(threadNames); } }
1,735
34.428571
98
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/threadpool/Ejb3ThreadPoolBase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2010, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.threadpool; import static org.jboss.as.test.shared.integration.ejb.security.PermissionUtils.createPermissionsXmlAsset; import java.io.FilePermission; import javax.naming.InitialContext; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.integration.management.ManagementOperations; import org.jboss.as.test.integration.management.util.MgmtOperationException; import org.jboss.dmr.ModelNode; import org.jboss.remoting3.security.RemotingPermission; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; public class Ejb3ThreadPoolBase { static PathAddress DEFAULT_THREAD_POOL_ADDRESS = PathAddress.pathAddress("subsystem", "ejb3").append("thread-pool", "default"); @ArquillianResource static ManagementClient managementClient; @ArquillianResource InitialContext iniCtx; @Deployment public static Archive<?> deploy() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb3singleton.jar"); jar.addClass(ScheduleSingletonOneTimer.class); jar.addClasses(Ejb3ThreadPoolBase.class, Ejb3NonCoreThreadTimeoutTestCase.class, ModelNode.class, PathAddress.class, ManagementOperations.class, MgmtOperationException.class); jar.addAsManifestResource(new StringAsset("Dependencies: org.jboss.remoting, org.jboss.as.controller\n"), "MANIFEST.MF"); jar.addAsManifestResource(createPermissionsXmlAsset( new RemotingPermission("createEndpoint"), new RemotingPermission("connect"), new FilePermission(System.getProperty("jboss.inst") + "/standalone/tmp/auth/*", "read") ), "permissions.xml"); return jar; } void waitUntilThreadPoolProcessedAtLeast(int tasks, long timeoutInMillis) throws Exception { long startTime = System.currentTimeMillis(); ModelNode readTasks = Util.getReadAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "completed-task-count"); int actualTaskCount; while ((actualTaskCount = executeOperation(readTasks).asInt()) < tasks) { if (System.currentTimeMillis() - startTime > timeoutInMillis) { Assert.fail("There are not enough tasks (expected: " + tasks + ", actual: " + actualTaskCount + ") processed by thread pool in timeout " + timeoutInMillis); } Thread.sleep(500); } } ModelNode readAttribute(String attribute) throws Exception { return executeOperation(Util.getReadAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, attribute)); } static ModelNode executeOperation(ModelNode op) throws Exception { ModelNode result = ManagementOperations.executeOperation(managementClient.getControllerClient(), op); return result; } }
4,201
45.175824
172
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/threadpool/Ejb3NonCoreThreadTimeoutTestCase.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.ejb.threadpool; import org.jboss.arquillian.junit.Arquillian; import org.jboss.as.arquillian.api.ServerSetup; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.integration.management.ManagementOperations; import org.jboss.as.test.shared.SnapshotRestoreSetupTask; import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Ejb3NonCoreThreadTimeoutTestCase - start EJB singleton with 1 sec timer and check that threads timeout * <p> * * @author Miroslav Novak */ @RunWith(Arquillian.class) @ServerSetup(Ejb3NonCoreThreadTimeoutTestCase.ServerSetup.class) public class Ejb3NonCoreThreadTimeoutTestCase extends Ejb3ThreadPoolBase { private static final int MAX_THREADS = 10; private static final int CORE_THREADS = 0; private static final long KEEEP_ALIVE_TIME = 10; private static final String KEEP_ALIVE_TIME_UNIT = "MILLISECONDS"; @Test public void testThreadTimeout() throws Exception { ScheduleSingletonOneTimer scheduleSingletonLocal = (ScheduleSingletonOneTimer) iniCtx.lookup("java:module/" + ScheduleSingletonOneTimer.class.getSimpleName() + "!" + ScheduleSingletonOneTimer.class.getName()); waitUntilThreadPoolProcessedAtLeast(2, 10000); Assert.assertTrue("There must be at least 2 different threads as at least 2 tasks were processed and" + " in different threads", scheduleSingletonLocal.getThreadNames().size() > 1); } public static class ServerSetup extends SnapshotRestoreSetupTask { protected void doSetup(ManagementClient client, String containerId) throws Exception { // create one ModelNode writeMaxThreadsOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "max-threads", MAX_THREADS); ModelNode writeCoreThreadsOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "core-threads", CORE_THREADS); ModelNode writeKeepAliveTimeOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "keepalive-time", new ModelNode().get("keepalive-time").set(new ModelNode().add("unit", KEEP_ALIVE_TIME_UNIT) .add("time", KEEEP_ALIVE_TIME))); ManagementOperations.executeOperation(client.getControllerClient(), writeMaxThreadsOp); ManagementOperations.executeOperation(client.getControllerClient(), writeCoreThreadsOp); ManagementOperations.executeOperation(client.getControllerClient(), writeKeepAliveTimeOp); } } }
3,715
47.25974
134
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/threadpool/Ejb3ThreadReuseTestCase.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.ejb.threadpool; import org.jboss.arquillian.junit.Arquillian; import org.jboss.as.arquillian.api.ServerSetup; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.shared.SnapshotRestoreSetupTask; import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Ejb3ThreadReuseTestCase - start EJB singleton with 1 sec timer and check that single thread is reused * <p> * * @author Miroslav Novak */ @RunWith(Arquillian.class) @ServerSetup(Ejb3ThreadReuseTestCase.ServerSetup.class) public class Ejb3ThreadReuseTestCase extends Ejb3ThreadPoolBase { private static final int MAX_THREADS = 10; private static final int CORE_THREADS = 0; private static final long KEEEP_ALIVE_TIME = 100; private static final String KEEP_ALIVE_TIME_UNIT = "SECONDS"; @Test public void testNonCoreThreadReused() throws Exception { ScheduleSingletonOneTimer scheduleSingletonLocal = (ScheduleSingletonOneTimer) iniCtx.lookup("java:module/" + ScheduleSingletonOneTimer.class.getSimpleName() + "!" + ScheduleSingletonOneTimer.class.getName()); // check that at least 3 tasks were processed by thread pool and then verify that there is still just one thread waitUntilThreadPoolProcessedAtLeast(2, 10000); Assert.assertEquals("Number of threads in pool must be 1.", 1, readAttribute("current-thread-count").asInt()); // verify that it's still the same thread Assert.assertEquals("There is always different thread processing tasks but it should be one.", 1, scheduleSingletonLocal.getThreadNames().size()); } public static class ServerSetup extends SnapshotRestoreSetupTask { protected void doSetup(ManagementClient client, String containerId) throws Exception { // create one ModelNode writeMaxThreadsOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "max-threads", MAX_THREADS); ModelNode writeCoreThreadsOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "core-threads", CORE_THREADS); ModelNode writeKeepAliveTimeOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "keepalive-time", new ModelNode().get("keepalive-time").set(new ModelNode().add("unit", KEEP_ALIVE_TIME_UNIT) .add("time", KEEEP_ALIVE_TIME))); executeOperation(writeMaxThreadsOp); executeOperation(writeCoreThreadsOp); executeOperation(writeKeepAliveTimeOp); } } }
3,747
45.271605
134
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/threadpool/Ejb3ThreadPoolModelTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2010, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.threadpool; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; import org.jboss.as.arquillian.api.ServerSetup; import org.jboss.as.controller.PathAddress; import org.jboss.as.controller.operations.common.Util; import org.jboss.as.test.integration.common.DefaultConfiguration; import org.jboss.as.test.shared.SnapshotRestoreSetupTask; import org.jboss.dmr.ModelNode; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import javax.management.MBeanServerConnection; import javax.management.ObjectName; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import java.util.Set; /** * @author Miroslav Novak */ @RunWith(Arquillian.class) @RunAsClient @ServerSetup(SnapshotRestoreSetupTask.class) public class Ejb3ThreadPoolModelTestCase extends Ejb3ThreadPoolBase { private PathAddress myPoolPathAddress = PathAddress.pathAddress("subsystem", "ejb3").append("thread-pool", "myPool"); @Test public void testCreateRemoveThreadPool() throws Exception { int maxThreads = 27; int coreThreads = 6; long keepAliveTime = 18; String keepAliveTimeUnit = "SECONDS"; // we don't know exact name of thread pool created for ejb3 subsystem in jboss-threads // thus we create one and query based on attributes // first make sure there is no such thread pool final MBeanServerConnection mbs = getMBeanServerConnection(); Set<ObjectName> objs = mbs.queryNames(new ObjectName("jboss.threads:name=*,type=thread-pool"), null); Assert.assertEquals("There is already thread pool with given params but it shouldn't be.", 0, objs.stream() .filter((o) -> ((int) readAttributeValueFromMBeanObject(mbs, o, "MaximumPoolSize")) == maxThreads) .filter((o) -> ((int) readAttributeValueFromMBeanObject(mbs, o, "CorePoolSize")) == coreThreads) .filter((o) -> ((long) readAttributeValueFromMBeanObject(mbs, o, "KeepAliveTimeSeconds")) == keepAliveTime) .count()); // create one ModelNode addThreadPool = Util.createAddOperation(myPoolPathAddress); addThreadPool.get("max-threads").set(maxThreads); addThreadPool.get("core-threads").set(coreThreads); addThreadPool.get("keepalive-time").set(new ModelNode().add("unit", keepAliveTimeUnit) .add("time", keepAliveTime)); executeOperation(addThreadPool); final MBeanServerConnection mbs2 = getMBeanServerConnection(); objs = mbs2.queryNames(new ObjectName("jboss.threads:name=*,type=thread-pool"), null); Assert.assertEquals("Thread pool was not created or does not have given params.", 1, objs.stream() .filter((o) -> ((int) readAttributeValueFromMBeanObject(mbs2, o, "MaximumPoolSize")) == maxThreads) .filter((o) -> ((int) readAttributeValueFromMBeanObject(mbs2, o, "CorePoolSize")) == coreThreads) .filter((o) -> ((long) readAttributeValueFromMBeanObject(mbs2, o, "KeepAliveTimeSeconds")) == keepAliveTime) .count()); ModelNode removeThreadPool = Util.createRemoveOperation(myPoolPathAddress); executeOperation(removeThreadPool); } @Test public void testWriteReadAttributes() throws Exception { int maxThreads = 12; int coreThreads = 4; long keepAliveTime = 5; String keepAliveTimeUnit = "SECONDS"; // create one ModelNode writeMaxThreadsOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "max-threads", maxThreads); ModelNode writeCoreThreadsOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "core-threads", coreThreads); ModelNode writeKeepAliveTimeOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "keepalive-time", new ModelNode().get("keepalive-time").set(new ModelNode().add("unit", keepAliveTimeUnit) .add("time", keepAliveTime))); executeOperation(writeMaxThreadsOp); executeOperation(writeCoreThreadsOp); executeOperation(writeKeepAliveTimeOp); // read from mbean final MBeanServerConnection mbs2 = getMBeanServerConnection(); Set<ObjectName> objs = mbs2.queryNames(new ObjectName("jboss.threads:name=*,type=thread-pool"), null); Assert.assertEquals("Parameters were not applied into thread-pool " + DEFAULT_THREAD_POOL_ADDRESS, 1, objs.stream() .filter((o) -> ((int) readAttributeValueFromMBeanObject(mbs2, o, "MaximumPoolSize")) == maxThreads) .filter((o) -> ((int) readAttributeValueFromMBeanObject(mbs2, o, "CorePoolSize")) == coreThreads) .filter((o) -> ((long) readAttributeValueFromMBeanObject(mbs2, o, "KeepAliveTimeSeconds")) == keepAliveTime) .count()); // read from CLI ModelNode readMaxThreadsOp = Util.getReadAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "max-threads"); ModelNode readCoreThreadsOp = Util.getReadAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "core-threads"); ModelNode readKeepAliveOp = Util.getReadAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "keepalive-time"); Assert.assertEquals(maxThreads, executeOperation(readMaxThreadsOp).asInt()); Assert.assertEquals(coreThreads, executeOperation(readCoreThreadsOp).asInt()); ModelNode readKeepAliveTime = executeOperation(readKeepAliveOp); Assert.assertEquals(readKeepAliveTime.get("time").asLong(), keepAliveTime); Assert.assertEquals(readKeepAliveTime.get("unit").asString(), keepAliveTimeUnit); } @Test(expected = Exception.class) public void testNegativeMaxThreadValue() throws Exception { ModelNode writeMaxThreadsOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "max-threads", -12); executeOperation(writeMaxThreadsOp); } @Test(expected = Exception.class) public void testNegativeCoreThreadValue() throws Exception { ModelNode writeCoreThreadsOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "core-threads", -12); executeOperation(writeCoreThreadsOp); } @Test(expected = Exception.class) public void testNegativeKeepAliveTimeoutValue() throws Exception { ModelNode writeKeepAliveTimeOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "keepalive-time", new ModelNode().get("keepalive-time").set(new ModelNode().add("unit", "SECONDS") .add("time", -12))); executeOperation(writeKeepAliveTimeOp); } @Test(expected = Exception.class) public void testIllegalTimeUnitValue() throws Exception { ModelNode writeKeepAliveTimeOp = Util.getWriteAttributeOperation(DEFAULT_THREAD_POOL_ADDRESS, "keepalive-time", new ModelNode().get("keepalive-time").set(new ModelNode().add("unit", "BADUNIT") .add("time", 12))); executeOperation(writeKeepAliveTimeOp); } private MBeanServerConnection getMBeanServerConnection() throws Exception { final String address = managementClient.getMgmtAddress() + ":" + managementClient.getMgmtPort(); JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL("service:jmx:remote+http://" + address), DefaultConfiguration.credentials()); return connector.getMBeanServerConnection(); } private Object readAttributeValueFromMBeanObject(MBeanServerConnection mbs, ObjectName o, String attribute) { try { return mbs.getAttribute(o, attribute); } catch (Exception ex) { throw new RuntimeException(ex); } } }
9,055
50.748571
156
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/java8/Airplane.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, 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.ejb.java8; import jakarta.ejb.Local; @Local public interface Airplane { static boolean barrelRoll() { return true; } boolean takeOff(); String getPlaneType(); }
1,251
32.837838
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/java8/Java8InterfacesEJBTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, 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.ejb.java8; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.classfilewriter.InvalidBytecodeException; 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; /** * Verifies that deployment does not fail with {@link InvalidBytecodeException} if EJB's local interface declares a static method (Java 8 feature). * See WFLY-4316 for details. * * @author Jozef Hartinger * @author Stuart Douglas */ @RunWith(Arquillian.class) public class Java8InterfacesEJBTestCase { @Inject private Airplane airplane; @Deployment public static Archive<?> getDeployment() { return ShrinkWrap.create(WebArchive.class).addPackage(Java8InterfacesEJBTestCase.class.getPackage()); } @Test public void testDeploymentWorks() { Assert.assertTrue(Airplane.barrelRoll()); Assert.assertTrue(airplane.takeOff()); } // See https://issues.jboss.org/browse/WFCORE-3512 @Test public void testDefaultMethodWorks() { Assert.assertEquals("Cargo", airplane.getPlaneType()); } }
2,354
34.149254
147
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/java8/CargoPlane.java
package org.jboss.as.test.integration.ejb.java8; public interface CargoPlane extends Airplane { default String getPlaneType() { return "Cargo"; } }
166
17.555556
48
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/java8/AirplaneImpl.java
/* * JBoss, Home of Professional Open Source. * Copyright 2015, 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.ejb.java8; import jakarta.ejb.Stateful; @Stateful public class AirplaneImpl implements CargoPlane { @Override public boolean takeOff() { return true; } }
1,239
34.428571
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/AnnotatedGreeterBean.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.descriptor; import jakarta.ejb.Stateless; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @Stateless(name = "AnnotatedGreeter") public class AnnotatedGreeterBean { public String greet(String name) { return "Hi " + name; } }
1,336
37.2
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/MergedDescriptorTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.descriptor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import javax.naming.InitialContext; import javax.naming.NameNotFoundException; import javax.naming.NamingException; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Test; import org.junit.runner.RunWith; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @RunWith(Arquillian.class) public class MergedDescriptorTestCase extends AbstractCustomDescriptorTests { @Deployment public static Archive<?> deployment() { final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb-descriptor-test.jar") .addPackage(DescriptorGreeterBean.class.getPackage()) .addAsManifestResource(MergedDescriptorTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml") .addAsManifestResource(MergedDescriptorTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml"); return jar; } @ArquillianResource private InitialContext ctx; @Test public void testAnnotated() throws NamingException { try { final AnnotatedGreeterBean bean = (AnnotatedGreeterBean) ctx.lookup("java:global/ejb-descriptor-test/AnnotatedGreeter!org.jboss.as.test.integration.ejb.descriptor.AnnotatedGreeterBean"); final String name = "testAnnotated"; final String result = bean.greet(name); assertEquals("Hi testAnnotated", result); } catch (NameNotFoundException e) { fail(e.getMessage()); } } @Test public void testSpec() throws NamingException { try { final DescriptorGreeterBean bean = (DescriptorGreeterBean) ctx.lookup("java:global/ejb-descriptor-test/SpecGreeter"); final String name = "testSpec"; final String result = bean.greet(name); assertEquals("Hi testSpec", result); } catch (NameNotFoundException e) { fail(e.getMessage()); } } /** * AS7-2634 The @Singleton annotation should be used to determine that the bean definied in ejb-jar.xml is a singleton * bean. */ @Test public void testSessionTypeCanBeDeterminedFromAnnotation() throws NamingException { try { SessionTypeSpecifiedBean bean = (SessionTypeSpecifiedBean) ctx.lookup("java:module/SessionTypeSpecifiedBean"); assertEquals(0, bean.increment()); assertEquals(1, bean.increment()); bean = (SessionTypeSpecifiedBean) ctx.lookup("java:module/RedefinedSingletonBean"); assertEquals(0, bean.increment()); assertEquals(1, bean.increment()); } catch (NameNotFoundException e) { fail(e.getMessage()); } } }
4,090
40.323232
198
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/MetadataCompleteCustomDescriptorTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.descriptor; import static org.junit.Assert.fail; import javax.naming.InitialContext; import javax.naming.NameNotFoundException; import javax.naming.NamingException; 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.spec.JavaArchive; import org.junit.Test; import org.junit.runner.RunWith; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @RunWith(Arquillian.class) public class MetadataCompleteCustomDescriptorTestCase extends AbstractCustomDescriptorTests { @Deployment public static Archive<?> deployment() { final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb-descriptor-test.jar") .addPackage(DescriptorGreeterBean.class.getPackage()) .addAsManifestResource(MetadataCompleteCustomDescriptorTestCase.class.getPackage(), "jboss-ejb3-md-complete.xml", "jboss-ejb3.xml"); return jar; } @Test public void testAnnotated() throws NamingException { final InitialContext ctx = new InitialContext(); try { final AnnotatedGreeterBean bean = (AnnotatedGreeterBean) ctx.lookup("java:global/ejb-descriptor-test/AnnotatedGreeter!org.jboss.as.test.integration.ejb.descriptor.AnnotatedGreeterBean"); fail("The annotated bean should not be available"); } catch (NameNotFoundException e) { // good } } }
2,613
41.16129
198
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/AbstractCustomDescriptorTests.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.descriptor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import javax.naming.InitialContext; import javax.naming.NameNotFoundException; import javax.naming.NamingException; import org.junit.Test; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ public abstract class AbstractCustomDescriptorTests { @Test public void test1() throws NamingException { final InitialContext ctx = new InitialContext(); try { final DescriptorGreeterBean bean = (DescriptorGreeterBean) ctx.lookup("java:global/ejb-descriptor-test/DescriptorGreeter!org.jboss.as.test.integration.ejb.descriptor.DescriptorGreeterBean"); final String name = "test1"; final String result = bean.greet(name); assertEquals("Hi test1", result); } catch (NameNotFoundException e) { fail(e.getMessage()); } } }
2,001
39.04
202
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/AS835TestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.descriptor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import javax.naming.NamingException; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.as.test.integration.common.Naming; 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; /** * [AS7-835] ejb-jar.xml doesn't need to define a session-type * * https://issues.jboss.org/browse/AS7-835 * * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @RunWith(Arquillian.class) public class AS835TestCase { @Deployment public static Archive<?> deployment() { // using JavaArchive doesn't work, because of a bug in Arquillian, it only deploys wars properly WebArchive deployment = ShrinkWrap.create(WebArchive.class, "as835.war") .addPackage(SimpleStatelessBean.class.getPackage()) .addPackage(Naming.class.getPackage()) .addAsWebInfResource(AS835TestCase.class.getPackage(), "ejb-jar-as835.xml", "ejb-jar.xml"); return deployment; } /** * Make sure the ejb-jar.xml is actually processed. */ @Test public void testEnvEntry() throws NamingException { final SimpleStatelessBean bean = Naming.lookup("java:global/as835/SimpleStatelessBean", SimpleStatelessBean.class); final String envValue = bean.getTest(); // see ejb-jar.xml for the value assertEquals("*Hello world", envValue); } /** * Make sure the ejb-jar.xml is actually processed. */ @Test public void testInterceptor() throws NamingException { final SimpleStatelessBean bean = Naming.lookup("java:global/as835/SimpleStatelessBean", SimpleStatelessBean.class); final String envValue = bean.getTest(); // see SimpleStatelessBean.aroundInvoke for the value assertNotNull(envValue); assertTrue(envValue.startsWith("*")); } @Test public void testInvocation() throws NamingException { final SimpleStatelessBean bean = Naming.lookup("java:global/as835/SimpleStatelessBean", SimpleStatelessBean.class); bean.getTest(); // if we can invoke the bean it must have been deployed properly } }
3,521
38.133333
123
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/DescriptorGreeterBean.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.descriptor; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ // do not annotate //@Stateless(name = "Greeter") public class DescriptorGreeterBean { public String greet(String name) { return "Hi " + name; } }
1,318
37.794118
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/SimpleStatelessBean.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.descriptor; import jakarta.annotation.Resource; import jakarta.ejb.LocalBean; import jakarta.ejb.Stateless; import jakarta.interceptor.InvocationContext; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @Stateless @LocalBean public class SimpleStatelessBean { @Resource(name="test") private String test; // added in ejb-jar.xml public Object aroundInvoke(final InvocationContext context) throws Exception { return "*" + context.proceed(); } public String getTest() { return test; } }
1,625
33.595745
82
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/SessionTypeSpecifiedBean.java
package org.jboss.as.test.integration.ejb.descriptor; import jakarta.ejb.Singleton; /** * @author Stuart Douglas */ @Singleton public class SessionTypeSpecifiedBean { private int value; public int increment() { return value++; } }
258
13.388889
53
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/CustomDescriptorTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.descriptor; import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; import javax.naming.InitialContext; import javax.naming.NameNotFoundException; import javax.naming.NamingException; 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.spec.JavaArchive; import org.junit.Test; import org.junit.runner.RunWith; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @RunWith(Arquillian.class) public class CustomDescriptorTestCase extends AbstractCustomDescriptorTests { @Deployment public static Archive<?> deployment() { final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "ejb-descriptor-test.jar") .addPackage(DescriptorGreeterBean.class.getPackage()) .addAsManifestResource(CustomDescriptorTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml"); return jar; } // @EJB // private DescriptorGreeterBean bean; @Test public void testAnnotated() throws NamingException { final InitialContext ctx = new InitialContext(); try { final AnnotatedGreeterBean bean = (AnnotatedGreeterBean) ctx.lookup("java:global/ejb-descriptor-test/AnnotatedGreeter!org.jboss.as.test.integration.ejb.descriptor.AnnotatedGreeterBean"); final String name = "testAnnotated"; final String result = bean.greet(name); assertEquals("Hi testAnnotated", result); } catch (NameNotFoundException e) { fail(e.getMessage()); } } }
2,765
39.676471
198
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/ejbnamewildcard/BeanOne.java
package org.jboss.as.test.integration.ejb.descriptor.ejbnamewildcard; import jakarta.ejb.LocalBean; import jakarta.ejb.Stateless; /** * @author Jan Martiska */ @Stateless @LocalBean public class BeanOne { public void wildcardRestrictedMethod() { } public void wildcardExcludedMethod() { } }
316
13.409091
69
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/ejbnamewildcard/BeanTwo.java
package org.jboss.as.test.integration.ejb.descriptor.ejbnamewildcard; import jakarta.ejb.LocalBean; import jakarta.ejb.Stateless; /** * @author Jan Martiska */ @Stateless @LocalBean public class BeanTwo { public void wildcardRestrictedMethod() { } public void wildcardExcludedMethod() { } public void localRestrictedMethod() { } public void localExcludedMethod() { } public void unRestrictedMethod() { } public void notExcludedMethod() { } }
506
12.702703
69
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/descriptor/ejbnamewildcard/EJBNameWildcardTestCase.java
package org.jboss.as.test.integration.ejb.descriptor.ejbnamewildcard; import jakarta.ejb.EJBAccessException; import javax.naming.InitialContext; import javax.naming.NamingException; 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.spec.JavaArchive; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests for wildcard (*) in ejb-name element of jboss-ejb3.xml * @author Jan Martiska */ @RunWith(Arquillian.class) public class EJBNameWildcardTestCase { @Deployment public static Archive<?> deployment() { return ShrinkWrap.create(JavaArchive.class, "ejb-name-wildcard-test.jar") .addPackage(BeanOne.class.getPackage()) .addPackage(BeanTwo.class.getPackage()) .addAsManifestResource(BeanOne.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml"); } /* * Try to invoke a method which requires special privileges, * as defined in jboss-ejb3.xml using ejb-name=*,method-name=restrictedMethod. * It shouldn't be allowed. */ @Test(expected = EJBAccessException.class) public void testWildcardRestrictedMethodOnBeanOne() throws Exception { getRestrictedBean(BeanOne.class).wildcardRestrictedMethod(); } @Test(expected = EJBAccessException.class) public void testWildcardRestrictedMethodOnBeanTwo() throws Exception { getRestrictedBean(BeanTwo.class).wildcardRestrictedMethod(); } /* * Try to invoke a method which is excluded * by jboss-ejb3.xml using ejb-name=*,method-name=excludedMethod * and shouldn't be callable at all. */ @Test(expected = EJBAccessException.class) public void testWildcardExcludedMethodOnBeanOne() throws Exception { getRestrictedBean(BeanOne.class).wildcardExcludedMethod(); } @Test(expected = EJBAccessException.class) public void testWildcardExcludedMethodOnBeanTwo() throws Exception { getRestrictedBean(BeanTwo.class).wildcardExcludedMethod(); } /* * Try to invoke a method which is excluded * by jboss-ejb3.xml using ejb-name=*,method-name=excludedMethod * and shouldn't be callable at all. */ @Test(expected = EJBAccessException.class) public void testLocalRestrictedMethodOnBeanTwo() throws Exception { getRestrictedBean(BeanTwo.class).localRestrictedMethod(); } @Test(expected = EJBAccessException.class) public void testLocalExcludedMethodOnBeanTwo() throws Exception { getRestrictedBean(BeanTwo.class).localExcludedMethod(); } /* * Try to invoke not excluded / restricted methods */ @Test public void testUnRestrictedMethodOnBeanTwo() throws Exception { getRestrictedBean(BeanTwo.class).unRestrictedMethod(); } @Test public void testNotExcludedMethodOnBeanTwo() throws Exception { getRestrictedBean(BeanTwo.class).notExcludedMethod(); } private <T> T getRestrictedBean(Class<T> clazz) throws NamingException { return (T) new InitialContext().lookup("java:global/ejb-name-wildcard-test/" + clazz.getSimpleName()); } }
3,278
33.882979
110
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/localhome/SimpleLocalInterface.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.ejb.home.localhome; import jakarta.ejb.EJBLocalObject; /** * @author Stuart Douglas */ public interface SimpleLocalInterface extends EJBLocalObject { String sayHello(); String otherMethod(); }
1,261
35.057143
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/localhome/SimpleStatefulLocalHome.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.ejb.home.localhome; import jakarta.ejb.EJBLocalHome; /** * * @author Stuart Douglas */ public interface SimpleStatefulLocalHome extends EJBLocalHome{ SimpleLocalInterface createSimple(String message); SimpleLocalInterface createComplex(String first, String second); }
1,338
35.189189
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/localhome/SimpleLocalHome.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.ejb.home.localhome; import jakarta.ejb.EJBLocalHome; /** * Simple local home interface * * @author Stuart Douglas */ public interface SimpleLocalHome extends EJBLocalHome { SimpleLocalInterface createSimple(); }
1,278
34.527778
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/localhome/descriptor/SimpleLocalHomeTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.home.localhome.descriptor; import javax.naming.InitialContext; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.integration.ejb.home.localhome.SimpleLocalHome; import org.jboss.as.test.integration.ejb.home.localhome.SimpleLocalInterface; import org.jboss.as.test.integration.ejb.home.localhome.SimpleStatefulLocalHome; 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 that lifecycle methods defined on classes in a different module to the component class * are called. */ @RunWith(Arquillian.class) public class SimpleLocalHomeTestCase { private static final String ARCHIVE_NAME = "SimpleLocalHomeTest.war"; @ArquillianResource private InitialContext iniCtx; @Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME); war.addPackage(SimpleLocalHomeTestCase.class.getPackage()); war.addPackage(SimpleLocalInterface.class.getPackage()); war.addAsWebInfResource(SimpleLocalHomeTestCase.class.getPackage(),"ejb-jar.xml" , "ejb-jar.xml"); return war; } @Test public void testStatelessLocalHome() throws Exception { final SimpleLocalHome home = (SimpleLocalHome) iniCtx.lookup("java:module/SimpleLocalHomeBean!" + SimpleLocalHome.class.getName()); final SimpleLocalInterface ejbInstance = home.createSimple(); Assert.assertEquals("Hello World", ejbInstance.sayHello()); } @Test public void testGetEjbLocalHome() throws Exception { final SimpleLocalHome home = (SimpleLocalHome) iniCtx.lookup("java:module/SimpleLocalHomeBean!" + SimpleLocalHome.class.getName()); final SimpleLocalInterface ejbInstance = home.createSimple(); Assert.assertEquals("Hello World", ejbInstance.otherMethod()); } @Test public void testStatefulLocalHome() throws Exception { final String message = "Bean Message"; final SimpleStatefulLocalHome home = (SimpleStatefulLocalHome) iniCtx.lookup("java:module/SimpleStatefulLocalHomeBean!" + SimpleStatefulLocalHome.class.getName()); SimpleLocalInterface ejbInstance = home.createSimple(message); Assert.assertEquals(message, ejbInstance.sayHello()); ejbInstance = home.createComplex("hello", "world"); Assert.assertEquals("hello world", ejbInstance.sayHello()); } @Test public void testgetEjbLocalObject() throws Exception { final String message = "Bean Message"; final SimpleStatefulLocalHome home = (SimpleStatefulLocalHome) iniCtx.lookup("java:module/SimpleStatefulLocalHomeBean!" + SimpleStatefulLocalHome.class.getName()); SimpleLocalInterface ejbInstance = home.createSimple(message); Assert.assertEquals(message, ejbInstance.otherMethod()); ejbInstance = home.createComplex("hello", "world"); Assert.assertEquals("hello world", ejbInstance.otherMethod()); } }
4,291
43.708333
171
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/localhome/descriptor/SimpleStatelessLocalBean.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.ejb.home.localhome.descriptor; import jakarta.annotation.Resource; import jakarta.ejb.SessionContext; import org.jboss.as.test.integration.ejb.home.localhome.SimpleLocalHome; /** * @author Stuart Douglas */ public class SimpleStatelessLocalBean { @Resource private SessionContext sessionContext; public String sayHello() { return "Hello World"; } public String otherMethod() { return ((SimpleLocalHome)sessionContext.getEJBLocalHome()).createSimple().sayHello(); } }
1,573
32.489362
94
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/localhome/descriptor/SimpleStatefulLocalBean.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.ejb.home.localhome.descriptor; import jakarta.annotation.Resource; import jakarta.ejb.SessionContext; import org.jboss.as.test.integration.ejb.home.localhome.SimpleLocalInterface; /** * @author Stuart Douglas */ public class SimpleStatefulLocalBean { @Resource private SessionContext sessionContext; private String message; public void ejbCreateSimple(String message) { this.message = message; } public void ejbCreateComplex(String first, String second) { this.message = first + " " + second; } public String sayHello() { return message; } public String otherMethod() { return ((SimpleLocalInterface)sessionContext.getEJBLocalObject()).sayHello(); } public void remove() { } }
1,829
30.016949
85
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/localhome/annotation/SimpleStatelessLocalBean.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.ejb.home.localhome.annotation; import jakarta.annotation.Resource; import jakarta.ejb.LocalHome; import jakarta.ejb.SessionContext; import jakarta.ejb.Stateless; import org.jboss.as.test.integration.ejb.home.localhome.SimpleLocalHome; /** * @author Stuart Douglas */ @Stateless @LocalHome(SimpleLocalHome.class) public class SimpleStatelessLocalBean { @Resource private SessionContext sessionContext; private String message; //this should be treated as a post construct method public void ejbCreate() { message = "Hello World"; } public String sayHello() { return message; } public String otherMethod() { return ((SimpleLocalHome) sessionContext.getEJBLocalHome()).createSimple().sayHello(); } }
1,826
30.5
94
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/localhome/annotation/AnnotationLocalHomeTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.home.localhome.annotation; import jakarta.ejb.EJBException; import javax.naming.InitialContext; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.integration.ejb.home.localhome.SimpleLocalHome; import org.jboss.as.test.integration.ejb.home.localhome.SimpleLocalInterface; import org.jboss.as.test.integration.ejb.home.localhome.SimpleStatefulLocalHome; 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 @LocalHome annotation works as expected */ @RunWith(Arquillian.class) public class AnnotationLocalHomeTestCase { private static final String ARCHIVE_NAME = "SimpleLocalHomeTest.war"; @ArquillianResource private InitialContext iniCtx; @Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME); war.addPackage(AnnotationLocalHomeTestCase.class.getPackage()); war.addPackage(SimpleLocalInterface.class.getPackage()); return war; } @Test public void testStatelessLocalHome() throws Exception { final SimpleLocalHome home = (SimpleLocalHome) iniCtx.lookup("java:module/SimpleStatelessLocalBean!" + SimpleLocalHome.class.getName()); final SimpleLocalInterface ejbInstance = home.createSimple(); Assert.assertEquals("Hello World", ejbInstance.sayHello()); } @Test public void testGetEjbLocalHome() throws Exception { final SimpleLocalHome home = (SimpleLocalHome) iniCtx.lookup("java:module/SimpleStatelessLocalBean!" + SimpleLocalHome.class.getName()); Assert.assertTrue(home.createSimple().getEJBLocalHome() instanceof SimpleLocalHome); } @Test public void testStatefulLocalHome() throws Exception { final String message = "Bean Message"; final SimpleStatefulLocalHome home = (SimpleStatefulLocalHome) iniCtx.lookup("java:module/SimpleStatefulLocalBean!" + SimpleStatefulLocalHome.class.getName()); SimpleLocalInterface ejbInstance = home.createSimple(message); Assert.assertEquals(message, ejbInstance.sayHello()); ejbInstance = home.createComplex("hello", "world"); Assert.assertEquals("hello world", ejbInstance.sayHello()); } @Test public void testGetEjbLocalObject() throws Exception { final String message = "Bean Message"; final SimpleStatefulLocalHome home = (SimpleStatefulLocalHome) iniCtx.lookup("java:module/SimpleStatefulLocalBean!" + SimpleStatefulLocalHome.class.getName()); SimpleLocalInterface ejbInstance = home.createSimple(message); try { Assert.assertEquals(message, ejbInstance.otherMethod()); } catch (EJBException e) { Assert.assertEquals(IllegalStateException.class, e.getCause().getClass()); } } }
4,141
41.701031
167
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/localhome/annotation/SimpleStatefulLocalBean.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.ejb.home.localhome.annotation; import jakarta.annotation.Resource; import jakarta.ejb.LocalHome; import jakarta.ejb.SessionContext; import jakarta.ejb.Stateful; import org.jboss.as.test.integration.ejb.home.localhome.SimpleLocalInterface; import org.jboss.as.test.integration.ejb.home.localhome.SimpleStatefulLocalHome; /** * @author Stuart Douglas */ @Stateful @LocalHome(SimpleStatefulLocalHome.class) public class SimpleStatefulLocalBean { @Resource private SessionContext sessionContext; private String message; public void ejbCreateSimple(String message) { this.message = message; } public void ejbCreateComplex(String first, String second) { this.message = first + " " + second; } public String sayHello() { return message; } public String otherMethod() { return ((SimpleLocalInterface) sessionContext.getEJBLocalObject()).sayHello(); } }
1,986
32.116667
86
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/SimpleStatefulHome.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.ejb.home.remotehome; import java.rmi.RemoteException; import jakarta.ejb.EJBHome; /** * * @author Stuart Douglas */ public interface SimpleStatefulHome extends EJBHome { SimpleInterface createSimple(String message) throws RemoteException; SimpleInterface createComplex(String first, String second) throws RemoteException; }
1,395
34.794872
86
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/SimpleHome.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.ejb.home.remotehome; import java.rmi.RemoteException; import jakarta.ejb.EJBHome; /** * Simple local home interface * * @author Stuart Douglas */ public interface SimpleHome extends EJBHome { SimpleInterface createSimple() throws RemoteException; }
1,316
33.657895
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/SimpleInterface.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.ejb.home.remotehome; import java.rmi.RemoteException; import jakarta.ejb.EJBObject; /** * @author Stuart Douglas */ public interface SimpleInterface extends EJBObject { String sayHello() throws RemoteException; String otherMethod() throws RemoteException; }
1,327
34.891892
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/descriptor/SimpleHomeTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.home.remotehome.descriptor; import javax.naming.InitialContext; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleHome; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleInterface; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleStatefulHome; 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 that lifecycle methods defined on classes in a different module to the component class * are called. */ @RunWith(Arquillian.class) public class SimpleHomeTestCase { private static final String ARCHIVE_NAME = "SimpleHomeTest.war"; @ArquillianResource private InitialContext iniCtx; @Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME); war.addPackage(SimpleHomeTestCase.class.getPackage()); war.addPackage(SimpleInterface.class.getPackage()); war.addAsWebInfResource(SimpleHomeTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml"); return war; } @Test public void testStatelessLocalHome() throws Exception { final SimpleHome home = (SimpleHome) iniCtx.lookup("java:module/SimpleHomeBean!" + SimpleHome.class.getName()); final SimpleInterface ejbInstance = home.createSimple(); Assert.assertEquals("Hello World", ejbInstance.sayHello()); } @Test public void testGetEjbLocalHome() throws Exception { final SimpleHome home = (SimpleHome) iniCtx.lookup("java:module/SimpleHomeBean!" + SimpleHome.class.getName()); final SimpleInterface ejbInstance = home.createSimple(); Assert.assertEquals("Hello World", ejbInstance.otherMethod()); } @Test public void testStatefulLocalHome() throws Exception { final String message = "Bean Message"; final SimpleStatefulHome home = (SimpleStatefulHome) iniCtx.lookup("java:module/SimpleStatefulHomeBean!" + SimpleStatefulHome.class.getName()); SimpleInterface ejbInstance = home.createSimple(message); Assert.assertEquals(message, ejbInstance.sayHello()); ejbInstance = home.createComplex("hello", "world"); Assert.assertEquals("hello world", ejbInstance.sayHello()); } @Test public void testgetEjbLocalObject() throws Exception { final String message = "Bean Message"; final SimpleStatefulHome home = (SimpleStatefulHome) iniCtx.lookup("java:module/SimpleStatefulHomeBean!" + SimpleStatefulHome.class.getName()); SimpleInterface ejbInstance = home.createSimple(message); Assert.assertEquals(message, ejbInstance.otherMethod()); ejbInstance = home.createComplex("hello", "world"); Assert.assertEquals("hello world", ejbInstance.otherMethod()); } }
4,155
42.291667
151
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/descriptor/SimpleStatelessBean.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.ejb.home.remotehome.descriptor; import java.rmi.RemoteException; import jakarta.annotation.Resource; import jakarta.ejb.SessionContext; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleHome; /** * @author Stuart Douglas */ public class SimpleStatelessBean { @Resource private SessionContext sessionContext; public String sayHello() { return "Hello World"; } public String otherMethod() throws RemoteException { return ((SimpleHome)sessionContext.getEJBHome()).createSimple().sayHello(); } }
1,611
31.897959
84
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/descriptor/SimpleStatefulBean.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.ejb.home.remotehome.descriptor; import java.rmi.RemoteException; import jakarta.annotation.Resource; import jakarta.ejb.SessionContext; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleInterface; /** * @author Stuart Douglas */ public class SimpleStatefulBean { @Resource private SessionContext sessionContext; private String message; public void ejbCreateSimple(String message) { this.message = message; } public void ejbCreateComplex(String first, String second) { this.message = first + " " + second; } public String sayHello() { return message; } public String otherMethod() throws RemoteException { return ((SimpleInterface)sessionContext.getEJBObject()).sayHello(); } }
1,832
31.157895
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/injection/RemoteHomeInjectionTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.home.remotehome.injection; import javax.naming.InitialContext; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleInterface; 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 */ @RunWith(Arquillian.class) public class RemoteHomeInjectionTestCase { private static final String ARCHIVE_NAME = "SimpleLocalHomeTest.war"; @ArquillianResource private InitialContext iniCtx; @Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME); war.addPackage(RemoteHomeInjectionTestCase.class.getPackage()); war.addPackage(SimpleInterface.class.getPackage()); return war; } @Test public void testRemoteHomeInjection() throws Exception { final InjectingEjb ejb = (InjectingEjb) iniCtx.lookup("java:module/" + InjectingEjb.class.getSimpleName()); Assert.assertEquals("OtherEjb", ejb.getMessage()); } }
2,358
34.742424
115
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/injection/InjectionHome.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.ejb.home.remotehome.injection; import java.rmi.RemoteException; import jakarta.ejb.EJBHome; /** * @author Stuart Douglas */ public interface InjectionHome extends EJBHome{ Injection create() throws RemoteException; }
1,281
35.628571
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/injection/InjectingEjb.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.ejb.home.remotehome.injection; import java.rmi.RemoteException; import jakarta.ejb.EJB; import jakarta.ejb.Stateless; /** * @author Stuart Douglas */ @Stateless public class InjectingEjb { @EJB private InjectionHome home; public String getMessage() { try { return home.create().message(); } catch (RemoteException e) { throw new RuntimeException(e); } } }
1,482
30.553191
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/injection/Injection.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.ejb.home.remotehome.injection; import java.rmi.RemoteException; import jakarta.ejb.EJBObject; /** * @author Stuart Douglas */ public interface Injection extends EJBObject { String message() throws RemoteException; }
1,281
34.611111
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/injection/OtherEjb.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.ejb.home.remotehome.injection; import jakarta.ejb.RemoteHome; import jakarta.ejb.Stateful; /** * @author Stuart Douglas */ @Stateful @RemoteHome(InjectionHome.class) public class OtherEjb { public void ejbCreate() { } public String message() { return "OtherEjb"; } }
1,353
30.488372
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/annotation/SimpleStatelessBean.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.ejb.home.remotehome.annotation; import java.rmi.RemoteException; import jakarta.annotation.Resource; import jakarta.ejb.RemoteHome; import jakarta.ejb.SessionContext; import jakarta.ejb.Stateless; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleHome; /** * @author Stuart Douglas */ @Stateless @RemoteHome(SimpleHome.class) public class SimpleStatelessBean { @Resource private SessionContext sessionContext; public String sayHello() { return "Hello World"; } public String otherMethod() throws RemoteException { return ((SimpleHome)sessionContext.getEJBHome()).createSimple().sayHello(); } }
1,713
31.339623
84
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/annotation/SimpleStatefulBean.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.ejb.home.remotehome.annotation; import java.rmi.RemoteException; import jakarta.annotation.Resource; import jakarta.ejb.RemoteHome; import jakarta.ejb.SessionContext; import jakarta.ejb.Stateful; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleInterface; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleStatefulHome; /** * @author Stuart Douglas */ @Stateful @RemoteHome(SimpleStatefulHome.class) public class SimpleStatefulBean { @Resource private SessionContext sessionContext; private String message; public void ejbCreateSimple(String message) { this.message = message; } public void ejbCreateComplex(String first, String second) { this.message = first + " " + second; } public String sayHello() { return message; } public String otherMethod() throws RemoteException { return ((SimpleInterface)sessionContext.getEJBObject()).sayHello(); } }
2,017
31.548387
76
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/home/remotehome/annotation/AnnotationHomeTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.home.remotehome.annotation; import static org.junit.Assert.fail; import java.rmi.NoSuchObjectException; import jakarta.ejb.EJBException; import javax.naming.InitialContext; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleHome; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleInterface; import org.jboss.as.test.integration.ejb.home.remotehome.SimpleStatefulHome; 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 */ @RunWith(Arquillian.class) public class AnnotationHomeTestCase { private static final String ARCHIVE_NAME = "SimpleLocalHomeTest.war"; @ArquillianResource private InitialContext iniCtx; @Deployment public static Archive<?> deploy() { WebArchive war = ShrinkWrap.create(WebArchive.class, ARCHIVE_NAME); war.addPackage(AnnotationHomeTestCase.class.getPackage()); war.addPackage(SimpleInterface.class.getPackage()); return war; } @Test public void testStatelessLocalHome() throws Exception { final SimpleHome home = (SimpleHome) iniCtx.lookup("java:module/SimpleStatelessBean!" + SimpleHome.class.getName()); final SimpleInterface ejbInstance = home.createSimple(); Assert.assertEquals("Hello World", ejbInstance.sayHello()); } @Test public void testGetEjbHome() throws Exception { final SimpleHome home = (SimpleHome) iniCtx.lookup("java:module/SimpleStatelessBean!" + SimpleHome.class.getName()); Assert.assertTrue( home.createSimple().getEJBHome() instanceof SimpleHome); } @Test public void testStatefulLocalHome() throws Exception { final String message = "Bean Message"; final SimpleStatefulHome home = (SimpleStatefulHome) iniCtx.lookup("java:module/SimpleStatefulBean!" + SimpleStatefulHome.class.getName()); SimpleInterface ejbInstance = home.createSimple(message); Assert.assertEquals(message, ejbInstance.sayHello()); ejbInstance = home.createComplex("hello", "world"); Assert.assertEquals("hello world", ejbInstance.sayHello()); ejbInstance.remove(); try { ejbInstance.sayHello(); fail("Expected bean to be removed"); } catch (NoSuchObjectException expected) { } } @Test public void testGetEjbLocalObject() throws Exception { final String message = "Bean Message"; final SimpleStatefulHome home = (SimpleStatefulHome) iniCtx.lookup("java:module/SimpleStatefulBean!" + SimpleStatefulHome.class.getName()); SimpleInterface ejbInstance = home.createSimple(message); try { Assert.assertEquals(message, ejbInstance.otherMethod()); } catch (EJBException e) { Assert.assertEquals(IllegalStateException.class, e.getCause().getClass()); } } }
4,234
38.579439
147
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/iiop/naming/IIOPNamingInContainerTestCase.java
package org.jboss.as.test.integration.ejb.iiop.naming; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.OperateOnDeployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import jakarta.ejb.RemoveException; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import java.rmi.NoSuchObjectException; import java.rmi.RemoteException; import java.util.Properties; /** * Tests that corba name lookups work from inside the AS itself * * @author Stuart Douglas */ @RunWith(Arquillian.class) public class IIOPNamingInContainerTestCase { @ArquillianResource private ManagementClient managementClient; @Deployment(name="test") public static Archive<?> deploy() { return ShrinkWrap.create(JavaArchive.class, "test.jar") .addPackage(IIOPNamingInContainerTestCase.class.getPackage()) .addAsManifestResource(IIOPNamingInContainerTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml") .addAsManifestResource(IIOPNamingInContainerTestCase.class.getPackage(), "permissions.xml", "permissions.xml"); } @Test @OperateOnDeployment("test") public void testIIOPNamingInvocation() throws NamingException, RemoteException { final Properties prope = new Properties(); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("corbaname:iiop:" + managementClient.getMgmtAddress() + ":3528#IIOPNamingBean"); final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class); final IIOPRemote result = object.create(); Assert.assertEquals("hello", result.hello()); } @Test @OperateOnDeployment("test") public void testStatefulIIOPNamingInvocation() throws NamingException, RemoteException, RemoveException { final Properties prope = new Properties(); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("corbaname:iiop:" + managementClient.getMgmtAddress() + ":3528#IIOPStatefulNamingBean"); final IIOPStatefulNamingHome object = (IIOPStatefulNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPStatefulNamingHome.class); final IIOPStatefulRemote result = object.create(10); Assert.assertEquals(11, result.increment()); Assert.assertEquals(12, result.increment()); result.remove(); try { result.increment(); Assert.fail("Expected NoSuchObjectException"); } catch (NoSuchObjectException expected) { } } }
3,040
40.657534
138
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/iiop/naming/IIOPNamingBean.java
package org.jboss.as.test.integration.ejb.iiop.naming; import jakarta.ejb.RemoteHome; import jakarta.ejb.Stateless; /** * @author Stuart Douglas */ @RemoteHome(IIOPNamingHome.class) @Stateless public class IIOPNamingBean { public String hello() { return "hello"; } }
289
15.111111
54
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/iiop/naming/IIOPStatefulNamingBean.java
package org.jboss.as.test.integration.ejb.iiop.naming; import java.rmi.RemoteException; import jakarta.ejb.RemoteHome; import jakarta.ejb.Stateful; /** * @author Stuart Douglas */ @RemoteHome(IIOPStatefulNamingHome.class) @Stateful public class IIOPStatefulNamingBean { int count = 0; public void ejbCreate(int start) { count = start; } public int increment() throws RemoteException { return ++count; } }
450
16.346154
54
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/iiop/naming/IIOPNamingTestCase.java
package org.jboss.as.test.integration.ejb.iiop.naming; import java.rmi.NoSuchObjectException; import java.rmi.RemoteException; import java.util.Properties; import jakarta.ejb.RemoveException; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; 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.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * @author Stuart Douglas * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ @RunWith(Arquillian.class) @RunAsClient public class IIOPNamingTestCase { @ContainerResource private ManagementClient managementClient; @Deployment(testable = false) public static Archive<?> deploy() { System.setProperty("com.sun.CORBA.ORBUseDynamicStub", "true"); return ShrinkWrap.create(JavaArchive.class, "test.jar") .addPackage(IIOPNamingTestCase.class.getPackage()) .addAsManifestResource(IIOPNamingTestCase.class.getPackage(), "jboss-ejb3.xml", "jboss-ejb3.xml"); } @Deployment(name="test2", testable = false) public static Archive<?> descriptorOverrideDeploy() { return ShrinkWrap.create(JavaArchive.class, "test2.jar") .addClasses(IIOPNamingHome.class, IIOPRemote.class, IIOPNamingBean.class) .addAsManifestResource(IIOPNamingTestCase.class.getPackage(), "jboss-ejb3-naming.xml", "jboss-ejb3.xml"); } private static String property(final String name) { return System.getProperty(name); } @Test public void testIIOPNamingInvocation() throws NamingException, RemoteException { final Properties prope = new Properties(); prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); prope.put(Context.PROVIDER_URL, "corbaloc::" +managementClient.getMgmtAddress() + ":3528/NameService"); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("IIOPNamingBean"); final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class); final IIOPRemote result = object.create(); Assert.assertEquals("hello", result.hello()); } @Test public void testStatefulIIOPNamingInvocation() throws NamingException, RemoteException, RemoveException { final Properties prope = new Properties(); prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() +":3528/NameService"); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("IIOPStatefulNamingBean"); final IIOPStatefulNamingHome object = (IIOPStatefulNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPStatefulNamingHome.class); final IIOPStatefulRemote result = object.create(10); Assert.assertEquals(11, result.increment()); Assert.assertEquals(12, result.increment()); result.remove(); try { result.increment(); Assert.fail("Expected NoSuchObjectException"); } catch (NoSuchObjectException expected) { } } @Test public void testIIOPNamingCorbanameInvocation() throws NamingException, RemoteException { final Properties prope = new Properties(); prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() +":3528"); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("corbaname:iiop:" + managementClient.getMgmtAddress() +":3528#IIOPNamingBean"); final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class); final IIOPRemote result = object.create(); Assert.assertEquals("hello", result.hello()); } @Test public void testStatefulIIOPNamingCorbanameInvocation() throws NamingException, RemoteException, RemoveException { final Properties prope = new Properties(); prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() + ":3528"); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("IIOPStatefulNamingBean"); final IIOPStatefulNamingHome object = (IIOPStatefulNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPStatefulNamingHome.class); final IIOPStatefulRemote result = object.create(10); Assert.assertEquals(11, result.increment()); Assert.assertEquals(12, result.increment()); result.remove(); try { result.increment(); Assert.fail("Expected NoSuchObjectException"); } catch (NoSuchObjectException expected) { } } @Test public void testIIOPNamingIIOPInvocation() throws NamingException, RemoteException { final Properties prope = new Properties(); prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); prope.put(Context.PROVIDER_URL, "iiop://" + managementClient.getMgmtAddress() +":3528"); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("IIOPNamingBean"); final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class); final IIOPRemote result = object.create(); Assert.assertEquals("hello", result.hello()); } @Test public void testStatefulIIOPNamingIIOPInvocation() throws NamingException, RemoteException, RemoveException { final Properties prope = new Properties(); prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); prope.put(Context.PROVIDER_URL, "iiop://" + managementClient.getMgmtAddress() +":3528"); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("IIOPStatefulNamingBean"); final IIOPStatefulNamingHome object = (IIOPStatefulNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPStatefulNamingHome.class); final IIOPStatefulRemote result = object.create(10); Assert.assertEquals(11, result.increment()); Assert.assertEquals(12, result.increment()); result.remove(); try { result.increment(); Assert.fail("Expected NoSuchObjectException"); } catch (NoSuchObjectException expected) { } } /** * <p> * Tests the corbaloc lookup of a bean that used the jboss-ejb3.xml deployment descriptor to override the COSNaming * binding. So, insteand of looking for the standard test2/IIOPNamingBean context we will look for the configured * bean/custom/name/IIOPNamingBean context. * </p> * * @throws NamingException if an error occurs while looking up the bean. * @throws RemoteException if an error occurs while invoking the remote bean. */ @Test public void testCorbalocInvocationWithDDOverride() throws NamingException, RemoteException { final Properties prope = new Properties(); prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() +":3528/NameService"); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("bean/custom/name/IIOPNamingBean"); final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class); final IIOPRemote result = object.create(); Assert.assertEquals("hello", result.hello()); } /** * <p> * Tests the corbaname lookup of a bean that used the jboss-ejb3.xml deployment descriptor to override the COSNaming * binding. So, insteand of looking for the standard test2/IIOPNamingBean context we will look for the configured * bean/custom/name/IIOPNamingBean context. * </p> * * @throws NamingException if an error occurs while looking up the bean. * @throws RemoteException if an error occurs while invoking the remote bean. */ @Test public void testCorbanameInvocationWithDDOverride() throws NamingException, RemoteException { final Properties prope = new Properties(); prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); prope.put(Context.PROVIDER_URL, "corbaloc::" + managementClient.getMgmtAddress() +":3528"); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("corbaname:iiop:" + managementClient.getMgmtAddress() +":3528#bean/custom/name/IIOPNamingBean"); final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class); final IIOPRemote result = object.create(); Assert.assertEquals("hello", result.hello()); } /** * <p> * Tests the iiop lookup of a bean that used the jboss-ejb3.xml deployment descriptor to override the COSNaming * binding. So, insteand of looking for the standard test2/IIOPNamingBean context we will look for the configured * bean/custom/name/IIOPNamingBean context. * </p> * * @throws NamingException if an error occurs while looking up the bean. * @throws RemoteException if an error occurs while invoking the remote bean. */ @Test public void testIIOPInvocationWithDDOverride() throws NamingException, RemoteException { final Properties prope = new Properties(); prope.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.cosnaming.CNCtxFactory"); prope.put(Context.PROVIDER_URL, "iiop://" + managementClient.getMgmtAddress() +":3528"); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("bean/custom/name/IIOPNamingBean"); final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class); final IIOPRemote result = object.create(); Assert.assertEquals("hello", result.hello()); } }
10,889
49.416667
142
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/iiop/naming/IIOPNamingHome.java
package org.jboss.as.test.integration.ejb.iiop.naming; import jakarta.ejb.EJBHome; import java.rmi.RemoteException; /** * @author Stuart Douglas */ public interface IIOPNamingHome extends EJBHome { IIOPRemote create() throws RemoteException; }
254
17.214286
54
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/iiop/naming/IIOPStatefulRemote.java
package org.jboss.as.test.integration.ejb.iiop.naming; import java.rmi.RemoteException; import jakarta.ejb.EJBObject; /** * @author Stuart Douglas */ public interface IIOPStatefulRemote extends EJBObject { int increment() throws RemoteException; }
258
17.5
55
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/iiop/naming/IIOPStatefulNamingHome.java
package org.jboss.as.test.integration.ejb.iiop.naming; import java.rmi.RemoteException; import jakarta.ejb.EJBHome; /** * @author Stuart Douglas */ public interface IIOPStatefulNamingHome extends EJBHome { IIOPStatefulRemote create(int start) throws RemoteException; }
280
17.733333
64
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/iiop/naming/IIOPRemote.java
package org.jboss.as.test.integration.ejb.iiop.naming; import jakarta.ejb.EJBObject; import java.rmi.RemoteException; /** * @author Stuart Douglas */ public interface IIOPRemote extends EJBObject { String hello() throws RemoteException; }
248
18.153846
54
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/iiop/naming/IIOPNamingInContainerDDNameTestCase.java
package org.jboss.as.test.integration.ejb.iiop.naming; import java.rmi.RemoteException; import java.util.Properties; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.rmi.PortableRemoteObject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.OperateOnDeployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.arquillian.container.ManagementClient; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that corba name lookups work from inside the AS itself - IIOP bean name defined in deployment descriptor * * @author <a href="mailto:[email protected]">Tomasz Adamski</a> */ @RunWith(Arquillian.class) public class IIOPNamingInContainerDDNameTestCase { @ArquillianResource private ManagementClient managementClient; @Deployment(name="test") public static Archive<?> descriptorOverrideDeploy() { return ShrinkWrap.create(JavaArchive.class, "test.jar") .addPackage(IIOPNamingInContainerDDNameTestCase.class.getPackage()) .addAsManifestResource(IIOPNamingInContainerDDNameTestCase.class.getPackage(), "jboss-ejb3-naming.xml", "jboss-ejb3.xml") .addAsManifestResource(IIOPNamingInContainerDDNameTestCase.class.getPackage(), "permissions.xml", "permissions.xml"); } /** * <p> * Tests the lookup of a bean that used the jboss-ejb3.xml deployment descriptor to override the COSNaming binding. * So, insteand of looking for the standard test2/IIOPNamingBean context we will look for the configured * bean/custom/name/IIOPNamingBean context. * </p> * * @throws NamingException if an error occurs while looking up the bean. * @throws RemoteException if an error occurs while invoking the remote bean. */ @Test @OperateOnDeployment("test") public void testIIOPNamingInvocationWithDDOverride() throws NamingException, RemoteException { final Properties prope = new Properties(); final InitialContext context = new InitialContext(prope); final Object iiopObj = context.lookup("corbaname:iiop:" + managementClient.getMgmtAddress() + ":3528#bean/custom/name/IIOPNamingBean"); final IIOPNamingHome object = (IIOPNamingHome) PortableRemoteObject.narrow(iiopObj, IIOPNamingHome.class); final IIOPRemote result = object.create(); Assert.assertEquals("hello", result.hello()); } }
2,709
42.015873
143
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/injection/injectiontarget/EjbRefInjectionTargetTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2011, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.ejb.injection.injectiontarget; import javax.naming.InitialContext; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * */ @RunWith(Arquillian.class) public class EjbRefInjectionTargetTestCase { private static final String ARCHIVE_NAME = "ejbreftest.jar"; @ArquillianResource private InitialContext iniCtx; @Deployment public static Archive<?> deploy() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, ARCHIVE_NAME); jar.addPackage(EjbRefInjectionTargetTestCase.class.getPackage()); jar.addAsManifestResource(EjbRefInjectionTargetTestCase.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml"); return jar; } @Test public void testEjbRefLookup() throws Exception { final InjectingBean bean = (InjectingBean) iniCtx.lookup("java:module/" + InjectingBean.class.getSimpleName()); Assert.assertEquals(InjectedBean.class.getName(), bean.getName()); } }
2,340
35.015385
119
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/injection/injectiontarget/InjectingBean.java
package org.jboss.as.test.integration.ejb.injection.injectiontarget; import jakarta.ejb.Stateless; /** * @author Stuart Douglas */ @Stateless public class InjectingBean { private SuperInterface injected; public String getName() { return injected.getName(); } }
288
15.055556
68
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/injection/injectiontarget/SuperInterface.java
package org.jboss.as.test.integration.ejb.injection.injectiontarget; /** * @author Stuart Douglas */ public interface SuperInterface { String getName(); }
162
17.111111
68
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/injection/injectiontarget/SubInterface.java
package org.jboss.as.test.integration.ejb.injection.injectiontarget; import jakarta.ejb.Local; /** * @author Stuart Douglas */ @Local public interface SubInterface extends SuperInterface { }
195
16.818182
68
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/injection/injectiontarget/InjectedBean.java
package org.jboss.as.test.integration.ejb.injection.injectiontarget; import jakarta.ejb.Stateless; /** * @author Stuart Douglas */ @Stateless public class InjectedBean implements SubInterface{ @Override public String getName() { return InjectedBean.class.getName(); } }
294
18.666667
68
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/injection/multiple/view/WSViewEJBInjectionTestCase.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.ejb.injection.multiple.view; 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.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import javax.naming.InitialContext; /** * @author Jaikiran Pai */ @RunWith(Arquillian.class) public class WSViewEJBInjectionTestCase { @Deployment public static Archive createDeployment() { final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "multiple-view-ejb-injection"); jar.addPackage(WSViewEJBInjectionTestCase.class.getPackage()); return jar; } @Test public void testInjection() throws Exception { final InjectingBean injectingBean = InitialContext.doLookup("java:module/" + InjectingBean.class.getSimpleName() + "!" + InjectingBean.class.getName()); Assert.assertTrue("@EJB injection did not happen in bean", injectingBean.isBeanInjected()); // try an invocation on the bean injectingBean.invokeInjectedBean(); } }
2,230
38.140351
160
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/ejb/injection/multiple/view/NoInterfaceAndWebServiceViewBean.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.ejb.injection.multiple.view; import jakarta.ejb.LocalBean; import jakarta.ejb.Stateless; import jakarta.jws.WebService; /** * @author Jaikiran Pai */ @LocalBean @Stateless @WebService public class NoInterfaceAndWebServiceViewBean { public void doNothing() { } }
1,338
31.658537
70
java