You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2014/01/06 14:20:56 UTC
[2/2] git commit: DELTASPIKE-491 @ConversationSubGroup
DELTASPIKE-491 @ConversationSubGroup
Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/50fc96e4
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/50fc96e4
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/50fc96e4
Branch: refs/heads/master
Commit: 50fc96e4102d32b774eaea8c13d6596df5b75a83
Parents: 1931c62
Author: gpetracek <gp...@apache.org>
Authored: Mon Jan 6 13:39:11 2014 +0100
Committer: gpetracek <gp...@apache.org>
Committed: Mon Jan 6 14:07:51 2014 +0100
----------------------------------------------------------------------
.../core/api/scope/ConversationSubGroup.java | 85 +++++++++
.../core/util/context/AbstractContext.java | 9 +-
.../GroupedConversationContext.java | 53 +++++-
.../core/impl/util/ConversationUtils.java | 36 +++-
.../scope/conversation/ExplicitTestGroup.java | 23 ---
.../conversation/ExplicitlyGroupedBeanX.java | 53 ------
.../conversation/ExplicitlyGroupedBeanY.java | 53 ------
.../ExplicitlyGroupedConversationsTest.java | 181 -------------------
.../conversation/ImplicitlyGroupedBean.java | 51 ------
.../ImplicitlyGroupedConversationsTest.java | 167 -----------------
.../grouped/explicit/ExplicitTestGroup.java | 23 +++
.../explicit/ExplicitlyGroupedBeanX.java | 53 ++++++
.../explicit/ExplicitlyGroupedBeanY.java | 53 ++++++
.../ExplicitlyGroupedConversationsTest.java | 181 +++++++++++++++++++
.../grouped/implicit/ImplicitlyGroupedBean.java | 51 ++++++
.../ImplicitlyGroupedConversationsTest.java | 167 +++++++++++++++++
.../subgroup/shared/TestBaseBean.java | 47 +++++
.../conversation/subgroup/shared/TestBeanA.java | 29 +++
.../conversation/subgroup/shared/TestBeanB.java | 29 +++
.../conversation/subgroup/shared/TestBeanC.java | 29 +++
.../conversation/subgroup/shared/TestGroup.java | 23 +++
.../uc001/GroupedConversationSubGroupTest.java | 97 ++++++++++
.../subgroup/uc001/TestSubGroup.java | 29 +++
.../uc002/GroupedConversationSubGroupTest.java | 101 +++++++++++
.../subgroup/uc002/TestSubGroup.java | 29 +++
.../uc003/GroupedConversationSubGroupTest.java | 98 ++++++++++
.../conversation/subgroup/uc003/TestBeanX.java | 31 ++++
.../conversation/subgroup/uc003/TestBeanY.java | 31 ++++
.../conversation/subgroup/uc003/TestBeanZ.java | 31 ++++
.../subgroup/uc003/TestImplicitSubGroup.java | 27 +++
.../subgroup/uc003/TestSubGroupContract.java | 24 +++
31 files changed, 1360 insertions(+), 534 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/scope/ConversationSubGroup.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/scope/ConversationSubGroup.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/scope/ConversationSubGroup.java
new file mode 100644
index 0000000..1d4ba13
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/scope/ConversationSubGroup.java
@@ -0,0 +1,85 @@
+/*
+ * 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.core.api.scope;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Allows to close a part of a group e.g.:
+ *
+ * public class MyGroup{}
+ * @ConversationScoped
+ * @ConversationGroup(MyGroup.class)
+ * public class BeanA {}
+ * <p/>
+ * @ConversationScoped
+ * @ConversationGroup(MyGroup.class)
+ * public class BeanB {}
+ * <p/>
+ * @ConversationScoped
+ * @ConversationGroup(MyGroup.class)
+ * public class BeanC {}
+ * <p/>
+ * @ConversationSubGroup(of = MyGroup.class, subGroup = {BeanA.class, BeanB.class})
+ * public class MySubGroup {}
+ * <br/>or</br>
+ * @ConversationSubGroup(subGroup = {BeanA.class, BeanB.class})
+ * public class MySubGroup extends MyGroup {}
+ * <p/>
+ * //...
+ * this.groupedConversationManager.closeConversation(MySubGroup.class)
+ *
+ * OR it's possible to use implicit sub-groups (point to the interface(s) instead of the bean-class itself):
+ * public interface MyUseCase {}
+ *
+ * @ConversationSubGroup(of = MyGroup.class, subGroup = MyUseCase.class)
+ * public class ImplicitSubGroup {}
+ *
+ * @Named("myController")
+ * @ConversationScoped
+ * @ConversationGroup(MyGroup.class)
+ * public class MyController implements Serializable, MyUseCase
+ * {
+ * //...
+ * }
+ * //...
+ * this.groupedConversationManager.closeConversation(ImplicitSubGroup.class)
+ */
+@Target(TYPE)
+@Retention(RUNTIME)
+@Documented
+public @interface ConversationSubGroup
+{
+ /**
+ * Optionally defines the base conversation group
+ * @return base conversation group or ConversationSubGroup if the subgroup inherits from the base conversation group
+ */
+ Class<?> of() default ConversationSubGroup.class;
+
+ /**
+ * Beans of the group which should be closed
+ * @return beans of the group which should be closed
+ */
+ Class<?>[] subGroup();
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/context/AbstractContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/context/AbstractContext.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/context/AbstractContext.java
index 1154a78..2857174 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/context/AbstractContext.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/context/AbstractContext.java
@@ -144,7 +144,7 @@ public abstract class AbstractContext implements Context
return false;
}
- bean.destroy(contextualInstanceInfo.getContextualInstance(), contextualInstanceInfo.getCreationalContext());
+ destroyBean(bean, contextualInstanceInfo);
return true;
}
@@ -184,11 +184,16 @@ public abstract class AbstractContext implements Context
Contextual bean = storage.getBean(entry.getKey());
ContextualInstanceInfo<?> contextualInstanceInfo = entry.getValue();
- bean.destroy(contextualInstanceInfo.getContextualInstance(), contextualInstanceInfo.getCreationalContext());
+ destroyBean(bean, contextualInstanceInfo);
}
return contextMap;
}
+ public static void destroyBean(Contextual bean, ContextualInstanceInfo<?> contextualInstanceInfo)
+ {
+ bean.destroy(contextualInstanceInfo.getContextualInstance(), contextualInstanceInfo.getCreationalContext());
+ }
+
/**
* Make sure that the Context is really active.
* @throws ContextNotActiveException if there is no active
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java
index ea9b612..bfa2cf1 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/scope/conversation/GroupedConversationContext.java
@@ -18,11 +18,13 @@
*/
package org.apache.deltaspike.core.impl.scope.conversation;
+import org.apache.deltaspike.core.api.scope.ConversationSubGroup;
import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
import org.apache.deltaspike.core.impl.scope.window.WindowContextImpl;
import org.apache.deltaspike.core.impl.util.ConversationUtils;
import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationManager;
import org.apache.deltaspike.core.util.context.AbstractContext;
+import org.apache.deltaspike.core.util.context.ContextualInstanceInfo;
import org.apache.deltaspike.core.util.context.ContextualStorage;
import javax.enterprise.context.spi.Contextual;
@@ -30,6 +32,7 @@ import javax.enterprise.inject.Typed;
import javax.enterprise.inject.spi.BeanManager;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -107,19 +110,63 @@ public class GroupedConversationContext extends AbstractContext implements Group
{
Set<ContextualStorage> result = new HashSet<ContextualStorage>();
+ ConversationSubGroup conversationSubGroup = conversationGroup.getAnnotation(ConversationSubGroup.class);
+ Set<Class<?>> subGroups = null;
+
+ if (conversationSubGroup != null)
+ {
+ conversationGroup = ConversationUtils.getDeclaredConversationGroup(conversationGroup);
+
+ subGroups = new HashSet<Class<?>>(conversationSubGroup.subGroup().length);
+ Collections.addAll(subGroups, conversationSubGroup.subGroup());
+ }
+
Map<ConversationKey, ContextualStorage> storageMap = this.conversationBeanHolder.getStorageMap();
for (Map.Entry<ConversationKey, ContextualStorage> entry : storageMap.entrySet())
{
if (entry.getKey().getConversationGroup().equals(conversationGroup))
{
- AbstractContext.destroyAllActive(entry.getValue());
- result.add(entry.getValue());
- storageMap.remove(entry.getKey()); //ok due to ConcurrentHashMap
+ if (subGroups == null)
+ {
+ AbstractContext.destroyAllActive(entry.getValue());
+ result.add(entry.getValue());
+ storageMap.remove(entry.getKey()); //ok due to ConcurrentHashMap
+ }
+ else
+ {
+ tryToDestroySubGroup(subGroups, entry);
+
+ if (entry.getValue().getStorage().isEmpty())
+ {
+ storageMap.remove(entry.getKey()); //ok due to ConcurrentHashMap
+ }
+ }
}
}
return result;
}
+ private void tryToDestroySubGroup(Set<Class<?>> subGroups, Map.Entry<ConversationKey, ContextualStorage> entry)
+ {
+ ContextualStorage storage = entry.getValue();
+
+ for (Map.Entry<Object, ContextualInstanceInfo<?>> storageEntry : storage.getStorage().entrySet())
+ {
+ for (Class<?> subGroup : subGroups)
+ {
+ Class classOfEntry = storageEntry.getValue().getContextualInstance().getClass();
+ if (subGroup.equals(classOfEntry) ||
+ (subGroup.isInterface() && subGroup.isAssignableFrom(classOfEntry)))
+ {
+ Contextual bean = storage.getBean(storageEntry.getKey());
+ AbstractContext.destroyBean(bean, storageEntry.getValue());
+ storage.getStorage().remove(storageEntry.getKey()); //ok due to ConcurrentHashMap
+ break;
+ }
+ }
+ }
+ }
+
@Override
public void closeConversations()
{
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java
index d763d5d..9cc3e31 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ConversationUtils.java
@@ -19,6 +19,7 @@
package org.apache.deltaspike.core.impl.util;
import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.api.scope.ConversationSubGroup;
import org.apache.deltaspike.core.impl.scope.conversation.ConversationKey;
import javax.enterprise.context.spi.Contextual;
@@ -47,7 +48,7 @@ public abstract class ConversationUtils
else
{
throw new IllegalArgumentException(
- contextual.getClass().getName() + " is not of type " + Bean.class.getName());
+ contextual.getClass().getName() + " is not of type " + Bean.class.getName());
}
}
@@ -83,4 +84,37 @@ public abstract class ConversationUtils
}
return null;
}
+
+ public static Class<?> getDeclaredConversationGroup(Class<?> conversationGroup)
+ {
+ ConversationSubGroup conversationSubGroup = conversationGroup.getAnnotation(ConversationSubGroup.class);
+
+ if (conversationSubGroup == null)
+ {
+ return conversationGroup;
+ }
+
+ Class<?> result = conversationSubGroup.of();
+
+ if (!ConversationSubGroup.class.equals(result))
+ {
+ return result;
+ }
+
+ result = conversationGroup.getSuperclass();
+
+ if ((result == null || Object.class.getName().equals(result.getName())) &&
+ conversationGroup.getInterfaces().length == 1)
+ {
+ return conversationGroup.getInterfaces()[0];
+ }
+
+ if (result == null)
+ {
+ //TODO move validation to the bootstrapping process
+ throw new IllegalStateException(conversationGroup.getName() + " hosts an invalid usage of @" +
+ ConversationSubGroup.class.getName());
+ }
+ return result;
+ }
}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitTestGroup.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitTestGroup.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitTestGroup.java
deleted file mode 100644
index e328385..0000000
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitTestGroup.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * 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.scope.conversation;
-
-public interface ExplicitTestGroup
-{
-}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedBeanX.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedBeanX.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedBeanX.java
deleted file mode 100644
index 9a44626..0000000
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedBeanX.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.scope.conversation;
-
-import org.apache.deltaspike.core.api.scope.ConversationGroup;
-import org.apache.deltaspike.core.api.scope.GroupedConversation;
-import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
-
-import javax.inject.Inject;
-import java.io.Serializable;
-
-@GroupedConversationScoped
-@ConversationGroup(ExplicitTestGroup.class)
-public class ExplicitlyGroupedBeanX implements Serializable
-{
- private static final long serialVersionUID = -1291355584482007178L;
-
- private String value;
-
- @Inject
- private GroupedConversation conversation;
-
- public String getValue()
- {
- return value;
- }
-
- public void setValue(String value)
- {
- this.value = value;
- }
-
- public void done()
- {
- this.conversation.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedBeanY.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedBeanY.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedBeanY.java
deleted file mode 100644
index 0cb6df7..0000000
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedBeanY.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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.scope.conversation;
-
-import org.apache.deltaspike.core.api.scope.ConversationGroup;
-import org.apache.deltaspike.core.api.scope.GroupedConversation;
-import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
-
-import javax.inject.Inject;
-import java.io.Serializable;
-
-@GroupedConversationScoped
-@ConversationGroup(ExplicitTestGroup.class)
-public class ExplicitlyGroupedBeanY implements Serializable
-{
- private static final long serialVersionUID = -1291355584482007178L;
-
- private String value;
-
- @Inject
- private GroupedConversation conversation;
-
- public String getValue()
- {
- return value;
- }
-
- public void setValue(String value)
- {
- this.value = value;
- }
-
- public void done()
- {
- this.conversation.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedConversationsTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedConversationsTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedConversationsTest.java
deleted file mode 100644
index e7b45dd..0000000
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ExplicitlyGroupedConversationsTest.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * 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.scope.conversation;
-
-import org.apache.deltaspike.core.api.scope.ConversationGroup;
-import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationManager;
-import org.apache.deltaspike.core.spi.scope.window.WindowContext;
-import org.apache.deltaspike.test.category.SeCategory;
-import org.apache.deltaspike.test.util.ArchiveUtils;
-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.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import javax.enterprise.context.ContextNotActiveException;
-import javax.inject.Inject;
-
-@RunWith(Arquillian.class)
-@Category(SeCategory.class)
-public class ExplicitlyGroupedConversationsTest
-{
- @Deployment
- public static WebArchive deploy()
- {
- String simpleName = ExplicitlyGroupedConversationsTest.class.getSimpleName();
- String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
-
- JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
- .addPackage(ExplicitlyGroupedConversationsTest.class.getPackage().getName())
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
-
- return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
- .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
- .addAsLibraries(testJar)
- .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private WindowContext windowContext;
-
- @Inject
- @ConversationGroup(ExplicitTestGroup.class)
- private ExplicitlyGroupedBeanX explicitlyGroupedBeanX;
-
- @Inject
- @ConversationGroup(ExplicitTestGroup.class)
- private ExplicitlyGroupedBeanY explicitlyGroupedBeanY;
-
- @Inject
- private GroupedConversationManager conversationManager;
-
- @Test
- public void parallelConversationsTest()
- {
- windowContext.activateWindow("w1");
-
- explicitlyGroupedBeanX.setValue("x1");
- explicitlyGroupedBeanY.setValue("x2");
- Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
- Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
-
- windowContext.activateWindow("w2");
-
- Assert.assertNull(explicitlyGroupedBeanX.getValue());
- Assert.assertNull(explicitlyGroupedBeanY.getValue());
-
- explicitlyGroupedBeanX.setValue("y1");
- explicitlyGroupedBeanY.setValue("y2");
- Assert.assertEquals("y1", explicitlyGroupedBeanX.getValue());
- Assert.assertEquals("y2", explicitlyGroupedBeanY.getValue());
- }
-
- @Test
- public void immediatelyClosedConversationTest()
- {
- windowContext.activateWindow("w1");
-
- explicitlyGroupedBeanX.setValue("x1");
- explicitlyGroupedBeanY.setValue("x2");
- Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
- Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
-
- explicitlyGroupedBeanX.done();
-
- Assert.assertNull(explicitlyGroupedBeanX.getValue());
- Assert.assertNull(explicitlyGroupedBeanY.getValue());
- }
-
- @Test
- public void immediatelyClosedConversationViaConversationManagerTest()
- {
- windowContext.activateWindow("w1");
-
- explicitlyGroupedBeanX.setValue("x1");
- explicitlyGroupedBeanY.setValue("x2");
- Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
- Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
-
- this.conversationManager.closeConversationGroup(ExplicitTestGroup.class);
-
- Assert.assertNull(explicitlyGroupedBeanX.getValue());
- Assert.assertNull(explicitlyGroupedBeanY.getValue());
- }
-
- @Test
- public void immediatelyClosedConversationsTest()
- {
- windowContext.activateWindow("w1");
-
- explicitlyGroupedBeanX.setValue("x1");
- explicitlyGroupedBeanY.setValue("x2");
- Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
- Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
-
- this.conversationManager.closeConversations();
-
- Assert.assertNull(explicitlyGroupedBeanX.getValue());
- Assert.assertNull(explicitlyGroupedBeanY.getValue());
- }
-
- @Test
- public void immediatelyClosedConversationsViaWindowContextTest()
- {
- windowContext.activateWindow("w1");
-
- explicitlyGroupedBeanX.setValue("x1");
- explicitlyGroupedBeanY.setValue("x2");
- Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
- Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
-
- Assert.assertTrue(this.windowContext.closeWindow("w1"));
- windowContext.activateWindow("w1");
-
- Assert.assertNull(explicitlyGroupedBeanX.getValue());
- Assert.assertNull(explicitlyGroupedBeanY.getValue());
- }
-
- @Test(expected = ContextNotActiveException.class)
- public void noWindowTest()
- {
- try
- {
- windowContext.activateWindow("w1");
-
- explicitlyGroupedBeanX.setValue("x1");
- explicitlyGroupedBeanY.setValue("x2");
- Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
- Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
-
- this.windowContext.closeWindow("w1");
- }
- catch (ContextNotActiveException e)
- {
- Assert.fail();
- }
-
- explicitlyGroupedBeanX.getValue();
- }
-}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ImplicitlyGroupedBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ImplicitlyGroupedBean.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ImplicitlyGroupedBean.java
deleted file mode 100644
index 874c29c..0000000
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ImplicitlyGroupedBean.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.scope.conversation;
-
-import org.apache.deltaspike.core.api.scope.GroupedConversation;
-import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
-
-import javax.inject.Inject;
-import java.io.Serializable;
-
-@GroupedConversationScoped
-public class ImplicitlyGroupedBean implements Serializable
-{
- private static final long serialVersionUID = -4722854711870629520L;
-
- private String value;
-
- @Inject
- private GroupedConversation conversation;
-
- public String getValue()
- {
- return value;
- }
-
- public void setValue(String value)
- {
- this.value = value;
- }
-
- public void done()
- {
- this.conversation.close();
- }
-}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ImplicitlyGroupedConversationsTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ImplicitlyGroupedConversationsTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ImplicitlyGroupedConversationsTest.java
deleted file mode 100644
index e843595..0000000
--- a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/ImplicitlyGroupedConversationsTest.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * 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.scope.conversation;
-
-import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationManager;
-import org.apache.deltaspike.core.spi.scope.window.WindowContext;
-import org.apache.deltaspike.test.category.SeCategory;
-import org.apache.deltaspike.test.util.ArchiveUtils;
-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.experimental.categories.Category;
-import org.junit.runner.RunWith;
-
-import javax.enterprise.context.ContextNotActiveException;
-import javax.inject.Inject;
-
-@RunWith(Arquillian.class)
-@Category(SeCategory.class)
-public class ImplicitlyGroupedConversationsTest
-{
- @Deployment
- public static WebArchive deploy()
- {
- String simpleName = ImplicitlyGroupedConversationsTest.class.getSimpleName();
- String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
-
- JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
- .addPackage(ImplicitlyGroupedConversationsTest.class.getPackage().getName())
- .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
-
- return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
- .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
- .addAsLibraries(testJar)
- .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
- }
-
- @Inject
- private WindowContext windowContext;
-
- @Inject
- private ImplicitlyGroupedBean implicitlyGroupedBean;
-
- @Inject
- private GroupedConversationManager conversationManager;
-
- @Test
- public void parallelConversationsTest()
- {
- windowContext.activateWindow("w1");
-
- implicitlyGroupedBean.setValue("x");
- Assert.assertEquals("x", implicitlyGroupedBean.getValue());
-
- windowContext.activateWindow("w2");
-
- Assert.assertNull(implicitlyGroupedBean.getValue());
-
- implicitlyGroupedBean.setValue("y");
- Assert.assertEquals("y", implicitlyGroupedBean.getValue());
-
- windowContext.activateWindow("w1");
- Assert.assertEquals("x", implicitlyGroupedBean.getValue());
- }
-
- @Test
- public void immediatelyClosedConversationTest()
- {
- windowContext.activateWindow("w1");
-
- implicitlyGroupedBean.setValue("x");
- Assert.assertEquals("x", implicitlyGroupedBean.getValue());
-
- implicitlyGroupedBean.done();
-
- Assert.assertNull(implicitlyGroupedBean.getValue());
- }
-
- @Test
- public void immediatelyClosedConversationViaConversationManagerTest()
- {
- windowContext.activateWindow("w1");
-
- implicitlyGroupedBean.setValue("x");
- Assert.assertEquals("x", implicitlyGroupedBean.getValue());
-
- this.conversationManager.closeConversation(ImplicitlyGroupedBean.class);
-
- Assert.assertNull(implicitlyGroupedBean.getValue());
-
-
- implicitlyGroupedBean.setValue("y");
- Assert.assertEquals("y", implicitlyGroupedBean.getValue());
-
- this.conversationManager.closeConversationGroup(ImplicitlyGroupedBean.class);
-
- Assert.assertNull(implicitlyGroupedBean.getValue());
- }
-
- @Test
- public void immediatelyClosedConversationsTest()
- {
- windowContext.activateWindow("w1");
-
- implicitlyGroupedBean.setValue("x");
- Assert.assertEquals("x", implicitlyGroupedBean.getValue());
-
- this.conversationManager.closeConversations();
-
- Assert.assertNull(implicitlyGroupedBean.getValue());
- }
-
- @Test
- public void immediatelyClosedConversationsViaWindowContextTest()
- {
- windowContext.activateWindow("w1");
-
- implicitlyGroupedBean.setValue("x");
- Assert.assertEquals("x", implicitlyGroupedBean.getValue());
-
- Assert.assertTrue(this.windowContext.closeWindow("w1"));
- windowContext.activateWindow("w1");
-
- Assert.assertNull(implicitlyGroupedBean.getValue());
- }
-
- @Test(expected = ContextNotActiveException.class)
- public void noWindowTest()
- {
- try
- {
- windowContext.activateWindow("w1");
-
- implicitlyGroupedBean.setValue("x");
- Assert.assertEquals("x", implicitlyGroupedBean.getValue());
-
- this.windowContext.closeWindow("w1");
- }
- catch (ContextNotActiveException e)
- {
- Assert.fail();
- }
-
- implicitlyGroupedBean.getValue();
- }
-}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitTestGroup.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitTestGroup.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitTestGroup.java
new file mode 100644
index 0000000..b5b2897
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitTestGroup.java
@@ -0,0 +1,23 @@
+/*
+ * 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.scope.conversation.grouped.explicit;
+
+public interface ExplicitTestGroup
+{
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedBeanX.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedBeanX.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedBeanX.java
new file mode 100644
index 0000000..9e4e583
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedBeanX.java
@@ -0,0 +1,53 @@
+/*
+ * 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.scope.conversation.grouped.explicit;
+
+import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.api.scope.GroupedConversation;
+import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
+
+import javax.inject.Inject;
+import java.io.Serializable;
+
+@GroupedConversationScoped
+@ConversationGroup(ExplicitTestGroup.class)
+public class ExplicitlyGroupedBeanX implements Serializable
+{
+ private static final long serialVersionUID = -1291355584482007178L;
+
+ private String value;
+
+ @Inject
+ private GroupedConversation conversation;
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public void done()
+ {
+ this.conversation.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedBeanY.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedBeanY.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedBeanY.java
new file mode 100644
index 0000000..8e4b0c7
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedBeanY.java
@@ -0,0 +1,53 @@
+/*
+ * 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.scope.conversation.grouped.explicit;
+
+import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.api.scope.GroupedConversation;
+import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
+
+import javax.inject.Inject;
+import java.io.Serializable;
+
+@GroupedConversationScoped
+@ConversationGroup(ExplicitTestGroup.class)
+public class ExplicitlyGroupedBeanY implements Serializable
+{
+ private static final long serialVersionUID = -1291355584482007178L;
+
+ private String value;
+
+ @Inject
+ private GroupedConversation conversation;
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public void done()
+ {
+ this.conversation.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedConversationsTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedConversationsTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedConversationsTest.java
new file mode 100644
index 0000000..e5762ea
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/explicit/ExplicitlyGroupedConversationsTest.java
@@ -0,0 +1,181 @@
+/*
+ * 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.scope.conversation.grouped.explicit;
+
+import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationManager;
+import org.apache.deltaspike.core.spi.scope.window.WindowContext;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+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.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.context.ContextNotActiveException;
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+@Category(SeCategory.class)
+public class ExplicitlyGroupedConversationsTest
+{
+ @Deployment
+ public static WebArchive deploy()
+ {
+ String simpleName = ExplicitlyGroupedConversationsTest.class.getSimpleName();
+ String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+ JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
+ .addPackage(ExplicitlyGroupedConversationsTest.class.getPackage().getName())
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+ return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
+ .addAsLibraries(testJar)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ @Inject
+ private WindowContext windowContext;
+
+ @Inject
+ @ConversationGroup(ExplicitTestGroup.class)
+ private ExplicitlyGroupedBeanX explicitlyGroupedBeanX;
+
+ @Inject
+ @ConversationGroup(ExplicitTestGroup.class)
+ private ExplicitlyGroupedBeanY explicitlyGroupedBeanY;
+
+ @Inject
+ private GroupedConversationManager conversationManager;
+
+ @Test
+ public void parallelConversationsTest()
+ {
+ windowContext.activateWindow("w1");
+
+ explicitlyGroupedBeanX.setValue("x1");
+ explicitlyGroupedBeanY.setValue("x2");
+ Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
+ Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
+
+ windowContext.activateWindow("w2");
+
+ Assert.assertNull(explicitlyGroupedBeanX.getValue());
+ Assert.assertNull(explicitlyGroupedBeanY.getValue());
+
+ explicitlyGroupedBeanX.setValue("y1");
+ explicitlyGroupedBeanY.setValue("y2");
+ Assert.assertEquals("y1", explicitlyGroupedBeanX.getValue());
+ Assert.assertEquals("y2", explicitlyGroupedBeanY.getValue());
+ }
+
+ @Test
+ public void immediatelyClosedConversationTest()
+ {
+ windowContext.activateWindow("w1");
+
+ explicitlyGroupedBeanX.setValue("x1");
+ explicitlyGroupedBeanY.setValue("x2");
+ Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
+ Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
+
+ explicitlyGroupedBeanX.done();
+
+ Assert.assertNull(explicitlyGroupedBeanX.getValue());
+ Assert.assertNull(explicitlyGroupedBeanY.getValue());
+ }
+
+ @Test
+ public void immediatelyClosedConversationViaConversationManagerTest()
+ {
+ windowContext.activateWindow("w1");
+
+ explicitlyGroupedBeanX.setValue("x1");
+ explicitlyGroupedBeanY.setValue("x2");
+ Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
+ Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
+
+ this.conversationManager.closeConversationGroup(ExplicitTestGroup.class);
+
+ Assert.assertNull(explicitlyGroupedBeanX.getValue());
+ Assert.assertNull(explicitlyGroupedBeanY.getValue());
+ }
+
+ @Test
+ public void immediatelyClosedConversationsTest()
+ {
+ windowContext.activateWindow("w1");
+
+ explicitlyGroupedBeanX.setValue("x1");
+ explicitlyGroupedBeanY.setValue("x2");
+ Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
+ Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
+
+ this.conversationManager.closeConversations();
+
+ Assert.assertNull(explicitlyGroupedBeanX.getValue());
+ Assert.assertNull(explicitlyGroupedBeanY.getValue());
+ }
+
+ @Test
+ public void immediatelyClosedConversationsViaWindowContextTest()
+ {
+ windowContext.activateWindow("w1");
+
+ explicitlyGroupedBeanX.setValue("x1");
+ explicitlyGroupedBeanY.setValue("x2");
+ Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
+ Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
+
+ Assert.assertTrue(this.windowContext.closeWindow("w1"));
+ windowContext.activateWindow("w1");
+
+ Assert.assertNull(explicitlyGroupedBeanX.getValue());
+ Assert.assertNull(explicitlyGroupedBeanY.getValue());
+ }
+
+ @Test(expected = ContextNotActiveException.class)
+ public void noWindowTest()
+ {
+ try
+ {
+ windowContext.activateWindow("w1");
+
+ explicitlyGroupedBeanX.setValue("x1");
+ explicitlyGroupedBeanY.setValue("x2");
+ Assert.assertEquals("x1", explicitlyGroupedBeanX.getValue());
+ Assert.assertEquals("x2", explicitlyGroupedBeanY.getValue());
+
+ this.windowContext.closeWindow("w1");
+ }
+ catch (ContextNotActiveException e)
+ {
+ Assert.fail();
+ }
+
+ explicitlyGroupedBeanX.getValue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/implicit/ImplicitlyGroupedBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/implicit/ImplicitlyGroupedBean.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/implicit/ImplicitlyGroupedBean.java
new file mode 100644
index 0000000..84e08a0
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/implicit/ImplicitlyGroupedBean.java
@@ -0,0 +1,51 @@
+/*
+ * 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.scope.conversation.grouped.implicit;
+
+import org.apache.deltaspike.core.api.scope.GroupedConversation;
+import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
+
+import javax.inject.Inject;
+import java.io.Serializable;
+
+@GroupedConversationScoped
+public class ImplicitlyGroupedBean implements Serializable
+{
+ private static final long serialVersionUID = -4722854711870629520L;
+
+ private String value;
+
+ @Inject
+ private GroupedConversation conversation;
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public void done()
+ {
+ this.conversation.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/implicit/ImplicitlyGroupedConversationsTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/implicit/ImplicitlyGroupedConversationsTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/implicit/ImplicitlyGroupedConversationsTest.java
new file mode 100644
index 0000000..219579c
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/grouped/implicit/ImplicitlyGroupedConversationsTest.java
@@ -0,0 +1,167 @@
+/*
+ * 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.scope.conversation.grouped.implicit;
+
+import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationManager;
+import org.apache.deltaspike.core.spi.scope.window.WindowContext;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+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.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.enterprise.context.ContextNotActiveException;
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+@Category(SeCategory.class)
+public class ImplicitlyGroupedConversationsTest
+{
+ @Deployment
+ public static WebArchive deploy()
+ {
+ String simpleName = ImplicitlyGroupedConversationsTest.class.getSimpleName();
+ String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+ JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
+ .addPackage(ImplicitlyGroupedConversationsTest.class.getPackage().getName())
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+ return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
+ .addAsLibraries(testJar)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ @Inject
+ private WindowContext windowContext;
+
+ @Inject
+ private ImplicitlyGroupedBean implicitlyGroupedBean;
+
+ @Inject
+ private GroupedConversationManager conversationManager;
+
+ @Test
+ public void parallelConversationsTest()
+ {
+ windowContext.activateWindow("w1");
+
+ implicitlyGroupedBean.setValue("x");
+ Assert.assertEquals("x", implicitlyGroupedBean.getValue());
+
+ windowContext.activateWindow("w2");
+
+ Assert.assertNull(implicitlyGroupedBean.getValue());
+
+ implicitlyGroupedBean.setValue("y");
+ Assert.assertEquals("y", implicitlyGroupedBean.getValue());
+
+ windowContext.activateWindow("w1");
+ Assert.assertEquals("x", implicitlyGroupedBean.getValue());
+ }
+
+ @Test
+ public void immediatelyClosedConversationTest()
+ {
+ windowContext.activateWindow("w1");
+
+ implicitlyGroupedBean.setValue("x");
+ Assert.assertEquals("x", implicitlyGroupedBean.getValue());
+
+ implicitlyGroupedBean.done();
+
+ Assert.assertNull(implicitlyGroupedBean.getValue());
+ }
+
+ @Test
+ public void immediatelyClosedConversationViaConversationManagerTest()
+ {
+ windowContext.activateWindow("w1");
+
+ implicitlyGroupedBean.setValue("x");
+ Assert.assertEquals("x", implicitlyGroupedBean.getValue());
+
+ this.conversationManager.closeConversation(ImplicitlyGroupedBean.class);
+
+ Assert.assertNull(implicitlyGroupedBean.getValue());
+
+
+ implicitlyGroupedBean.setValue("y");
+ Assert.assertEquals("y", implicitlyGroupedBean.getValue());
+
+ this.conversationManager.closeConversationGroup(ImplicitlyGroupedBean.class);
+
+ Assert.assertNull(implicitlyGroupedBean.getValue());
+ }
+
+ @Test
+ public void immediatelyClosedConversationsTest()
+ {
+ windowContext.activateWindow("w1");
+
+ implicitlyGroupedBean.setValue("x");
+ Assert.assertEquals("x", implicitlyGroupedBean.getValue());
+
+ this.conversationManager.closeConversations();
+
+ Assert.assertNull(implicitlyGroupedBean.getValue());
+ }
+
+ @Test
+ public void immediatelyClosedConversationsViaWindowContextTest()
+ {
+ windowContext.activateWindow("w1");
+
+ implicitlyGroupedBean.setValue("x");
+ Assert.assertEquals("x", implicitlyGroupedBean.getValue());
+
+ Assert.assertTrue(this.windowContext.closeWindow("w1"));
+ windowContext.activateWindow("w1");
+
+ Assert.assertNull(implicitlyGroupedBean.getValue());
+ }
+
+ @Test(expected = ContextNotActiveException.class)
+ public void noWindowTest()
+ {
+ try
+ {
+ windowContext.activateWindow("w1");
+
+ implicitlyGroupedBean.setValue("x");
+ Assert.assertEquals("x", implicitlyGroupedBean.getValue());
+
+ this.windowContext.closeWindow("w1");
+ }
+ catch (ContextNotActiveException e)
+ {
+ Assert.fail();
+ }
+
+ implicitlyGroupedBean.getValue();
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBaseBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBaseBean.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBaseBean.java
new file mode 100644
index 0000000..9d3eac8
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBaseBean.java
@@ -0,0 +1,47 @@
+/*
+ * 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.scope.conversation.subgroup.shared;
+
+import org.apache.deltaspike.core.api.scope.GroupedConversation;
+
+import javax.inject.Inject;
+import java.io.Serializable;
+
+public abstract class TestBaseBean implements Serializable
+{
+ private String value;
+
+ @Inject
+ private GroupedConversation conversation;
+
+ public String getValue()
+ {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+ public void done()
+ {
+ this.conversation.close();
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanA.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanA.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanA.java
new file mode 100644
index 0000000..0b8eeaf
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanA.java
@@ -0,0 +1,29 @@
+/*
+ * 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.scope.conversation.subgroup.shared;
+
+import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
+
+@GroupedConversationScoped
+@ConversationGroup(TestGroup.class)
+public class TestBeanA extends TestBaseBean
+{
+ private static final long serialVersionUID = -1291355584482007178L;
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanB.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanB.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanB.java
new file mode 100644
index 0000000..c3847d6
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanB.java
@@ -0,0 +1,29 @@
+/*
+ * 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.scope.conversation.subgroup.shared;
+
+import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
+
+@GroupedConversationScoped
+@ConversationGroup(TestGroup.class)
+public class TestBeanB extends TestBaseBean
+{
+ private static final long serialVersionUID = -1291355584482007178L;
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanC.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanC.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanC.java
new file mode 100644
index 0000000..ab68508
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestBeanC.java
@@ -0,0 +1,29 @@
+/*
+ * 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.scope.conversation.subgroup.shared;
+
+import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.api.scope.GroupedConversationScoped;
+
+@GroupedConversationScoped
+@ConversationGroup(TestGroup.class)
+public class TestBeanC extends TestBaseBean
+{
+ private static final long serialVersionUID = -1291355584482007178L;
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestGroup.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestGroup.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestGroup.java
new file mode 100644
index 0000000..44582c8
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/shared/TestGroup.java
@@ -0,0 +1,23 @@
+/*
+ * 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.scope.conversation.subgroup.shared;
+
+public interface TestGroup
+{
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc001/GroupedConversationSubGroupTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc001/GroupedConversationSubGroupTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc001/GroupedConversationSubGroupTest.java
new file mode 100644
index 0000000..b1c6a62
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc001/GroupedConversationSubGroupTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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.scope.conversation.subgroup.uc001;
+
+import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationManager;
+import org.apache.deltaspike.core.spi.scope.window.WindowContext;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.*;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+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.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+@Category(SeCategory.class)
+public class GroupedConversationSubGroupTest
+{
+ @Deployment
+ public static WebArchive deploy()
+ {
+ String simpleName = GroupedConversationSubGroupTest.class.getSimpleName();
+ String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+ JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
+ .addPackage(GroupedConversationSubGroupTest.class.getPackage())
+ .addPackage(TestBaseBean.class.getPackage())
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+ return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
+ .addAsLibraries(testJar)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ @Inject
+ private WindowContext windowContext;
+
+ @Inject
+ @ConversationGroup(TestGroup.class)
+ private TestBeanA testBeanA;
+
+ @Inject
+ @ConversationGroup(TestGroup.class)
+ private TestBeanB testBeanB;
+
+ @Inject
+ @ConversationGroup(TestGroup.class)
+ private TestBeanC testBeanC;
+
+ @Inject
+ private GroupedConversationManager conversationManager;
+
+ @Test
+ public void closedSubGroupTest()
+ {
+ windowContext.activateWindow("w1");
+
+ testBeanA.setValue("x1");
+ testBeanB.setValue("x2");
+ testBeanC.setValue("x3");
+ Assert.assertEquals("x1", testBeanA.getValue());
+ Assert.assertEquals("x2", testBeanB.getValue());
+ Assert.assertEquals("x3", testBeanC.getValue());
+
+ this.conversationManager.closeConversationGroup(TestSubGroup.class);
+
+ Assert.assertNull(testBeanA.getValue());
+ Assert.assertEquals("x2", testBeanB.getValue()); //not part of the sub-group
+ Assert.assertNull(testBeanC.getValue());
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc001/TestSubGroup.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc001/TestSubGroup.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc001/TestSubGroup.java
new file mode 100644
index 0000000..15b5db2
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc001/TestSubGroup.java
@@ -0,0 +1,29 @@
+/*
+ * 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.scope.conversation.subgroup.uc001;
+
+import org.apache.deltaspike.core.api.scope.ConversationSubGroup;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestBeanA;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestBeanC;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestGroup;
+
+@ConversationSubGroup(of = TestGroup.class, subGroup = {TestBeanA.class, TestBeanC.class})
+public interface TestSubGroup
+{
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc002/GroupedConversationSubGroupTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc002/GroupedConversationSubGroupTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc002/GroupedConversationSubGroupTest.java
new file mode 100644
index 0000000..6b235b6
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc002/GroupedConversationSubGroupTest.java
@@ -0,0 +1,101 @@
+/*
+ * 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.scope.conversation.subgroup.uc002;
+
+import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationManager;
+import org.apache.deltaspike.core.spi.scope.window.WindowContext;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestBaseBean;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestBeanA;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestBeanB;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestBeanC;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestGroup;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+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.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+@Category(SeCategory.class)
+public class GroupedConversationSubGroupTest
+{
+ @Deployment
+ public static WebArchive deploy()
+ {
+ String simpleName = GroupedConversationSubGroupTest.class.getSimpleName();
+ String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+ JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
+ .addPackage(GroupedConversationSubGroupTest.class.getPackage())
+ .addPackage(TestBaseBean.class.getPackage())
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+ return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
+ .addAsLibraries(testJar)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ @Inject
+ private WindowContext windowContext;
+
+ @Inject
+ @ConversationGroup(TestGroup.class)
+ private TestBeanA testBeanA;
+
+ @Inject
+ @ConversationGroup(TestGroup.class)
+ private TestBeanB testBeanB;
+
+ @Inject
+ @ConversationGroup(TestGroup.class)
+ private TestBeanC testBeanC;
+
+ @Inject
+ private GroupedConversationManager conversationManager;
+
+ @Test
+ public void closedSubGroupTest()
+ {
+ windowContext.activateWindow("w1");
+
+ testBeanA.setValue("x1");
+ testBeanB.setValue("x2");
+ testBeanC.setValue("x3");
+ Assert.assertEquals("x1", testBeanA.getValue());
+ Assert.assertEquals("x2", testBeanB.getValue());
+ Assert.assertEquals("x3", testBeanC.getValue());
+
+ this.conversationManager.closeConversationGroup(TestSubGroup.class);
+
+ Assert.assertNull(testBeanA.getValue());
+ Assert.assertEquals("x2", testBeanB.getValue()); //not part of the sub-group
+ Assert.assertNull(testBeanC.getValue());
+ }
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc002/TestSubGroup.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc002/TestSubGroup.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc002/TestSubGroup.java
new file mode 100644
index 0000000..387adf8
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc002/TestSubGroup.java
@@ -0,0 +1,29 @@
+/*
+ * 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.scope.conversation.subgroup.uc002;
+
+import org.apache.deltaspike.core.api.scope.ConversationSubGroup;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestBeanA;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestBeanC;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestGroup;
+
+@ConversationSubGroup(subGroup = {TestBeanA.class, TestBeanC.class})
+public interface TestSubGroup extends TestGroup
+{
+}
http://git-wip-us.apache.org/repos/asf/deltaspike/blob/50fc96e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc003/GroupedConversationSubGroupTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc003/GroupedConversationSubGroupTest.java b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc003/GroupedConversationSubGroupTest.java
new file mode 100644
index 0000000..946c221
--- /dev/null
+++ b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/api/scope/conversation/subgroup/uc003/GroupedConversationSubGroupTest.java
@@ -0,0 +1,98 @@
+/*
+ * 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.scope.conversation.subgroup.uc003;
+
+import org.apache.deltaspike.core.api.scope.ConversationGroup;
+import org.apache.deltaspike.core.spi.scope.conversation.GroupedConversationManager;
+import org.apache.deltaspike.core.spi.scope.window.WindowContext;
+import org.apache.deltaspike.test.category.SeCategory;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestBaseBean;
+import org.apache.deltaspike.test.core.api.scope.conversation.subgroup.shared.TestGroup;
+import org.apache.deltaspike.test.util.ArchiveUtils;
+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.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import javax.inject.Inject;
+
+@RunWith(Arquillian.class)
+@Category(SeCategory.class)
+public class GroupedConversationSubGroupTest
+{
+ @Deployment
+ public static WebArchive deploy()
+ {
+ String simpleName = GroupedConversationSubGroupTest.class.getSimpleName();
+ String archiveName = simpleName.substring(0, 1).toLowerCase() + simpleName.substring(1);
+
+ JavaArchive testJar = ShrinkWrap.create(JavaArchive.class, archiveName + ".jar")
+ .addPackage(GroupedConversationSubGroupTest.class.getPackage())
+ .addPackage(TestBaseBean.class.getPackage())
+ .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
+
+ return ShrinkWrap.create(WebArchive.class, archiveName + ".war")
+ .addAsLibraries(ArchiveUtils.getDeltaSpikeCoreArchive())
+ .addAsLibraries(testJar)
+ .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
+ }
+
+ @Inject
+ private WindowContext windowContext;
+
+ @Inject
+ @ConversationGroup(TestGroup.class)
+ private TestBeanX testBeanX;
+
+ @Inject
+ @ConversationGroup(TestGroup.class)
+ private TestBeanY testBeanY;
+
+ @Inject
+ @ConversationGroup(TestGroup.class)
+ private TestBeanZ testBeanZ;
+
+ @Inject
+ private GroupedConversationManager conversationManager;
+
+ @Test
+ public void closedSubGroupTest()
+ {
+ windowContext.activateWindow("w1");
+
+ testBeanX.setValue("x1");
+ testBeanY.setValue("x2");
+ testBeanZ.setValue("x3");
+ Assert.assertEquals("x1", testBeanX.getValue());
+ Assert.assertEquals("x2", testBeanY.getValue());
+ Assert.assertEquals("x3", testBeanZ.getValue());
+
+ this.conversationManager.closeConversationGroup(TestImplicitSubGroup.class);
+
+ Assert.assertNull(testBeanX.getValue());
+ Assert.assertEquals("x2", testBeanY.getValue()); //not part of the sub-group
+ Assert.assertNull(testBeanZ.getValue());
+ }
+}