From 40ad7b2a2fa142d59a6eb43c2a60a82c534c7461 Mon Sep 17 00:00:00 2001 From: Kyle Aure Date: Thu, 28 Jul 2022 14:18:42 -0500 Subject: [PATCH 1/2] Update TCK for web profile --- tck-dist/src/main/starter/suite.xml | 5 + .../tck/concurrent/common/TestGroups.java | 3 + .../concurrent/framework/EJBJNDIProvider.java | 13 + .../contextPropagate/ContextEJBProvider.java | 25 ++ .../ContextPropagationTests.java | 8 +- .../ContextPropagationWebTests.java | 278 ++++++++++++++++++ .../ContextServiceDefinitionWebBean.java | 55 ++++ .../TestSecurityRunnableWork.java | 6 +- .../ManagedExecutorDefinitionWebTests.java | 129 ++++++++ .../security/SecurityEJBProvider.java | 25 ++ .../security/SecurityTestTask.java | 6 +- .../security/SecurityTests.java | 8 +- .../security/SecurityWebTests.java | 75 +++++ .../inheritedapi/CounterEJBProvider.java | 25 ++ .../inheritedapi/InheritedAPITests.java | 5 +- .../inheritedapi/InheritedAPIWebTests.java | 133 +++++++++ .../inheritedapi/TestEjb.java | 11 +- ...edScheduledExecutorDefinitionWebTests.java | 139 +++++++++ .../security/SecurityEJBProvider.java | 25 ++ .../security/SecurityTestTask.java | 6 +- .../security/SecurityTests.java | 6 +- .../security/SecurityWebTests.java | 73 +++++ .../context/ContextWebTests.java | 72 +++++ ...anagedThreadFactoryDefinitionWebTests.java | 108 +++++++ .../dd/DeploymentDescriptorWebTests.java | 86 ++++++ .../tck/concurrent/spec/Platform/dd/web.xml | 48 +++ 26 files changed, 1355 insertions(+), 18 deletions(-) create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/framework/EJBJNDIProvider.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextEJBProvider.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionWebBean.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityEJBProvider.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/CounterEJBProvider.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIWebTests.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityEJBProvider.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityWebTests.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextWebTests.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java create mode 100644 tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/web.xml diff --git a/tck-dist/src/main/starter/suite.xml b/tck-dist/src/main/starter/suite.xml index b7b08cc1..63f12080 100644 --- a/tck-dist/src/main/starter/suite.xml +++ b/tck-dist/src/main/starter/suite.xml @@ -19,6 +19,11 @@ + + + + + diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/TestGroups.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/TestGroups.java index 72768724..3eadcec9 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/TestGroups.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/TestGroups.java @@ -18,4 +18,7 @@ public interface TestGroups { /** Group for tests requiring the full platform */ String JAKARTAEE_FULL = "eefull"; + + /** Group for tests requiring the full platform */ + String JAKARTAEE_WEB = "eeweb"; } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/framework/EJBJNDIProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/EJBJNDIProvider.java new file mode 100644 index 00000000..a56e49cc --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/framework/EJBJNDIProvider.java @@ -0,0 +1,13 @@ +package ee.jakarta.tck.concurrent.framework; + +/** + * A service provider to pass along EJB JNDI names from test class to servlet, or tasks. + * This is a necessary provider since the same test packaged as an EAR for Full profile, and a + * WAR for Web Profile will have different JNDI names for their EJBs. + */ +public interface EJBJNDIProvider { + /** + * Provides the EJB JNDI name for the test. + */ + public String getEJBJNDIName(); +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextEJBProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextEJBProvider.java new file mode 100644 index 00000000..4260df17 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextEJBProvider.java @@ -0,0 +1,25 @@ +package ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate; + +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; + +/** + * Need to provide different JNDI names depending application deployment + */ +public class ContextEJBProvider { + + public static class FullProvider implements EJBJNDIProvider { + public FullProvider() {} + @Override + public String getEJBJNDIName() { + return "java:app/ContextPropagationTests_ejb/LimitedBean"; + } + } + + public static class WebProvider implements EJBJNDIProvider { + public WebProvider() {} + @Override + public String getEJBJNDIName() { + return "java:app/ContextPropagationTests_web/LimitedBean"; + } + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationTests.java index 6d0b66fc..bdbf526a 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationTests.java @@ -26,6 +26,7 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; import org.testng.annotations.Test; +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.URLBuilder; @@ -37,9 +38,6 @@ @Test(groups = JAKARTAEE_FULL) public class ContextPropagationTests extends TestClient { - - public static final String LimitedBeanAppJNDI = "java:app/ContextPropagationTests_ejb/LimitedBean"; - @Deployment(name="ContextPropagationTests", testable=false) public static EnterpriseArchive createDeployment() { @@ -65,7 +63,9 @@ public static EnterpriseArchive createDeployment() { JNDIServlet.class, SecurityServlet.class, JSPSecurityServlet.class, - ContextServiceDefinitionFromEJBServlet.class) + ContextServiceDefinitionFromEJBServlet.class, + ContextServiceDefinitionWebBean.class) + .addAsServiceProvider(EJBJNDIProvider.class, ContextEJBProvider.FullProvider.class) .addAsManifestResource(ContextPropagationTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml"); //TODO document how users can dynamically inject vendor specific deployment descriptors into this archive diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java new file mode 100644 index 00000000..8c48e6e4 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextPropagationWebTests.java @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate; + +import java.net.URL; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.annotations.Test; + +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; +import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.TestConstants; +import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.spi.context.IntContextProvider; +import ee.jakarta.tck.concurrent.spi.context.StringContextProvider; +import jakarta.enterprise.concurrent.spi.ThreadContextProvider; + +import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_WEB;; + +@Test(groups = JAKARTAEE_WEB) +public class ContextPropagationWebTests extends TestClient { + + @Deployment(name="ContextPropagationTests", testable=false) + public static WebArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ContextPropagationTests_web.war") + .addPackages(true, + ContextPropagationWebTests.class.getPackage(), + getFrameworkPackage(), + getContextPackage(), + getContextProvidersPackage()) + .deleteClasses(ContextServiceDefinitionBean.class) + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()) + .addAsServiceProvider(EJBJNDIProvider.class, ContextEJBProvider.WebProvider.class) + .addAsWebInfResource(ContextPropagationWebTests.class.getPackage(), "web.xml", "web.xml") + .addAsWebResource(ContextPropagationWebTests.class.getPackage(), "jspTests.jsp", "jspTests.jsp"); + + return war; + } + + @ArquillianResource(JNDIServlet.class) + URL jndiURL; + + @ArquillianResource(JSPSecurityServlet.class) + URL jspURL; + + @ArquillianResource(ClassloaderServlet.class) + URL classloaderURL; + + @ArquillianResource(SecurityServlet.class) + URL securityURL; + + @ArquillianResource(ContextServiceDefinitionServlet.class) + URL contextURL; + + @ArquillianResource(ContextServiceDefinitionFromEJBServlet.class) + URL ejbContextURL; + + // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from another thread or the current user is changed + @Test(enabled = false) + public void testSecurityClearedContext() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testName); + runTest(requestURL); + } + + // HttpServletRequest.getUserPrincipal behavior is unclear when accessed from another thread or the current user is changed + @Test(enabled = false) + public void testSecurityUnchangedContext() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testName); + runTest(requestURL); + } + + @Test + public void testSecurityPropagatedContext() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(jspURL).withPaths("jspTests.jsp").withTestName(testName); + runTest(requestURL); + } + + /* + * @testName: testJNDIContextAndCreateProxyInServlet + * + * @assertion_ids: + * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; + * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; + * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:2;CONCURRENCY:SPEC:4.1; + * + * @test_Strategy: create proxy in servlet and pass it into ejb container, then + * verify JNDI Context. + * + */ + @Test + public void testJNDIContextAndCreateProxyInServlet() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(jndiURL).withPaths("JNDIServlet").withTestName(testName); + String resp = runTestWithResponse(requestURL, null); + this.assertStringInResponse(testName + "failed to get correct result.", "JNDIContextWeb", resp); + } + + /* + * @testName: testJNDIContextAndCreateProxyInEJB + * + * @assertion_ids: + * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; + * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; + * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:3;CONCURRENCY:SPEC:3.1; + * CONCURRENCY:SPEC:3.2;CONCURRENCY:SPEC:3.3;CONCURRENCY:SPEC:3.4; + * CONCURRENCY:SPEC:4; + * + * @test_Strategy: create proxy in servlet and pass it into ejb container, then + * verify JNDI Context. + * + */ + @Test (enabled = false) //This test will return JNDIContextWeb because we are running with web.xml and not ejb-jar.xml + public void testJNDIContextAndCreateProxyInEJB() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(jndiURL).withPaths("JNDIServlet").withTestName(testName); + String resp = runTestWithResponse(requestURL, null); + this.assertStringInResponse(testName + "failed to get correct result.", "JNDIContextEJB", resp); + } + + /* + * @testName: testClassloaderAndCreateProxyInServlet + * + * @assertion_ids: + * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; + * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; + * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:4.2;CONCURRENCY:SPEC:4.4; + * + * @test_Strategy: create proxy in servlet and pass it into ejb container, then + * verify classloader. + * + */ + @Test + public void testClassloaderAndCreateProxyInServlet() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(securityURL).withPaths("ClassloaderServlet").withTestName(testName); + String resp = runTestWithResponse(requestURL, null); + this.assertStringInResponse(testName + "failed to get correct result.", TestConstants.ComplexReturnValue, resp); + } + + /* + * @testName: testSecurityAndCreateProxyInServlet + * + * @assertion_ids: + * CONCURRENCY:SPEC:85;CONCURRENCY:SPEC:76;CONCURRENCY:SPEC:76.1; + * CONCURRENCY:SPEC:76.2;CONCURRENCY:SPEC:76.3;CONCURRENCY:SPEC:77; + * CONCURRENCY:SPEC:84;CONCURRENCY:SPEC:4.3;CONCURRENCY:SPEC:4.4; + * CONCURRENCY:SPEC:4.4; + * + * @test_Strategy: create proxy in servlet and pass it into ejb container, then + * verify permission. + * + */ + @Test + public void testSecurityAndCreateProxyInServlet() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(classloaderURL).withPaths("SecurityServlet").withTestName(testName); + String resp = runTestWithResponse(requestURL, null); + this.assertStringInResponse(testName + "failed to get correct result.", TestConstants.ComplexReturnValue, resp); + } + + /** + * A ContextServiceDefinition with all attributes configured + * propagates/clears/ignores context types as configured. + * ContextA, which is tested here, propagates Application context and IntContext, + * clears StringContext, and leaves Transaction context unchanged. + */ + @Test + public void testContextServiceDefinitionAllAttributes() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testName); + runTest(requestURL); + } + + /** + * A ContextServiceDefinition defined in an EJB with all attributes configured + * propagates/clears/ignores context types as configured. + * ContextA, which is tested here, propagates Application context and IntContext, + * clears StringContext, and leaves Transaction context unchanged. + */ + @Test + public void testContextServiceDefinitionFromEJBAllAttributes() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testName); + runTest(requestURL); + } + + /** + * A ContextServiceDefinition with minimal attributes configured + * clears transaction context and propagates other types. + */ + @Test + public void testContextServiceDefinitionDefaults() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testName); + runTest(requestURL); + } + + /** + * A ContextServiceDefinition defined in an EJB with minimal attributes configured + * clears transaction context and propagates other types. + */ + @Test + public void testContextServiceDefinitionFromEJBDefaults() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testName); + runTest(requestURL); + } + + /** + * A ContextServiceDefinition can specify a third-party context type to be propagated/cleared/ignored. + * This test uses 2 ContextServiceDefinitions: + * ContextA with IntContext propagated and StringContext cleared. + * ContextB with IntContext unchanged and StringContext propagated (per ALL_REMAINING). + */ + @Test + public void testContextServiceDefinitionWithThirdPartyContext() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testName); + runTest(requestURL); + } + + /** + * A ContextService contextualizes a Consumer, which can be supplied as a dependent stage action + * to an unmanaged CompletableFuture. The dependent stage action runs with the thread context of + * the thread that contextualizes the Consumer, per the configuration of the ContextServiceDefinition. + */ + @Test + public void testContextualConsumer() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testName); + runTest(requestURL); + } + + /** + * A ContextService contextualizes a Function, which can be supplied as a dependent stage action + * to an unmanaged CompletableFuture. The dependent stage action runs with the thread context of + * the thread that contextualizes the Function, per the configuration of the ContextServiceDefinition. + * + * Assertions on results[0] and results[1] are both invalid because treating those two UNCHANGED context types as + * though they were CLEARED. + * TCK challenge: https://github.com/jakartaee/concurrency/issues/253 + */ + @Test(enabled = false) + public void testContextualFunction() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testName); + runTest(requestURL); + } + + /** + * A ContextService contextualizes a Supplier, which can be supplied as a dependent stage action + * to an unmanaged CompletableFuture. The dependent stage action runs with the thread context of + * the thread that contextualizes the Supplier, per the configuration of the ContextServiceDefinition. + */ + @Test + public void testContextualSupplier() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testName); + runTest(requestURL); + requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ContextServiceDefinitionFromEJBServlet").withTestName(testName); + runTest(requestURL); + } + + /** + * ContextService can create a contextualized copy of an unmanaged CompletableFuture. + */ + @Test + public void testCopyWithContextCapture() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(contextURL).withPaths("ContextServiceDefinitionServlet").withTestName(testName); + runTest(requestURL); + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionWebBean.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionWebBean.java new file mode 100644 index 00000000..525d9578 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/ContextServiceDefinitionWebBean.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate; + +import static jakarta.enterprise.concurrent.ContextServiceDefinition.APPLICATION; +import static jakarta.enterprise.concurrent.ContextServiceDefinition.TRANSACTION; + +import jakarta.ejb.Local; +import jakarta.ejb.Stateless; +import jakarta.enterprise.concurrent.ContextService; +import jakarta.enterprise.concurrent.ContextServiceDefinition; +import ee.jakarta.tck.concurrent.common.context.IntContext; +import ee.jakarta.tck.concurrent.common.context.StringContext; + +import javax.naming.InitialContext; +import javax.naming.NamingException; + +@ContextServiceDefinition(name = "java:app/concurrent/EJBContextA", + propagated = { APPLICATION, IntContext.NAME }, + cleared = StringContext.NAME, + unchanged = TRANSACTION) +@ContextServiceDefinition(name = "java:comp/concurrent/EJBContextC") +@Local(ContextServiceDefinitionInterface.class) +@Stateless +public class ContextServiceDefinitionWebBean implements ContextServiceDefinitionInterface { + + /** + * Get java:comp/concurrent/EJBContextC from the bean. + */ + @Override + public ContextService getContextC() throws NamingException { + return InitialContext.doLookup("java:comp/concurrent/EJBContextC"); + } + + /** + * Get java:comp/concurrent/ContextB from the bean. + */ + @Override + public ContextService getContextB() throws NamingException { + return InitialContext.doLookup("java:module/concurrent/ContextB"); + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestSecurityRunnableWork.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestSecurityRunnableWork.java index b5bc2d6c..c660a729 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestSecurityRunnableWork.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ContextService/contextPropagate/TestSecurityRunnableWork.java @@ -16,6 +16,9 @@ package ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate; +import java.util.ServiceLoader; + +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestUtil; @SuppressWarnings("serial") @@ -23,6 +26,7 @@ public class TestSecurityRunnableWork extends BaseTestRunnableWork { @Override protected String work() { - return ( (LimitedInterface) TestUtil.lookup(ContextPropagationTests.LimitedBeanAppJNDI) ).doSomething(); + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + return ( (LimitedInterface) TestUtil.lookup(nameProvider.getEJBJNDIName()) ).doSomething(); } } diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java new file mode 100644 index 00000000..d60688d3 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/resourcedef/ManagedExecutorDefinitionWebTests.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2022 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.concurrent.spec.ManagedExecutorService.resourcedef; + +import java.net.URL; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; +import org.jboss.shrinkwrap.api.spec.JavaArchive; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.annotations.Test; + +import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionWebBean; +import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionInterface; +import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionServlet; +import ee.jakarta.tck.concurrent.spi.context.IntContextProvider; +import ee.jakarta.tck.concurrent.spi.context.StringContextProvider; +import jakarta.enterprise.concurrent.spi.ThreadContextProvider; + +import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_WEB;; + +@Test(groups = JAKARTAEE_WEB) +public class ManagedExecutorDefinitionWebTests extends TestClient{ + + @ArquillianResource(ManagedExecutorDefinitionServlet.class) + URL baseURL; + + @ArquillianResource(ManagedExecutorDefinitionOnEJBServlet.class) + URL ejbContextURL; + + @Deployment(name="ManagedExecutorDefinitionTests", testable=false) + public static WebArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedExecutorDefinitionTests_web.war") + .addPackages(false, + ManagedExecutorDefinitionWebTests.class.getPackage(), + getFrameworkPackage(), + getContextPackage(), + getContextProvidersPackage()) + .addClasses( + ContextServiceDefinitionInterface.class, + ContextServiceDefinitionWebBean.class, + ContextServiceDefinitionServlet.class) + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); + + return war; + } + + @Override + protected String getServletPath() { + return "ManagedExecutorDefinitionServlet"; + } + + @Test + public void testAsyncCompletionStage() { + runTest(baseURL); + } + + @Test + public void testAsynchronousMethodReturnsCompletableFuture() { + runTest(baseURL); + } + + @Test + public void testAsynchronousMethodReturnsCompletionStage() { + runTest(baseURL); + } + + @Test + public void testAsynchronousMethodVoidReturnType() { + runTest(baseURL); + } + + // TCK Accepted Challenge: https://github.com/jakartaee/concurrency/issues/224 + @Test(enabled = false) + public void testCompletedFuture() { + runTest(baseURL); + } + + @Test + public void testCopyCompletableFuture() { + runTest(baseURL); + } + + @Test + public void testCopyCompletableFutureEJB() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testName); + runTest(requestURL); + } + + @Test + public void testIncompleteFuture() { + runTest(baseURL); + } + + @Test + public void testIncompleteFutureEJB() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedExecutorDefinitionOnEJBServlet").withTestName(testName); + runTest(requestURL); + } + + @Test + public void testManagedExecutorDefinitionAllAttributes() { + runTest(baseURL); + } + + @Test + public void testManagedExecutorDefinitionDefaults() { + runTest(baseURL); + } + +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityEJBProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityEJBProvider.java new file mode 100644 index 00000000..dfb74aa9 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityEJBProvider.java @@ -0,0 +1,25 @@ +package ee.jakarta.tck.concurrent.spec.ManagedExecutorService.security; + +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; + +/** + * Need to provide different JNDI names depending application deployment + */ +public class SecurityEJBProvider { + + public static class FullProvider implements EJBJNDIProvider { + public FullProvider() {} + @Override + public String getEJBJNDIName() { + return "java:global/security/security_ejb/SecurityTestEjb"; + } + } + + public static class WebProvider implements EJBJNDIProvider { + public WebProvider() {} + @Override + public String getEJBJNDIName() { + return "java:global/security_web/SecurityTestEjb"; + } + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestTask.java index 0d367e9b..095f342c 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTestTask.java @@ -16,17 +16,21 @@ package ee.jakarta.tck.concurrent.spec.ManagedExecutorService.security; +import java.util.ServiceLoader; import java.util.concurrent.Callable; import javax.naming.InitialContext; +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; + public class SecurityTestTask implements Callable { public String call() { try { InitialContext context = new InitialContext(); + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); SecurityTestInterface str = (SecurityTestInterface) context - .lookup(SecurityTests.SecurityEJBJNDI); + .lookup(nameProvider.getEJBJNDIName()); return str.managerMethod1(); } catch (Exception e) { throw new RuntimeException(e); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTests.java index ea4b63bd..a391225e 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityTests.java @@ -26,15 +26,14 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; import org.testng.annotations.Test; +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_FULL; @Test(groups = JAKARTAEE_FULL) public class SecurityTests extends TestClient { - - public static final String SecurityEJBJNDI = "java:global/security/security_ejb/SecurityTestEjb"; - + @ArquillianResource URL baseURL; @@ -45,7 +44,8 @@ public static EnterpriseArchive createDeployment() { .deleteClasses(SecurityTestInterface.class, SecurityTestEjb.class); //SecurityTestEjb and SecurityTestInterface are in the jar; JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "security_ejb.jar") - .addClasses(SecurityTestInterface.class, SecurityTestEjb.class); + .addClasses(SecurityTestInterface.class, SecurityTestEjb.class) + .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.FullProvider.class);; EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "security.ear") .addAsModules(war, jar); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java new file mode 100644 index 00000000..2d18ec18 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedExecutorService/security/SecurityWebTests.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.concurrent.spec.ManagedExecutorService.security; + +import java.net.URL; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.annotations.Test; + +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; +import ee.jakarta.tck.concurrent.framework.TestClient; + +import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_WEB;; + +@Test(groups = JAKARTAEE_WEB) +public class SecurityWebTests extends TestClient { + + @ArquillianResource + URL baseURL; + + @Deployment(name="SecurityTests", testable=false) + public static WebArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class, "security_web.war") + .addPackages(true, + SecurityWebTests.class.getPackage(), + getFrameworkPackage(), + getCommonPackage()) + .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.WebProvider.class); +; + + return war; + } + + @Override + protected String getServletPath() { + return "SecurityServlet"; + } + + /* + * @testName: managedExecutorServiceAPISecurityTest + * + * @assertion_ids: CONCURRENCY:SPEC:4.3; CONCURRENCY:SPEC:50; + * CONCURRENCY:SPEC:85; CONCURRENCY:SPEC:96.6; CONCURRENCY:SPEC:106; + * CONCURRENCY:SPEC:22; + * + * @test_Strategy: login in a servlet with username "javajoe(in role manager)", + * then submit a task by ManagedExecutorService in which call a ejb that + * requires role manager. + * + * Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/227 + * fix: https://github.com/jakartaee/concurrency/pull/218 + * Can be reenabled in next release of Concurrency + */ + @Test(enabled = false) + public void managedExecutorServiceAPISecurityTest() { + runTest(baseURL); + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/CounterEJBProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/CounterEJBProvider.java new file mode 100644 index 00000000..cd9c687c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/CounterEJBProvider.java @@ -0,0 +1,25 @@ +package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.inheritedapi; + +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; + +/** + * Need to provide different JNDI names depending application deployment + */ +public class CounterEJBProvider { + + public static class FullProvider implements EJBJNDIProvider { + public FullProvider() {} + @Override + public String getEJBJNDIName() { + return "java:global/inheritedapi/inheritedapi_counter/CounterSingleton"; + } + } + + public static class WebProvider implements EJBJNDIProvider { + public WebProvider() {} + @Override + public String getEJBJNDIName() { + return "java:global/inheritedapi/CounterSingleton"; + } + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPITests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPITests.java index 54b0f298..7e5a4f36 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPITests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPITests.java @@ -22,6 +22,7 @@ import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.testng.annotations.Test; +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import jakarta.ejb.EJB; @@ -29,12 +30,12 @@ @Test(groups = JAKARTAEE_FULL) public class InheritedAPITests extends TestClient { - public static final String CounterSingletonJNDI = "java:global/inheritedapi/inheritedapi_counter/CounterSingleton"; @Deployment(name="InheritedAPITests") public static EnterpriseArchive createDeployment() { JavaArchive counterJAR = ShrinkWrap.create(JavaArchive.class, "inheritedapi_counter.jar") - .addPackages(true, getFrameworkPackage(), getCommonPackage() ,getCommonCounterPackage()); + .addPackages(true, getFrameworkPackage(), getCommonPackage() ,getCommonCounterPackage()) + .addAsServiceProvider(EJBJNDIProvider.class, CounterEJBProvider.FullProvider.class); //TODO document how users can dynamically inject vendor specific deployment descriptors into this archive JavaArchive inheritedJAR = ShrinkWrap.create(JavaArchive.class, "inheritedapi.jar") diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIWebTests.java new file mode 100644 index 00000000..40a1b8d4 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/InheritedAPIWebTests.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.inheritedapi; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.annotations.Test; + +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; +import ee.jakarta.tck.concurrent.framework.TestClient; +import jakarta.ejb.EJB; + +import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_WEB;; + +@Test(groups = JAKARTAEE_WEB) +public class InheritedAPIWebTests extends TestClient { + + @Deployment(name="InheritedAPITests") + public static WebArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class, "inheritedapi.war") + .addPackages(true, + InheritedAPIWebTests.class.getPackage(), + getFrameworkPackage(), + getCommonPackage(), + getCommonCounterPackage()) + .deleteClasses(InheritedAPIWebTests.class, InheritedAPITests.class) + .addAsServiceProvider(EJBJNDIProvider.class, CounterEJBProvider.WebProvider.class); + return war; + } + + @EJB + private TestEjbInterface testEjb; + + /* + * @testName: testApiSubmit + * + * @assertion_ids: CONCURRENCY:SPEC:44.1 + * + * @test_Strategy: + */ + @Test + public void testApiSubmit() { + testEjb.testApiSubmit(); + } + + /* + * @testName: testApiExecute + * + * @assertion_ids: CONCURRENCY:SPEC:44.2 + * + * @test_Strategy: + */ + @Test + public void testApiExecute() { + testEjb.testApiExecute(); + } + + /* + * @testName: testApiInvokeAll + * + * @assertion_ids: CONCURRENCY:SPEC:44.3 + * + * @test_Strategy: + */ + @Test + public void testApiInvokeAll() { + testEjb.testApiInvokeAll(); + } + + /* + * @testName: testApiInvokeAny + * + * @assertion_ids: CONCURRENCY:SPEC:44.4 + * + * @test_Strategy: + */ + @Test + public void testApiInvokeAny() { + testEjb.testApiInvokeAny(); + } + + /* + * @testName: testApiSchedule + * + * @assertion_ids: CONCURRENCY:SPEC:44.5 + * + * @test_Strategy: + */ + @Test + public void testApiSchedule() { + testEjb.testApiSchedule(); + } + + /* + * @testName: testApiScheduleAtFixedRate + * + * @assertion_ids: CONCURRENCY:SPEC:44.6 + * + * @test_Strategy: + */ + @Test + public void testApiScheduleAtFixedRate() { + testEjb.testApiScheduleAtFixedRate(); + } + + /* + * @testName: testApiScheduleWithFixedDelay + * + * @assertion_ids: CONCURRENCY:SPEC:44.7 + * + * @test_Strategy: + */ + @Test + public void testApiScheduleWithFixedDelay() { + testEjb.testApiScheduleWithFixedDelay(); + } + +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java index 29acbccc..1941b76d 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/inheritedapi/TestEjb.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.ServiceLoader; import java.util.concurrent.CancellationException; import java.util.concurrent.Future; import java.util.concurrent.ScheduledFuture; @@ -30,6 +31,7 @@ import ee.jakarta.tck.concurrent.common.CommonTasks; import ee.jakarta.tck.concurrent.common.counter.CounterInterface; import ee.jakarta.tck.concurrent.common.counter.CounterRunnableTask; +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestConstants; import ee.jakarta.tck.concurrent.framework.TestUtil; import jakarta.ejb.EJB; @@ -61,7 +63,8 @@ public void testApiSubmit() { public void testApiExecute() { try { - TestUtil.getManagedScheduledExecutorService().execute(new CounterRunnableTask(InheritedAPITests.CounterSingletonJNDI)); + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + TestUtil.getManagedScheduledExecutorService().execute(new CounterRunnableTask(nameProvider.getEJBJNDIName())); waitForCounter(1); } catch (Exception e) { fail(e.getMessage()); @@ -156,7 +159,8 @@ public void testApiSchedule() { public void testApiScheduleAtFixedRate() { ScheduledFuture result = null; try { - result = TestUtil.getManagedScheduledExecutorService().scheduleAtFixedRate(new CounterRunnableTask(InheritedAPITests.CounterSingletonJNDI), + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + result = TestUtil.getManagedScheduledExecutorService().scheduleAtFixedRate(new CounterRunnableTask(nameProvider.getEJBJNDIName()), TestConstants.PollInterval.getSeconds(), TestConstants.PollInterval.getSeconds(), TimeUnit.SECONDS); TestUtil.sleep(TestConstants.WaitTimeout); TestUtil.assertIntInRange(TestConstants.PollsPerTimeout - 2, TestConstants.PollsPerTimeout + 2, counter.getCount()); @@ -178,8 +182,9 @@ public void testApiScheduleAtFixedRate() { public void testApiScheduleWithFixedDelay() { ScheduledFuture result = null; try { + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); result = TestUtil.getManagedScheduledExecutorService().scheduleWithFixedDelay( - new CounterRunnableTask(InheritedAPITests.CounterSingletonJNDI, TestConstants.PollInterval.toMillis()), //task + new CounterRunnableTask(nameProvider.getEJBJNDIName(), TestConstants.PollInterval.toMillis()), //task TestConstants.PollInterval.getSeconds(), //initial delay TestConstants.PollInterval.getSeconds(), //delay TimeUnit.SECONDS); //Time units diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java new file mode 100644 index 00000000..62be7cb7 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/resourcedef/ManagedScheduledExecutorDefinitionWebTests.java @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.resourcedef; + +import java.net.URL; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.annotations.Test; + +import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionWebBean; +import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionInterface; +import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionServlet; +import ee.jakarta.tck.concurrent.spi.context.IntContextProvider; +import ee.jakarta.tck.concurrent.spi.context.StringContextProvider; +import jakarta.enterprise.concurrent.spi.ThreadContextProvider; + +import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_WEB;; + + +@Test(groups = JAKARTAEE_WEB) +public class ManagedScheduledExecutorDefinitionWebTests extends TestClient { + + @ArquillianResource(ManagedScheduledExecutorDefinitionServlet.class) + URL baseURL; + + @ArquillianResource(ManagedScheduledExecutorDefinitionOnEJBServlet.class) + URL ejbContextURL; + + @Deployment(name="ManagedScheduledExecutorDefinitionTests", testable=false) + public static WebArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedScheduledExecutorDefinitionTests_web.war") + .addPackages(false, + ManagedScheduledExecutorDefinitionWebTests.class.getPackage(), + getFrameworkPackage(), + getContextPackage(), + getContextProvidersPackage()) + .addClasses( + ContextServiceDefinitionServlet.class, + ContextServiceDefinitionInterface.class, + ContextServiceDefinitionWebBean.class) + .addAsWebInfResource(ManagedScheduledExecutorDefinitionWebTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml") + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); + + return war; + } + + @Override + protected String getServletPath() { + return "ManagedScheduledExecutorDefinitionServlet"; + } + + + @Test + public void testAsyncCompletionStageMSE() { + runTest(baseURL); + } + + @Test + public void testAsynchronousMethodRunsWithContext() { + runTest(baseURL); + } + + @Test + public void testAsynchronousMethodWithMaxAsync3() { + runTest(baseURL); + } + // Accepted TCK Challenge: https://github.com/jakartaee/concurrency/issues/224 + @Test(enabled = false) + public void testCompletedFutureMSE() { + runTest(baseURL); + } + + @Test + public void testIncompleteFutureMSE() { + runTest(baseURL); + } + + @Test + public void testIncompleteFutureMSE_EJB() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testName); + runTest(requestURL); + } + + @Test + public void testManagedScheduledExecutorDefinitionAllAttributes() { + runTest(baseURL); + } + + @Test + public void testManagedScheduledExecutorDefinitionAllAttributes_EJB() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testName); + runTest(requestURL); + } + + @Test + public void testManagedScheduledExecutorDefinitionDefaults() { + runTest(baseURL); + } + + @Test + public void testManagedScheduledExecutorDefinitionDefaults_EJB() { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedScheduledExecutorDefinitionOnEJBServlet").withTestName(testName); + runTest(requestURL); + } + + @Test + public void testNotAnAsynchronousMethod() { + runTest(baseURL); + } + + @Test + public void testScheduleWithCronTrigger() { + runTest(baseURL); + } + + @Test + public void testScheduleWithZonedTrigger() { + runTest(baseURL); + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityEJBProvider.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityEJBProvider.java new file mode 100644 index 00000000..9bb543eb --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityEJBProvider.java @@ -0,0 +1,25 @@ +package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.security; + +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; + +/** + * Need to provide different JNDI names depending application deployment + */ +public class SecurityEJBProvider { + + public static class FullProvider implements EJBJNDIProvider { + public FullProvider() {} + @Override + public String getEJBJNDIName() { + return "java:global/security/security_ejb/SecurityTestEjb"; + } + } + + public static class WebProvider implements EJBJNDIProvider { + public WebProvider() {} + @Override + public String getEJBJNDIName() { + return "java:global/security_web/SecurityTestEjb"; + } + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestTask.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestTask.java index e4b2b091..0e817d90 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestTask.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTestTask.java @@ -16,16 +16,20 @@ package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.security; +import java.util.ServiceLoader; import java.util.concurrent.Callable; import javax.naming.InitialContext; +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; + public class SecurityTestTask implements Callable { public String call() { try { InitialContext context = new InitialContext(); - SecurityTestInterface str = (SecurityTestInterface) context.lookup(SecurityTests.SecurityEJBJNDI); + EJBJNDIProvider nameProvider = ServiceLoader.load(EJBJNDIProvider.class).findFirst().orElseThrow(); + SecurityTestInterface str = (SecurityTestInterface) context.lookup(nameProvider.getEJBJNDIName()); return str.managerMethod1(); } catch (Exception e) { throw new RuntimeException(e); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTests.java index 6358a45e..88e6a4f5 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTests.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityTests.java @@ -26,13 +26,13 @@ import org.jboss.shrinkwrap.api.spec.WebArchive; import org.testng.annotations.Test; +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; import ee.jakarta.tck.concurrent.framework.TestClient; import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_FULL; @Test(groups = JAKARTAEE_FULL) public class SecurityTests extends TestClient { - public static final String SecurityEJBJNDI = "java:global/security/security_ejb/SecurityTestEjb"; @ArquillianResource(SecurityServlet.class) URL baseURL; @@ -44,7 +44,9 @@ public static EnterpriseArchive createDeployment() { .deleteClasses(SecurityTestInterface.class, SecurityTestEjb.class); //SecurityTestEjb and SecurityTestInterface are in the jar JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "security_ejb.jar") - .addClasses(SecurityTestInterface.class, SecurityTestEjb.class); + .addPackage(getFrameworkPackage()) + .addClasses(SecurityTestInterface.class, SecurityTestEjb.class) + .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.FullProvider.class); EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "security.ear") .addAsModules(war, jar); diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityWebTests.java new file mode 100644 index 00000000..38099764 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedScheduledExecutorService/security/SecurityWebTests.java @@ -0,0 +1,73 @@ +/* + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.concurrent.spec.ManagedScheduledExecutorService.security; + +import java.net.URL; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.annotations.Test; + +import ee.jakarta.tck.concurrent.framework.EJBJNDIProvider; +import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.URLBuilder; + +import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_WEB; + +@Test(groups = JAKARTAEE_WEB) +public class SecurityWebTests extends TestClient { + + @ArquillianResource(SecurityServlet.class) + URL baseURL; + + @Deployment(name="SecurityTests", testable=false) + public static WebArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class, "security_web.war") + .addPackages(true, + SecurityWebTests.class.getPackage(), + getFrameworkPackage(), + getCommonPackage()) + .addAsServiceProvider(EJBJNDIProvider.class, SecurityEJBProvider.WebProvider.class); + + return war; + } + + @Override + protected String getServletPath() { + return "SecurityServlet"; + } + + /* + * @testName: managedScheduledExecutorServiceAPISecurityTest + * + * @assertion_ids: CONCURRENCY:SPEC:4.3; CONCURRENCY:SPEC:50; + * + * @test_Strategy: login in a servlet with username "javajoe(in role manager)", + * then submit a task by ManagedScheduledExecutorService in which call a ejb + * that requires role manager. + * + * Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/227 + * fix: https://github.com/jakartaee/concurrency/pull/221 + * Can be reenabled in the next release of Jakarta Concurrency + */ + @Test(enabled = false) + public void managedScheduledExecutorServiceAPISecurityTest() { + runTest(baseURL); + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextWebTests.java new file mode 100644 index 00000000..9716660c --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/context/ContextWebTests.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2013, 2022 Oracle and/or its affiliates. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ + +package ee.jakarta.tck.concurrent.spec.ManagedThreadFactory.context; + +import java.net.URL; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.annotations.Test; + +import ee.jakarta.tck.concurrent.framework.TestClient; + +import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_WEB; + +@Test(groups = JAKARTAEE_WEB) +public class ContextWebTests extends TestClient { + + @ArquillianResource + URL baseURL; + + @Deployment(name="ContextTests", testable=false) + public static WebArchive createDeployment() { + WebArchive war = ShrinkWrap.create(WebArchive.class) + .addPackages(true, + ContextWebTests.class.getPackage(), + getFrameworkPackage(), + getCommonPackage()) + .addAsWebInfResource(ContextWebTests.class.getPackage(), "web.xml", "web.xml"); + + return war; + } + + @Override + protected String getServletPath() { + return "SecurityServlet"; + } + + /* + * @testName: jndiClassloaderPropagationTest + * + * @assertion_ids: CONCURRENCY:SPEC:96.7; CONCURRENCY:SPEC:100; + * CONCURRENCY:SPEC:106; + * + * @test_Strategy: + */ + @Test + public void jndiClassloaderPropagationTest() { + runTest(baseURL); + } + + @Test + public void jndiClassloaderPropagationWithSecurityTest() { + runTest(baseURL); + } + +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java new file mode 100644 index 00000000..8e99daec --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/ManagedThreadFactory/resourcedef/ManagedThreadFactoryDefinitionWebTests.java @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2021, 2022 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.concurrent.spec.ManagedThreadFactory.resourcedef; + +import java.net.URL; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.annotations.Test; + +import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.framework.URLBuilder; +import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionWebBean; +import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionInterface; +import ee.jakarta.tck.concurrent.spec.ContextService.contextPropagate.ContextServiceDefinitionServlet; +import ee.jakarta.tck.concurrent.spi.context.IntContextProvider; +import ee.jakarta.tck.concurrent.spi.context.StringContextProvider; +import jakarta.enterprise.concurrent.spi.ThreadContextProvider; + +import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_WEB;; + + +@Test(groups = JAKARTAEE_WEB) +public class ManagedThreadFactoryDefinitionWebTests extends TestClient { + + @ArquillianResource(ManagedThreadFactoryDefinitionServlet.class) + URL baseURL; + + @ArquillianResource(ManagedThreadFactoryDefinitionOnEJBServlet.class) + URL ejbContextURL; + + @Deployment(name="ManagedThreadFactoryDefinitionTests", testable=false) + public static WebArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "ManagedThreadFactoryDefinitionTests_web.war") + .addPackages(false, + ManagedThreadFactoryDefinitionWebTests.class.getPackage(), + getFrameworkPackage(), + getContextPackage(), + getContextProvidersPackage()) + .addClasses( + ContextServiceDefinitionInterface.class, + ContextServiceDefinitionWebBean.class, + ContextServiceDefinitionServlet.class) + .addAsWebInfResource(ManagedThreadFactoryDefinitionWebTests.class.getPackage(), "web.xml", "web.xml") + .addAsWebInfResource(ManagedThreadFactoryDefinitionWebTests.class.getPackage(), "ejb-jar.xml", "ejb-jar.xml") + .addAsServiceProvider(ThreadContextProvider.class.getName(), IntContextProvider.class.getName(), StringContextProvider.class.getName()); + + return war; + } + + @Override + protected String getServletPath() { + return "ManagedThreadFactoryDefinitionServlet"; + } + + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 + @Test(enabled = false) + public void testManagedThreadFactoryDefinitionAllAttributes() throws Throwable { + runTest(baseURL); + } + + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 + @Test(enabled = false) + public void testManagedThreadFactoryDefinitionAllAttributesEJB() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testName); + runTest(requestURL); + } + + @Test + public void testManagedThreadFactoryDefinitionDefaults() throws Throwable { + runTest(baseURL); + } + + @Test + public void testManagedThreadFactoryDefinitionDefaultsEJB() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testName); + runTest(requestURL); + } + + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 + @Test(enabled = false) + public void testParallelStreamBackedByManagedThreadFactory() throws Throwable { + runTest(baseURL); + } + + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 + @Test(enabled = false) + public void testParallelStreamBackedByManagedThreadFactoryEJB() throws Throwable { + URLBuilder requestURL = URLBuilder.get().withBaseURL(ejbContextURL).withPaths("ManagedThreadFactoryDefinitionOnEJBServlet").withTestName(testName); + runTest(requestURL); + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java new file mode 100644 index 00000000..5933d5f8 --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/DeploymentDescriptorWebTests.java @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2022 Contributors to the Eclipse Foundation + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package ee.jakarta.tck.concurrent.spec.Platform.dd; + +import static ee.jakarta.tck.concurrent.common.TestGroups.JAKARTAEE_WEB; + +import java.net.URL; + +import org.jboss.arquillian.container.test.api.Deployment; +import org.jboss.arquillian.test.api.ArquillianResource; +import org.jboss.shrinkwrap.api.ShrinkWrap; +import org.jboss.shrinkwrap.api.spec.WebArchive; +import org.testng.annotations.Test; + +import ee.jakarta.tck.concurrent.framework.TestClient; +import ee.jakarta.tck.concurrent.spi.context.IntContextProvider; +import ee.jakarta.tck.concurrent.spi.context.StringContextProvider; +import jakarta.enterprise.concurrent.spi.ThreadContextProvider; + +/** + * Covers context-service, managed-executor, managed-scheduled-executor, + * and managed-thread-factory defined in a deployment descriptor. + */ +@Test(groups = JAKARTAEE_WEB) +public class DeploymentDescriptorWebTests extends TestClient{ + + @ArquillianResource(DeploymentDescriptorServlet.class) + URL baseURL; + + @Deployment(name="DeploymentDescriptorTests", testable=false) + public static WebArchive createDeployment() { + + WebArchive war = ShrinkWrap.create(WebArchive.class, "DeploymentDescriptorTests_web.war") + .addPackages(false, + DeploymentDescriptorWebTests.class.getPackage(), + getFrameworkPackage(), + getContextPackage(), + getContextProvidersPackage()) + .addAsServiceProvider(ThreadContextProvider.class.getName(), + IntContextProvider.class.getName(), + StringContextProvider.class.getName()) + .addAsWebInfResource(DeploymentDescriptorWebTests.class.getPackage(), "web.xml", "web.xml"); + + + return war; + } + + @Override + protected String getServletPath() { + return "DeploymentDescriptorServlet"; + } + + @Test + public void testDeploymentDescriptorDefinesContextService() { + runTest(baseURL); + } + + @Test + public void testDeploymentDescriptorDefinesManagedExecutor() { + runTest(baseURL); + } + + @Test + public void testDeploymentDescriptorDefinesManagedScheduledExecutor() { + runTest(baseURL); + } + + // Accepted TCK challenge: https://github.com/jakartaee/concurrency/issues/226 + @Test(enabled = false) + public void testDeploymentDescriptorDefinesManagedThreadFactory() { + runTest(baseURL); + } +} diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/web.xml b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/web.xml new file mode 100644 index 00000000..7d06e3cf --- /dev/null +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/spec/Platform/dd/web.xml @@ -0,0 +1,48 @@ + + + + + + + java:global/concurrent/ContextD + IntContext + Application + StringContext + Transaction + + + + java:app/concurrent/ExecutorD + java:global/concurrent/ContextD + 3 + + + + java:global/concurrent/ScheduledExecutorD + java:global/concurrent/ContextD + 2 + 200000 + + + + java:app/concurrent/ThreadFactoryD + java:global/concurrent/ContextD + 6 + + + \ No newline at end of file From 64b61987720869b72cd9f175284b408348d95823 Mon Sep 17 00:00:00 2001 From: Arjan Tijms Date: Fri, 29 Jul 2022 19:59:31 +0200 Subject: [PATCH 2/2] Update TestGroups.java --- .../main/java/ee/jakarta/tck/concurrent/common/TestGroups.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tck/src/main/java/ee/jakarta/tck/concurrent/common/TestGroups.java b/tck/src/main/java/ee/jakarta/tck/concurrent/common/TestGroups.java index 3eadcec9..e0153955 100644 --- a/tck/src/main/java/ee/jakarta/tck/concurrent/common/TestGroups.java +++ b/tck/src/main/java/ee/jakarta/tck/concurrent/common/TestGroups.java @@ -19,6 +19,6 @@ public interface TestGroups { /** Group for tests requiring the full platform */ String JAKARTAEE_FULL = "eefull"; - /** Group for tests requiring the full platform */ + /** Group for tests requiring the web platform */ String JAKARTAEE_WEB = "eeweb"; }