deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject deltaspike git commit: DELTASPIKE-785 added test
Date Thu, 20 Nov 2014 14:24:08 GMT
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 <gpetracek@apache.org>
Authored: Thu Nov 20 15:14:53 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
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


Mime
View raw message