deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-760 added test for application-scoped beans in test-control tests
Date Sat, 01 Nov 2014 15:28:18 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 8f98608a9 -> 730c8a9b7


DELTASPIKE-760 added test for application-scoped beans in test-control tests


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

Branch: refs/heads/master
Commit: 730c8a9b7eb16eea871726b01f8dd9f59325e736
Parents: 8f98608
Author: gpetracek <gpetracek@apache.org>
Authored: Sat Nov 1 16:25:13 2014 +0100
Committer: gpetracek <gpetracek@apache.org>
Committed: Sat Nov 1 16:25:13 2014 +0100

----------------------------------------------------------------------
 .../uc012/ApplicationScopedBeanTest.java        | 70 ++++++++++++++++++++
 .../uc012/ApplicationScopedTestBean.java        | 42 ++++++++++++
 .../uc012/ApplicationScopedTestBeanClient.java  | 35 ++++++++++
 3 files changed, 147 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/730c8a9b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedBeanTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedBeanTest.java
b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedBeanTest.java
new file mode 100644
index 0000000..d355136
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedBeanTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.uc012;
+
+import org.apache.deltaspike.core.api.provider.BeanProvider;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+//Usually NOT needed! Currently only needed due to our arquillian-setup
+@Category(SeCategory.class)
+
+
+
+@RunWith(CdiTestRunner.class)
+public class ApplicationScopedBeanTest
+{
+    @Inject
+    private ApplicationScopedTestBean testBean;
+
+    @Inject
+    private ApplicationScopedTestBeanClient testBeanClient;
+
+    @Test
+    public void beanAccess()
+    {
+        this.testBean.setValue(0);
+        Assert.assertEquals(1, this.testBeanClient.getNextValue());
+        Assert.assertEquals(1, this.testBean.getValue());
+    }
+
+    @AfterClass
+    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 was created");
+        }
+
+        if (nextValue == 1)
+        {
+            throw new IllegalStateException("new application-scoped bean was created");
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/730c8a9b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedTestBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedTestBean.java
b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedTestBean.java
new file mode 100644
index 0000000..488f28b
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/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.testcontrol.uc012;
+
+import javax.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;
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/730c8a9b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedTestBeanClient.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedTestBeanClient.java
b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/uc012/ApplicationScopedTestBeanClient.java
new file mode 100644
index 0000000..ec7694a
--- /dev/null
+++ b/deltaspike/modules/test-control/impl/src/test/java/org/apache/deltaspike/test/testcontrol/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.testcontrol.uc012;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+
+@ApplicationScoped
+public class ApplicationScopedTestBeanClient
+{
+    @Inject
+    private ApplicationScopedTestBean testBean;
+
+    public int getNextValue()
+    {
+        this.testBean.increaseValue();
+        return this.testBean.getValue();
+    }
+}


Mime
View raw message