Return-Path: X-Original-To: apmail-deltaspike-commits-archive@www.apache.org Delivered-To: apmail-deltaspike-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id F0024CF4A for ; Thu, 20 Nov 2014 14:24:08 +0000 (UTC) Received: (qmail 72522 invoked by uid 500); 20 Nov 2014 14:24:08 -0000 Delivered-To: apmail-deltaspike-commits-archive@deltaspike.apache.org Received: (qmail 72486 invoked by uid 500); 20 Nov 2014 14:24:08 -0000 Mailing-List: contact commits-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltaspike.apache.org Delivered-To: mailing list commits@deltaspike.apache.org Received: (qmail 72477 invoked by uid 99); 20 Nov 2014 14:24:08 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Nov 2014 14:24:08 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 33AB792559B; Thu, 20 Nov 2014 14:24:08 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gpetracek@apache.org To: commits@deltaspike.apache.org Message-Id: <891740da58da4e36b833d13b59e8766e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: deltaspike git commit: DELTASPIKE-785 added test Date: Thu, 20 Nov 2014 14:24:08 +0000 (UTC) Repository: deltaspike Updated Branches: refs/heads/master 3f99af400 -> e68beb191 DELTASPIKE-785 added test Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/e68beb19 Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/e68beb19 Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/e68beb19 Branch: refs/heads/master Commit: e68beb191b96c96e2c12fd9b62346bd2f3a381d6 Parents: 3f99af4 Author: gpetracek Authored: Thu Nov 20 15:14:53 2014 +0100 Committer: gpetracek Committed: Thu Nov 20 15:21:19 2014 +0100 ---------------------------------------------------------------------- .../testcontrol/uc013/ContainerConfigTest.java | 38 +++++++++++++++++++- .../META-INF/apache-deltaspike.properties | 2 ++ .../apache-deltaspike_test-container.properties | 2 +- .../test/dsTestContainerBootConfig.properties | 24 +++++++++++++ 4 files changed, 64 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e68beb19/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc013/ContainerConfigTest.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc013/ContainerConfigTest.java b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc013/ContainerConfigTest.java index 7f4ed28..df8a4f7 100644 --- a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc013/ContainerConfigTest.java +++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc013/ContainerConfigTest.java @@ -18,24 +18,60 @@ */ package org.apache.deltaspike.test.testcontrol.uc013; +import org.apache.deltaspike.core.api.config.ConfigResolver; +import org.apache.deltaspike.core.api.projectstage.ProjectStage; +import org.apache.deltaspike.core.util.ExceptionUtils; import org.apache.deltaspike.test.category.SeCategory; +import org.apache.deltaspike.testcontrol.api.TestControl; +import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner; import org.apache.deltaspike.testcontrol.api.junit.CdiTestSuiteRunner; import org.junit.Assert; +import org.junit.Before; import org.junit.Test; import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; + +import java.lang.reflect.Field; //Usually NOT needed! Currently only needed due to our arquillian-setup @Category(SeCategory.class) +@RunWith(CdiTestRunner.class) public class ContainerConfigTest { + @Before + public void resetConfig() + { + //TODO discuss an api to reset the ConfigResolver + try + { + Field projectStageField = ConfigResolver.class.getDeclaredField("projectStage"); + projectStageField.setAccessible(true); + projectStageField.set(null, null); + } + catch (Exception e) + { + throw ExceptionUtils.throwAsRuntimeException(e); + } + } + @Test - public void configForTestContainer() + @TestControl(projectStage = ProjectStage.UnitTest.class) //just for internal tests + public void configForTestContainerStageUnitTest() { Assert.assertNotNull(CdiTestSuiteRunner.getTestContainerConfig()); Assert.assertEquals("jdbc:hsqldb:mem:demoDB", CdiTestSuiteRunner.getTestContainerConfig().getProperty("demoDatabase.JdbcUrl")); } + + @Test + @TestControl(projectStage = ProjectStage.IntegrationTest.class) //just for internal tests + public void configForTestContainerStageIntegrationTest() + { + Assert.assertNotNull(CdiTestSuiteRunner.getTestContainerConfig()); + Assert.assertEquals("jdbc:hsqldb:file:demoDB", + CdiTestSuiteRunner.getTestContainerConfig().getProperty("demoDatabase.JdbcUrl")); + } } http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e68beb19/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike.properties ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike.properties b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike.properties index 6dca7fd..12f8713 100644 --- a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike.properties +++ b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike.properties @@ -18,3 +18,5 @@ 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.testcontrol.InternalTestClassDeactivator + +deltaspike.testcontrol.test-container.config-file.UnitTest=META-INF/test/dsTestContainerBootConfig.properties http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e68beb19/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike_test-container.properties ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike_test-container.properties b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike_test-container.properties index a766a00..d5fa3d0 100644 --- a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike_test-container.properties +++ b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/apache-deltaspike_test-container.properties @@ -21,4 +21,4 @@ #(out-of-the-box) which supports that config is openejb-embedded) #just random config-entries -demoDatabase.JdbcUrl=jdbc:hsqldb:mem:demoDB +demoDatabase.JdbcUrl=jdbc:hsqldb:file:demoDB http://git-wip-us.apache.org/repos/asf/deltaspike/blob/e68beb19/deltaspike/modules/test-control/impl/src/test/resources/META-INF/test/dsTestContainerBootConfig.properties ---------------------------------------------------------------------- diff --git a/deltaspike/modules/test-control/impl/src/test/resources/META-INF/test/dsTestContainerBootConfig.properties b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/test/dsTestContainerBootConfig.properties new file mode 100644 index 0000000..a766a00 --- /dev/null +++ b/deltaspike/modules/test-control/impl/src/test/resources/META-INF/test/dsTestContainerBootConfig.properties @@ -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. + + +#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