Updated Branches: refs/heads/master 89309c311 -> 4939550ed
DELTASPIKE-342 added test for injection in base-class Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/4939550e Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/4939550e Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/4939550e Branch: refs/heads/master Commit: 4939550ed208c4e6be98ee12e6019ebe7d271afd Parents: 89309c3 Author: gpetracek <[email protected]> Authored: Fri Jan 3 11:48:41 2014 +0100 Committer: gpetracek <[email protected]> Committed: Fri Jan 3 11:53:33 2014 +0100 ---------------------------------------------------------------------- .../test/testcontrol/uc007/BaseTest.java | 37 ++++++++++++++++ .../test/testcontrol/uc007/ExtendedTest.java | 46 ++++++++++++++++++++ 2 files changed, 83 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4939550e/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc007/BaseTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc007/BaseTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc007/BaseTest.java new file mode 100644 index 0000000..32fe578 --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/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.testcontrol.uc007; + +import org.apache.deltaspike.test.testcontrol.shared.ApplicationScopedBean; +import org.apache.deltaspike.test.testcontrol.shared.RequestScopedBean; +import org.apache.deltaspike.test.testcontrol.shared.SessionScopedBean; + +import javax.inject.Inject; + +public abstract class BaseTest +{ + @Inject + protected ApplicationScopedBean applicationScopedBean; + + @Inject + protected SessionScopedBean sessionScopedBean; + + @Inject + protected RequestScopedBean requestScopedBean; +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/4939550e/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc007/ExtendedTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc007/ExtendedTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc007/ExtendedTest.java new file mode 100644 index 0000000..1a14b75 --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc007/ExtendedTest.java @@ -0,0 +1,46 @@ +/* + * 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.testcontrol.uc007; + +import org.apache.deltaspike.test.category.SeCategory; +import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner; +import org.junit.Assert; +import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +//Usually NOT needed! Currently only needed due to our arquillian-setup +@Category(SeCategory.class) + + + +@RunWith(CdiTestRunner.class) +public class ExtendedTest extends BaseTest +{ + @Test + public void inheritedInjectionTest() + { + applicationScopedBean.increaseCount(); + sessionScopedBean.increaseCount(); + + Assert.assertEquals(0, requestScopedBean.getCount()); + requestScopedBean.increaseCount(); + Assert.assertEquals(1, requestScopedBean.getCount()); + } +}
