deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-647 partial-bean scope tests
Date Sat, 05 Jul 2014 13:26:10 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 727f95365 -> 87eb87eca


DELTASPIKE-647 partial-bean scope tests


Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/87eb87ec
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/87eb87ec
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/87eb87ec

Branch: refs/heads/master
Commit: 87eb87ecac1c2daf9994f479dc2c95f1d594ba54
Parents: 727f953
Author: gpetracek <gpetracek@apache.org>
Authored: Sat Jul 5 15:19:07 2014 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Sat Jul 5 15:25:13 2014 +0200

----------------------------------------------------------------------
 .../partialbean/uc004/PartialBeanWithScope.java | 37 ++++++++
 .../uc004/PartialBeanWithoutScope.java          | 34 +++++++
 .../uc004/ScopedPartialBeanTest.java            | 94 ++++++++++++++++++++
 3 files changed, 165 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/87eb87ec/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/PartialBeanWithScope.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/PartialBeanWithScope.java
b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/PartialBeanWithScope.java
new file mode 100644
index 0000000..7527ace
--- /dev/null
+++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/PartialBeanWithScope.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.core.api.partialbean.uc004;
+
+import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@TestPartialBeanBinding
+@ApplicationScoped
+public abstract class PartialBeanWithScope
+{
+    private int count;
+
+    public abstract String getResult();
+
+    public int getManualResult()
+    {
+        return count++;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/87eb87ec/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/PartialBeanWithoutScope.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/PartialBeanWithoutScope.java
b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/PartialBeanWithoutScope.java
new file mode 100644
index 0000000..4e1cd48
--- /dev/null
+++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/PartialBeanWithoutScope.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.core.api.partialbean.uc004;
+
+import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding;
+
+@TestPartialBeanBinding
+public abstract class PartialBeanWithoutScope
+{
+    private int count;
+
+    public abstract String getResult();
+
+    public int getManualResult()
+    {
+        return count++;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/87eb87ec/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/ScopedPartialBeanTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/ScopedPartialBeanTest.java
b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/ScopedPartialBeanTest.java
new file mode 100644
index 0000000..483c4fd
--- /dev/null
+++ b/deltaspike/modules/partial-bean/impl/src/test/java/org/apache/deltaspike/test/core/api/partialbean/uc004/ScopedPartialBeanTest.java
@@ -0,0 +1,94 @@
+/*
+ * 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.core.api.partialbean.uc004;
+
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.test.core.api.partialbean.shared.TestPartialBeanBinding;
+import org.apache.deltaspike.test.core.api.partialbean.util.ArchiveUtils;
+import org.apache.deltaspike.test.utils.CdiContainerUnderTest;
+import org.jboss.arquillian.container.test.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.EmptyAsset;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.shrinkwrap.api.spec.WebArchive;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(Arquillian.class)
+public class ScopedPartialBeanTest
+{
+    @Deployment
+    public static WebArchive war()
+    {
+        String simpleName = ScopedPartialBeanTest.class.getSimpleName();
+        String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+        JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
+                .addPackage(ScopedPartialBeanTest.class.getPackage())
+                .addPackage(TestPartialBeanBinding.class.getPackage())
+                .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        WebArchive webArchive =  ShrinkWrap.create(WebArchive.class, archiveName + ".war")
+                .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreAndPartialBeanArchive())
+                .addAsLibraries(testJar)
+                .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+
+        if (CdiContainerUnderTest.is("owb-.*")   ||
+            CdiContainerUnderTest.is("tomee-.*") ||
+            CdiContainerUnderTest.is("wildfly-.*") ||
+            CdiContainerUnderTest.is("glassfish-.*"))
+        {
+            JavaArchive javassistJar = ShrinkWrap.create(JavaArchive.class, "dsjavassist.jar")
+                    .addPackages(true, "javassist");
+            webArchive.addAsLibrary(javassistJar);
+        }
+
+        return webArchive;
+    }
+
+    @Test
+    public void testPartialBeanWithApplicationScope() throws Exception
+    {
+        String result = BeanProvider.getContextualReference(PartialBeanWithScope.class).getResult();
+
+        Assert.assertEquals("partial-test-false", result);
+
+        int count = BeanProvider.getContextualReference(PartialBeanWithScope.class).getManualResult();
+        Assert.assertEquals(0, count);
+
+        count = BeanProvider.getContextualReference(PartialBeanWithScope.class).getManualResult();
+        Assert.assertEquals(1, count);
+    }
+
+    @Test
+    public void testPartialBeanWithDependentScope() throws Exception
+    {
+        String result = BeanProvider.getContextualReference(PartialBeanWithoutScope.class).getResult();
+
+        Assert.assertEquals("partial-test-false", result);
+
+        int count = BeanProvider.getContextualReference(PartialBeanWithoutScope.class).getManualResult();
+        Assert.assertEquals(0, count);
+
+        count = BeanProvider.getContextualReference(PartialBeanWithoutScope.class).getManualResult();
+        Assert.assertEquals(0, count);
+    }
+}


Mime
View raw message