This is an automated email from the ASF dual-hosted git repository. asf-gitbox-commits pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/deltaspike.git
commit ab0db99f1915599212f1959613038ac31851f7bf Author: Mark Struberg <[email protected]> AuthorDate: Sun May 10 15:35:21 2026 +0200 DELTASPIKE-1366 copy over unit tests from the old test-control version For now we have a rather similar API as the old test-control junit4 implementation. This should make it easier to move from junit4 to junit5. --- .../api/junit/CdiTestSuiteExtension.java | 24 ++--- .../test/testcontrol5/CustomMockManager.java | 54 +++++++++++ .../testcontrol5/InternalTestClassDeactivator.java | 33 +++++++ .../test/testcontrol5/InternalTestMockFilter.java | 33 +++++++ .../mock/uc015/InterceptedBeanClassLevel.java | 31 ++++++ .../mock/uc015/InterceptedBeanMethodLevel.java | 31 ++++++ .../mock/uc015/InterceptedBeanTest.java | 61 ++++++++++++ .../mock/uc015/InterceptionResultStorage.java | 37 +++++++ .../testcontrol5/mock/uc015/TestInterceptor.java | 35 +++++++ .../mock/uc015/TestInterceptorImplementation.java | 40 ++++++++ .../testcontrol5/shared/ApplicationScopedBean.java | 60 ++++++++++++ .../testcontrol5/shared/RequestScopedBean.java | 55 +++++++++++ .../testcontrol5/shared/SessionScopedBean.java | 39 ++++++++ .../test/testcontrol5/shared/TestUtils.java | 43 +++++++++ .../RequestAndSessionScopePerTestMethodTest.java | 107 +++++++++++++++++++++ .../uc002/SessionScopePerTestClassTest.java | 106 ++++++++++++++++++++ .../RequestAndSessionScopePerTestMethodTest.java | 78 +++++++++++++++ .../uc003/SessionScopePerTestClassTest.java | 72 ++++++++++++++ .../test/testcontrol5/uc003/TestSuite.java | 40 ++++++++ .../uc004/ProjectStageTestControlTest.java | 57 +++++++++++ .../test/testcontrol5/uc007/BaseTest.java | 37 +++++++ .../test/testcontrol5/uc007/ExtendedTest.java | 44 +++++++++ .../uc008/BeforeAndAfterInjectionTest.java | 74 ++++++++++++++ .../uc011/InterceptedBeanClassLevel.java | 31 ++++++ .../uc011/InterceptedBeanMethodLevel.java | 31 ++++++ .../testcontrol5/uc011/InterceptedBeanTest.java | 61 ++++++++++++ .../uc011/InterceptionResultStorage.java | 37 +++++++ .../test/testcontrol5/uc011/TestInterceptor.java | 35 +++++++ .../uc011/TestInterceptorImplementation.java | 40 ++++++++ .../uc012/ApplicationScopedBeanTest.java | 68 +++++++++++++ .../uc012/ApplicationScopedTestBean.java | 42 ++++++++ .../uc012/ApplicationScopedTestBeanClient.java | 35 +++++++ .../testcontrol5/uc013/ContainerConfigTest.java | 56 +++++++++++ .../testcontrol5/uc019/DefaultTestService.java | 31 ++++++ .../testcontrol5/uc019/TestBeanClassFilter.java | 65 +++++++++++++ .../test/testcontrol5/uc019/TestLabeled.java | 34 +++++++ .../uc019/TestLabeledAlternativeFilter.java | 56 +++++++++++ .../test/testcontrol5/uc019/TestService.java | 24 +++++ .../test/testcontrol5/uc019/TestServiceLabelX.java | 34 +++++++ .../testcontrol5/uc019/TestServiceLabelXTest.java | 61 ++++++++++++ .../test/testcontrol5/uc019/TestServiceLabelY.java | 34 +++++++ .../testcontrol5/uc019/TestServiceLabelYTest.java | 61 ++++++++++++ .../META-INF/apache-deltaspike.properties | 27 ++++++ .../apache-deltaspike_test-container.properties | 26 +++++ .../impl/src/test/resources/META-INF/beans.xml | 37 +++++++ ...re.spi.alternative.AlternativeBeanClassProvider | 20 ++++ ...che.deltaspike.testcontrol5.spi.mock.MockFilter | 20 ++++ .../test/dsTestContainerBootConfig.properties | 26 +++++ 48 files changed, 2168 insertions(+), 15 deletions(-) diff --git a/deltaspike/modules/test-control5/api/src/main/java/org/apache/deltaspike/testcontrol5/api/junit/CdiTestSuiteExtension.java b/deltaspike/modules/test-control5/api/src/main/java/org/apache/deltaspike/testcontrol5/api/junit/CdiTestSuiteExtension.java index 18b305820..3c13849da 100644 --- a/deltaspike/modules/test-control5/api/src/main/java/org/apache/deltaspike/testcontrol5/api/junit/CdiTestSuiteExtension.java +++ b/deltaspike/modules/test-control5/api/src/main/java/org/apache/deltaspike/testcontrol5/api/junit/CdiTestSuiteExtension.java @@ -42,14 +42,14 @@ import java.util.concurrent.ConcurrentHashMap; public class CdiTestSuiteExtension implements BeforeAllCallback, AfterAllCallback { public static final String CUSTOM_TEST_CONTAINER_CONFIG_FILE_KEY = - "deltaspike.testcontrol5.test-container.config-file"; + "deltaspike.testcontrol.test-container.config-file"; public static final String DEFAULT_TEST_CONTAINER_CONFIG_FILE_NAME = "META-INF/apache-deltaspike_test-container"; private static final boolean STOP_CONTAINER; - private static final ThreadLocal<Boolean> IS_CDI_TEST_RUNNER_EXECUTION = new ThreadLocal<Boolean>(); + private static final ThreadLocal<Boolean> IS_CDI_TEST_RUNNER_EXECUTION = new ThreadLocal<>(); private static volatile boolean containerStarted; @@ -79,25 +79,19 @@ public class CdiTestSuiteExtension implements BeforeAllCallback, AfterAllCallbac container.boot(getTestContainerConfig()); containerStarted = true; } - - try - { - // Tests will be executed by JUnit 5 - } - finally - { - if (STOP_CONTAINER) - { - container.shutdown(); - containerStarted = false; - } - } } @Override public void afterAll(ExtensionContext extensionContext) throws Exception { // Cleanup if needed + if (STOP_CONTAINER) + { + CdiContainer container = CdiContainerLoader.getCdiContainer(); + + container.shutdown(); + containerStarted = false; + } } public static boolean isContainerStarted() diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/CustomMockManager.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/CustomMockManager.java new file mode 100644 index 000000000..dedb3da3e --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/CustomMockManager.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5; + +import jakarta.enterprise.inject.Typed; +import org.apache.deltaspike.testcontrol5.api.mock.DynamicMockManager; +import org.apache.deltaspike.testcontrol5.impl.mock.SimpleMockManager; + +import jakarta.enterprise.context.RequestScoped; +import jakarta.enterprise.inject.Alternative; +import java.lang.annotation.Annotation; + +@Alternative + +@RequestScoped +@Typed(DynamicMockManager.class) +public class CustomMockManager extends SimpleMockManager +{ + private static boolean isCalled; + + @Override + public <T> T getMock(Class<T> beanClass, Annotation... qualifiers) + { + isCalled = true; + + return super.getMock(beanClass, qualifiers); + } + + public static boolean isIsCalled() + { + return isCalled; + } + + public static void resetInternals() + { + isCalled = false; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/InternalTestClassDeactivator.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/InternalTestClassDeactivator.java new file mode 100644 index 000000000..3e9d104fb --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/InternalTestClassDeactivator.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5; + +import org.apache.deltaspike.core.spi.activation.ClassDeactivator; +import org.apache.deltaspike.core.spi.activation.Deactivatable; +import org.apache.deltaspike.testcontrol5.impl.mock.DefaultMockFilter; + +//just needed because the internal test-packages need to be handled differently +public class InternalTestClassDeactivator implements ClassDeactivator +{ + @Override + public Boolean isActivated(Class<? extends Deactivatable> targetClass) + { + return !DefaultMockFilter.class.equals(targetClass); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/InternalTestMockFilter.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/InternalTestMockFilter.java new file mode 100644 index 000000000..ae055ff3e --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/InternalTestMockFilter.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5; + +import org.apache.deltaspike.testcontrol5.impl.mock.DefaultMockFilter; + +public class InternalTestMockFilter extends DefaultMockFilter +{ + private static final String DS_TEST_BASE_PACKAGE = "org.apache.deltaspike.test.testcontrol.mock."; + + protected boolean isInternalPackage(String packageName) + { + return super.isInternalPackage(packageName) && + (!packageName.startsWith(DS_TEST_BASE_PACKAGE) || + packageName.equals(CustomMockManager.class.getPackage().getName())); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptedBeanClassLevel.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptedBeanClassLevel.java new file mode 100644 index 000000000..1b1537571 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptedBeanClassLevel.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.mock.uc015; + +import jakarta.enterprise.context.RequestScoped; + +@RequestScoped +@TestInterceptor +public class InterceptedBeanClassLevel +{ + public void test() + { + //do nothing - any method is fine + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptedBeanMethodLevel.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptedBeanMethodLevel.java new file mode 100644 index 000000000..87ea4252b --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptedBeanMethodLevel.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.mock.uc015; + +import jakarta.enterprise.context.RequestScoped; + +@RequestScoped +public class InterceptedBeanMethodLevel +{ + @TestInterceptor + public void test() + { + //do nothing - any method is fine + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptedBeanTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptedBeanTest.java new file mode 100644 index 000000000..8d9e5e6bb --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptedBeanTest.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.mock.uc015; + +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) +public class InterceptedBeanTest +{ + @Inject + private InterceptionResultStorage interceptionResultStorage; + + @Inject + private InterceptedBeanClassLevel interceptedBeanClassLevel; + + @Inject + private InterceptedBeanMethodLevel interceptedBeanMethodLevel; + + @Test + public void classLevelInterception() + { + assertFalse(this.interceptionResultStorage.isInterceptionDetected()); + this.interceptedBeanClassLevel.test(); + assertTrue(this.interceptionResultStorage.isInterceptionDetected()); + } + + @Test + public void methodLevelInterception() + { + assertFalse(this.interceptionResultStorage.isInterceptionDetected()); + this.interceptedBeanMethodLevel.test(); + assertTrue(this.interceptionResultStorage.isInterceptionDetected()); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptionResultStorage.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptionResultStorage.java new file mode 100644 index 000000000..930407ff2 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/InterceptionResultStorage.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.mock.uc015; + +import jakarta.enterprise.context.RequestScoped; + +@RequestScoped +public class InterceptionResultStorage +{ + private boolean intercepted; + + public void markAsIntercepted() + { + this.intercepted = true; + } + + public boolean isInterceptionDetected() + { + return intercepted; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/TestInterceptor.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/TestInterceptor.java new file mode 100644 index 000000000..3d5d61df7 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/TestInterceptor.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.mock.uc015; + +import jakarta.interceptor.InterceptorBinding; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@InterceptorBinding + +@Target({ METHOD, TYPE }) +@Retention(RUNTIME) +public @interface TestInterceptor +{ +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/TestInterceptorImplementation.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/TestInterceptorImplementation.java new file mode 100644 index 000000000..f15c80e72 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/mock/uc015/TestInterceptorImplementation.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.mock.uc015; + +import jakarta.inject.Inject; +import jakarta.interceptor.AroundInvoke; +import jakarta.interceptor.Interceptor; +import jakarta.interceptor.InvocationContext; +import java.io.Serializable; + +@TestInterceptor +@Interceptor +public class TestInterceptorImplementation implements Serializable +{ + @Inject + private InterceptionResultStorage interceptionResultStorage; + + @AroundInvoke + public Object intercept(InvocationContext ctx) throws Exception + { + this.interceptionResultStorage.markAsIntercepted(); + return ctx.proceed(); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/ApplicationScopedBean.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/ApplicationScopedBean.java new file mode 100644 index 000000000..a34d77c22 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/ApplicationScopedBean.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.shared; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class ApplicationScopedBean +{ + private int count = 0; + private static int instanceCount = 0; + + @PostConstruct + protected void init() + { + instanceCount++; + } + + public int getCount() + { + return count; + } + + public void increaseCount() + { + this.count++; + } + + public void resetCount() + { + this.count = 0; + } + + public static int getInstanceCount() + { + return instanceCount; + } + + public static void resetInstanceCount() + { + instanceCount = 0; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/RequestScopedBean.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/RequestScopedBean.java new file mode 100644 index 000000000..b34f2b2dd --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/RequestScopedBean.java @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.shared; + +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.RequestScoped; + +@RequestScoped +public class RequestScopedBean +{ + private int count = 0; + private static int instanceCount = 0; + + @PostConstruct + protected void init() + { + instanceCount++; + } + + public int getCount() + { + return count; + } + + public void increaseCount() + { + this.count++; + } + + public static int getInstanceCount() + { + return instanceCount; + } + + public static int resetInstanceCount() + { + return instanceCount = 0; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/SessionScopedBean.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/SessionScopedBean.java new file mode 100644 index 000000000..7863f5457 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/SessionScopedBean.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.shared; + +import jakarta.enterprise.context.SessionScoped; +import java.io.Serializable; + +@SessionScoped +public class SessionScopedBean implements Serializable +{ + private static final long serialVersionUID = -6055362670706159152L; + private int count = 0; + + public int getCount() + { + return count; + } + + public void increaseCount() + { + this.count++; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/TestUtils.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/TestUtils.java new file mode 100644 index 000000000..958c34535 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/shared/TestUtils.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.shared; + +import org.junit.jupiter.api.Test; + +import java.lang.reflect.Method; + +public abstract class TestUtils +{ + private TestUtils() + { + } + + public static int getTestMethodCount(Class testClass) + { + int result = 0; + for (Method method : testClass.getDeclaredMethods()) + { + if (method.isAnnotationPresent(Test.class)) + { + result++; + } + } + return result; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc001/RequestAndSessionScopePerTestMethodTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc001/RequestAndSessionScopePerTestMethodTest.java new file mode 100644 index 000000000..a5ed71829 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc001/RequestAndSessionScopePerTestMethodTest.java @@ -0,0 +1,107 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc001; + +import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.test.testcontrol5.shared.ApplicationScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.RequestScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.SessionScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.TestUtils; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) //starts container once and one session + request per test-method +//implicitly annotated with @TestControl without the default-scope settings +public class RequestAndSessionScopePerTestMethodTest +{ + @Inject + private ApplicationScopedBean applicationScopedBean; + + @Inject + private SessionScopedBean sessionScopedBean; + + @Inject + private RequestScopedBean requestScopedBean; + + @Test + //implicitly annotated with @TestControl and its default-values + public void firstTest() + { + applicationScopedBean.increaseCount(); + + assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + assertEquals(1, requestScopedBean.getCount()); + + assertEquals(0, sessionScopedBean.getCount()); + sessionScopedBean.increaseCount(); + assertEquals(1, sessionScopedBean.getCount()); + } + + @Test + //implicitly annotated with @TestControl and its default-values + public void secondTest() + { + applicationScopedBean.increaseCount(); + + assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + assertEquals(1, requestScopedBean.getCount()); + + assertEquals(0, sessionScopedBean.getCount()); + sessionScopedBean.increaseCount(); + assertEquals(1, sessionScopedBean.getCount()); + } + + @BeforeAll + public static void resetSharedState() + { + BeanProvider.getContextualReference(ApplicationScopedBean.class).resetCount(); + RequestScopedBean.resetInstanceCount(); + } + + @AfterAll + public static void finalCheckAndCleanup() + { + int testCount = TestUtils.getTestMethodCount(RequestAndSessionScopePerTestMethodTest.class); + + if (RequestScopedBean.getInstanceCount() != testCount) + { + throw new IllegalStateException("unexpected instance count"); + } + RequestScopedBean.resetInstanceCount(); + + if (BeanProvider.getContextualReference(ApplicationScopedBean.class).getCount() != testCount) + { + throw new IllegalStateException("unexpected count"); + } + BeanProvider.getContextualReference(ApplicationScopedBean.class).resetCount(); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc002/SessionScopePerTestClassTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc002/SessionScopePerTestClassTest.java new file mode 100644 index 000000000..56e33f296 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc002/SessionScopePerTestClassTest.java @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc002; + +import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.test.testcontrol5.shared.ApplicationScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.RequestScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.SessionScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.TestUtils; +import org.apache.deltaspike.testcontrol5.api.TestControl; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.enterprise.context.SessionScoped; +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) //starts container and session once and one request per test-method +@TestControl(startScopes = SessionScoped.class) +public class SessionScopePerTestClassTest +{ + @Inject + private ApplicationScopedBean applicationScopedBean; + + @Inject + private SessionScopedBean sessionScopedBean; + + @Inject + private RequestScopedBean requestScopedBean; + + @Test + public void firstTest() + { + applicationScopedBean.increaseCount(); + sessionScopedBean.increaseCount(); + + assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + assertEquals(1, requestScopedBean.getCount()); + } + + @Test + public void secondTest() + { + applicationScopedBean.increaseCount(); + sessionScopedBean.increaseCount(); + + assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + assertEquals(1, requestScopedBean.getCount()); + } + + @BeforeAll + public static void resetSharedState() + { + BeanProvider.getContextualReference(ApplicationScopedBean.class).resetCount(); + RequestScopedBean.resetInstanceCount(); + } + + @AfterAll + public static void finalCheckAndCleanup() + { + int testCount = TestUtils.getTestMethodCount(SessionScopePerTestClassTest.class); + + if (RequestScopedBean.getInstanceCount() != testCount) + { + throw new IllegalStateException("unexpected instance count"); + } + RequestScopedBean.resetInstanceCount(); + + if (BeanProvider.getContextualReference(ApplicationScopedBean.class).getCount() != testCount) + { + throw new IllegalStateException("unexpected count"); + } + + if (BeanProvider.getContextualReference(SessionScopedBean.class).getCount() != testCount) + { + throw new IllegalStateException("unexpected count"); + } + BeanProvider.getContextualReference(ApplicationScopedBean.class).resetCount(); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc003/RequestAndSessionScopePerTestMethodTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc003/RequestAndSessionScopePerTestMethodTest.java new file mode 100644 index 000000000..3235484bb --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc003/RequestAndSessionScopePerTestMethodTest.java @@ -0,0 +1,78 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc003; + +import org.apache.deltaspike.test.testcontrol5.shared.ApplicationScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.RequestScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.SessionScopedBean; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) //starts container once and one session + request per test-method +//implicitly annotated with @TestControl without the default-scope settings +public class RequestAndSessionScopePerTestMethodTest +{ + @Inject + private ApplicationScopedBean applicationScopedBean; + + @Inject + private SessionScopedBean sessionScopedBean; + + @Inject + private RequestScopedBean requestScopedBean; + + @Test + //implicitly annotated with @TestControl and its default-values + public void firstTest() + { + applicationScopedBean.increaseCount(); + + assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + assertEquals(1, requestScopedBean.getCount()); + + assertEquals(0, sessionScopedBean.getCount()); + sessionScopedBean.increaseCount(); + assertEquals(1, sessionScopedBean.getCount()); + } + + @Test + //implicitly annotated with @TestControl and its default-values + public void secondTest() + { + applicationScopedBean.increaseCount(); + + assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + assertEquals(1, requestScopedBean.getCount()); + + assertEquals(0, sessionScopedBean.getCount()); + sessionScopedBean.increaseCount(); + assertEquals(1, sessionScopedBean.getCount()); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc003/SessionScopePerTestClassTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc003/SessionScopePerTestClassTest.java new file mode 100644 index 000000000..55d655005 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc003/SessionScopePerTestClassTest.java @@ -0,0 +1,72 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc003; + +import org.apache.deltaspike.test.testcontrol5.shared.ApplicationScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.RequestScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.SessionScopedBean; +import org.apache.deltaspike.testcontrol5.api.TestControl; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.enterprise.context.SessionScoped; +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) //starts container and session once and one request per test-method +@TestControl(startScopes = SessionScoped.class) +public class SessionScopePerTestClassTest +{ + @Inject + private ApplicationScopedBean applicationScopedBean; + + @Inject + private SessionScopedBean sessionScopedBean; + + @Inject + private RequestScopedBean requestScopedBean; + + @Test + public void firstTest() + { + applicationScopedBean.increaseCount(); + sessionScopedBean.increaseCount(); + + assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + assertEquals(1, requestScopedBean.getCount()); + } + + @Test + public void secondTest() + { + applicationScopedBean.increaseCount(); + sessionScopedBean.increaseCount(); + + assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + assertEquals(1, requestScopedBean.getCount()); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc003/TestSuite.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc003/TestSuite.java new file mode 100644 index 000000000..ced20ca42 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc003/TestSuite.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc003; + +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +/** + * JUnit 5 replacement for the JUnit 4 Suite. + * Each test class with @ExtendWith(CdiTestExtension.class) shares the same CDI container. + */ +public class TestSuite +{ + @Test + void suiteMarker() + { + // This class is a marker for the test suite. + // The actual tests are in RequestAndSessionScopePerTestMethodTest and SessionScopePerTestClassTest. + // They share the same container via CdiTestExtension. + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc004/ProjectStageTestControlTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc004/ProjectStageTestControlTest.java new file mode 100644 index 000000000..6e0f92221 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc004/ProjectStageTestControlTest.java @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc004; + +import jakarta.enterprise.inject.Typed; +import org.apache.deltaspike.core.api.projectstage.ProjectStage; +import org.apache.deltaspike.test.testcontrol5.uc001.RequestAndSessionScopePerTestMethodTest; +import org.apache.deltaspike.testcontrol5.api.TestControl; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) +@TestControl(projectStage = ProjectStage.Development.class) //can be a custom stage +@Typed() //needed due to RequestAndSessionScopePerTestMethodTest +public class ProjectStageTestControlTest extends RequestAndSessionScopePerTestMethodTest //just to inherit the tests - to check that @TestControl#projectStage doesn't influence the default handling +{ + @Inject + private ProjectStage projectStage; + + @Test + public void firstProjectStageTest() + { + assertEquals(ProjectStage.Development, this.projectStage); + } + + @Test + @TestControl(projectStage = ProjectStage.UnitTest.class) //can be a custom stage - e.g. for a special test + public void secondProjectStageTest() + { + assertEquals(ProjectStage.UnitTest, this.projectStage); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc007/BaseTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc007/BaseTest.java new file mode 100644 index 000000000..9b89b93b6 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc007/BaseTest.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc007; + +import org.apache.deltaspike.test.testcontrol5.shared.ApplicationScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.RequestScopedBean; +import org.apache.deltaspike.test.testcontrol5.shared.SessionScopedBean; + +import jakarta.inject.Inject; + +public abstract class BaseTest +{ + @Inject + protected ApplicationScopedBean applicationScopedBean; + + @Inject + protected SessionScopedBean sessionScopedBean; + + @Inject + protected RequestScopedBean requestScopedBean; +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc007/ExtendedTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc007/ExtendedTest.java new file mode 100644 index 000000000..415a30397 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc007/ExtendedTest.java @@ -0,0 +1,44 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc007; + +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) +public class ExtendedTest extends BaseTest +{ + @Test + public void inheritedInjectionTest() + { + applicationScopedBean.increaseCount(); + sessionScopedBean.increaseCount(); + + assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + assertEquals(1, requestScopedBean.getCount()); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc008/BeforeAndAfterInjectionTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc008/BeforeAndAfterInjectionTest.java new file mode 100644 index 000000000..2cf585dc6 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc008/BeforeAndAfterInjectionTest.java @@ -0,0 +1,74 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc008; + +import org.apache.deltaspike.test.testcontrol5.shared.ApplicationScopedBean; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertNotNull; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) +public class BeforeAndAfterInjectionTest +{ + @Inject + private ApplicationScopedBean applicationScopedBean; + + private Integer foundValue; + + @BeforeEach + public void before() + { + if (this.applicationScopedBean == null) + { + throw new IllegalStateException("injection failed"); + } + + this.foundValue = this.applicationScopedBean.getCount(); + } + + @Test + public void injectionTest() + { + assertNotNull(this.applicationScopedBean); + assertNotNull(this.foundValue); + } + + @AfterEach + public void after() + { + if (this.applicationScopedBean == null) + { + throw new IllegalStateException("injection failed"); + } + if (this.foundValue == null) + { + throw new IllegalStateException("different instance without initialized value found"); + } + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptedBeanClassLevel.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptedBeanClassLevel.java new file mode 100644 index 000000000..3c373f2f1 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptedBeanClassLevel.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc011; + +import jakarta.enterprise.context.RequestScoped; + +@RequestScoped +@TestInterceptor +public class InterceptedBeanClassLevel +{ + public void test() + { + //do nothing - any method is fine + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptedBeanMethodLevel.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptedBeanMethodLevel.java new file mode 100644 index 000000000..346c6255c --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptedBeanMethodLevel.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc011; + +import jakarta.enterprise.context.RequestScoped; + +@RequestScoped +public class InterceptedBeanMethodLevel +{ + @TestInterceptor + public void test() + { + //do nothing - any method is fine + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptedBeanTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptedBeanTest.java new file mode 100644 index 000000000..4c41dce61 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptedBeanTest.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc011; + +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) +public class InterceptedBeanTest +{ + @Inject + private InterceptionResultStorage interceptionResultStorage; + + @Inject + private InterceptedBeanClassLevel interceptedBeanClassLevel; + + @Inject + private InterceptedBeanMethodLevel interceptedBeanMethodLevel; + + @Test + public void classLevelInterception() + { + assertFalse(this.interceptionResultStorage.isInterceptionDetected()); + this.interceptedBeanClassLevel.test(); + assertTrue(this.interceptionResultStorage.isInterceptionDetected()); + } + + @Test + public void methodLevelInterception() + { + assertFalse(this.interceptionResultStorage.isInterceptionDetected()); + this.interceptedBeanMethodLevel.test(); + assertTrue(this.interceptionResultStorage.isInterceptionDetected()); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptionResultStorage.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptionResultStorage.java new file mode 100644 index 000000000..c9c13f06c --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/InterceptionResultStorage.java @@ -0,0 +1,37 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc011; + +import jakarta.enterprise.context.RequestScoped; + +@RequestScoped +public class InterceptionResultStorage +{ + private boolean intercepted; + + public void markAsIntercepted() + { + this.intercepted = true; + } + + public boolean isInterceptionDetected() + { + return intercepted; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/TestInterceptor.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/TestInterceptor.java new file mode 100644 index 000000000..26f3be768 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/TestInterceptor.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc011; + +import jakarta.interceptor.InterceptorBinding; +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.METHOD; +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@InterceptorBinding + +@Target({ METHOD, TYPE }) +@Retention(RUNTIME) +public @interface TestInterceptor +{ +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/TestInterceptorImplementation.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/TestInterceptorImplementation.java new file mode 100644 index 000000000..29c7ae4ec --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc011/TestInterceptorImplementation.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc011; + +import jakarta.inject.Inject; +import jakarta.interceptor.AroundInvoke; +import jakarta.interceptor.Interceptor; +import jakarta.interceptor.InvocationContext; +import java.io.Serializable; + +@TestInterceptor +@Interceptor +public class TestInterceptorImplementation implements Serializable +{ + @Inject + private InterceptionResultStorage interceptionResultStorage; + + @AroundInvoke + public Object intercept(InvocationContext ctx) throws Exception + { + this.interceptionResultStorage.markAsIntercepted(); + return ctx.proceed(); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc012/ApplicationScopedBeanTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc012/ApplicationScopedBeanTest.java new file mode 100644 index 000000000..aa227db75 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc012/ApplicationScopedBeanTest.java @@ -0,0 +1,68 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc012; + +import org.apache.deltaspike.core.api.provider.BeanProvider; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) +public class ApplicationScopedBeanTest +{ + @Inject + private ApplicationScopedTestBean testBean; + + @Inject + private ApplicationScopedTestBeanClient testBeanClient; + + @Test + public void beanAccess() + { + this.testBean.setValue(0); + assertEquals(1, this.testBeanClient.getNextValue()); + assertEquals(1, this.testBean.getValue()); + } + + @AfterAll + public static void finalCheck() + { + int value = BeanProvider.getContextualReference(ApplicationScopedTestBean.class).getValue(); + int nextValue = BeanProvider.getContextualReference(ApplicationScopedTestBeanClient.class).getNextValue(); + + if (value == 0) + { + throw new IllegalStateException("new application-scoped bean instance was created"); + } + + if (nextValue == 1) + { + throw new IllegalStateException("new application-scoped bean instance was created"); + } + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc012/ApplicationScopedTestBean.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc012/ApplicationScopedTestBean.java new file mode 100644 index 000000000..681bf68b8 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc012/ApplicationScopedTestBean.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc012; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class ApplicationScopedTestBean +{ + private int value = 0; + + public void increaseValue() + { + this.value++; + } + + public int getValue() + { + return value; + } + + public void setValue(int value) + { + this.value = value; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc012/ApplicationScopedTestBeanClient.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc012/ApplicationScopedTestBeanClient.java new file mode 100644 index 000000000..d26aef4e0 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc012/ApplicationScopedTestBeanClient.java @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc012; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + +@ApplicationScoped +public class ApplicationScopedTestBeanClient +{ + @Inject + private ApplicationScopedTestBean testBean; + + public int getNextValue() + { + this.testBean.increaseValue(); + return this.testBean.getValue(); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc013/ContainerConfigTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc013/ContainerConfigTest.java new file mode 100644 index 000000000..d31c9e3f0 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc013/ContainerConfigTest.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc013; + +import org.apache.deltaspike.core.api.projectstage.ProjectStage; +import org.apache.deltaspike.testcontrol5.api.TestControl; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestSuiteExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) +public class ContainerConfigTest +{ + + @Test + @TestControl(projectStage = ProjectStage.UnitTest.class) //just for internal tests + public void configForTestContainerStageUnitTest() + { + assertNotNull(CdiTestSuiteExtension.getTestContainerConfig()); + assertEquals("jdbc:hsqldb:mem:demoDB", + CdiTestSuiteExtension.getTestContainerConfig().getProperty("demoDatabase.JdbcUrl")); + } + + @Test + @TestControl(projectStage = ProjectStage.IntegrationTest.class) //just for internal tests + public void configForTestContainerStageIntegrationTest() + { + assertNotNull(CdiTestSuiteExtension.getTestContainerConfig()); + assertEquals("jdbc:hsqldb:file:demoDB", + CdiTestSuiteExtension.getTestContainerConfig().getProperty("demoDatabase.JdbcUrl")); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/DefaultTestService.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/DefaultTestService.java new file mode 100644 index 000000000..8eb5b2917 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/DefaultTestService.java @@ -0,0 +1,31 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc019; + +import jakarta.enterprise.context.ApplicationScoped; + +@ApplicationScoped +public class DefaultTestService implements TestService +{ + @Override + public String getValue() + { + return "default-result"; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestBeanClassFilter.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestBeanClassFilter.java new file mode 100644 index 000000000..f0f843cc3 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestBeanClassFilter.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc019; + +import org.apache.deltaspike.core.api.config.ConfigResolver; +import org.apache.deltaspike.core.spi.filter.ClassFilter; +import org.apache.deltaspike.core.util.ClassUtils; +import org.apache.deltaspike.testcontrol5.api.TestControl; + +//!!!not!!! needed with cdi 1.1+ and @Priority (which is the target of this use-case) +//only needed because our test-suite is based on cdi v1.0 + +//also useful to test DELTASPIKE-1337 +public class TestBeanClassFilter implements ClassFilter +{ + @Override + public boolean isFiltered(Class<?> targetClass) + { + if (!targetClass.getName().startsWith("org.apache.deltaspike.test.")) + { + return false; + } + + String currentTestOrigin = ConfigResolver.getPropertyValue(TestControl.class.getName()); + + if (currentTestOrigin == null) //no known origin (no @TestControl is used) + { + //filter all classes which are located in packages using tests with class-filters + //(since we test the feature with ambiguous beans which isn't valid without filtering) + return getClass().getPackage().getName().equals(targetClass.getPackage().getName()); + } + else + { + Class<?> currentOrigin = ClassUtils.tryToLoadClassForName(currentTestOrigin); + //origin is in one of the packages for class-filtering tests + if (getClass().getPackage().getName().equals(currentOrigin.getPackage().getName())) + { + TestControl testControl = currentOrigin.getAnnotation(TestControl.class); + return ClassUtils.tryToInstantiateClass(testControl.classFilter()).isFiltered(targetClass); + } + return isInSamePackage(targetClass); + } + } + + private boolean isInSamePackage(Class<?> targetClass) + { + return targetClass.getPackage().getName().equals(getClass().getPackage().getName()); + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestLabeled.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestLabeled.java new file mode 100644 index 000000000..d3318872a --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestLabeled.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc019; + +import org.apache.deltaspike.testcontrol5.api.TestControl; + +import java.lang.annotation.Retention; +import java.lang.annotation.Target; + +import static java.lang.annotation.ElementType.TYPE; +import static java.lang.annotation.RetentionPolicy.RUNTIME; + +@Retention(RUNTIME) +@Target(TYPE) +public @interface TestLabeled +{ + Class<? extends TestControl.Label> value(); +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestLabeledAlternativeFilter.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestLabeledAlternativeFilter.java new file mode 100644 index 000000000..79555573a --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestLabeledAlternativeFilter.java @@ -0,0 +1,56 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc019; + +import org.apache.deltaspike.core.spi.filter.ClassFilter; +import org.apache.deltaspike.testcontrol5.api.TestControl; + +import jakarta.enterprise.inject.Alternative; + +public abstract class TestLabeledAlternativeFilter implements ClassFilter +{ + private final Class<? extends TestControl.Label> activeLabel; + + protected TestLabeledAlternativeFilter(Class<? extends TestControl.Label> activeLabel) + { + this.activeLabel = activeLabel; + } + + @Override + public boolean isFiltered(Class<?> targetClass) + { + if (!targetClass.isAnnotationPresent(Alternative.class)) + { + return false; + } + + TestLabeled testLabeled = targetClass.getAnnotation(TestLabeled.class); + + if (testLabeled == null) + { + return false; + } + + if (testLabeled.value().equals(activeLabel)) + { + return false; + } + return true; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestService.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestService.java new file mode 100644 index 000000000..a526c12d9 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestService.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc019; + +public interface TestService +{ + String getValue(); +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelX.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelX.java new file mode 100644 index 000000000..590edf875 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelX.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc019; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; + +@Alternative +@TestLabeled(TestServiceLabelXTest.TestLabelX.class) +@ApplicationScoped +public class TestServiceLabelX implements TestService +{ + @Override + public String getValue() + { + return "result-x"; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelXTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelXTest.java new file mode 100644 index 000000000..bc2c40b8d --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelXTest.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc019; + +import org.apache.deltaspike.testcontrol5.api.TestControl; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) +@TestControl( + activeAlternativeLabel = TestServiceLabelXTest.TestLabelX.class, + classFilter = TestServiceLabelXTest.LabelXFilter.class) +public class TestServiceLabelXTest +{ + @Inject + private TestService testService; + + @Test + public void resultX() + { + assertEquals("result-x", testService.getValue()); + } + + public static class TestLabelX implements TestControl.Label + { + } + + //replaces the text based config of labeled-alternatives + public static class LabelXFilter extends TestLabeledAlternativeFilter + { + public LabelXFilter() + { + super(TestLabelX.class); + } + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelY.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelY.java new file mode 100644 index 000000000..e6f5d8c44 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelY.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc019; + +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.enterprise.inject.Alternative; + +@Alternative +@TestLabeled(TestServiceLabelYTest.TestLabelY.class) +@ApplicationScoped +public class TestServiceLabelY implements TestService +{ + @Override + public String getValue() + { + return "result-y"; + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelYTest.java b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelYTest.java new file mode 100644 index 000000000..a1381f504 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/java/org/apache/deltaspike/test/testcontrol5/uc019/TestServiceLabelYTest.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.deltaspike.test.testcontrol5.uc019; + +import org.apache.deltaspike.testcontrol5.api.TestControl; +import org.apache.deltaspike.testcontrol5.api.junit.CdiTestExtension; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; + +import jakarta.inject.Inject; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Tag("SeCategory") + +@ExtendWith(CdiTestExtension.class) +@TestControl( + activeAlternativeLabel = TestServiceLabelYTest.TestLabelY.class, + classFilter = TestServiceLabelYTest.LabelYFilter.class) +public class TestServiceLabelYTest +{ + @Inject + private TestService testService; + + @Test + public void resultY() + { + assertEquals("result-y", testService.getValue()); + } + + public static class TestLabelY implements TestControl.Label + { + } + + //replaces the text based config of labeled-alternatives + public static class LabelYFilter extends TestLabeledAlternativeFilter + { + public LabelYFilter() + { + super(TestLabelY.class); + } + } +} diff --git a/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/apache-deltaspike.properties b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/apache-deltaspike.properties new file mode 100644 index 000000000..06ae1712d --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/apache-deltaspike.properties @@ -0,0 +1,27 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# + +deltaspike.testcontrol.mock-support.allow_mocked_beans=true +deltaspike.testcontrol.mock-support.allow_mocked_producers=true +org.apache.deltaspike.core.spi.activation.ClassDeactivator=org.apache.deltaspike.test.testcontrol5.InternalTestClassDeactivator + +deltaspike.testcontrol.test-container.config-file.UnitTest=META-INF/test/dsTestContainerBootConfig.properties + +#only needed because our test-suite is based on cdi v1.0. with v1.1+ and @Priority (which is the target of this use-case) the following part isn't needed: +org.apache.deltaspike.core.spi.filter.ClassFilter=org.apache.deltaspike.test.testcontrol5.uc019.TestBeanClassFilter \ No newline at end of file diff --git a/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/apache-deltaspike_test-container.properties b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/apache-deltaspike_test-container.properties new file mode 100644 index 000000000..188aade58 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/apache-deltaspike_test-container.properties @@ -0,0 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# + + +#can be used to configure the underlying test-container +#(currently the only container supported by deltaspike +#(out-of-the-box) which supports that config is openejb-embedded) + +#just random config-entries +demoDatabase.JdbcUrl=jdbc:hsqldb:file:demoDB diff --git a/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/beans.xml b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/beans.xml new file mode 100644 index 000000000..cffd0f702 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/beans.xml @@ -0,0 +1,37 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you 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. + --> +<beans xmlns="https://jakarta.ee/xml/ns/jakartaee" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/beans_3_0.xsd" + version="3.0" bean-discovery-mode="all"> + <trim/> + <interceptors> + <class>org.apache.deltaspike.test.testcontrol5.uc011.TestInterceptorImplementation</class> + <class>org.apache.deltaspike.test.testcontrol5.mock.uc015.TestInterceptorImplementation</class> + </interceptors> + + <alternatives> + <class>org.apache.deltaspike.test.testcontrol5.CustomMockManager</class> + + <!-- with cdi 1.1+ the following can be replaced with @Priority(...)--> + <class>org.apache.deltaspike.test.testcontrol5.uc019.TestServiceLabelX</class> + <class>org.apache.deltaspike.test.testcontrol5.uc019.TestServiceLabelY</class> + </alternatives> +</beans> diff --git a/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/services/org.apache.deltaspike.core.spi.alternative.AlternativeBeanClassProvider b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/services/org.apache.deltaspike.core.spi.alternative.AlternativeBeanClassProvider new file mode 100644 index 000000000..2490d3a67 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/services/org.apache.deltaspike.core.spi.alternative.AlternativeBeanClassProvider @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# + +org.apache.deltaspike.test.testcontrol.uc016.CustomAlternativeBeanClassProvider \ No newline at end of file diff --git a/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol5.spi.mock.MockFilter b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol5.spi.mock.MockFilter new file mode 100644 index 000000000..020e5a0a3 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/services/org.apache.deltaspike.testcontrol5.spi.mock.MockFilter @@ -0,0 +1,20 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# + +org.apache.deltaspike.test.testcontrol5.InternalTestMockFilter \ No newline at end of file diff --git a/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/test/dsTestContainerBootConfig.properties b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/test/dsTestContainerBootConfig.properties new file mode 100644 index 000000000..c223e1fe9 --- /dev/null +++ b/deltaspike/modules/test-control5/impl/src/test/resources/META-INF/test/dsTestContainerBootConfig.properties @@ -0,0 +1,26 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# + + +#can be used to configure the underlying test-container +#(currently the only container supported by deltaspike +#(out-of-the-box) which supports that config is openejb-embedded) + +#just random config-entries +demoDatabase.JdbcUrl=jdbc:hsqldb:mem:demoDB
