Weld SVN: r6302 - cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-25 07:31:33 -0400 (Tue, 25 May 2010)
New Revision: 6302
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/SimpleBean.java
Log:
CDITCK-164
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/SimpleBean.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/SimpleBean.java 2010-05-24 17:39:47 UTC (rev 6301)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/implementation/enterprise/newBean/SimpleBean.java 2010-05-25 11:31:33 UTC (rev 6302)
@@ -16,7 +16,7 @@
*/
package org.jboss.jsr299.tck.tests.implementation.enterprise.newBean;
-class SimpleBean
+public class SimpleBean
{
}
13 years, 11 months
Weld SVN: r6301 - in core/trunk/impl/src/main/java/org/jboss/weld: bean/proxy/util and 1 other directories.
by weld-commits@lists.jboss.org
Author: dallen6
Date: 2010-05-24 13:39:47 -0400 (Mon, 24 May 2010)
New Revision: 6301
Added:
core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SerializableProxy.java
Log:
Fixed serialization problem with proxies
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java 2010-05-24 16:45:51 UTC (rev 6300)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/DecoratorProxyFactory.java 2010-05-24 17:39:47 UTC (rev 6301)
@@ -56,7 +56,7 @@
this.delegateInjectionPoint = delegateInjectionPoint;
try
{
- delegateClass = classPool.get(((Class<?>) delegateInjectionPoint.getBaseType()).getName());
+ delegateClass = getClassPool().get(((Class<?>) delegateInjectionPoint.getBaseType()).getName());
}
catch (NotFoundException e)
{
@@ -77,7 +77,7 @@
{
try
{
- CtClass baseType = classPool.get(beanType.getName());
+ CtClass baseType = getClassPool().get(getBeanType().getName());
for (CtConstructor constructor : baseType.getConstructors())
{
int delegateInjectionPosition = getDelegateInjectionPosition(constructor);
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java 2010-05-24 16:45:51 UTC (rev 6300)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/EnterpriseProxyFactory.java 2010-05-24 17:39:47 UTC (rev 6301)
@@ -71,7 +71,7 @@
// Add methods for the EnterpriseBeanInstance interface
try
{
- CtClass enterpriseBeanInstanceInterface = classPool.get(EnterpriseBeanInstance.class.getName());
+ CtClass enterpriseBeanInstanceInterface = getClassPool().get(EnterpriseBeanInstance.class.getName());
proxyClassType.addInterface(enterpriseBeanInstanceInterface);
for (CtMethod method : enterpriseBeanInstanceInterface.getDeclaredMethods())
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-05-24 16:45:51 UTC (rev 6300)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/ProxyFactory.java 2010-05-24 17:39:47 UTC (rev 6301)
@@ -65,11 +65,11 @@
// Default proxy class name suffix
public static final String PROXY_SUFFIX = "Proxy";
- protected final Class<?> beanType;
- protected final ArrayList<Class<?>> additionalInterfaces = new ArrayList<Class<?>>();
- protected final ClassLoader classLoader;
- protected final ProtectionDomain protectionDomain;
- protected final ClassPool classPool;
+ private final Class<?> beanType;
+ private final ArrayList<Class<?>> additionalInterfaces = new ArrayList<Class<?>>();
+ private final ClassLoader classLoader;
+ private final ProtectionDomain protectionDomain;
+ private final ClassPool classPool;
/**
* Creates a new proxy factory from any type of BeanInstance. This bean
@@ -318,7 +318,7 @@
}
/**
- * Adds special serialization code be providing a writeReplace() method on
+ * Adds special serialization code by providing a writeReplace() method on
* the proxy. This method when first called will substitute the proxy
* object with an instance of {@link org.jboss.weld.proxy.util.SerializableProxy}.
* The next call will receive the proxy object itself permitting the substitute
@@ -515,4 +515,14 @@
return bodyString.toString();
}
+ public ClassPool getClassPool()
+ {
+ return classPool;
+ }
+
+ public Class<?> getBeanType()
+ {
+ return beanType;
+ }
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SerializableProxy.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SerializableProxy.java 2010-05-24 16:45:51 UTC (rev 6300)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/proxy/util/SerializableProxy.java 2010-05-24 17:39:47 UTC (rev 6301)
@@ -52,6 +52,7 @@
// The wrapped proxy object not serialized by default actions
private transient Object proxyObject;
+ private transient boolean writeProxy;
public SerializableProxy(Object proxyObject)
{
@@ -75,9 +76,8 @@
private void writeObject(ObjectOutputStream out) throws IOException
{
out.defaultWriteObject();
- // Must use another OO stream since the proxy was replaced in the original
- ObjectOutputStream out2 = new ObjectOutputStream(out);
- out2.writeObject(proxyObject);
+ writeProxy = true;
+ out.writeUnshared(this);
}
/**
@@ -91,8 +91,6 @@
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
{
in.defaultReadObject();
- // Must use another OO stream per writeObject() above
- ObjectInputStream in2 = new ObjectInputStream(in);
Class<?> proxyBeanType = Container.instance().services().get(ProxyServices.class).loadProxySuperClass(proxySuperClassName);
Class<?> proxyClass = null;
if (proxyClassName.endsWith(ProxyFactory.PROXY_SUFFIX))
@@ -106,7 +104,7 @@
}
try
{
- proxyObject = proxyClass.getDeclaredMethod("deserializeProxy", ObjectInputStream.class).invoke(null, in2);
+ proxyObject = proxyClass.getDeclaredMethod("deserializeProxy", ObjectInputStream.class).invoke(null, in);
}
catch (Exception e)
{
@@ -125,6 +123,11 @@
return proxyObject;
}
+ Object writeReplace() throws ObjectStreamException
+ {
+ return writeProxy ? proxyObject : this;
+ }
+
private <T> Class<?> generateClientProxyClass(Class<T> beanType)
{
return new ProxyFactory<T>(beanType).getProxyClass();
Added: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java 2010-05-24 17:39:47 UTC (rev 6301)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat, Inc. and/or its affiliates, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * Licensed 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.jboss.weld.util.collections;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * <p>
+ * A {@link Set} which is backed by a simple array of elements. This provides
+ * all the behaviors of a set backed by an array, thus insert and remove
+ * operations are always O(n) time to check for uniqueness. This should only be
+ * used for sets which are known to be mostly empty or to contain only a handful
+ * of elements.
+ * </p>
+ * <p>
+ * The primary use of this set is for those cases where small sets exists and
+ * will not be changed. The savings in memory is significant compared to hash
+ * sets which may contain many empty buckets.
+ * </p>
+ *
+ * @author David Allen
+ */
+public class ArraySet<E> implements Set<E>
+{
+ // Underlying array of set elements
+ private ArrayList<E> elements;
+
+ public ArraySet(Collection<E> initialElements)
+ {
+ this(initialElements.size());
+ addAll(initialElements);
+ }
+
+ public ArraySet(int size)
+ {
+ elements = new ArrayList<E>(size);
+ }
+
+ public ArraySet()
+ {
+ this(5);
+ }
+
+ public boolean add(E e)
+ {
+ if (contains(e))
+ {
+ return false;
+ }
+ else
+ {
+ elements.add(e);
+ return true;
+ }
+ }
+
+ public boolean addAll(Collection<? extends E> otherCollection)
+ {
+ boolean modified = false;
+ boolean realSet = otherCollection instanceof Set<?>;
+ Iterator<? extends E> setIterator = otherCollection.iterator();
+ while (setIterator.hasNext())
+ {
+ E element = setIterator.next();
+ if (realSet || !contains(element))
+ {
+ elements.add(element);
+ modified = true;
+ }
+ }
+ elements.trimToSize();
+ return modified;
+ }
+
+ public void clear()
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public boolean contains(Object o)
+ {
+ return elements.contains(o);
+ }
+
+ public boolean containsAll(Collection<?> c)
+ {
+ return elements.containsAll(c);
+ }
+
+ public boolean isEmpty()
+ {
+ return elements.isEmpty();
+ }
+
+ public Iterator<E> iterator()
+ {
+ return elements.iterator();
+ }
+
+ public boolean remove(Object o)
+ {
+ return elements.remove(o);
+ }
+
+ public boolean removeAll(Collection<?> c)
+ {
+ return elements.removeAll(c);
+ }
+
+ public boolean retainAll(Collection<?> c)
+ {
+ return elements.retainAll(c);
+ }
+
+ public int size()
+ {
+ return elements.size();
+ }
+
+ public Object[] toArray()
+ {
+ return elements.toArray();
+ }
+
+ public <T> T[] toArray(T[] a)
+ {
+ return elements.toArray(a);
+ }
+
+ // Needed to provide set equals semantics
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj)
+ {
+ return true;
+ }
+ if (obj instanceof Set<?>)
+ {
+ int elementQuantity = size();
+ Object[] otherArray = ((Set<?>) obj).toArray();
+ if (elementQuantity != otherArray.length)
+ {
+ return false;
+ }
+ boolean arraysEqual = true;
+ for (int i = 0; i < elementQuantity; i++)
+ {
+ boolean objFound = false;
+ for (int j = 0; j < otherArray.length; j++)
+ {
+ if (elements.get(i).equals(otherArray[j]))
+ {
+ objFound = true;
+ break;
+ }
+ }
+ if (!objFound)
+ {
+ arraysEqual = false;
+ break;
+ }
+ }
+ return arraysEqual;
+ }
+ return false;
+ }
+
+ @Override
+ public String toString()
+ {
+ return elements.toString();
+ }
+
+}
Property changes on: core/trunk/impl/src/main/java/org/jboss/weld/util/collections/ArraySet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
13 years, 11 months
Weld SVN: r6300 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-24 12:45:51 -0400 (Mon, 24 May 2010)
New Revision: 6300
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java
Log:
CDITCK-156
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java 2010-05-24 16:41:58 UTC (rev 6299)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java 2010-05-24 16:45:51 UTC (rev 6300)
@@ -33,7 +33,7 @@
@Artifact
@IntegrationTest
@Packaging(PackagingType.EAR)
-@SpecVersion(spec="cdi", version="20091101")
+@SpecVersion(spec = "cdi", version = "20091101")
public class ApplicationContextSharedTest extends AbstractJSR299Test
{
@@ -41,21 +41,39 @@
@SpecAssertion(section = "6.7.3", id = "e")
public void testApplicationContextShared() throws Exception
{
+ FMSModelIII.reset();
FMS flightManagementSystem = getInstanceByType(FMS.class);
flightManagementSystem.climb();
+ waitForClimbed();
flightManagementSystem.descend();
- Thread.sleep(350);
+ waitForDescended();
assert flightManagementSystem.isSameBean();
}
-
+
+ private void waitForClimbed() throws Exception
+ {
+ for (int i = 0; !FMSModelIII.isClimbed() && i < 2000; i++)
+ {
+ Thread.sleep(10);
+ }
+ }
+
@Test(groups = { "contexts", "ejb3", "integration" })
@SpecAssertion(section = "6.7.3", id = "dc")
public void testApplicationScopeActiveDuringCallToEjbTimeoutMethod() throws Exception
{
FMS flightManagementSystem = getInstanceByType(FMS.class);
flightManagementSystem.climb();
- Thread.sleep(250);
+ waitForClimbed();
assert flightManagementSystem.isApplicationScopeActive();
}
+ private void waitForDescended() throws Exception
+ {
+ for (int i = 0; !FMSModelIII.isDescended() && i < 2000; i++)
+ {
+ Thread.sleep(10);
+ }
+ }
+
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java 2010-05-24 16:41:58 UTC (rev 6299)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java 2010-05-24 16:45:51 UTC (rev 6300)
@@ -30,6 +30,9 @@
public class FMSModelIII implements FMS
{
private static final long serialVersionUID = 1L;
+
+ private static final String CLIMB_COMMAND = "ClimbCommand";
+ private static final String DESCEND_COMMAND = "DescendCommand";
@Resource
private TimerService timerService;
@@ -44,46 +47,30 @@
private static volatile double beanId = 0.0d;
private static volatile boolean sameBean = false;
- private static volatile int climbState;
- private static volatile int descendState;
+ private static boolean climbed;
+ private static boolean descended;
public void climb() throws Exception
{
- climbState = 0;
- timerService.createTimer(200, "Climb command timeout");
- long timestamp = System.currentTimeMillis();
- // Wait for the timer
- while (climbState == 0)
- {
- // but don't wait more than 10s so we don't just hang!
- if (System.currentTimeMillis() > timestamp + 10000)
- {
- return;
- }
- Thread.sleep(1);
- }
+ timerService.createTimer(200, CLIMB_COMMAND);
}
public void descend() throws Exception
{
- descendState = 0;
- timerService.createTimer(100, "Descend command timeout");
- long timestamp = System.currentTimeMillis();
- // Wait for the timer
- while (descendState == 0)
- {
- // but don't wait more than 10s so we don't just hang!
- if (System.currentTimeMillis() > timestamp + 10000)
- {
- return;
- }
- Thread.sleep(1);
- }
+ timerService.createTimer(100, DESCEND_COMMAND);
}
@Timeout
public void timeout(Timer timer)
{
+ if (timer.getInfo().equals(CLIMB_COMMAND))
+ {
+ climbed = true;
+ }
+ if (timer.getInfo().equals(DESCEND_COMMAND))
+ {
+ descended = true;
+ }
if (beanManager.getContext(ApplicationScoped.class).isActive())
{
applicationScopeActive = true;
@@ -99,8 +86,6 @@
beanId = simpleApplicationBeanInstance.get().getId();
}
}
- climbState = 1;
- descendState = 1;
}
public boolean isApplicationScopeActive()
@@ -112,5 +97,24 @@
{
return sameBean;
}
+
+ public static boolean isClimbed()
+ {
+ return climbed;
+ }
+
+ public static boolean isDescended()
+ {
+ return descended;
+ }
+
+ public static void reset()
+ {
+ beanId = 0.0d;
+ climbed = false;
+ descended = false;
+ applicationScopeActive = false;
+ sameBean = false;
+ }
}
13 years, 11 months
Weld SVN: r6299 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-24 12:41:58 -0400 (Mon, 24 May 2010)
New Revision: 6299
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
Log:
CDITCK-155, CDITCK-157
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java 2010-05-24 16:39:04 UTC (rev 6298)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java 2010-05-24 16:41:58 UTC (rev 6299)
@@ -45,11 +45,20 @@
@SpecAssertion(section = "6.7.1", id = "gc")
public void testRequestScopeActiveDuringCallToEjbTimeoutMethod() throws Exception
{
+ FMSModelIII.reset();
FMS flightManagementSystem = getInstanceByType(FMS.class);
flightManagementSystem.climb();
- Thread.sleep(250);
+ waitForClimbed();
assert flightManagementSystem.isRequestScopeActive();
}
+
+ private void waitForClimbed() throws Exception
+ {
+ for (int i = 0; !FMSModelIII.isClimbed() && i < 2000; i++)
+ {
+ Thread.sleep(10);
+ }
+ }
/**
* The request context is destroyed after the remote method invocation,
@@ -59,12 +68,22 @@
@SpecAssertion(section = "6.7.1", id = "hc")
public void testRequestScopeDestroyedAfterCallToEjbTimeoutMethod() throws Exception
{
+ FMSModelIII.reset();
FMS flightManagementSystem = getInstanceByType(FMS.class);
flightManagementSystem.climb();
+ waitForClimbed();
flightManagementSystem.descend();
- Thread.sleep(250);
+ waitForDescended();
assert !flightManagementSystem.isSameBean();
assert SimpleRequestBean.isBeanDestroyed();
}
+
+ private void waitForDescended() throws Exception
+ {
+ for (int i = 0; !FMSModelIII.isDescended() && i < 2000; i++)
+ {
+ Thread.sleep(10);
+ }
+ }
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java 2010-05-24 16:39:04 UTC (rev 6298)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java 2010-05-24 16:41:58 UTC (rev 6299)
@@ -21,17 +21,12 @@
@Local
public interface FMS
{
- public void turnLeft();
- public void turnRight();
-
public void climb();
public void descend();
public boolean isRequestScopeActive();
-
- public void setRequestScopeActive(boolean requestScopeActive);
public boolean isSameBean();
}
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java 2010-05-24 16:39:04 UTC (rev 6298)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java 2010-05-24 16:41:58 UTC (rev 6299)
@@ -22,6 +22,7 @@
import javax.ejb.Timer;
import javax.ejb.TimerService;
import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
@@ -29,53 +30,59 @@
public class FMSModelIII implements FMS
{
private static final long serialVersionUID = 1L;
+
+ private static final String CLIMB_COMMAND = "ClimbCommand";
+ private static final String DESCEND_COMMAND = "DescendCommand";
@Resource
private TimerService timerService;
@Inject
private BeanManager beanManager;
+
+ @Inject Instance<SimpleRequestBean> simpleRequestBean;
- private static boolean requestScopeActive = false;
- private static double beanId = 0.0d;
- private static boolean sameBean = false;
+ private static volatile boolean requestScopeActive = false;
+ private static volatile double beanId = 0.0d;
+ private static volatile boolean sameBean = false;
+
+ private static volatile boolean climbed;
+ private static volatile boolean descended;
public void climb()
{
- timerService.createTimer(200, "Climb command timeout");
+ timerService.createTimer(200, CLIMB_COMMAND);
}
public void descend()
{
- timerService.createTimer(100, "Descend command timeout");
- beanId = 0.0d;
- sameBean = false;
+ timerService.createTimer(100, DESCEND_COMMAND);
}
- public void turnLeft()
- {
- }
-
- public void turnRight()
- {
- }
-
@Timeout
public void timeout(Timer timer)
{
+ if (timer.getInfo().equals(CLIMB_COMMAND))
+ {
+ climbed = true;
+ }
+ if (timer.getInfo().equals(DESCEND_COMMAND))
+ {
+ descended = true;
+ }
if (beanManager.getContext(RequestScoped.class).isActive())
{
requestScopeActive = true;
if (beanId > 0.0)
{
- if (beanId == org.jboss.jsr299.tck.impl.OldSPIBridge.getInstanceByType(beanManager,SimpleRequestBean.class).getId())
+ if (beanId == simpleRequestBean.get().getId())
{
sameBean = true;
}
}
else
{
- beanId = org.jboss.jsr299.tck.impl.OldSPIBridge.getInstanceByType(beanManager,SimpleRequestBean.class).getId();
+ beanId = simpleRequestBean.get().getId();
}
}
}
@@ -84,15 +91,29 @@
{
return requestScopeActive;
}
-
- public void setRequestScopeActive(boolean requestScopeActive)
+
+ public static void reset()
{
- FMSModelIII.requestScopeActive = requestScopeActive;
+ beanId = 0.0d;
+ climbed = false;
+ descended = false;
+ requestScopeActive = false;
+ sameBean = false;
}
public boolean isSameBean()
{
return sameBean;
}
+
+ public static boolean isClimbed()
+ {
+ return climbed;
+ }
+
+ public static boolean isDescended()
+ {
+ return descended;
+ }
}
13 years, 11 months
Weld SVN: r6298 - cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-24 12:39:04 -0400 (Mon, 24 May 2010)
New Revision: 6298
Modified:
cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution/DecoratorResolutionTest.java
Log:
CDITCK-139
Modified: cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution/DecoratorResolutionTest.java
===================================================================
--- cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution/DecoratorResolutionTest.java 2010-05-24 16:37:53 UTC (rev 6297)
+++ cdi-tck/trunk/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution/DecoratorResolutionTest.java 2010-05-24 16:39:04 UTC (rev 6298)
@@ -41,7 +41,7 @@
@Artifact
@BeansXml("beans.xml")
@SpecVersion(spec="cdi", version="20091101")
-public class DecoratorResolutionTest<T, C extends Cow> extends AbstractJSR299Test
+public class DecoratorResolutionTest<T, C extends Cow, F extends FresianCow> extends AbstractJSR299Test
{
private final TypeLiteral<Bar<T>> BAR_TYPE_VARIABLE_LITERAL = new TypeLiteral<Bar<T>>() {};
@@ -52,7 +52,7 @@
private final TypeLiteral<Qux<List<String>>> QUX_STRING_LIST_LITERAL = new TypeLiteral<Qux<List<String>>>() {};
private final TypeLiteral<Grault<Integer>> GRAULT_INTEGER_LITERAL = new TypeLiteral<Grault<Integer>>() {};
private final TypeLiteral<Corge<C, C>> CORGE_TYPE_VARIABLE_EXTENDS_COW_LITERAL = new TypeLiteral<Corge<C, C>>(){};
- private final TypeLiteral<Garply<? extends FresianCow>> GARPLY_EXTENDS_FRESIAN_COW_LITERAL = new TypeLiteral<Garply<? extends FresianCow>>() {};
+ private final TypeLiteral<Garply<F>> GARPLY_EXTENDS_FRESIAN_COW_LITERAL = new TypeLiteral<Garply<F>>() {};
private final TypeLiteral<Garply<Cow>> GARPLY_COW_LITERAL = new TypeLiteral<Garply<Cow>>() {};
private static boolean decoratorCollectionMatches(Collection<Decorator<?>> decorators, Class<?>... types)
13 years, 11 months
Weld SVN: r6297 - cdi-tck/trunk/impl.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-24 12:37:53 -0400 (Mon, 24 May 2010)
New Revision: 6297
Modified:
cdi-tck/trunk/impl/pom.xml
Log:
CDITCK-115
Modified: cdi-tck/trunk/impl/pom.xml
===================================================================
--- cdi-tck/trunk/impl/pom.xml 2010-05-24 16:07:50 UTC (rev 6296)
+++ cdi-tck/trunk/impl/pom.xml 2010-05-24 16:37:53 UTC (rev 6297)
@@ -233,6 +233,11 @@
<type>html</type>
<classifier>coverage-mb</classifier>
</artifact>
+ <artifact>
+ <file>../target/coverage-int.html</file>
+ <type>html</type>
+ <classifier>coverage-int</classifier>
+ </artifact>
</artifacts>
</configuration>
</execution>
13 years, 11 months
Weld SVN: r6296 - cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-24 12:07:50 -0400 (Mon, 24 May 2010)
New Revision: 6296
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java
Log:
CDITCK-156
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java 2010-05-24 16:07:29 UTC (rev 6295)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/ApplicationContextSharedTest.java 2010-05-24 16:07:50 UTC (rev 6296)
@@ -41,21 +41,40 @@
@SpecAssertion(section = "6.7.3", id = "e")
public void testApplicationContextShared() throws Exception
{
+ FMSModelIII.reset();
FMS flightManagementSystem = getInstanceByType(FMS.class);
flightManagementSystem.climb();
+ waitForClimbed();
flightManagementSystem.descend();
- Thread.sleep(250);
+ waitForDescended();
assert flightManagementSystem.isSameBean();
}
+ private void waitForClimbed() throws Exception
+ {
+ for (int i = 0; !FMSModelIII.isClimbed() && i < 2000; i++)
+ {
+ Thread.sleep(10);
+ }
+ }
+
@Test(groups = { "contexts", "ejb3", "integration" })
@SpecAssertion(section = "6.7.3", id = "dc")
public void testApplicationScopeActiveDuringCallToEjbTimeoutMethod() throws Exception
{
+ FMSModelIII.reset();
FMS flightManagementSystem = getInstanceByType(FMS.class);
flightManagementSystem.climb();
- Thread.sleep(250);
+ waitForClimbed();
assert flightManagementSystem.isApplicationScopeActive();
}
+
+ private void waitForDescended() throws Exception
+ {
+ for (int i = 0; !FMSModelIII.isDescended() && i < 2000; i++)
+ {
+ Thread.sleep(10);
+ }
+ }
}
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java 2010-05-24 16:07:29 UTC (rev 6295)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/application/ejb/FMSModelIII.java 2010-05-24 16:07:50 UTC (rev 6296)
@@ -30,6 +30,9 @@
public class FMSModelIII implements FMS
{
private static final long serialVersionUID = 1L;
+
+ private static final String CLIMB_COMMAND = "ClimbCommand";
+ private static final String DESCEND_COMMAND = "DescendCommand";
@Resource
private TimerService timerService;
@@ -44,46 +47,30 @@
private static volatile double beanId = 0.0d;
private static volatile boolean sameBean = false;
- private static volatile int climbState;
- private static volatile int descendState;
+ private static boolean climbed;
+ private static boolean descended;
public void climb() throws Exception
{
- climbState = 0;
- timerService.createTimer(200, "Climb command timeout");
- long timestamp = System.currentTimeMillis();
- // Wait for the timer
- while (climbState == 0)
- {
- // but don't wait more than 10s so we don't just hang!
- if (System.currentTimeMillis() > timestamp + 10000)
- {
- return;
- }
- Thread.sleep(1);
- }
+ timerService.createTimer(200, CLIMB_COMMAND);
}
public void descend() throws Exception
{
- descendState = 0;
- timerService.createTimer(100, "Descend command timeout");
- long timestamp = System.currentTimeMillis();
- // Wait for the timer
- while (descendState == 0)
- {
- // but don't wait more than 10s so we don't just hang!
- if (System.currentTimeMillis() > timestamp + 10000)
- {
- return;
- }
- Thread.sleep(1);
- }
+ timerService.createTimer(100, DESCEND_COMMAND);
}
@Timeout
public void timeout(Timer timer)
{
+ if (timer.getInfo().equals(CLIMB_COMMAND))
+ {
+ climbed = true;
+ }
+ if (timer.getInfo().equals(DESCEND_COMMAND))
+ {
+ descended = true;
+ }
if (beanManager.getContext(ApplicationScoped.class).isActive())
{
applicationScopeActive = true;
@@ -99,8 +86,6 @@
beanId = simpleApplicationBeanInstance.get().getId();
}
}
- climbState = 1;
- descendState = 1;
}
public boolean isApplicationScopeActive()
@@ -112,5 +97,24 @@
{
return sameBean;
}
+
+ public static boolean isClimbed()
+ {
+ return climbed;
+ }
+
+ public static boolean isDescended()
+ {
+ return descended;
+ }
+
+ public static void reset()
+ {
+ beanId = 0.0d;
+ climbed = false;
+ descended = false;
+ applicationScopeActive = false;
+ sameBean = false;
+ }
}
13 years, 11 months
Weld SVN: r6295 - cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-24 12:07:29 -0400 (Mon, 24 May 2010)
New Revision: 6295
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
Log:
CDITCK-155, CDITCK-157
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java 2010-05-24 15:46:59 UTC (rev 6294)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java 2010-05-24 16:07:29 UTC (rev 6295)
@@ -42,12 +42,12 @@
@Inject Instance<SimpleRequestBean> simpleRequestBean;
- private static boolean requestScopeActive = false;
- private static double beanId = 0.0d;
- private static boolean sameBean = false;
+ private static volatile boolean requestScopeActive = false;
+ private static volatile double beanId = 0.0d;
+ private static volatile boolean sameBean = false;
- private static boolean climbed;
- private static boolean descended;
+ private static volatile boolean climbed;
+ private static volatile boolean descended;
public void climb()
{
@@ -57,9 +57,6 @@
public void descend()
{
timerService.createTimer(100, DESCEND_COMMAND);
- // Resets
- beanId = 0.0d;
- sameBean = false;
}
@Timeout
13 years, 11 months
Weld SVN: r6294 - cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-24 11:46:59 -0400 (Mon, 24 May 2010)
New Revision: 6294
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
Log:
CDITCK-155, CDITCK-157
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java 2010-05-24 15:06:33 UTC (rev 6293)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/EJBRequestContextTest.java 2010-05-24 15:46:59 UTC (rev 6294)
@@ -45,11 +45,20 @@
@SpecAssertion(section = "6.7.1", id = "gc")
public void testRequestScopeActiveDuringCallToEjbTimeoutMethod() throws Exception
{
+ FMSModelIII.reset();
FMS flightManagementSystem = getInstanceByType(FMS.class);
flightManagementSystem.climb();
- Thread.sleep(250);
+ waitForClimbed();
assert flightManagementSystem.isRequestScopeActive();
}
+
+ private void waitForClimbed() throws Exception
+ {
+ for (int i = 0; !FMSModelIII.isClimbed() && i < 2000; i++)
+ {
+ Thread.sleep(10);
+ }
+ }
/**
* The request context is destroyed after the remote method invocation,
@@ -59,12 +68,22 @@
@SpecAssertion(section = "6.7.1", id = "hc")
public void testRequestScopeDestroyedAfterCallToEjbTimeoutMethod() throws Exception
{
+ FMSModelIII.reset();
FMS flightManagementSystem = getInstanceByType(FMS.class);
flightManagementSystem.climb();
+ waitForClimbed();
flightManagementSystem.descend();
- Thread.sleep(250);
+ waitForDescended();
assert !flightManagementSystem.isSameBean();
assert SimpleRequestBean.isBeanDestroyed();
}
+
+ private void waitForDescended() throws Exception
+ {
+ for (int i = 0; !FMSModelIII.isDescended() && i < 2000; i++)
+ {
+ Thread.sleep(10);
+ }
+ }
}
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java 2010-05-24 15:06:33 UTC (rev 6293)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMS.java 2010-05-24 15:46:59 UTC (rev 6294)
@@ -21,17 +21,12 @@
@Local
public interface FMS
{
- public void turnLeft();
- public void turnRight();
-
public void climb();
public void descend();
public boolean isRequestScopeActive();
-
- public void setRequestScopeActive(boolean requestScopeActive);
public boolean isSameBean();
}
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java 2010-05-24 15:06:33 UTC (rev 6293)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/context/request/ejb/FMSModelIII.java 2010-05-24 15:46:59 UTC (rev 6294)
@@ -22,6 +22,7 @@
import javax.ejb.Timer;
import javax.ejb.TimerService;
import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Instance;
import javax.enterprise.inject.spi.BeanManager;
import javax.inject.Inject;
@@ -29,53 +30,62 @@
public class FMSModelIII implements FMS
{
private static final long serialVersionUID = 1L;
+
+ private static final String CLIMB_COMMAND = "ClimbCommand";
+ private static final String DESCEND_COMMAND = "DescendCommand";
@Resource
private TimerService timerService;
@Inject
private BeanManager beanManager;
+
+ @Inject Instance<SimpleRequestBean> simpleRequestBean;
private static boolean requestScopeActive = false;
private static double beanId = 0.0d;
private static boolean sameBean = false;
+
+ private static boolean climbed;
+ private static boolean descended;
public void climb()
{
- timerService.createTimer(200, "Climb command timeout");
+ timerService.createTimer(200, CLIMB_COMMAND);
}
public void descend()
{
- timerService.createTimer(100, "Descend command timeout");
+ timerService.createTimer(100, DESCEND_COMMAND);
+ // Resets
beanId = 0.0d;
sameBean = false;
}
- public void turnLeft()
- {
- }
-
- public void turnRight()
- {
- }
-
@Timeout
public void timeout(Timer timer)
{
+ if (timer.getInfo().equals(CLIMB_COMMAND))
+ {
+ climbed = true;
+ }
+ if (timer.getInfo().equals(DESCEND_COMMAND))
+ {
+ descended = true;
+ }
if (beanManager.getContext(RequestScoped.class).isActive())
{
requestScopeActive = true;
if (beanId > 0.0)
{
- if (beanId == org.jboss.jsr299.tck.impl.OldSPIBridge.getInstanceByType(beanManager,SimpleRequestBean.class).getId())
+ if (beanId == simpleRequestBean.get().getId())
{
sameBean = true;
}
}
else
{
- beanId = org.jboss.jsr299.tck.impl.OldSPIBridge.getInstanceByType(beanManager,SimpleRequestBean.class).getId();
+ beanId = simpleRequestBean.get().getId();
}
}
}
@@ -84,15 +94,29 @@
{
return requestScopeActive;
}
-
- public void setRequestScopeActive(boolean requestScopeActive)
+
+ public static void reset()
{
- FMSModelIII.requestScopeActive = requestScopeActive;
+ beanId = 0.0d;
+ climbed = false;
+ descended = false;
+ requestScopeActive = false;
+ sameBean = false;
}
public boolean isSameBean()
{
return sameBean;
}
+
+ public static boolean isClimbed()
+ {
+ return climbed;
+ }
+
+ public static boolean isDescended()
+ {
+ return descended;
+ }
}
13 years, 11 months
Weld SVN: r6293 - cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-05-24 11:06:33 -0400 (Mon, 24 May 2010)
New Revision: 6293
Modified:
cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution/DecoratorResolutionTest.java
Log:
CDITCK-139
Modified: cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution/DecoratorResolutionTest.java
===================================================================
--- cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution/DecoratorResolutionTest.java 2010-05-24 14:49:24 UTC (rev 6292)
+++ cdi-tck/branches/1.0/impl/src/main/java/org/jboss/jsr299/tck/tests/decorators/resolution/DecoratorResolutionTest.java 2010-05-24 15:06:33 UTC (rev 6293)
@@ -41,7 +41,7 @@
@Artifact
@BeansXml("beans.xml")
@SpecVersion(spec="cdi", version="20091101")
-public class DecoratorResolutionTest<T, C extends Cow> extends AbstractJSR299Test
+public class DecoratorResolutionTest<T, C extends Cow, F extends FresianCow> extends AbstractJSR299Test
{
private final TypeLiteral<Bar<T>> BAR_TYPE_VARIABLE_LITERAL = new TypeLiteral<Bar<T>>() {};
@@ -52,7 +52,7 @@
private final TypeLiteral<Qux<List<String>>> QUX_STRING_LIST_LITERAL = new TypeLiteral<Qux<List<String>>>() {};
private final TypeLiteral<Grault<Integer>> GRAULT_INTEGER_LITERAL = new TypeLiteral<Grault<Integer>>() {};
private final TypeLiteral<Corge<C, C>> CORGE_TYPE_VARIABLE_EXTENDS_COW_LITERAL = new TypeLiteral<Corge<C, C>>(){};
- private final TypeLiteral<Garply<? extends FresianCow>> GARPLY_EXTENDS_FRESIAN_COW_LITERAL = new TypeLiteral<Garply<? extends FresianCow>>() {};
+ private final TypeLiteral<Garply<F>> GARPLY_EXTENDS_FRESIAN_COW_LITERAL = new TypeLiteral<Garply<F>>() {};
private final TypeLiteral<Garply<Cow>> GARPLY_COW_LITERAL = new TypeLiteral<Garply<Cow>>() {};
private static boolean decoratorCollectionMatches(Collection<Decorator<?>> decorators, Class<?>... types)
13 years, 11 months