forked from wildfly/wildfly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request wildfly#16775 from istudens/WFLY-17871
[WFLY-17871] added test-case for managed executor service defined via…
- Loading branch information
Showing
3 changed files
with
85 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...ava/org/jboss/as/test/integration/ee/concurrent/ManagedExecutorServiceAnnotationBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.test.integration.ee.concurrent; | ||
|
||
import static jakarta.enterprise.concurrent.ContextServiceDefinition.APPLICATION; | ||
import static jakarta.enterprise.concurrent.ContextServiceDefinition.SECURITY; | ||
|
||
import java.util.concurrent.ExecutionException; | ||
import java.util.concurrent.Future; | ||
|
||
import jakarta.annotation.Resource; | ||
import jakarta.ejb.LocalBean; | ||
import jakarta.ejb.Stateless; | ||
import jakarta.enterprise.concurrent.ContextServiceDefinition; | ||
import jakarta.enterprise.concurrent.ManagedExecutorDefinition; | ||
import jakarta.enterprise.concurrent.ManagedExecutorService; | ||
|
||
@ManagedExecutorDefinition( | ||
name = "java:module/concurrent/MyExecutor", | ||
context = "java:module/concurrent/MyExecutorContext", | ||
hungTaskThreshold = 120000, | ||
maxAsync = 5) | ||
@ContextServiceDefinition( | ||
name = "java:module/concurrent/MyExecutorContext", | ||
propagated = { SECURITY, APPLICATION }) | ||
@Stateless | ||
@LocalBean | ||
public class ManagedExecutorServiceAnnotationBean { | ||
|
||
@Resource(lookup = "java:module/concurrent/MyExecutor") | ||
ManagedExecutorService executorService; | ||
|
||
public Future<?> testRunnable(Runnable runnable) throws ExecutionException, InterruptedException { | ||
assert executorService != null; | ||
return executorService.submit(runnable); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...org/jboss/as/test/integration/ee/concurrent/ManagedExecutorServiceAnnotationTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright The WildFly Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.jboss.as.test.integration.ee.concurrent; | ||
|
||
import jakarta.annotation.Resource; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* Test for ManagedExecutorService defined via @ManagedExecutorDefinition | ||
* | ||
* @author Ivo Studensky | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class ManagedExecutorServiceAnnotationTestCase { | ||
|
||
@Deployment | ||
public static Archive<?> getDeployment() { | ||
return ShrinkWrap.create(JavaArchive.class, ManagedExecutorServiceAnnotationTestCase.class.getSimpleName() + ".jar") | ||
.addClasses(ManagedExecutorServiceAnnotationTestCase.class, ManagedExecutorServiceAnnotationBean.class); | ||
} | ||
|
||
@Resource(lookup = "java:module/ManagedExecutorServiceAnnotationBean") | ||
ManagedExecutorServiceAnnotationBean service; | ||
|
||
private static void testMethod() { | ||
// empty method | ||
} | ||
|
||
@Test | ||
public void testExecutorService() throws Exception { | ||
Assert.assertNotNull(service); | ||
service.testRunnable(ManagedExecutorServiceAnnotationTestCase::testMethod).get(); | ||
} | ||
} |