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/weld/deployment/Bravo.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; import jakarta.enterprise.context.Dependent; @Dependent public class Bravo implements Ping { @Override public void pong() { } }
975
32.655172
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/LegacyAlpha.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; import jakarta.enterprise.context.RequestScoped; @RequestScoped public class LegacyAlpha implements Ping { @Override public void pong() { } }
989
33.137931
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Ping.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; public interface Ping { void pong(); }
877
35.583333
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/VerifyingExtension.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; import java.util.ArrayList; import java.util.List; import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.ProcessAnnotatedType; public class VerifyingExtension implements Extension { private List<Class<?>> observedAnnotatedTypes = new ArrayList<Class<?>>(); public void observeProcessAnnotatedType(@Observes ProcessAnnotatedType<?> event) { observedAnnotatedTypes.add(event.getAnnotatedType().getJavaClass()); } public List<Class<?>> getObservedAnnotatedTypes() { return observedAnnotatedTypes; } }
1,445
36.076923
86
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Alpha.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; public class Alpha implements Ping { @Override public void pong() { } }
918
34.346154
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/EchoNotABean.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; public class EchoNotABean implements Ping { @Override public void pong() { } }
925
34.615385
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Charlie.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; import jakarta.enterprise.context.Dependent; @Dependent public class Charlie implements Ping { @Override public void pong() { } }
977
32.724138
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Delta.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; import jakarta.enterprise.context.RequestScoped; @RequestScoped public class Delta implements Ping { @Override public void pong() { } }
983
32.931034
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/ChatWebsocketResource.java
/* * Copyright 2019 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.weld.deployment; import jakarta.enterprise.context.ApplicationScoped; import jakarta.websocket.OnClose; import jakarta.websocket.OnError; import jakarta.websocket.OnMessage; import jakarta.websocket.OnOpen; import jakarta.websocket.Session; import jakarta.websocket.server.PathParam; import jakarta.websocket.server.ServerEndpoint; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /** * Created by Marek Marusic <[email protected]> on 3/26/19. */ @ServerEndpoint("/chat/{username}") @ApplicationScoped public class ChatWebsocketResource { Map<String, Session> sessions = new ConcurrentHashMap<>(); @OnOpen public void onOpen(Session session, @PathParam("username") String username) { sessions.put(username, session); broadcast("User " + username + " joined"); } @OnClose public void onClose(Session session, @PathParam("username") String username) { sessions.remove(username); broadcast("User " + username + " left"); } @OnError public void onError(Session session, @PathParam("username") String username, Throwable throwable) { sessions.remove(username); broadcast("User " + username + " left on error: " + throwable); } @OnMessage public void onMessage(String message, @PathParam("username") String username) { broadcast(">> " + username + ": " + message); } private void broadcast(String message) { sessions.values().forEach(s -> { s.getAsyncRemote().sendObject(message, result -> { if (result.getException() != null) { System.out.println("Unable to send message: " + result.getException()); } }); }); } }
2,383
32.111111
103
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/LegacyBravo.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; import jakarta.enterprise.context.RequestScoped; @RequestScoped public class LegacyBravo { }
927
36.12
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/WebsocketApplicationScopedTestCase.java
/* * Copyright 2019 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.weld.deployment; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.OperateOnDeployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.shared.TestSuiteEnvironment; import org.jboss.as.test.shared.TimeoutUtil; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import jakarta.websocket.ClientEndpoint; import jakarta.websocket.ContainerProvider; import jakarta.websocket.OnMessage; import jakarta.websocket.OnOpen; import jakarta.websocket.Session; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; import java.util.HashMap; import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; /** * Created by Marek Marusic <[email protected]> on 3/26/19. */ @RunWith(Arquillian.class) public class WebsocketApplicationScopedTestCase { private static final String CLIENT_STANDALONE = "standalone"; private static final HashMap<String, LinkedBlockingDeque<String>> queues = new HashMap<>(); private static final long TIMEOUT = TimeoutUtil.adjust(20000); @Deployment(testable = false, name = CLIENT_STANDALONE) public static WebArchive createThinDeployment() { return ShrinkWrap.create(WebArchive.class, CLIENT_STANDALONE + ".war") .addClasses(ChatWebsocketResource.class) .addAsManifestResource(new StringAsset("io.undertow.websockets.jsr.UndertowContainerProvider"), "services/jakarta.websocket.ContainerProvider"); } @Test @OperateOnDeployment(CLIENT_STANDALONE) @RunAsClient public void testClientStandalone(@ArquillianResource URL webapp) throws Exception { URI uriUser1 = createUri(webapp,"/chat/user1"); URI uriUser2 = createUri(webapp,"/chat/user2"); try (Session session = ContainerProvider.getWebSocketContainer().connectToServer(Client.class, uriUser1)) { //Wait until the client is initialized e.q. the OnOpen is executed waitForClientInitialization(queues, 1); //Check if the user1 is connected Assert.assertEquals("CONNECT", queues.get(session.getId()).poll(10, TimeUnit.SECONDS)); Assert.assertEquals("User user1 joined", queues.get(session.getId()).poll(10, TimeUnit.SECONDS)); session.getAsyncRemote().sendText("hello world"); Assert.assertEquals(">> user1: hello world", queues.get(session.getId()).poll(10, TimeUnit.SECONDS)); try (Session sessioUser2 = ContainerProvider.getWebSocketContainer().connectToServer(Client.class, uriUser2)) { //Wait until the client is initialized e.q. the OnOpen is executed waitForClientInitialization(queues, 2); //Assert that the sessioUser2 got the messages Assert.assertEquals("CONNECT", queues.get(sessioUser2.getId()).poll(10, TimeUnit.SECONDS)); Assert.assertEquals("User user2 joined", queues.get(sessioUser2.getId()).poll(10, TimeUnit.SECONDS)); sessioUser2.getAsyncRemote().sendText("hello world"); Assert.assertEquals(">> user2: hello world", queues.get(sessioUser2.getId()).poll(10, TimeUnit.SECONDS)); //Assert that the user1's session got user2's messages Assert.assertEquals("User user2 joined", queues.get(session.getId()).poll(10, TimeUnit.SECONDS)); Assert.assertEquals(">> user2: hello world", queues.get(session.getId()).poll(10, TimeUnit.SECONDS)); } } } private void waitForClientInitialization(HashMap<String, LinkedBlockingDeque<String>> queues, int expectedQueueSize) throws InterruptedException { long end = System.currentTimeMillis() + TIMEOUT; while (end > System.currentTimeMillis()) { if (queues.size() > expectedQueueSize-1) { break; } Thread.sleep(100); } Assert.assertTrue(queues.size() > expectedQueueSize-1); } private URI createUri(URL webapp, String path) throws URISyntaxException { return new URI("ws", "", TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getHttpPort(), webapp.getPath() + path, "", ""); } @ClientEndpoint public static class Client { @OnOpen public void open(Session session) { queues.put(session.getId(), new LinkedBlockingDeque<>()); queues.get(session.getId()).add("CONNECT"); } @OnMessage void message(Session session, String msg) { queues.get(session.getId()).add(msg); } } }
5,587
41.656489
150
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/Bravo_Undiscovered.java
package org.jboss.as.test.integration.weld.deployment; public class Bravo_Undiscovered implements Ping { @Override public void pong() { } }
153
18.25
54
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/LegacyExtension.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment; import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.AfterTypeDiscovery; import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.inject.spi.Extension; public class LegacyExtension implements Extension { public void observeBeforeBeanDiscovery(@Observes AfterTypeDiscovery event, BeanManager beanManager) { event.addAnnotatedType(beanManager.createAnnotatedType(LegacyAlpha.class), LegacyExtension.class.getName()); } }
1,315
41.451613
116
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/BeanDiscoveryTest.java
package org.jboss.as.test.integration.weld.deployment; import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.inject.spi.Extension; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; /** * * @author Martin Kouba */ @RunWith(Arquillian.class) public class BeanDiscoveryTest { @Deployment public static WebArchive createTestArchive() { // 1.1 version beans.xml with bean-discovery-mode of all JavaArchive alpha = ShrinkWrap .create(JavaArchive.class) .addClass(Alpha.class) .addAsManifestResource(newBeans11Descriptor("all"), "beans.xml"); // Empty beans.xml JavaArchive bravo = ShrinkWrap.create(JavaArchive.class).addClasses(Bravo.class, Bravo_Undiscovered.class) .addAsManifestResource(new StringAsset(""), "beans.xml"); // No version beans.xml JavaArchive charlie = ShrinkWrap .create(JavaArchive.class) .addClasses(Charlie.class, Bravo_Undiscovered.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); // Bean defining annotation and no beans.xml JavaArchive delta = ShrinkWrap.create(JavaArchive.class).addClass(Delta.class); // Bean defining annotation and 1.1 version beans.xml with bean-discovery-mode of annotated JavaArchive echo = ShrinkWrap .create(JavaArchive.class) .addClasses(Echo.class, EchoNotABean.class) .addAsManifestResource(newBeans11Descriptor("annotated"), "beans.xml"); // Bean defining annotation and 1.1 version beans.xml with bean-discovery-mode of none JavaArchive foxtrot = ShrinkWrap .create(JavaArchive.class) .addClass(Foxtrot.class) .addAsManifestResource(newBeans11Descriptor("none"), "beans.xml"); // Archive which contains an extension and no beans.xml file JavaArchive legacy = ShrinkWrap.create(JavaArchive.class).addClasses(LegacyExtension.class, LegacyAlpha.class, LegacyBravo.class).addAsServiceProvider(Extension.class, LegacyExtension.class); return ShrinkWrap.create(WebArchive.class).addClasses(BeanDiscoveryTest.class, VerifyingExtension.class) .addAsServiceProvider(Extension.class, VerifyingExtension.class) .addAsLibrary(ShrinkWrap.create(JavaArchive.class).addClass(Ping.class)) .addAsLibraries(alpha, bravo, charlie, delta, echo, foxtrot, legacy); } @Inject private VerifyingExtension extension; @Inject private BeanManager manager; @Test public void testExplicitBeanArchiveModeAll(Alpha alpha) { assertDiscoveredAndAvailable(alpha, Alpha.class); } @Ignore("This test already expects Weld 5/CDI 4 behavior and can be enabled once WFLY fully moves to that version") @Test public void testImplicitBeanArchiveEmptyDescriptor(Bravo bravo) { assertDiscoveredAndAvailable(bravo, Bravo.class); assertNotDiscoveredAndNotAvailable(Bravo_Undiscovered.class); } @Ignore("This test already expects Weld 5/CDI 4 behavior and can be enabled once WFLY fully moves to that version") @Test public void testImplicitBeanArchiveLegacyDescriptor(Charlie charlie) { assertDiscoveredAndAvailable(charlie, Charlie.class); assertNotDiscoveredAndNotAvailable(Bravo_Undiscovered.class); } @Test public void testImplicitBeanArchiveNoDescriptor(Delta delta) { assertDiscoveredAndAvailable(delta, Delta.class); } @Test public void testImplicitBeanArchiveModeAnnotated(Echo echo) { assertDiscoveredAndAvailable(echo, Echo.class); assertNotDiscoveredAndNotAvailable(EchoNotABean.class); } @Test public void testNoBeanArchiveModeNone() { assertNotDiscoveredAndNotAvailable(Foxtrot.class); } @Test public void testNotBeanArchiveExtension(LegacyAlpha legacyAlpha) { assertDiscoveredAndAvailable(legacyAlpha, LegacyAlpha.class); assertNotDiscoveredAndNotAvailable(LegacyBravo.class); } private <T extends Ping> void assertDiscoveredAndAvailable(T reference, Class<T> clazz) { Assert.assertTrue(extension.getObservedAnnotatedTypes().contains(clazz)); Assert.assertNotNull(reference); reference.pong(); manager.resolve(manager.getBeans(clazz)); } private <T> void assertNotDiscoveredAndNotAvailable(Class<T> clazz) { Assert.assertFalse(extension.getObservedAnnotatedTypes().contains(clazz)); Assert.assertTrue(manager.getBeans(clazz).isEmpty()); } private static StringAsset newBeans11Descriptor(String mode) { return new StringAsset("<beans bean-discovery-mode=\"" + mode + "\" version=\"1.1\"/>"); } }
5,288
40
119
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/scopes/ViewScopedBean.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2013, 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.weld.deployment.scopes; import java.io.Serializable; import jakarta.faces.view.ViewScoped; @ViewScoped public class ViewScopedBean implements Serializable { }
1,226
39.9
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/scopes/EE7ScopeAsBeanDefiningAnnotationTest.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2013, 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.weld.deployment.scopes; import jakarta.enterprise.inject.spi.BeanManager; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(Arquillian.class) public class EE7ScopeAsBeanDefiningAnnotationTest { @Inject private BeanManager manager; @Deployment public static Archive<?> getDeployment() { return ShrinkWrap.create(WebArchive.class).addClasses(ViewScopedBean.class, FlowScopedBean.class, TransactionScopedBean.class); } @Test public void testViewScopedBeanDiscovered() { Assert.assertNotNull(manager.resolve(manager.getBeans(ViewScopedBean.class))); } @Test public void testFlowScopedBeanDiscovered() { Assert.assertNotNull(manager.resolve(manager.getBeans(FlowScopedBean.class))); } @Test public void testTransactionScopedBeanDiscovered() { Assert.assertNotNull(manager.resolve(manager.getBeans(TransactionScopedBean.class))); } }
2,298
36.080645
135
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/scopes/FlowScopedBean.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2013, 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.weld.deployment.scopes; import java.io.Serializable; import jakarta.faces.flow.FlowScoped; @FlowScoped("myFlow") public class FlowScopedBean implements Serializable { }
1,236
40.233333
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/scopes/TransactionScopedBean.java
/* * JBoss, Home of Professional Open Source. * Copyright (c) 2013, 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.weld.deployment.scopes; import java.io.Serializable; import jakarta.transaction.TransactionScoped; @SuppressWarnings("serial") @TransactionScoped public class TransactionScopedBean implements Serializable { }
1,278
37.757576
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/EnterpriseBeanDiscoveryTest.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.enterprise.context.spi.CreationalContext; import jakarta.enterprise.inject.spi.Bean; import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.inject.spi.Extension; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * * @author Martin Kouba */ @RunWith(Arquillian.class) public class EnterpriseBeanDiscoveryTest { private static final String ALPHA_JAR = "alpha.jar"; private static final String BRAVO_JAR = "bravo.jar"; private static final String CHARLIE_JAR = "charlie.jar"; private static final String DELTA_JAR = "delta.jar"; private static final String ECHO_JAR = "echo.jar"; private static final String FOXTROT_JAR = "foxtrot.jar"; private static final String LEGACY_JAR = "legacy.jar"; @Deployment public static EnterpriseArchive createTestArchive() { // 1.1 version beans.xml with bean-discovery-mode of all JavaArchive alpha = ShrinkWrap .create(JavaArchive.class, ALPHA_JAR) .addClasses(Alpha.class, AlphaLocal.class) .addAsManifestResource(newBeans11Descriptor("all"), "beans.xml"); // Empty beans.xml JavaArchive bravo = ShrinkWrap.create(JavaArchive.class, BRAVO_JAR).addClasses(Bravo.class, BravoLocal.class) .addAsManifestResource(new StringAsset(""), "beans.xml"); // No version beans.xml JavaArchive charlie = ShrinkWrap .create(JavaArchive.class, CHARLIE_JAR) .addClasses(Charlie.class, CharlieLocal.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); // Session bean and no beans.xml JavaArchive delta = ShrinkWrap.create(JavaArchive.class, DELTA_JAR).addClasses(Delta.class, DeltaLocal.class); // Session bean and 1.1 version beans.xml with bean-discovery-mode of annotated JavaArchive echo = ShrinkWrap .create(JavaArchive.class, ECHO_JAR) .addClasses(Echo.class, EchoLocal.class) .addAsManifestResource(newBeans11Descriptor("annotated"), "beans.xml"); // Session bean and 1.1 version beans.xml with bean-discovery-mode of none JavaArchive foxtrot = ShrinkWrap .create(JavaArchive.class, FOXTROT_JAR) .addClasses(Foxtrot.class, FoxtrotLocal.class) .addAsManifestResource(newBeans11Descriptor("none"), "beans.xml"); // Archive which contains an extension and no beans.xml file - not a bean archive JavaArchive legacy = ShrinkWrap.create(JavaArchive.class, LEGACY_JAR) .addClasses(LegacyExtension.class, LegacyBean.class) .addAsServiceProvider(Extension.class, LegacyExtension.class); StringBuilder manifestBuilder = new StringBuilder("Class-Path:"); for (String s : new String[] {ALPHA_JAR, BRAVO_JAR, CHARLIE_JAR, DELTA_JAR, ECHO_JAR, FOXTROT_JAR, LEGACY_JAR}) { manifestBuilder.append(" "); manifestBuilder.append(s); } WebArchive webArchive = ShrinkWrap.create(WebArchive.class) .addClasses(EnterpriseBeanDiscoveryTest.class, VerifyingExtension.class) .addAsServiceProvider(Extension.class, VerifyingExtension.class) .setManifest(new StringAsset(manifestBuilder.toString())); return ShrinkWrap.create(EnterpriseArchive.class) .addAsModules(webArchive, alpha, bravo, charlie, delta, echo, foxtrot, legacy) .addAsLibrary(ShrinkWrap.create(JavaArchive.class).addClass(Ping.class)); } @Inject VerifyingExtension extension; @Inject private BeanManager manager; @Test public void testExplicitBeanArchiveModeAll() { assertDiscoveredAndAvailable(AlphaLocal.class, Alpha.class); } @Test public void testExplicitBeanArchiveEmptyDescriptor() { assertDiscoveredAndAvailable(BravoLocal.class, Bravo.class); } @Test public void testExplicitBeanArchiveLegacyDescriptor() { assertDiscoveredAndAvailable(CharlieLocal.class, Charlie.class); } @Test public void testImplicitBeanArchiveNoDescriptor() { assertDiscoveredAndAvailable(DeltaLocal.class, Delta.class); } @Test public void testImplicitBeanArchiveModeAnnotated() { assertDiscoveredAndAvailable(EchoLocal.class, Echo.class); } @Test public void testNoBeanArchiveModeNone() { assertNotDiscoveredAndNotAvailable(FoxtrotLocal.class, Foxtrot.class); } @Test public void testNotBeanArchiveExtension() { assertNotDiscoveredAndNotAvailable(LegacyBean.class, LegacyBean.class); } private <T extends Ping, B extends Ping> void assertDiscoveredAndAvailable(Class<T> beanType, Class<B> beanClazz) { Bean<?> bean = manager.resolve(manager.getBeans(beanType)); CreationalContext<?> ctx = manager.createCreationalContext(bean); @SuppressWarnings("unchecked") T instance = (T) manager.getReference(bean, beanType, ctx); Assert.assertNotNull(instance); Assert.assertTrue(extension.getObservedAnnotatedTypes().contains(beanClazz)); instance.pong(); } private <T extends Ping, B extends Ping> void assertNotDiscoveredAndNotAvailable(Class<T> beanType, Class<B> beanClazz) { Assert.assertFalse(extension.getObservedAnnotatedTypes().contains(beanClazz)); Assert.assertTrue(manager.getBeans(beanType).isEmpty()); } private static StringAsset newBeans11Descriptor(String mode) { return new StringAsset("<beans bean-discovery-mode=\"" + mode + "\" version=\"1.1\"/>"); } }
6,991
41.895706
125
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/Echo.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Stateful; @Stateful public class Echo implements EchoLocal { @Override public void pong() { } }
973
32.586207
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/Foxtrot.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Stateful; @Stateful public class Foxtrot implements FoxtrotLocal { @Override public void pong() { } }
979
32.793103
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/DeltaLocal.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Local; @Local public interface DeltaLocal extends Ping { }
923
35.96
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/LegacyBean.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Stateless; @Stateless public class LegacyBean implements Ping { @Override public void pong() { } }
976
32.689655
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/Bravo.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Stateful; @Stateful public class Bravo implements BravoLocal { @Override public void pong() { } }
975
32.655172
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/Ping.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; public interface Ping { void pong(); }
888
36.041667
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/VerifyingExtension.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import java.util.ArrayList; import java.util.List; import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.ProcessAnnotatedType; public class VerifyingExtension implements Extension { private List<Class<?>> observedAnnotatedTypes = new ArrayList<Class<?>>(); public void observeProcessAnnotatedType(@Observes ProcessAnnotatedType<?> event) { observedAnnotatedTypes.add(event.getAnnotatedType().getJavaClass()); } public List<Class<?>> getObservedAnnotatedTypes() { return observedAnnotatedTypes; } }
1,456
36.358974
86
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/CharlieLocal.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Local; @Local public interface CharlieLocal extends Ping { }
925
36.04
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/FoxtrotLocal.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Local; @Local public interface FoxtrotLocal extends Ping { }
925
36.04
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/Alpha.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Stateful; @Stateful public class Alpha implements AlphaLocal { @Override public void pong() { } }
975
32.655172
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/Charlie.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Stateful; @Stateful public class Charlie implements CharlieLocal { @Override public void pong() { } }
979
32.793103
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/Delta.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Stateful; @Stateful public class Delta implements DeltaLocal { @Override public void pong() { } }
975
32.655172
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/AlphaLocal.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Local; @Local public interface AlphaLocal extends Ping { }
923
35.96
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/BravoLocal.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Local; @Local public interface BravoLocal extends Ping { }
923
35.96
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/LegacyExtension.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.AfterTypeDiscovery; import jakarta.enterprise.inject.spi.BeanManager; import jakarta.enterprise.inject.spi.Extension; public class LegacyExtension implements Extension { public void observeBeforeBeanDiscovery(@Observes AfterTypeDiscovery event, BeanManager beanManager) { // Do nothing } }
1,231
38.741935
105
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/enterprise/EchoLocal.java
/* * JBoss, Home of Professional Open Source * Copyright 2013, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.enterprise; import jakarta.ejb.Local; @Local public interface EchoLocal extends Ping { }
922
35.92
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/beandeploymentarchive/SomeBean.java
/* * JBoss, Home of Professional Open Source * Copyright 2017, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.beandeploymentarchive; import jakarta.enterprise.context.ApplicationScoped; /** * * @author <a href="mailto:[email protected]">Matej Novotny</a> */ @ApplicationScoped public class SomeBean { }
1,031
34.586207
76
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/beandeploymentarchive/SomeOtherBean.java
/* * JBoss, Home of Professional Open Source * Copyright 2017, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.beandeploymentarchive; import jakarta.enterprise.context.ApplicationScoped; /** * * @author <a href="mailto:[email protected]">Matej Novotny</a> */ @ApplicationScoped public class SomeOtherBean { }
1,036
34.758621
76
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/beandeploymentarchive/NotABean.java
/* * JBoss, Home of Professional Open Source * Copyright 2017, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.beandeploymentarchive; /** * * @author <a href="mailto:[email protected]">Matej Novotny</a> */ public class NotABean { }
958
35.884615
76
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/deployment/beandeploymentarchive/BeanDeploymentArchiveLookupTest.java
/* * JBoss, Home of Professional Open Source * Copyright 2017, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.deployment.beandeploymentarchive; import jakarta.enterprise.inject.spi.BeanManager; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.weld.bean.builtin.BeanManagerProxy; import org.jboss.weld.manager.BeanManagerImpl; import org.jboss.weld.manager.BeanManagerLookupService; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests WFLY-9536 * @author <a href="mailto:[email protected]">Matej Novotny</a> */ @RunWith(Arquillian.class) public class BeanDeploymentArchiveLookupTest { @Deployment public static WebArchive createTestArchive() { // we are going to use WAR and one JAR, the reason is that the JAR should have different BM Impl against which we can compare JavaArchive lib = ShrinkWrap.create(JavaArchive.class).addClasses(NotABean.class, SomeBean.class) .addAsManifestResource(createBeansXml("annotated"), "beans.xml"); return ShrinkWrap.create(WebArchive.class).addClasses(BeanDeploymentArchiveLookupTest.class, SomeOtherBean.class) .addAsWebInfResource(createBeansXml("annotated"), "beans.xml") .addAsLibraries(lib); } private static StringAsset createBeansXml(String mode) { return new StringAsset("<beans bean-discovery-mode=\"" + mode + "\" version=\"2.0\"/>"); } @Inject BeanManager bm; @Test public void verifyDiscoveryOfAllClasses() { // BM proxy is injected, we unwrap it BeanManagerImpl bmImpl = BeanManagerProxy.unwrap(bm); // use service to lookup BM based on class BeanManagerImpl bmFromSomeBean = BeanManagerLookupService.lookupBeanManager(SomeBean.class, bmImpl); BeanManagerImpl bmFromNotABean = BeanManagerLookupService.lookupBeanManager(NotABean.class, bmImpl); BeanManagerImpl bmFromSomeOtherBean = BeanManagerLookupService.lookupBeanManager(SomeOtherBean.class, bmImpl); Assert.assertNotNull(bmFromSomeBean); Assert.assertNotNull(bmFromNotABean); Assert.assertNotNull(bmFromSomeOtherBean); // verify that BMs from WAR and JAR differ Assert.assertNotEquals(bmFromSomeBean, bmFromSomeOtherBean); // Manager injected here is the same as the one for SomeOtherBean as they are in the same archive Assert.assertEquals(bmImpl, bmFromSomeOtherBean); // BM injected here should be different from that we get from classes in JAR lib Assert.assertNotEquals(bmImpl, bmFromSomeBean); Assert.assertNotEquals(bmImpl, bmFromNotABean); // classes in JAR lib should have the same BM Impl Assert.assertEquals(bmFromSomeBean, bmFromNotABean); } }
3,773
44.46988
133
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/services/TestWS.java
/* * JBoss, Home of Professional Open Source * Copyright 2018, 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.weld.services; import jakarta.jws.WebService; @WebService(targetNamespace = "http://www.jboss.org/jboss/as/test/TestWS") public interface TestWS { String sayHello(); }
1,230
37.46875
74
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/services/WeldResourceInjectionServicesTestCase.java
/* * JBoss, Home of Professional Open Source * Copyright 2018, 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.weld.services; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.shared.TimeoutUtil; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import javax.xml.namespace.QName; import jakarta.xml.ws.Service; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; /** * * Tests that WeldResourceInjectionServices works correctly even in multithreaded scenarios. * * WFLY-9884 * * @author Peter Mackay */ @RunWith(Arquillian.class) @RunAsClient public class WeldResourceInjectionServicesTestCase { @Deployment public static WebArchive getDeployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "weldResourceInjectionServicesTest.war"); war.addClasses(TestWS.class, TestWSImpl.class, ContextBean.class); war.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); return war; } /** * Test that injecting a WebServiceContext into a bean used in a web service is working correctly * even in concurrent service calls. * See https://issues.jboss.org/browse/WFLY-9884 for details. */ @Test public void testWebServiceContextInject(@ArquillianResource URL deploymentUrl) throws Exception { QName serviceName = new QName("http://www.jboss.org/jboss/as/test/TestWS", "TestService"); URL wsdlUrl = new URL(deploymentUrl.toExternalForm() + "/" + TestWSImpl.SERVICE_NAME + "?wsdl"); TestWS testService = Service.create(wsdlUrl, serviceName).getPort(TestWS.class); int workerCount = 20; ExecutorService executor = Executors.newFixedThreadPool(workerCount); List<Future<String>> results = new ArrayList<>(); try { for (int i = 0; i < workerCount; i++) { results.add(executor.submit(new Worker(testService))); } for (Future<String> result : results) { Assert.assertTrue(result.get(TimeoutUtil.adjust(5), TimeUnit.SECONDS).startsWith("Hello")); } } finally { executor.shutdown(); } } private class Worker implements Callable<String> { TestWS service; private Worker(TestWS service) { this.service = service; } @Override public String call() { return service.sayHello(); } } }
3,941
35.165138
107
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/services/ContextBean.java
/* * JBoss, Home of Professional Open Source * Copyright 2018, 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.weld.services; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; import jakarta.enterprise.context.RequestScoped; import jakarta.xml.ws.WebServiceContext; import java.security.Principal; @RequestScoped public class ContextBean { @Resource private WebServiceContext context; private String name; @PostConstruct private void postConstruct() { if (context != null) { Principal principal = context.getUserPrincipal(); name = (principal == null) ? "anonymous" : principal.getName(); } } public String getName() { return this.name; } }
1,698
32.313725
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/services/TestWSImpl.java
/* * JBoss, Home of Professional Open Source * Copyright 2018, 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.weld.services; import jakarta.inject.Inject; import jakarta.jws.WebService; @WebService( serviceName = TestWSImpl.SERVICE_NAME, portName = "TestWS", targetNamespace = "http://www.jboss.org/jboss/as/test/TestWS", endpointInterface = "org.jboss.as.test.integration.weld.services.TestWS") public class TestWSImpl { public static final String SERVICE_NAME = "TestService"; @Inject ContextBean contextBean; public String sayHello() { return "Hello" + contextBean.getName(); } }
1,577
34.863636
77
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/InjectedSessionBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, 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.weld.multideployment; import jakarta.ejb.Stateful; import jakarta.inject.Inject; @Stateful public class InjectedSessionBean { @Inject private SimpleBean bean; public SimpleBean getBean() { return bean; } }
1,295
34.027027
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/WeldModuleDeploymentTestCase.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.weld.multideployment; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.net.URL; import java.nio.file.Files; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.jandex.Index; import org.jboss.jandex.IndexWriter; import org.jboss.jandex.Indexer; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.ByteArrayAsset; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.exporter.ZipExporter; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.AfterClass; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that beans definied in a static can be used by a deployment * * @author Stuart Douglas */ @RunWith(Arquillian.class) public class WeldModuleDeploymentTestCase { public static void doSetup() throws Exception { File testModuleRoot = new File(getModulePath(), "org/jboss/test/weldModule"); File file = testModuleRoot; while (!getModulePath().equals(file.getParentFile())) file = file.getParentFile(); deleteRecursively(file); createTestModule(testModuleRoot); } @AfterClass public static void tearDown() throws Exception { File testModuleRoot = new File(getModulePath(), "org/jboss/test/weldModule"); File file = testModuleRoot; while (!getModulePath().equals(file.getParentFile())) file = file.getParentFile(); deleteRecursively(file); } private static void deleteRecursively(File file) { if (file.exists()) { if (file.isDirectory()) { for (String name : file.list()) { deleteRecursively(new File(file, name)); } } file.delete(); } } private static void createTestModule(File testModuleRoot) throws IOException { if (testModuleRoot.exists()) { throw new IllegalArgumentException(testModuleRoot + " already exists"); } File file = new File(testModuleRoot, "main"); if (!file.mkdirs()) { throw new IllegalArgumentException("Could not create " + file); } URL url = WeldModuleDeploymentTestCase.class.getResource("module.xml"); if (url == null) { throw new IllegalStateException("Could not find module.xml"); } copyFile(new File(file, "module.xml"), url.openStream()); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "weldTest.jar"); jar.addClasses(SimpleBean.class, ModuleEjb.class); jar.addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml"); Indexer indexer = new Indexer(); try (InputStream resource = ModuleEjb.class.getResourceAsStream(ModuleEjb.class.getSimpleName() + ".class")) { indexer.index(resource); } Index index = indexer.complete(); ByteArrayOutputStream data = new ByteArrayOutputStream(); IndexWriter writer = new IndexWriter(data); writer.write(index); jar.addAsManifestResource(new ByteArrayAsset(data.toByteArray()), "jandex.idx"); FileOutputStream jarFile = new FileOutputStream(new File(file, "weldTest.jar")); try { jar.as(ZipExporter.class).exportTo(jarFile); } finally { jarFile.flush(); jarFile.close(); } } private static void copyFile(File target, InputStream src) throws IOException { Files.copy(src, target.toPath()); } private static File getModulePath() { String modulePath = System.getProperty("module.path", null); if (modulePath == null) { String jbossHome = System.getProperty("jboss.home", null); if (jbossHome == null) { throw new IllegalStateException("Neither -Dmodule.path nor -Djboss.home were set"); } modulePath = jbossHome + File.separatorChar + "modules"; } else { modulePath = modulePath.split(File.pathSeparator)[0]; } File moduleDir = new File(modulePath); if (!moduleDir.exists()) { throw new IllegalStateException("Determined module path does not exist"); } if (!moduleDir.isDirectory()) { throw new IllegalStateException("Determined module path is not a dir"); } return moduleDir; } @Deployment public static Archive<?> deploy2() throws Exception { doSetup(); JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "d2.jar"); jar.addClasses(WeldModuleDeploymentTestCase.class); jar.addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml"); jar.addAsManifestResource(new StringAsset("Dependencies: org.jboss.test.weldModule meta-inf annotations\n"), "MANIFEST.MF"); return jar; } @Inject private SimpleBean bean; @Inject private ModuleEjb moduleEjb; @Test public void testSimpleBeanInjected() throws Exception { Assert.assertNotNull(bean); Assert.assertNotNull(moduleEjb); } }
6,494
36.114286
132
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/WeldBundledLibraryDeploymentEarTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, 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.weld.multideployment; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that CDI beans defined in an installed library can be used in an .ear deployment. * * @author Jozef Hartinger * @see https://issues.jboss.org/browse/AS7-6821 */ @RunWith(Arquillian.class) public class WeldBundledLibraryDeploymentEarTestCase extends AbstractBundledLibraryDeploymentTestCase { @Inject private SimpleBean bean; @Inject private InjectedBean injectedBean; @Inject private InjectedSessionBean injectedSessionBean; @Test public void testSimpleBeanInjected() { Assert.assertNotNull(bean); bean.ping(); Assert.assertNotNull(injectedBean); Assert.assertNotNull(injectedBean.getBean()); injectedBean.getBean().ping(); Assert.assertNotNull(injectedSessionBean); Assert.assertNotNull(injectedSessionBean.getBean()); injectedSessionBean.getBean().ping(); } @Deployment public static Archive<?> getDeployment() throws Exception { doSetup(); StringAsset beansXml = new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"); WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war") .addClasses(WeldBundledLibraryDeploymentEarTestCase.class, AbstractBundledLibraryDeploymentTestCase.class) .addAsWebInfResource(beansXml, "beans.xml"); JavaArchive library = ShrinkWrap.create(JavaArchive.class, "library.jar").addClasses(InjectedBean.class).addAsManifestResource(beansXml, "beans.xml"); JavaArchive ejbJar = ShrinkWrap.create(JavaArchive.class, "ejb-archive.jar").addClasses(InjectedSessionBean.class).addAsManifestResource(beansXml, "beans.xml"); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class); ear.addAsModule(war); ear.addAsModule(ejbJar); ear.addAsLibrary(library); ear.setManifest(new StringAsset("Extension-List: weld1\nweld1-Extension-Name: " + EXTENSION_NAME + "\n")); return ear; } }
3,573
40.08046
168
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/AbstractBundledLibraryDeploymentTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, 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.weld.multideployment; import java.io.File; import java.io.IOException; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.exporter.ZipExporter; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.AfterClass; public abstract class AbstractBundledLibraryDeploymentTestCase { public static final String BUNDLED_LIBRARY_NAME = "weld-bundled-library.jar"; public static final String EXTENSION_NAME = "org.jboss.as.test.integration.weld.multideployment.WeldBundledLibraryDeploymentTestCase"; private static File libraryRoot; private static File bundledLibraryFile; public static void doSetup() throws Exception { libraryRoot = createLibraryRoot(); bundledLibraryFile = new File(libraryRoot, BUNDLED_LIBRARY_NAME); deleteFile(bundledLibraryFile); createTestModule(bundledLibraryFile); } @AfterClass public static void tearDown() throws Exception { deleteFile(bundledLibraryFile); } private static void deleteFile(File file) { if (file.exists()) { file.delete(); } } private static void createTestModule(File bundledLibraryFile) throws IOException { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, BUNDLED_LIBRARY_NAME); jar.addClasses(SimpleBean.class); jar.addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml"); jar.setManifest(new StringAsset("Extension-Name: " + EXTENSION_NAME + "\n")); jar.as(ZipExporter.class).exportTo(bundledLibraryFile, true); } private static File createLibraryRoot() { String jbossHome = System.getProperty("jboss.home", null); if (jbossHome == null) { throw new IllegalStateException("-Djboss.home not set"); } String standalonePath = jbossHome + File.separatorChar + "standalone"; File standaloneDir = new File(standalonePath); if (!standaloneDir.exists()) { throw new IllegalStateException("Determined standalone folder path " + standalonePath + " does not exist"); } if (!standaloneDir.isDirectory()) { throw new IllegalStateException("Determined standalone folder path " + standalonePath + " is not a dir"); } String libraryPath = standalonePath + File.separatorChar + "lib" + File.separatorChar + "ext"; File libraryDir = new File(libraryPath); if (libraryDir.exists()) { if (!libraryDir.isDirectory()) { throw new IllegalStateException("Determined library folder path " + libraryPath + " is not a dir"); } } else { libraryDir.mkdirs(); } return libraryDir; } }
3,880
40.731183
138
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/ModuleEjb.java
package org.jboss.as.test.integration.weld.multideployment; import jakarta.ejb.Stateless; /** * @author Stuart Douglas */ @Stateless public class ModuleEjb { public String sayHello() { return "hello"; } }
226
14.133333
59
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/SimpleBean.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.weld.multideployment; import java.io.Serializable; import jakarta.inject.Named; /** * @author Stuart Douglas */ @Named public class SimpleBean implements Serializable{ public void ping() { } }
1,269
32.421053
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/WeldBundledLibraryDeploymentTestCase.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, 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.weld.multideployment; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that Jakarta Contexts and Dependency Injection beans defined in a bundled library can be used in a deployment * * @author Jozef Hartinger * */ @RunWith(Arquillian.class) public class WeldBundledLibraryDeploymentTestCase extends AbstractBundledLibraryDeploymentTestCase { @Inject private SimpleBean bean; @Test public void testSimpleBeanInjected() { Assert.assertNotNull(bean); bean.ping(); } @Deployment public static Archive<?> getDeployment() throws Exception { doSetup(); JavaArchive jar = ShrinkWrap.create(JavaArchive.class); jar.addClasses(WeldBundledLibraryDeploymentTestCase.class, AbstractBundledLibraryDeploymentTestCase.class); jar.addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml"); jar.setManifest(new StringAsset("Extension-List: weld1\nweld1-Extension-Name: " + EXTENSION_NAME + "\n")); return jar; } }
2,470
37.609375
118
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/InjectedBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2013, 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.weld.multideployment; import jakarta.inject.Inject; public class InjectedBean { @Inject private SimpleBean bean; public SimpleBean getBean() { return bean; } }
1,249
34.714286
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/multideployment/WeldCrossDeploymentTestCase.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.weld.multideployment; import jakarta.inject.Inject; 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.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Weld cross deployment injection test case. Verifies that weld can read beans.xml and scan classes outside the * deployment. * * @author Stuart Douglas */ @RunWith(Arquillian.class) public class WeldCrossDeploymentTestCase { @Deployment(name = "d1", order = 1, testable = false) public static Archive<?> deploy() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "d1.jar"); jar.addClasses(SimpleBean.class); jar.addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml"); return jar; } @Deployment(name = "d2", order = 2) public static Archive<?> deploy2() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "d2.jar"); jar.addClass(WeldCrossDeploymentTestCase.class); jar.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); jar.addAsManifestResource(WeldCrossDeploymentTestCase.class.getPackage(), "jboss-deployment-structure.xml", "jboss-deployment-structure.xml"); return jar; } @Inject private SimpleBean bean; @Test @OperateOnDeployment("d2") public void testSimpleBeanInjected() throws Exception { Assert.assertNotNull(bean); } }
2,844
36.434211
150
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/jta/CdiBean.java
/* * JBoss, Home of Professional Open Source * * Copyright 2018 Red Hat, Inc. and/or its affiliates. * * 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.weld.jta; import jakarta.annotation.Resource; import jakarta.enterprise.context.ApplicationScoped; import jakarta.transaction.Status; import jakarta.transaction.TransactionSynchronizationRegistry; import jakarta.transaction.Transactional; @ApplicationScoped public class CdiBean { @Resource TransactionSynchronizationRegistry transactionSynchronizationRegistry; public boolean isTransactionSynchronizationRegistryInjected() { return transactionSynchronizationRegistry != null; } @Transactional public boolean isTransactionActive() { return transactionSynchronizationRegistry.getTransactionStatus() == Status.STATUS_ACTIVE; } public boolean isTransactionInactive() { return transactionSynchronizationRegistry.getTransactionStatus() == Status.STATUS_NO_TRANSACTION; } }
1,539
32.478261
105
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/jta/TransactionalCdiEarTestCase.java
/* * JBoss, Home of Professional Open Source * * Copyright 2018 Red Hat, Inc. and/or its affiliates. * * 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.weld.jta; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that the Transactional annotation works in a CDI Bean which is in an ear deployment. * <p> * This is a test case for WFLY-11506 that requires standalone.xml server configuration. Notice that if you are using * -Dtest= system property to run this test, the result could end up in a false negative because Wildfly uses * standalone-full.xml configuration file to run individual tests, and this variant includes the org.jboss.jts module in * the ear classpath via MessagingDependencyProcessor, making the issue not reproducible. * * @author Yeray Borges */ @RunWith(Arquillian.class) public class TransactionalCdiEarTestCase { @Inject CdiBean cdiBean; @Deployment public static EnterpriseArchive deployment(){ final String deployName = TransactionalCdiEarTestCase.class.getSimpleName(); final WebArchive warModule = ShrinkWrap.create(WebArchive.class, deployName + ".war") .addClasses(CdiBean.class, TransactionalCdiEarTestCase.class) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, deployName + ".ear") .addAsModule(warModule); return ear; } @Test public void testIfTransactionIsActive() { Assert.assertTrue(cdiBean.isTransactionActive()); } @Test public void testIfTransactionIsInactive() { Assert.assertTrue(cdiBean.isTransactionInactive()); } }
2,629
34.540541
120
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/jta/TransactionSynchronizationRegistryInjectionTestCase.java
/* * JBoss, Home of Professional Open Source * * Copyright 2018 Red Hat, Inc. and/or its affiliates. * * 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.weld.jta; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(Arquillian.class) public class TransactionSynchronizationRegistryInjectionTestCase { @Inject CdiBean cdiBean; @Deployment public static WebArchive deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class) .addPackage(TransactionSynchronizationRegistryInjectionTestCase.class.getPackage()) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); return war; } @Test public void testTransactionSynchronizationRegistryIsInjected() { Assert.assertTrue(cdiBean.isTransactionSynchronizationRegistryInjected()); } }
1,696
32.27451
99
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/SessionObjectReferenceTestCase.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.weld.ejb; import java.beans.XMLDecoder; import java.io.ByteArrayInputStream; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.nio.charset.StandardCharsets; import java.util.List; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import jakarta.ejb.ConcurrentAccessException; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.container.test.api.RunAsClient; import org.jboss.arquillian.junit.Arquillian; import org.jboss.arquillian.test.api.ArquillianResource; import org.jboss.as.test.integration.common.HttpRequest; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.jboss.stdio.WriterOutputStream; import org.junit.Test; import org.junit.runner.RunWith; import static java.util.concurrent.TimeUnit.SECONDS; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; /** * Test two things: * 1. EJBTHREE-697: First concurrent call doesn't throw exception * 2. make sure the SFSB is instantiated in the same thread as the Servlet, so propagation works * <p/> * Make sure a concurrent call to a SFSB proxy over Weld gets a ConcurrentAccessException. * * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @RunWith(Arquillian.class) @RunAsClient public class SessionObjectReferenceTestCase { @ArquillianResource private URL url; @Deployment public static WebArchive deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "war-example.war") .addClasses(HttpRequest.class, SimpleServlet.class, SimpleStatefulSessionBean.class, WriterOutputStream.class) .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml") .addAsWebInfResource(new StringAsset(WEB_XML), "web.xml"); return war; } private String performCall(String urlPattern, String param) { String spec = url.toExternalForm() + urlPattern + "?input=" + param; try { return HttpRequest.get(spec, 30, SECONDS); } catch (ExecutionException e) { throw new RuntimeException(e.getCause()); } catch (MalformedURLException e) { throw new RuntimeException(e); } catch (TimeoutException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } @Test public void testEcho() throws Exception { String result = performCall("simple", "Hello+world"); XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(result.getBytes(StandardCharsets.UTF_8))); List<String> results = (List<String>) decoder.readObject(); List<Exception> exceptions = (List<Exception>) decoder.readObject(); String sharedContext = (String) decoder.readObject(); decoder.close(); assertEquals(1, results.size()); assertEquals("Echo Hello world", results.get(0)); assertEquals(1, exceptions.size()); assertTrue(exceptions.get(0) instanceof ConcurrentAccessException); assertEquals("Shared context", sharedContext); } private static final String WEB_XML = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" + "<!--org.jboss.as.weld.deployment.processors.WebIntegrationProcessor checks for the existence of WebMetaData -->\n" + "<web-app version=\"3.0\" xmlns=\"http://java.sun.com/xml/ns/j2ee\"\n" + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" + " xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_3_0.xsd\">\n" + " <!-- if I have a web.xml, annotations won't work anymore -->\n" + " <servlet>\n" + " <servlet-name>SimpleServlet</servlet-name>\n" + " <servlet-class>org.jboss.as.test.integration.weld.ejb.SimpleServlet</servlet-class>\n" + " </servlet>\n" + " <servlet-mapping>\n" + " <servlet-name>SimpleServlet</servlet-name>\n" + " <url-pattern>/simple</url-pattern>\n" + " </servlet-mapping>\n" + "</web-app>"; }
5,489
42.92
130
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/SimpleStatefulSessionBean.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.weld.ejb; import static java.util.concurrent.TimeUnit.SECONDS; import static jakarta.ejb.TransactionAttributeType.NEVER; import java.util.concurrent.CountDownLatch; import jakarta.annotation.PostConstruct; import jakarta.ejb.AccessTimeout; import jakarta.ejb.LocalBean; import jakarta.ejb.Stateful; import jakarta.ejb.TransactionAttribute; /** * A simple stateful session bean. * * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @Stateful @LocalBean // do not wait, but throw immediately @AccessTimeout(0) // we don't want any interference from tx association (probably a bug) @TransactionAttribute(NEVER) public class SimpleStatefulSessionBean { public String echo(CountDownLatch latch, String msg) throws InterruptedException { boolean tripped = latch.await(5, SECONDS); if (!tripped) return "Timed out"; return "Echo " + msg; } @PostConstruct public void postConstruct() { SimpleServlet.propagated.set("Shared context"); } }
2,084
34.338983
86
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/SimpleServlet.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.weld.ejb; import static java.util.concurrent.TimeUnit.SECONDS; import java.beans.XMLEncoder; import java.io.IOException; import java.io.PrintWriter; import java.util.LinkedList; import java.util.List; import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Future; import java.util.concurrent.TimeoutException; import jakarta.annotation.PostConstruct; import jakarta.inject.Inject; import jakarta.servlet.ServletException; import jakarta.servlet.annotation.WebServlet; import jakarta.servlet.http.HttpServlet; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpServletResponse; import org.jboss.stdio.WriterOutputStream; /** * @author <a href="mailto:[email protected]">Carlo de Wolf</a> */ @WebServlet(name="SimpleServlet", urlPatterns={"/simple"}) public class SimpleServlet extends HttpServlet { static ThreadLocal<String> propagated = new ThreadLocal<String>(); @Inject private SimpleStatefulSessionBean bean; private String sharedContext; @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { final String msg = req.getParameter("input"); // the first call needs to be concurrent //bean.setMessage(msg); final ExecutorService executor = Executors.newFixedThreadPool(2); final CountDownLatch latch = new CountDownLatch(1); final Future<String>[] futures = new Future[2]; for (int i = 0; i < futures.length; i++) { futures[i] = executor.submit(new Callable<String>() { @Override public String call() throws Exception { try { return bean.echo(latch, msg); } finally { // the second concurrent call will throw ConcurrentAccessException // so now we make the first call proceed latch.countDown(); } } }); } final List<String> results = new LinkedList<String>(); final List<Throwable> exceptions = new LinkedList<Throwable>(); for (int i = 0; i < futures.length; i++) { try { String result = futures[i].get(10, SECONDS); results.add(result); } catch(ExecutionException e) { e.printStackTrace(); exceptions.add(e.getCause()); } catch (InterruptedException e) { e.printStackTrace(); exceptions.add(e); } catch (TimeoutException e) { e.printStackTrace(); exceptions.add(e); } } // make a 'nice' report PrintWriter writer = resp.getWriter(); XMLEncoder encoder = new XMLEncoder(new WriterOutputStream(writer)); encoder.writeObject(results); encoder.writeObject(exceptions); encoder.writeObject(sharedContext); encoder.close(); } @PostConstruct public void postConstruct() { this.sharedContext = propagated.get(); } }
4,410
36.067227
113
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/jbossall/JBossAllEjbJarTestCase.java
/* * JBoss, Home of Professional Open Source * Copyright 2021, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.weld.ejb.jbossall; 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.Test; import org.junit.runner.RunWith; /** * Tests that jboss-ejb3.xml is picked up from jboss-all.xml */ @RunWith(Arquillian.class) public class JBossAllEjbJarTestCase { @ArquillianResource private InitialContext ctx; @Deployment(name = "test") public static Archive<?> deploy() { final JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "jbossAllEjb.jar"); jar.addPackage(JBossAllEjbJarTestCase.class.getPackage()); jar.addAsManifestResource(JBossAllEjbJarTestCase.class.getPackage(), "jboss-all.xml", "jboss-all.xml"); return jar; } @Test public void testWeldParsing() throws Exception { //if the lookup passes then we know the bean was added ctx.lookup("java:module/" + JBossAllBean.class.getSimpleName()); } }
2,232
36.216667
111
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/jbossall/JBossAllBean.java
/* * JBoss, Home of Professional Open Source. * Copyright 2021, Red Hat, Inc., and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.weld.ejb.jbossall; /** * @author Stuart Douglas */ public class JBossAllBean { }
1,147
36.032258
70
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/Synchronizations.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.weld.ejb.inheritance; public interface Synchronizations { void register(); }
1,138
38.275862
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/AbstractBaseClass.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.weld.ejb.inheritance; /** * @author Stuart Douglas */ public abstract class AbstractBaseClass { public String sayHello() { return "Hello"; } public abstract String sayGoodbye(); }
1,260
34.027778
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/ParentInterface.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.weld.ejb.inheritance; /** * @author Stuart Douglas */ public interface ParentInterface { String interfaceMethod(); }
1,179
37.064516
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/ChildInterface.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.weld.ejb.inheritance; import jakarta.ejb.Local; /** * @author Stuart Douglas */ @Local public interface ChildInterface extends ParentInterface { }
1,206
35.575758
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/InjectingCDIBean.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.weld.ejb.inheritance; import jakarta.inject.Inject; /** * @author Stuart Douglas */ public class InjectingCDIBean { @Inject private AbstractBaseClass inheritingBean; @Inject private ParentInterface parentInterface; public String sayHello() { return inheritingBean.sayHello(); } public String sayGoodbye() { return inheritingBean.sayGoodbye(); } public String callInterfaceMethod() { return parentInterface.interfaceMethod(); } }
1,557
30.16
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/InterfaceBean.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.weld.ejb.inheritance; import jakarta.ejb.Stateless; /** * @author Stuart Douglas */ @Stateless public class InterfaceBean implements ChildInterface{ @Override public String interfaceMethod() { return "Interface"; } }
1,295
35
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/LocalSynchronizations.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.weld.ejb.inheritance; /** * @author Stuart Douglas */ public interface LocalSynchronizations extends Synchronizations { void destroy(); }
1,200
37.741935
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/SynchronizationsBean.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.weld.ejb.inheritance; import jakarta.ejb.Local; import jakarta.ejb.Stateful; /** * @author Stuart Douglas */ @Local(Synchronizations.class) @Stateful public class SynchronizationsBean implements LocalSynchronizations { @Override public void destroy() { } @Override public void register() { } }
1,378
31.833333
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/EjbInheritanceTestCase.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.weld.ejb.inheritance; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import jakarta.inject.Inject; /** * Tests that ejb's can be injected into an injection point of a type that does not exactly correlate * to one of their views. * * WELD-921 * Also tests that EJB invocations on base class methods work * */ @RunWith(Arquillian.class) public class EjbInheritanceTestCase { @Deployment public static WebArchive deployment() { WebArchive war = ShrinkWrap.create(WebArchive.class, "inheritance-test.war") .addPackage(EjbInheritanceTestCase.class.getPackage()) .addAsWebInfResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml"); return war; } @Inject private Synchronizations sync; @Inject private InjectingCDIBean injectingCDIBean; @Test public void testEjbCanBeInjectedViaNonViewInjectionPoint() { sync.register(); } @Test public void testCdiInjectedEjb() { Assert.assertEquals("Hello", injectingCDIBean.sayHello()); Assert.assertEquals("Goodbye", injectingCDIBean.sayGoodbye()); Assert.assertEquals("Interface", injectingCDIBean.callInterfaceMethod()); } }
2,575
34.287671
110
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/inheritance/InheritingBean.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.weld.ejb.inheritance; import jakarta.ejb.LocalBean; import jakarta.ejb.Stateless; /** * @author Stuart Douglas */ @Stateless @LocalBean public class InheritingBean extends AbstractBaseClass { @Override public String sayGoodbye() { return "Goodbye"; } }
1,334
32.375
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/injectiontarget/Bus.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.weld.ejb.injectiontarget; import jakarta.ejb.Singleton; @Singleton public class Bus { private boolean initialized = false; public boolean isInitialized() { return initialized; } public void setInitialized(boolean initialized) { this.initialized = initialized; } }
1,359
33.871795
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/injectiontarget/ForwardingInjectionTarget.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.weld.ejb.injectiontarget; import java.util.Set; import jakarta.enterprise.context.spi.CreationalContext; import jakarta.enterprise.inject.spi.InjectionPoint; import jakarta.enterprise.inject.spi.InjectionTarget; public abstract class ForwardingInjectionTarget<T> implements InjectionTarget<T> { public abstract InjectionTarget<T> getDelegate(); @Override public T produce(CreationalContext<T> ctx) { return getDelegate().produce(ctx); } @Override public void dispose(T instance) { getDelegate().dispose(instance); } @Override public Set<InjectionPoint> getInjectionPoints() { return getDelegate().getInjectionPoints(); } @Override public void inject(T instance, CreationalContext<T> ctx) { getDelegate().inject(instance, ctx); } @Override public void postConstruct(T instance) { getDelegate().postConstruct(instance); } @Override public void preDestroy(T instance) { getDelegate().preDestroy(instance); } }
2,095
31.75
82
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/injectiontarget/EjbInjectionTargetWrapTestCase.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.weld.ejb.injectiontarget; import jakarta.enterprise.inject.spi.Extension; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * AS7-1373 * * Tests that EJB's InjectionTarget can be wrapped. * * @author Jozef Hartinger */ @RunWith(Arquillian.class) public class EjbInjectionTargetWrapTestCase { @Deployment public static JavaArchive getDeployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class); jar.addPackage(EjbInjectionTargetWrapTestCase.class.getPackage()); jar.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); jar.addAsServiceProvider(Extension.class, WrappingExtension.class); return jar; } @Inject private Bus bus; @Test public void testEjbInjectionTargetWasWrapped() { Assert.assertTrue(bus.isInitialized()); } }
2,197
34.451613
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/injectiontarget/WrappingExtension.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.weld.ejb.injectiontarget; import jakarta.enterprise.context.spi.CreationalContext; import jakarta.enterprise.event.Observes; import jakarta.enterprise.inject.spi.Extension; import jakarta.enterprise.inject.spi.InjectionTarget; import jakarta.enterprise.inject.spi.ProcessInjectionTarget; public class WrappingExtension implements Extension { public void wrapInjectionTarget(@Observes ProcessInjectionTarget<Bus> event) { final InjectionTarget<Bus> injectionTarget = event.getInjectionTarget(); event.setInjectionTarget(new ForwardingInjectionTarget<Bus>() { @Override public void inject(Bus instance, CreationalContext<Bus> ctx) { super.inject(instance, ctx); instance.setInitialized(true); } @Override public InjectionTarget<Bus> getDelegate() { return injectionTarget; } }); } }
1,992
39.673469
82
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/Counter.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; /** * @author Marius Bogoevici */ public class Counter { static int count; public static int next() { return ++count; } }
1,037
33.6
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/Secured.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; import jakarta.interceptor.InterceptorBinding; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * @author Marius Bogoevici */ @InterceptorBinding @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @Target({ElementType.METHOD, ElementType.TYPE}) public @interface Secured { }
1,374
34.25641
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/EjbInterceptor.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.InvocationContext; /** * @author Marius Bogoevici */ public class EjbInterceptor { static int count; @AroundInvoke public Object doInTransaction(InvocationContext invocationContext) throws Exception { count = Counter.next(); return invocationContext.proceed(); } }
1,261
35.057143
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/CdiInterceptor2.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.Interceptor; import jakarta.interceptor.InvocationContext; /** * @author Marius Bogoevici */ @Interceptor @Counted public class CdiInterceptor2 { static int count; @AroundInvoke public Object doCounted(InvocationContext invocationContext) throws Exception { count = Counter.next(); return invocationContext.proceed(); } }
1,319
32.846154
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/Counted.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; import jakarta.interceptor.InterceptorBinding; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * @author Marius Bogoevici */ @InterceptorBinding @Retention(RetentionPolicy.RUNTIME) @Documented @Inherited @Target({ElementType.METHOD, ElementType.TYPE}) public @interface Counted { }
1,374
34.25641
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/CdiInterceptor.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.Interceptor; import jakarta.interceptor.InvocationContext; /** * @author Marius Bogoevici */ @Interceptor @Secured public class CdiInterceptor { static int count; @AroundInvoke public Object doSecured(InvocationContext invocationContext) throws Exception { count = Counter.next(); return invocationContext.proceed(); } }
1,318
32.820513
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/InterceptorOrderTest.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * @author Marius Bogoevici */ @RunWith(Arquillian.class) public class InterceptorOrderTest { @Deployment public static Archive<?> deploy() { return ShrinkWrap.create(JavaArchive.class) .addAsManifestResource(new StringAsset("<beans><interceptors><class>" + CdiInterceptor2.class.getName() + "</class><class>" + CdiInterceptor.class.getName() + "</class></interceptors></beans>"), "beans.xml") .addPackage(InterceptorOrderTest.class.getPackage()); } @Test public void testOrder(Processor processor) { Counter.count = 0; SimpleProcessor.count = 0; CdiInterceptor.count = 0; CdiInterceptor2.count = 0; EjbInterceptor.count = 0; EjbInterceptor2.count = 0; int sum = processor.add(8, 13); Assert.assertEquals(21, sum); Assert.assertEquals(1, EjbInterceptor.count); Assert.assertEquals(2, EjbInterceptor2.count); Assert.assertEquals(3, CdiInterceptor2.count); Assert.assertEquals(4, CdiInterceptor.count); Assert.assertEquals(5, SimpleProcessor.count); } @Test public void testOrder2(Processor processor) { Counter.count = 0; SimpleProcessor.count = 0; CdiInterceptor.count = 0; CdiInterceptor2.count = 0; EjbInterceptor.count = 0; EjbInterceptor2.count = 0; int sum = processor.subtract(34, 13); Assert.assertEquals(21, sum); Assert.assertEquals(0, EjbInterceptor.count); Assert.assertEquals(1, CdiInterceptor2.count); Assert.assertEquals(2, CdiInterceptor.count); Assert.assertEquals(3, SimpleProcessor.count); } }
2,965
36.075
223
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/SimpleProcessor.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; import jakarta.ejb.Stateless; import jakarta.interceptor.ExcludeClassInterceptors; import jakarta.interceptor.Interceptors; /** * @author Marius Bogoevici */ @Stateless @Counted @Interceptors(EjbInterceptor.class) public class SimpleProcessor implements Processor { static int count; @Secured @Interceptors(EjbInterceptor2.class) public int add(int x, int y) { count = Counter.next(); return x + y; } @Secured @ExcludeClassInterceptors public int subtract(int x, int y) { count = Counter.next(); return x - y; } }
1,481
29.244898
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/EjbInterceptor2.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.InvocationContext; /** * @author Marius Bogoevici */ public class EjbInterceptor2 { static int count; @AroundInvoke public Object doInTransaction(InvocationContext invocationContext) throws Exception { count = Counter.next(); return invocationContext.proceed(); } }
1,262
35.085714
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/interceptorsorderwithexclusions/Processor.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat, Inc. and/or its affiliates, and individual * contributors by the @authors tag. See the copyright.txt in the * distribution for a full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.interceptorsorderwithexclusions; /** * @author Marius Bogoevici */ public interface Processor { @Secured int add(int x, int y); int subtract(int x, int y); }
1,032
34.62069
91
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/injection/Message.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.weld.ejb.interceptor.injection; /** * @author Stuart Douglas */ public class Message { public String getMessage() { return " World"; } }
1,212
34.676471
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/injection/MessageInterceptor.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.weld.ejb.interceptor.injection; import jakarta.inject.Inject; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.InvocationContext; /** * EJB interceptor that uses CDI injection * @author Stuart Douglas */ public class MessageInterceptor { @Inject private Message message; @AroundInvoke public Object invoke(InvocationContext ctx) throws Exception { return ctx.proceed().toString() + message.getMessage(); } }
1,517
34.302326
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/injection/CDIInjectionIntoEJBInterceptorTestCase.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.weld.ejb.interceptor.injection; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * * Tests that EJB interceptors can use CDI injection. * * @author Stuart Douglas */ @RunWith(Arquillian.class) public class CDIInjectionIntoEJBInterceptorTestCase { @Deployment public static Archive<?> deploy() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class); jar.addPackage(CDIInjectionIntoEJBInterceptorTestCase.class.getPackage()); jar.addAsManifestResource(new StringAsset("<beans bean-discovery-mode=\"all\"></beans>"), "beans.xml"); return jar; } @Inject private MessageBean bean; @Test public void testCDIInjectionIntoEJBInterceptor() { Assert.assertEquals("Hello World", bean.getMessage()); } }
2,188
34.885246
111
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/injection/MessageBean.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.weld.ejb.interceptor.injection; import jakarta.ejb.Stateless; import jakarta.interceptor.Interceptors; /** * @author Stuart Douglas */ @Stateless @Interceptors(MessageInterceptor.class) public class MessageBean { public String getMessage() { return "Hello"; } }
1,338
33.333333
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/binding/SimpleSLSB.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.weld.ejb.interceptor.binding; import jakarta.ejb.Stateless; import jakarta.interceptor.Interceptors; import org.junit.Assert; /** * @author Stuart Douglas */ @Stateless @Binding @Interceptors(EjbInterceptor.class) public class SimpleSLSB { public String sayHello() { Assert.assertTrue(CdiInterceptor.invoked); Assert.assertTrue(EjbInterceptor.invoked); return "Hello"; } }
1,465
33.093023
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/binding/Binding.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.weld.ejb.interceptor.binding; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import jakarta.interceptor.InterceptorBinding; /** * @author Stuart Douglas */ @InterceptorBinding @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface Binding { }
1,444
35.125
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/binding/EjbInterceptor.java
/* * JBoss, Home of Professional Open Source * Copyright 2010, Red Hat Inc., and individual contributors as indicated * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA, or see the FSF site: http://www.fsf.org. */ package org.jboss.as.test.integration.weld.ejb.interceptor.binding; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.InvocationContext; import org.junit.Assert; /** * A normal non-cdi interceptor. This must be called before CDI interceptors * * @author Stuart Douglas */ public class EjbInterceptor { public static boolean invoked = false; @AroundInvoke public Object invoke(InvocationContext context) throws Exception { try { invoked = true; Assert.assertFalse(CdiInterceptor.invoked); return context.proceed() +" Ejb"; } finally { Assert.assertTrue(CdiInterceptor.invoked); } } }
1,714
34
76
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/binding/CdiInterceptor.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.weld.ejb.interceptor.binding; import jakarta.annotation.PostConstruct; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.Interceptor; import jakarta.interceptor.InvocationContext; import org.junit.Assert; /** * @author Stuart Douglas */ @Binding @Interceptor public class CdiInterceptor { public static boolean invoked = false; private String message = ""; @PostConstruct public void postConstruct(InvocationContext context) { message = " World"; } @AroundInvoke public Object invoke(InvocationContext ctx) throws Exception{ invoked = true; Assert.assertTrue(EjbInterceptor.invoked); return ctx.proceed() + message; } }
1,765
31.703704
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/binding/WeldInterceptorBindingTestCase.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.weld.ejb.interceptor.binding; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * * A simple test that Jakarta Contexts and Dependency Injection interceptors are applied to EJB's, * and that they are applied in the correct order. * * @author Stuart Douglas */ @RunWith(Arquillian.class) public class WeldInterceptorBindingTestCase { @Deployment public static Archive<?> deploy() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class); jar.addPackage(WeldInterceptorBindingTestCase.class.getPackage()); jar.addAsManifestResource(new StringAsset("<beans><interceptors><class>"+CdiInterceptor.class.getName() + "</class></interceptors></beans>"), "beans.xml"); return jar; } @Inject private SimpleSLSB bean; @Test public void testSlsbInterceptor() { Assert.assertEquals("Hello World Ejb", bean.sayHello()); Assert.assertTrue(CdiInterceptor.invoked); Assert.assertTrue(EjbInterceptor.invoked); } }
2,406
36.609375
163
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/context/TestSingleton.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.weld.ejb.interceptor.context; import jakarta.ejb.EJB; import jakarta.ejb.Singleton; import jakarta.ejb.Startup; @Singleton @Startup public class TestSingleton { @EJB private HelloEJB helloEJB; //@PostConstruct public boolean test() { return helloEJB.sayHello() != null; } }
1,360
33.025
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/context/ServiceLoggedInterceptor.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.weld.ejb.interceptor.context; import jakarta.annotation.PostConstruct; import jakarta.annotation.Resource; import jakarta.ejb.SessionContext; import jakarta.interceptor.AroundInvoke; import jakarta.interceptor.Interceptor; import jakarta.interceptor.InvocationContext; @Interceptor @ServiceLogged public class ServiceLoggedInterceptor { @Resource SessionContext sessionContext; @PostConstruct public void init(InvocationContext context) throws Exception { context.proceed(); } @AroundInvoke public Object log(InvocationContext ic) throws Exception { return ic.proceed(); } }
1,683
33.367347
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/context/WeldInterceptorEJBContextTestCase.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.weld.ejb.interceptor.context; import jakarta.inject.Inject; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; /** * * A simple test that CDI interceptors are applied to EJB's, and that they are * applied in the correct order. * * @author baranowb * @author Brad Maxwell */ @RunWith(Arquillian.class) public class WeldInterceptorEJBContextTestCase { @Deployment public static Archive<?> deploy() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class); jar.addPackage(WeldInterceptorEJBContextTestCase.class.getPackage()); jar.addAsManifestResource( new StringAsset("<beans><interceptors><class>" + ServiceLoggedInterceptor.class.getName() + "</class></interceptors></beans>"), "beans.xml"); return jar; } @Inject private TestSingleton bean; @Test public void testEJBContextInjection() { //deployment is enough Assert.assertTrue("Call failed?", bean.test()); } }
2,364
34.833333
143
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/context/ServiceLogged.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.weld.ejb.interceptor.context; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import jakarta.interceptor.InterceptorBinding; @InterceptorBinding @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface ServiceLogged { }
1,416
37.297297
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/context/HelloEJB.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.weld.ejb.interceptor.context; import jakarta.ejb.Stateless; import jakarta.ejb.Startup; import jakarta.ejb.TransactionAttribute; import jakarta.ejb.TransactionAttributeType; @Stateless @Startup @ServiceLogged @TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED) public class HelloEJB { public String sayHello() { return "hello"; } }
1,415
35.307692
73
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/ordering/CdiIntercepted.java
/* * JBoss, Home of Professional Open Source * Copyright 2012, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.ordering; import java.lang.annotation.Documented; import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.Target; import jakarta.interceptor.InterceptorBinding; import static java.lang.annotation.ElementType.METHOD; import static java.lang.annotation.ElementType.TYPE; import static java.lang.annotation.RetentionPolicy.RUNTIME; @InterceptorBinding @Inherited @Target({ TYPE, METHOD }) @Retention(RUNTIME) @Documented public @interface CdiIntercepted { }
1,345
34.421053
75
java
null
wildfly-main/testsuite/integration/basic/src/test/java/org/jboss/as/test/integration/weld/ejb/interceptor/ordering/SessionBeanInterceptorOrderingTest.java
/* * JBoss, Home of Professional Open Source * Copyright 2012, Red Hat, Inc., and individual contributors * by the @authors tag. See the copyright.txt in the distribution for a * full listing of individual contributors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.apache.org/licenses/LICENSE-2.0 * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.jboss.as.test.integration.weld.ejb.interceptor.ordering; import static org.junit.Assert.assertEquals; import java.util.ArrayList; import java.util.List; import jakarta.inject.Inject; import jakarta.interceptor.Interceptors; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.Archive; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.StringAsset; import org.jboss.shrinkwrap.api.spec.WebArchive; import org.junit.Test; import org.junit.runner.RunWith; /** * Tests that session bean interceptors are executed in the following order: * * 1) Interceptors bound using {@link Interceptors} (referred to as "legacy interceptors" hereafter) * 2) CDI interceptors * 3) Target class around invoke method * * @see https://issues.jboss.org/browse/AS7-6015 * * @author Jozef Hartinger * */ @RunWith(Arquillian.class) public class SessionBeanInterceptorOrderingTest { @Inject private InterceptedBean bean; @Deployment public static Archive<?> getDeployment() { return ShrinkWrap .create(WebArchive.class) .addPackage(SessionBeanInterceptorOrderingTest.class.getPackage()) .addAsWebInfResource( new StringAsset("<beans><interceptors><class>" + CdiInterceptor.class.getName() + "</class></interceptors></beans>"), "beans.xml"); } @Test public void testSessionBeanInterceptorOrdering() { List<String> expectedSequence = new ArrayList<String>(); expectedSequence.add("LegacyInterceptor"); expectedSequence.add("CdiInterceptor"); expectedSequence.add("TargetClassInterceptor"); expectedSequence.add("InterceptedBean"); List<String> actualSequence = new ArrayList<String>(); bean.ping(actualSequence); assertEquals(expectedSequence, actualSequence); } }
2,770
34.525641
103
java