Weld SVN: r6000 - in core/trunk/impl/src/main/java/org/jboss/weld: util and 1 other directory.
by weld-commits@lists.jboss.org
Author: pete.muir(a)jboss.org
Date: 2010-03-04 14:01:22 -0500 (Thu, 04 Mar 2010)
New Revision: 6000
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/CallableMethodHandler.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
Log:
always ignore finalize
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/CallableMethodHandler.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/CallableMethodHandler.java 2010-03-04 15:10:24 UTC (rev 5999)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/builtin/CallableMethodHandler.java 2010-03-04 19:01:22 UTC (rev 6000)
@@ -49,11 +49,6 @@
public Object invoke(Object self, Method proxiedMethod, Method proceed, Object[] args) throws Throwable
{
- // Ignore calls to finalize
- if ("finalize".equals(proxiedMethod.getName()))
- {
- return null;
- }
Object instance = callable.call();
if (instance == null)
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java 2010-03-04 15:10:24 UTC (rev 5999)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java 2010-03-04 19:01:22 UTC (rev 6000)
@@ -21,6 +21,7 @@
import static org.jboss.weld.util.reflection.Reflections.EMPTY_CLASSES;
import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
@@ -28,6 +29,7 @@
import java.util.LinkedHashSet;
import java.util.Set;
+import javassist.util.proxy.MethodFilter;
import javassist.util.proxy.MethodHandler;
import javassist.util.proxy.ProxyFactory;
import javassist.util.proxy.ProxyObject;
@@ -46,6 +48,17 @@
public class Proxies
{
+ private static class IgnoreFinalizeMethodFilter implements MethodFilter
+ {
+
+ public boolean isHandled(Method m)
+ {
+ return m.getName().equals("finalize");
+ }
+
+ }
+
+
public static class TypeInfo
{
@@ -90,6 +103,7 @@
{
ProxyFactory proxyFactory = new ProxyFactory();
ProxyFactory.useCache = false;
+ proxyFactory.setFilter(new IgnoreFinalizeMethodFilter());
Class<?> superClass = getSuperClass();
if(superClass != null && superClass != Object.class)
{
14 years, 1 month
Weld SVN: r5999 - examples/trunk/jsf/pastecode/war/src/main/webapp.
by weld-commits@lists.jboss.org
Author: mgencur(a)redhat.com
Date: 2010-03-04 10:10:24 -0500 (Thu, 04 Mar 2010)
New Revision: 5999
Added:
examples/trunk/jsf/pastecode/war/src/main/webapp/help.xhtml
Modified:
examples/trunk/jsf/pastecode/war/src/main/webapp/template.xhtml
Log:
added help page
Added: examples/trunk/jsf/pastecode/war/src/main/webapp/help.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/war/src/main/webapp/help.xhtml (rev 0)
+++ examples/trunk/jsf/pastecode/war/src/main/webapp/help.xhtml 2010-03-04 15:10:24 UTC (rev 5999)
@@ -0,0 +1,53 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:s="http://jboss.com/products/seam/taglib">
+
+ <ui:composition template="template.xhtml">
+
+ <ui:define name="mainarea">
+ <div style="width: 100%; padding: 7px;">
+ <div id="paging" style="width:98%; border-width:0px; background-color:#C1C1E8;text-align:center;"> <!-- height: 40px; -->
+ <strong>Useful Information</strong>
+ </div>
+ <br/>
+ <strong>Paste Code:</strong><br/>
+ <ul>
+ <li>Enter your nick - This is optional, if it is not entered the code will be listed under "Anonymous" user</li>
+ <li>Choose a language of your code - This way you can define formatting of code after submitting the form</li>
+ <li>Choose if this code is private - When this option is chosen the application will generate a hash value of your code and will provide you with
+ a unique link (something like http://localhost:8080/weld-pastecode/582ad4b5ed409ec8b81c6e33ee8b72377890...). Furthemore your code will not be
+ listed in the right panel and cannot even be found through a search capability. </li>
+ <li>Enter your code and a note you would like to send with the code</li>
+ <li>Submit the form and forward the resulting link</li>
+ </ul>
+
+ <strong>Search Code:</strong><br/>
+ <ul>
+ <li>Go to a history page - Now you can see all the posts with pagination</li>
+ <li>Enter data for searching - You can combine all the data together.</li>
+ </ul>
+
+ <strong>Weld Features Covered:</strong><br/>
+
+ <ul>
+ <li>Injecting into POJO, EJB (SFSB), Servlet</li>
+ <li>Annotations @ApplicationScoped, @Model, @SessionScoped et al.</li>
+ <li>Producer named methods</li>
+ <li>Decorators - This feature is used to log transactions during which a code larger than 65kB is stored to a database</li>
+ </ul>
+ <br/><br/><strong>Enjoy work with WELD !</strong>
+
+ </div>
+ </ui:define>
+
+ <ui:define name="rightmenu">
+ <ui:include src="rightMenuDefault.xhtml"/>
+ </ui:define>
+
+ </ui:composition>
+
+</html>
+
Modified: examples/trunk/jsf/pastecode/war/src/main/webapp/template.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/war/src/main/webapp/template.xhtml 2010-03-04 11:50:57 UTC (rev 5998)
+++ examples/trunk/jsf/pastecode/war/src/main/webapp/template.xhtml 2010-03-04 15:10:24 UTC (rev 5999)
@@ -37,7 +37,7 @@
<td>
<a href="home.jsf" style="text-decoration:none;"><span id="menuitem">New</span></a>
<a href="history.jsf" style="text-decoration:none;"><span id="menuitem">History</span></a>
- <span id="menuitem">Help</span>
+ <a href="help.jsf" style="text-decoration:none;"><span id="menuitem">Help</span></a>
</td>
</tr>
</table>
14 years, 1 month
Weld SVN: r5998 - in core/trunk/impl/src/main: java/org/jboss/weld/logging/messages and 3 other directories.
by weld-commits@lists.jboss.org
Author: nickarls
Date: 2010-03-04 06:50:57 -0500 (Thu, 04 Mar 2010)
New Revision: 5998
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/conversation/ServletConversationManager.java
core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ConversationMessage.java
core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java
core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpSessionManager.java
core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
core/trunk/impl/src/main/resources/org/jboss/weld/messages/conversation_en.properties
Log:
Direct usage of HttpSessionManager
Modified: core/trunk/impl/src/main/java/org/jboss/weld/conversation/ServletConversationManager.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/ServletConversationManager.java 2010-03-04 08:55:17 UTC (rev 5997)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/ServletConversationManager.java 2010-03-04 11:50:57 UTC (rev 5998)
@@ -25,6 +25,7 @@
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.servlet.ConversationBeanStore;
+import org.jboss.weld.servlet.HttpSessionManager;
@SessionScoped
public class ServletConversationManager extends AbstractConversationManager implements Serializable
@@ -38,7 +39,7 @@
private boolean sessionInvalidated;
@Inject
- private HttpSession httpSession;
+ private HttpSessionManager httpSessionManager;
@Produces
@ConversationInactivityTimeout
@@ -64,6 +65,7 @@
@Override
protected BeanStore getBeanStore(String cid)
{
+ HttpSession httpSession = httpSessionManager.getSession();
return ConversationBeanStore.of(httpSession, sessionInvalidated, cid);
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ConversationMessage.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ConversationMessage.java 2010-03-04 08:55:17 UTC (rev 5997)
+++ core/trunk/impl/src/main/java/org/jboss/weld/logging/messages/ConversationMessage.java 2010-03-04 11:50:57 UTC (rev 5998)
@@ -56,6 +56,8 @@
@MessageId("000318") DEMOTED_LRC,
@MessageId("000319") SWITCHED_CONVERSATION,
@MessageId("000214") BEGIN_CALLED_ON_LONG_RUNNING_CONVERSATION,
- @MessageId("000215") END_CALLED_ON_TRANSIENT_CONVERSATION;
+ @MessageId("000215") END_CALLED_ON_TRANSIENT_CONVERSATION,
+ @MessageId("000216") NULL_HTTP_SESSION;
+ ;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java 2010-03-04 08:55:17 UTC (rev 5997)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/ConversationBeanStore.java 2010-03-04 11:50:57 UTC (rev 5998)
@@ -21,7 +21,10 @@
import org.jboss.weld.context.ConversationContext;
import org.jboss.weld.context.api.BeanStore;
import org.jboss.weld.context.beanstore.NamingScheme;
+import org.jboss.weld.exceptions.ForbiddenArgumentException;
+import static org.jboss.weld.logging.messages.ConversationMessage.NULL_HTTP_SESSION;
+
/**
* A HTTP session backed bean store for the conversational scope
*
@@ -33,6 +36,10 @@
protected ConversationBeanStore(HttpSession session, boolean sessionInvalidated, String cid)
{
+ if (session == null)
+ {
+ throw new ForbiddenArgumentException(NULL_HTTP_SESSION);
+ }
this.namingScheme = new NamingScheme(ConversationContext.class.getName() + "[" + cid + "]", "#");
if (sessionInvalidated)
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpSessionManager.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpSessionManager.java 2010-03-04 08:55:17 UTC (rev 5997)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/HttpSessionManager.java 2010-03-04 11:50:57 UTC (rev 5998)
@@ -17,7 +17,6 @@
package org.jboss.weld.servlet;
import javax.enterprise.context.RequestScoped;
-import javax.enterprise.inject.Produces;
import javax.servlet.http.HttpSession;
@RequestScoped
@@ -30,8 +29,6 @@
this.session = session;
}
- @Produces
- @RequestScoped
public HttpSession getSession()
{
return session;
Modified: core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java 2010-03-04 08:55:17 UTC (rev 5997)
+++ core/trunk/impl/src/main/java/org/jboss/weld/util/Proxies.java 2010-03-04 11:50:57 UTC (rev 5998)
@@ -83,9 +83,13 @@
return interfaces.toArray(EMPTY_CLASSES);
}
+ /**
+ * @return
+ */
public ProxyFactory createProxyFactory()
{
ProxyFactory proxyFactory = new ProxyFactory();
+ ProxyFactory.useCache = false;
Class<?> superClass = getSuperClass();
if(superClass != null && superClass != Object.class)
{
Modified: core/trunk/impl/src/main/resources/org/jboss/weld/messages/conversation_en.properties
===================================================================
--- core/trunk/impl/src/main/resources/org/jboss/weld/messages/conversation_en.properties 2010-03-04 08:55:17 UTC (rev 5997)
+++ core/trunk/impl/src/main/resources/org/jboss/weld/messages/conversation_en.properties 2010-03-04 11:50:57 UTC (rev 5998)
@@ -20,3 +20,4 @@
SWITCHED_CONVERSATION=Switched conversation from {0} to {1}
BEGIN_CALLED_ON_LONG_RUNNING_CONVERSATION=Attempt to call begin() on a long-running conversation
END_CALLED_ON_TRANSIENT_CONVERSATION=Attempt to call end() on a transient conversation
+NULL_HTTP_SESSION=Cannot create ConversationBeanStore with a null HTTP session
14 years, 1 month
Weld SVN: r5997 - core/trunk/impl/src/main/java/org/jboss/weld/bean.
by weld-commits@lists.jboss.org
Author: nickarls
Date: 2010-03-04 03:55:17 -0500 (Thu, 04 Mar 2010)
New Revision: 5997
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java
core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
Log:
More informative toString() for producers
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java 2010-03-04 08:34:37 UTC (rev 5996)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerField.java 2010-03-04 08:55:17 UTC (rev 5997)
@@ -131,6 +131,12 @@
return field.get(InterceptionUtils.getRawInstance(getReceiver(creationalContext)));
}
+ @Override
+ public String toString()
+ {
+ return field.toString();
+ }
+
});
checkProducerField();
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java 2010-03-04 08:34:37 UTC (rev 5996)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/ProducerMethod.java 2010-03-04 08:55:17 UTC (rev 5997)
@@ -148,8 +148,12 @@
}
}
+ @Override
+ public String toString()
+ {
+ return method.toString();
+ }
-
});
}
}
14 years, 1 month
Weld SVN: r5996 - in core/trunk/impl/src/main/java/org/jboss/weld: servlet and 1 other directory.
by weld-commits@lists.jboss.org
Author: nickarls
Date: 2010-03-04 03:34:37 -0500 (Thu, 04 Mar 2010)
New Revision: 5996
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java
core/trunk/impl/src/main/java/org/jboss/weld/servlet/ServletLifecycle.java
Log:
Lifecycle changes for ending of request/session/conversation when invalidating session
Forced session creation (for HttpSessionManager null product prevention)
Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java 2010-03-04 04:23:13 UTC (rev 5995)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java 2010-03-04 08:34:37 UTC (rev 5996)
@@ -22,7 +22,6 @@
*/
package org.jboss.weld.context;
-import static org.jboss.weld.jsf.JsfHelper.getServletContext;
import static org.jboss.weld.logging.Category.CONTEXT;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
import static org.jboss.weld.logging.messages.ContextMessage.APPLICATION_ENDED;
@@ -31,10 +30,7 @@
import static org.jboss.weld.logging.messages.ContextMessage.REQUEST_STARTED;
import static org.jboss.weld.logging.messages.ContextMessage.SESSION_ENDED;
import static org.jboss.weld.logging.messages.ContextMessage.SESSION_RESTORED;
-import static org.jboss.weld.servlet.BeanProvider.conversationManager;
-import javax.faces.context.FacesContext;
-
import org.jboss.weld.bootstrap.api.Lifecycle;
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.context.api.BeanStore;
@@ -81,7 +77,6 @@
{
log.trace(SESSION_ENDED, id);
teardownContext(sessionContext);
- conversationManager(getServletContext(FacesContext.getCurrentInstance())).teardownContext();
}
public void beginRequest(String id, BeanStore requestBeanStore)
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/ServletLifecycle.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/ServletLifecycle.java 2010-03-04 04:23:13 UTC (rev 5995)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/ServletLifecycle.java 2010-03-04 08:34:37 UTC (rev 5996)
@@ -22,10 +22,12 @@
*/
package org.jboss.weld.servlet;
+import static org.jboss.weld.jsf.JsfHelper.getServletContext;
import static org.jboss.weld.logging.messages.ServletMessage.REQUEST_SCOPE_BEAN_STORE_MISSING;
import static org.jboss.weld.servlet.BeanProvider.conversationManager;
import static org.jboss.weld.servlet.BeanProvider.httpSessionManager;
+import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@@ -93,11 +95,9 @@
// at the end of the request.
beanStore.invalidate();
conversationManager.invalidateSession();
- conversationManager.destroyAllConversations();
}
else
{
- conversationManager.destroyAllConversations();
lifecycle.endSession(session.getId(), beanStore);
}
}
@@ -113,7 +113,6 @@
lifecycle.beginRequest("endSession-" + session.getId(), mockRequest);
BeanStore sessionBeanStore = restoreSessionContext(session);
- conversationManager.destroyAllConversations();
lifecycle.endSession(session.getId(), sessionBeanStore);
lifecycle.endRequest("endSession-" + session.getId(), mockRequest);
}
@@ -130,7 +129,7 @@
protected BeanStore restoreSessionContext(HttpServletRequest request)
{
HttpPassThruSessionBeanStore sessionBeanStore = new HttpPassThruOnDemandSessionBeanStore(request);
- HttpSession session = request.getSession(false);
+ HttpSession session = request.getSession(true);
lifecycle.restoreSession(session == null ? "Inactive session" : session.getId(), sessionBeanStore);
if (session != null)
{
@@ -174,6 +173,14 @@
{
if (request.getAttribute(REQUEST_ATTRIBUTE_NAME) != null)
{
+ HttpPassThruSessionBeanStore sessionBeanStore = (HttpPassThruSessionBeanStore) lifecycle.getSessionContext().getBeanStore();
+ if ((sessionBeanStore != null) && (sessionBeanStore.isInvalidated()))
+ {
+ conversationManager(request.getSession().getServletContext()).teardownContext();
+ lifecycle.endSession(request.getRequestedSessionId(), sessionBeanStore);
+ }
+ lifecycle.getSessionContext().setActive(false);
+ lifecycle.getSessionContext().setBeanStore(null);
BeanStore beanStore = (BeanStore) request.getAttribute(REQUEST_ATTRIBUTE_NAME);
if (beanStore == null)
{
@@ -181,13 +188,6 @@
}
lifecycle.endRequest(request.getRequestURI(), beanStore);
request.removeAttribute(REQUEST_ATTRIBUTE_NAME);
- HttpPassThruSessionBeanStore sessionBeanStore = (HttpPassThruSessionBeanStore) lifecycle.getSessionContext().getBeanStore();
- if ((sessionBeanStore != null) && (sessionBeanStore.isInvalidated()))
- {
- lifecycle.endSession(request.getRequestedSessionId(), sessionBeanStore);
- }
- lifecycle.getSessionContext().setActive(false);
- lifecycle.getSessionContext().setBeanStore(null);
}
}
14 years, 1 month
Weld SVN: r5995 - in core/trunk: impl/src/main/java/org/jboss/weld/bootstrap and 4 other directories.
by weld-commits@lists.jboss.org
Author: swd847
Date: 2010-03-03 23:23:13 -0500 (Wed, 03 Mar 2010)
New Revision: 5995
Added:
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeEjbExtension.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeSessionBeanTest.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/BigLathe.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/ConveyorShaft.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Lathe.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/LatheLocal.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Shaft.java
core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/SmallLathe.java
core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/ejb/
core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/ejb/javax.enterprise.inject.spi.Extension
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java
core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployer.java
Log:
WELD-460 this also fixed adding multiple ejb's with the same java type through BeforeBeanDiscovery.addAnnotatedType()
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java 2010-03-03 21:49:14 UTC (rev 5994)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bean/SessionBean.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -72,6 +72,7 @@
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.resources.ClassTransformer;
import org.jboss.weld.serialization.spi.helpers.SerializableContextual;
+import org.jboss.weld.util.AnnotatedTypes;
import org.jboss.weld.util.Beans;
import org.jboss.weld.util.Proxies;
import org.jboss.weld.util.Proxies.TypeInfo;
@@ -106,13 +107,39 @@
public static <T> SessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl beanManager)
{
WeldClass<T> type = beanManager.getServices().get(ClassTransformer.class).loadClass(ejbDescriptor.getBeanClass());
- return new SessionBean<T>(type, ejbDescriptor, createId(SessionBean.class.getSimpleName(), ejbDescriptor) , beanManager);
+ return new SessionBean<T>(type, ejbDescriptor, createId(SessionBean.class.getSimpleName(), ejbDescriptor, type), beanManager);
}
+ /**
+ * Creates a simple, annotation defined Enterprise Web Bean using the annotations specified on type
+ *
+ * @param <T> The type
+ * @param clazz The class
+ * @param beanManager the current manager
+ * @param type the AnnotatedType to use
+ * @return An Enterprise Web Bean
+ */
+ public static <T> SessionBean<T> of(InternalEjbDescriptor<T> ejbDescriptor, BeanManagerImpl beanManager, WeldClass<T> type)
+ {
+ return new SessionBean<T>(type, ejbDescriptor, createId(SessionBean.class.getSimpleName(), ejbDescriptor, type), beanManager);
+ }
+
protected static String createId(String beanType, InternalEjbDescriptor<?> ejbDescriptor)
{
return new StringBuilder().append(beanType).append(BEAN_ID_SEPARATOR).append(ejbDescriptor.getEjbName()).toString();
}
+
+ protected static String createId(String beanType, InternalEjbDescriptor<?> ejbDescriptor, WeldClass<?> type)
+ {
+ if (type.isDiscovered())
+ {
+ return createId(beanType, ejbDescriptor);
+ }
+ else
+ {
+ return new StringBuilder().append(beanType).append(BEAN_ID_SEPARATOR).append(ejbDescriptor.getEjbName()).append(AnnotatedTypes.createTypeId(type)).toString();
+ }
+ }
/**
* Constructor
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java 2010-03-03 21:49:14 UTC (rev 5994)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/AbstractBeanDeployer.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -265,6 +265,15 @@
return bean;
}
+ protected <T> SessionBean<T> createSessionBean(InternalEjbDescriptor<T> ejbDescriptor, WeldClass<T> weldClass)
+ {
+ // TODO Don't create enterprise bean if it has no local interfaces!
+ SessionBean<T> bean = SessionBean.of(ejbDescriptor, manager, weldClass);
+ getEnvironment().addSessionBean(bean);
+ createObserversProducersDisposers(bean);
+ return bean;
+ }
+
protected <T> void createNewSessionBean(InternalEjbDescriptor<T> ejbDescriptor)
{
getEnvironment().addSessionBean(NewSessionBean.of(ejbDescriptor, manager));
Modified: core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployer.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployer.java 2010-03-03 21:49:14 UTC (rev 5994)
+++ core/trunk/impl/src/main/java/org/jboss/weld/bootstrap/BeanDeployer.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -34,6 +34,9 @@
import org.jboss.weld.manager.BeanManagerImpl;
import org.jboss.weld.resources.ClassTransformer;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+
/**
* @author pmuir
*
@@ -92,6 +95,7 @@
public BeanDeployer createBeans()
{
+ Multimap<Class<?>, WeldClass<?>> otherWeldClasses = HashMultimap.create();
for (WeldClass<?> clazz : classes)
{
boolean managedBeanOrDecorator = !getEnvironment().getEjbDescriptors().contains(clazz.getJavaClass()) && isTypeManagedBeanOrDecoratorOrInterceptor(clazz);
@@ -109,12 +113,26 @@
{
createManagedBean(clazz);
}
+ else
+ {
+ otherWeldClasses.put(clazz.getJavaClass(), clazz);
+ }
}
for (InternalEjbDescriptor<?> ejbDescriptor : getEnvironment().getEjbDescriptors())
{
if (ejbDescriptor.isSingleton() || ejbDescriptor.isStateful() || ejbDescriptor.isStateless())
{
- createSessionBean(ejbDescriptor);
+ if (otherWeldClasses.containsKey(ejbDescriptor.getBeanClass()))
+ {
+ for (WeldClass<?> c : otherWeldClasses.get(ejbDescriptor.getBeanClass()))
+ {
+ createSessionBean(ejbDescriptor, (WeldClass) c);
+ }
+ }
+ else
+ {
+ createSessionBean(ejbDescriptor);
+ }
}
}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeEjbExtension.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeEjbExtension.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeEjbExtension.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.tests.extensions.annotatedType.ejb;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Produces;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.util.AnnotationLiteral;
+
+import org.jboss.weld.tests.util.annotated.TestAnnotatedTypeBuilder;
+
+public class AnnotatedTypeEjbExtension implements Extension
+{
+ /**
+ * Adds two ejb beans
+ */
+ public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery beforeBeanDiscovery)
+ {
+ TestAnnotatedTypeBuilder<Lathe> builder = new TestAnnotatedTypeBuilder<Lathe>(Lathe.class);
+ builder.addToClass(new AnnotationLiteral<SmallLathe>() { });
+ beforeBeanDiscovery.addAnnotatedType(builder.create());
+ builder = new TestAnnotatedTypeBuilder<Lathe>(Lathe.class);
+ builder.addToClass(new AnnotationLiteral<BigLathe>() { });
+ beforeBeanDiscovery.addAnnotatedType(builder.create());
+ }
+ /**
+ * Adds annotations to an EJB
+ */
+ public void overrideLatheAnnotations(@Observes ProcessAnnotatedType<Lathe> event) throws SecurityException, NoSuchMethodException
+ {
+ TestAnnotatedTypeBuilder<Lathe> builder = new TestAnnotatedTypeBuilder<Lathe>(Lathe.class);
+ for(Annotation a : event.getAnnotatedType().getAnnotations())
+ {
+ builder.addToClass(a);
+ }
+ Method method = Lathe.class.getMethod("doWork");
+ builder.addToMethod(method, new AnnotationLiteral<ConveyorShaft>() {});
+ builder.addToMethod(method, new AnnotationLiteral<Produces>() {});
+ event.setAnnotatedType(builder.create());
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeSessionBeanTest.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeSessionBeanTest.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/AnnotatedTypeSessionBeanTest.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.tests.extensions.annotatedType.ejb;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+import org.jboss.testharness.impl.packaging.Artifact;
+import org.jboss.testharness.impl.packaging.Classes;
+import org.jboss.testharness.impl.packaging.IntegrationTest;
+import org.jboss.testharness.impl.packaging.Packaging;
+import org.jboss.testharness.impl.packaging.PackagingType;
+import org.jboss.testharness.impl.packaging.jsr299.Extension;
+import org.jboss.weld.test.AbstractWeldTest;
+import org.testng.annotations.Test;
+/**
+ * Tests that it is possible to override ejb annotations through the SPI
+ * @author Stuart Douglas <stuart(a)baileyroberts.com.au>
+ *
+ */
+@Artifact
+(a)Packaging(PackagingType.EAR)
+@IntegrationTest
+@Extension("javax.enterprise.inject.spi.Extension")
+@Classes(packages = { "org.jboss.weld.tests.util.annotated" })
+public class AnnotatedTypeSessionBeanTest extends AbstractWeldTest
+{
+ @Test
+ public void testOverridingEjbAnnotations()
+ {
+ Shaft conveyerShaft = getReference(Shaft.class, new AnnotationLiteral<ConveyorShaft>() { });
+ assert conveyerShaft != null;
+ }
+
+ @Test
+ public void testAddingBultipleBeansPerEjbClass()
+ {
+ LatheLocal bigLathe = getReference(LatheLocal.class, new AnnotationLiteral<BigLathe>() { });
+ assert bigLathe != null;
+ LatheLocal smallLathe = getReference(LatheLocal.class, new AnnotationLiteral<SmallLathe>() { });
+ assert smallLathe != null;
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/BigLathe.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/BigLathe.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/BigLathe.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.tests.extensions.annotatedType.ejb;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface BigLathe
+{
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/ConveyorShaft.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/ConveyorShaft.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/ConveyorShaft.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.tests.extensions.annotatedType.ejb;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface ConveyorShaft
+{
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Lathe.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Lathe.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Lathe.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -0,0 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.tests.extensions.annotatedType.ejb;
+
+import javax.ejb.Stateless;
+
+@Stateless
+public class Lathe implements LatheLocal
+{
+ public Shaft doWork()
+ {
+ return new Shaft();
+ }
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/LatheLocal.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/LatheLocal.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/LatheLocal.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -0,0 +1,27 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.tests.extensions.annotatedType.ejb;
+
+import javax.ejb.Local;
+
+@Local
+public interface LatheLocal
+{
+
+ public Shaft doWork();
+
+}
\ No newline at end of file
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Shaft.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Shaft.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/Shaft.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -0,0 +1,22 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.tests.extensions.annotatedType.ejb;
+
+public class Shaft
+{
+
+}
Added: core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/SmallLathe.java
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/SmallLathe.java (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/tests/extensions/annotatedType/ejb/SmallLathe.java 2010-03-04 04:23:13 UTC (rev 5995)
@@ -0,0 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.tests.extensions.annotatedType.ejb;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+import javax.inject.Qualifier;
+
+@Qualifier
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface SmallLathe
+{
+
+}
Added: core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/ejb/javax.enterprise.inject.spi.Extension
===================================================================
--- core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/ejb/javax.enterprise.inject.spi.Extension (rev 0)
+++ core/trunk/tests/src/test/resources/org/jboss/weld/tests/extensions/annotatedType/ejb/javax.enterprise.inject.spi.Extension 2010-03-04 04:23:13 UTC (rev 5995)
@@ -0,0 +1 @@
+org.jboss.weld.tests.extensions.annotatedType.ejb.AnnotatedTypeEjbExtension
\ No newline at end of file
14 years, 1 month
Weld SVN: r5994 - in extensions/trunk/genericbeans/src: test/java/org/jboss/weld/extensions/genericbeans/test and 1 other directory.
by weld-commits@lists.jboss.org
Author: swd847
Date: 2010-03-03 16:49:14 -0500 (Wed, 03 Mar 2010)
New Revision: 5994
Added:
extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericConstructorArgument.java
extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/NormalBean.java
Modified:
extensions/trunk/genericbeans/src/main/java/org/jboss/weld/extensions/genericbeans/FieldSetter.java
extensions/trunk/genericbeans/src/main/java/org/jboss/weld/extensions/genericbeans/GenericExtension.java
extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericBeanTest.java
extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericMain.java
extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericProducer.java
extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/InjectedBean.java
Log:
removed the @InjectGeneric annotation
Modified: extensions/trunk/genericbeans/src/main/java/org/jboss/weld/extensions/genericbeans/FieldSetter.java
===================================================================
--- extensions/trunk/genericbeans/src/main/java/org/jboss/weld/extensions/genericbeans/FieldSetter.java 2010-03-03 18:47:14 UTC (rev 5993)
+++ extensions/trunk/genericbeans/src/main/java/org/jboss/weld/extensions/genericbeans/FieldSetter.java 2010-03-03 21:49:14 UTC (rev 5994)
@@ -32,7 +32,7 @@
Set<Bean<?>> beans = beanManager.getBeans(field.getType(), qualifier);
if (beans.size() == 0)
{
- throw new RuntimeException("Could not resolve bean for Generic Producer field " + field.getDeclaringClass() + "." + field.getName());
+ throw new RuntimeException("Could not resolve bean for Generic Producer field " + field.getDeclaringClass() + "." + field.getName() + " Type: " + field.getType() + " Qualifiers:" + qualifier);
}
if (beans.size() > 1)
{
Modified: extensions/trunk/genericbeans/src/main/java/org/jboss/weld/extensions/genericbeans/GenericExtension.java
===================================================================
--- extensions/trunk/genericbeans/src/main/java/org/jboss/weld/extensions/genericbeans/GenericExtension.java 2010-03-03 18:47:14 UTC (rev 5993)
+++ extensions/trunk/genericbeans/src/main/java/org/jboss/weld/extensions/genericbeans/GenericExtension.java 2010-03-03 21:49:14 UTC (rev 5994)
@@ -13,10 +13,12 @@
import javax.enterprise.event.Observes;
import javax.enterprise.inject.Produces;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
import javax.enterprise.inject.spi.AnnotatedField;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedParameter;
import javax.enterprise.inject.spi.AnnotatedType;
+import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
@@ -70,11 +72,11 @@
genericBeans.put(an.value(), new HashSet<AnnotatedType<?>>());
}
genericBeans.get(an.value()).add(type);
- // we will install this bean later
+ // we will install (multiple copies of) this bean later
event.veto();
}
-
+ //make note of any producer fields that produce generic beans
for (Object f : type.getFields())
{
AnnotatedField<?> field = (AnnotatedField<?>) f;
@@ -100,6 +102,9 @@
}
}
+ /**
+ * wraps InjectionTarget to initialise producer fields that produce generic beans
+ */
public <T> void processInjectionTarget(@Observes ProcessInjectionTarget<T> event, BeanManager beanManager)
{
Class javaClass = event.getAnnotatedType().getJavaClass();
@@ -118,6 +123,9 @@
}
}
+ /**
+ * Installs the generic beans.
+ */
public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager beanManager)
{
for (Entry<Class<?>, Set<AnnotatedType<?>>> i : genericBeans.entrySet())
@@ -136,13 +144,9 @@
for (AnnotatedField<?> f : rt.getFields())
{
ReannotatedField<?> field = (ReannotatedField<?>) f;
- if (field.isAnnotationPresent(InjectGeneric.class))
+
+ if (field.isAnnotationPresent(Inject.class))
{
- field.define(newQualifier);
- field.define(new InjectLiteral());
- }
- else if (field.isAnnotationPresent(Inject.class))
- {
//if this is a configuration injection point
if (conc.annotationType().isAssignableFrom(field.getJavaMember().getType()))
{
@@ -151,20 +155,69 @@
{
});
}
+ else
+ {
+ //check to see if we should be injecting a generic bean
+ //we do this by checking if there are any beans that can be injected into this point
+ //if there is not then we assume it is a generic injection point
+ //this has the downside that if it is actually a deployment error then it will confuse the user
+ Annotation[] qls = getQualifiers(field.getAnnotations(), beanManager);
+ Set<Bean<?>> beans = beanManager.getBeans(field.getJavaMember().getType(), qls);
+ if (beans.isEmpty())
+ {
+ field.define(newQualifier);
+ }
+ }
}
+ else if (field.isAnnotationPresent(Produces.class))
+ {
+ //TODO: register a producer with the appropriate qualifier
+ }
}
for (AnnotatedMethod<?> m : rt.getMethods())
{
- for (AnnotatedParameter<?> a : m.getParameters())
+ //TODO: need to properly handle Observer methods and Disposal methods
+ if (m.isAnnotationPresent(Produces.class))
{
- ReannotatedParameter<?> param = (ReannotatedParameter<?>) a;
- if (param.isAnnotationPresent(InjectGeneric.class))
+ //TODO: we need to register the producer bean, so this is not very useful at the moment
+ for (AnnotatedParameter<?> pm : m.getParameters())
{
- param.define(newQualifier);
- param.define(new InjectLiteral());
+ ReannotatedParameter<?> param = (ReannotatedParameter<?>) pm;
+
+ Class paramType = m.getJavaMember().getParameterTypes()[param.getPosition()];
+
+ //check to see if we should be injecting a generic bean
+ //we do this by checking if there are any beans that can be injected into this point
+ //if there is not then we assume it is a generic injection point
+ //this has the downside that if it is actually a deployment error then it will confuse the user
+ Annotation[] qls = getQualifiers(param.getAnnotations(), beanManager);
+ Set<Bean<?>> beans = beanManager.getBeans(paramType, qls);
+ if (beans.isEmpty())
+ {
+ param.define(newQualifier);
+ }
}
}
}
+
+ for (AnnotatedConstructor<?> m : rt.getConstructors())
+ {
+ if (m.isAnnotationPresent(Inject.class))
+ {
+ for (AnnotatedParameter<?> pm : m.getParameters())
+ {
+ ReannotatedParameter<?> param = (ReannotatedParameter<?>) pm;
+
+ Class paramType = m.getJavaMember().getParameterTypes()[param.getPosition()];
+ Annotation[] qls = getQualifiers(param.getAnnotations(), beanManager);
+ Set<Bean<?>> beans = beanManager.getBeans(paramType, qls);
+ if (beans.isEmpty())
+ {
+ param.define(newQualifier);
+ }
+ }
+ }
+ }
InjectionTarget<?> it = beanManager.createInjectionTarget(rt);
it = new GenericBeanInjectionTargetWrapper(rt, it, conc);
@@ -188,4 +241,22 @@
return qualifierMap.get(a);
}
+ static Annotation[] getQualifiers(Set<Annotation> annotations, BeanManager manager)
+ {
+ List<Annotation> qualifiers = new ArrayList<Annotation>();
+ for (Annotation a : annotations)
+ {
+ if (manager.isQualifier(a.annotationType()))
+ {
+ qualifiers.add(a);
+ }
+ }
+ Annotation[] qls = new Annotation[qualifiers.size()];
+ for (int j = 0; j < qls.length; ++j)
+ {
+ qls[j] = qualifiers.get(j);
+ }
+ return qls;
+ }
+
}
Modified: extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericBeanTest.java
===================================================================
--- extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericBeanTest.java 2010-03-03 18:47:14 UTC (rev 5993)
+++ extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericBeanTest.java 2010-03-03 21:49:14 UTC (rev 5994)
@@ -7,11 +7,12 @@
@Test
public void testGeneric()
{
+ //TODO: This needs to be split up into lots of little tests
InjectedBean bean = getReference(InjectedBean.class);
assert bean.main1.getValue().equals("hello1");
assert bean.main2.getValue().equals("hello2");
assert bean.main1.getNoData() == null;
assert bean.main2.getNoData() == null;
-
+ assert bean.main2.normalBean != null;
}
}
Added: extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericConstructorArgument.java
===================================================================
--- extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericConstructorArgument.java (rev 0)
+++ extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericConstructorArgument.java 2010-03-03 21:49:14 UTC (rev 5994)
@@ -0,0 +1,18 @@
+package org.jboss.weld.extensions.genericbeans.test;
+
+import javax.inject.Inject;
+
+import org.jboss.weld.extensions.genericbeans.Generic;
+
+(a)Generic(TestAnnotation.class)
+public class GenericConstructorArgument
+{
+ @Inject
+ TestAnnotation data;
+
+ public String getValue()
+ {
+ return data.value();
+ }
+
+}
Modified: extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericMain.java
===================================================================
--- extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericMain.java 2010-03-03 18:47:14 UTC (rev 5993)
+++ extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericMain.java 2010-03-03 21:49:14 UTC (rev 5994)
@@ -1,14 +1,26 @@
package org.jboss.weld.extensions.genericbeans.test;
+import javax.inject.Inject;
+
import org.jboss.weld.extensions.genericbeans.Generic;
-import org.jboss.weld.extensions.genericbeans.InjectGeneric;
@Generic(TestAnnotation.class)
public class GenericMain
{
- @InjectGeneric
+ @Inject
+ public GenericMain(GenericConstructorArgument args)
+ {
+ constArgs = args;
+ }
+
+ @Inject
GenericDep dep;
+ @Inject
+ NormalBean normalBean;
+
+ GenericConstructorArgument constArgs;
+
public String getValue()
{
return dep.getValue();
Modified: extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericProducer.java
===================================================================
--- extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericProducer.java 2010-03-03 18:47:14 UTC (rev 5993)
+++ extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/GenericProducer.java 2010-03-03 21:49:14 UTC (rev 5994)
@@ -13,4 +13,5 @@
@Produces
@TestAnnotation("hello2")
GenericMain main2;
+
}
Modified: extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/InjectedBean.java
===================================================================
--- extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/InjectedBean.java 2010-03-03 18:47:14 UTC (rev 5993)
+++ extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/InjectedBean.java 2010-03-03 21:49:14 UTC (rev 5994)
@@ -4,9 +4,12 @@
public class InjectedBean
{
- @Inject @SomeQualifier(1)
+ @Inject
+ @SomeQualifier(1)
public GenericMain main1;
-
- @Inject @SomeQualifier(2)
+
+ @Inject
+ @SomeQualifier(2)
public GenericMain main2;
+
}
Added: extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/NormalBean.java
===================================================================
--- extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/NormalBean.java (rev 0)
+++ extensions/trunk/genericbeans/src/test/java/org/jboss/weld/extensions/genericbeans/test/NormalBean.java 2010-03-03 21:49:14 UTC (rev 5994)
@@ -0,0 +1,6 @@
+package org.jboss.weld.extensions.genericbeans.test;
+
+public class NormalBean
+{
+
+}
14 years, 1 month
Weld SVN: r5993 - core/trunk/impl/src/main/java/org/jboss/weld/context and 3 other directories.
by weld-commits@lists.jboss.org
Author: nickarls
Date: 2010-03-03 13:47:14 -0500 (Wed, 03 Mar 2010)
New Revision: 5993
Added:
api/trunk/weld/src/main/java/org/jboss/weld/conversation/ConversationManager.java
core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManager2.java
core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManagerAdapter.java
Removed:
core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManager.java
Modified:
core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java
core/trunk/impl/src/main/java/org/jboss/weld/context/ConversationContext.java
core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java
core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java
core/trunk/impl/src/main/java/org/jboss/weld/conversation/ManagedConversation.java
core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java
core/trunk/impl/src/main/java/org/jboss/weld/servlet/BeanProvider.java
Log:
Restore ConversationManager API to weld-api
Adaptor to ConversationManager2
Lifecycle API changes to context destruction
Added: api/trunk/weld/src/main/java/org/jboss/weld/conversation/ConversationManager.java
===================================================================
--- api/trunk/weld/src/main/java/org/jboss/weld/conversation/ConversationManager.java (rev 0)
+++ api/trunk/weld/src/main/java/org/jboss/weld/conversation/ConversationManager.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -0,0 +1,56 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.conversation;
+
+import java.util.Set;
+
+import javax.enterprise.context.Conversation;
+
+/**
+ * A conversation manager responsible for starting, resuming and ending conversations
+ *
+ * @author Nicklas Karlsson
+ * @see org.jboss.weld.conversation.ConversationManager
+ */
+public interface ConversationManager
+{
+ /**
+ * Begins or restores a conversation
+ *
+ * @param cid The incoming conversation ID. Can be null in cases of transient conversations
+ */
+ public abstract void beginOrRestoreConversation(String cid);
+
+ /**
+ * Cleans up the current conversation, destroying transient conversation and handling
+ * long-running conversations
+ */
+ public abstract void cleanupConversation();
+
+ /**
+ * Destroys all long-running conversations
+ */
+ public abstract void destroyAllConversations();
+
+ /**
+ * Gets the currently managed long-running conversations
+ *
+ * @return the conversations
+ */
+ public abstract Set<Conversation> getLongRunningConversations();
+
+}
\ No newline at end of file
Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java 2010-03-03 13:31:43 UTC (rev 5992)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/ContextLifecycle.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -22,6 +22,7 @@
*/
package org.jboss.weld.context;
+import static org.jboss.weld.jsf.JsfHelper.getServletContext;
import static org.jboss.weld.logging.Category.CONTEXT;
import static org.jboss.weld.logging.LoggerFactory.loggerFactory;
import static org.jboss.weld.logging.messages.ContextMessage.APPLICATION_ENDED;
@@ -30,7 +31,10 @@
import static org.jboss.weld.logging.messages.ContextMessage.REQUEST_STARTED;
import static org.jboss.weld.logging.messages.ContextMessage.SESSION_ENDED;
import static org.jboss.weld.logging.messages.ContextMessage.SESSION_RESTORED;
+import static org.jboss.weld.servlet.BeanProvider.conversationManager;
+import javax.faces.context.FacesContext;
+
import org.jboss.weld.bootstrap.api.Lifecycle;
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.context.api.BeanStore;
@@ -39,15 +43,15 @@
import org.slf4j.cal10n.LocLogger;
/**
- * An implementation of the Weld lifecycle that supports restoring
- * and destroying all the built in contexts
+ * An implementation of the Weld lifecycle that supports restoring and
+ * destroying all the built in contexts
*
* @author Pete Muir
*
*/
public class ContextLifecycle implements Lifecycle, Service
{
-
+
private static final LocLogger log = loggerFactory().getLogger(CONTEXT);
private final AbstractApplicationContext applicationContext;
@@ -56,7 +60,7 @@
private final ConversationContext conversationContext;
private final RequestContext requestContext;
private final DependentContext dependentContext;
-
+
public ContextLifecycle(AbstractApplicationContext applicationContext, AbstractApplicationContext singletonContext, SessionContext sessionContext, ConversationContext conversationContext, RequestContext requestContext, DependentContext dependentContext)
{
this.applicationContext = applicationContext;
@@ -70,26 +74,22 @@
public void restoreSession(String id, BeanStore sessionBeanStore)
{
log.trace(SESSION_RESTORED, id);
- sessionContext.setBeanStore(sessionBeanStore);
- sessionContext.setActive(true);
+ setupContext(sessionContext, sessionBeanStore);
}
public void endSession(String id, BeanStore sessionBeanStore)
{
log.trace(SESSION_ENDED, id);
- sessionContext.setActive(true);
- sessionContext.destroy();
- sessionContext.setBeanStore(null);
- sessionContext.setActive(false);
+ teardownContext(sessionContext);
+ conversationManager(getServletContext(FacesContext.getCurrentInstance())).teardownContext();
}
public void beginRequest(String id, BeanStore requestBeanStore)
{
log.trace(REQUEST_STARTED, id);
- requestContext.setBeanStore(requestBeanStore);
- requestContext.setActive(true);
dependentContext.setActive(true);
- activateConversationContext();
+ setupContext(requestContext, requestBeanStore);
+ setupConversationContext();
}
public void endRequest(String id, BeanStore requestBeanStore)
@@ -97,54 +97,46 @@
log.trace(REQUEST_ENDED, id);
requestContext.setBeanStore(requestBeanStore);
dependentContext.setActive(false);
- requestContext.destroy();
- requestContext.setActive(false);
- requestContext.setBeanStore(null);
- deactivateConversationContext();
+ teardownContext(requestContext);
+ conversationContext.setBeanStore(null);
+ conversationContext.setActive(false);
}
-
+
public boolean isRequestActive()
{
return singletonContext.isActive() && applicationContext.isActive() && requestContext.isActive() && dependentContext.isActive();
}
-
+
public boolean isApplicationActive()
{
return singletonContext.isActive() && applicationContext.isActive() && dependentContext.isActive();
}
-
+
public boolean isConversationActive()
{
return singletonContext.isActive() && applicationContext.isActive() && sessionContext.isActive() && conversationContext.isActive() && dependentContext.isActive();
}
-
- public boolean isSessionActive()
+
+ public boolean isSessionActive()
{
return singletonContext.isActive() && applicationContext.isActive() && sessionContext.isActive() && dependentContext.isActive();
}
-
public void beginApplication(BeanStore applicationBeanStore)
{
log.trace(APPLICATION_STARTED, "");
- applicationContext.setBeanStore(applicationBeanStore);
- applicationContext.setActive(true);
- singletonContext.setBeanStore(new ConcurrentHashMapBeanStore());
- singletonContext.setActive(true);
+ setupContext(applicationContext, applicationBeanStore);
+ setupContext(singletonContext, new ConcurrentHashMapBeanStore());
}
-
+
public void endApplication()
{
log.trace(APPLICATION_ENDED, "");
- applicationContext.destroy();
- applicationContext.setActive(false);
- applicationContext.setBeanStore(null);
- singletonContext.destroy();
- singletonContext.setActive(false);
- singletonContext.setBeanStore(null);
+ teardownContext(applicationContext);
+ teardownContext(singletonContext);
}
-
- public void cleanup()
+
+ public void cleanup()
{
dependentContext.cleanup();
requestContext.cleanup();
@@ -153,47 +145,73 @@
singletonContext.cleanup();
applicationContext.cleanup();
}
-
+
public AbstractApplicationContext getApplicationContext()
{
return applicationContext;
}
-
+
public AbstractApplicationContext getSingletonContext()
{
return singletonContext;
}
-
+
public SessionContext getSessionContext()
{
return sessionContext;
}
-
+
public ConversationContext getConversationContext()
{
return conversationContext;
}
-
+
public RequestContext getRequestContext()
{
return requestContext;
}
-
+
public DependentContext getDependentContext()
{
return dependentContext;
}
- public void activateConversationContext()
+ public void setupConversationContext()
{
- conversationContext.setActive(true);
- conversationContext.setBeanStore(new HashMapBeanStore());
+ setupContext(conversationContext, new HashMapBeanStore());
}
- public void deactivateConversationContext()
+ public void teardownConversationContext()
{
- conversationContext.setActive(false);
- conversationContext.setBeanStore(null);
+ teardownContext(conversationContext);
}
+ private void setupContext(AbstractThreadLocalMapContext context, BeanStore beanStore)
+ {
+ context.setBeanStore(beanStore);
+ context.setActive(true);
+ }
+
+ private void setupContext(AbstractApplicationContext context, BeanStore beanStore)
+ {
+ context.setBeanStore(beanStore);
+ context.setActive(true);
+ }
+
+ private void teardownContext(AbstractThreadLocalMapContext context)
+ {
+ context.setActive(true);
+ context.destroy();
+ context.setBeanStore(null);
+ context.setActive(false);
+ }
+
+ private void teardownContext(AbstractApplicationContext context)
+ {
+ context.setActive(true);
+ context.destroy();
+ context.setBeanStore(null);
+ context.setActive(false);
+ }
+
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/context/ConversationContext.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/context/ConversationContext.java 2010-03-03 13:31:43 UTC (rev 5992)
+++ core/trunk/impl/src/main/java/org/jboss/weld/context/ConversationContext.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -63,5 +63,12 @@
String beanStoreInfo = getBeanStore() == null ? "" : getBeanStore().toString();
return active + "conversation context " + beanStoreInfo;
}
+
+ public static void destroyBeanStore(BeanStore beanStore)
+ {
+ ConversationContext terminatorContext = new ConversationContext();
+ terminatorContext.setBeanStore(beanStore);
+ terminatorContext.destroy();
+ }
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java 2010-03-03 13:31:43 UTC (rev 5992)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/AbstractConversationManager.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -55,7 +55,7 @@
* @author Nicklas Karlsson
*
*/
-public abstract class AbstractConversationManager implements ConversationManager, Serializable
+public abstract class AbstractConversationManager implements ConversationManager2, Serializable
{
private static final long serialVersionUID = 1L;
@@ -69,7 +69,8 @@
@Inject
private ConversationIdGenerator conversationIdGenerator;
- @Inject @ConversationConcurrentAccessTimeout
+ @Inject
+ @ConversationConcurrentAccessTimeout
private long concurrentAccessTimeout;
private Map<String, ManagedConversation> managedConversations;
@@ -79,7 +80,7 @@
managedConversations = new ConcurrentHashMap<String, ManagedConversation>();
}
- public ConversationManager setAsynchronous(boolean asynchronous)
+ public ConversationManager2 setAsynchronous(boolean asynchronous)
{
if (this.asynchronous == asynchronous)
{
@@ -131,7 +132,7 @@
}
}
- public ConversationManager setupConversation(String cid)
+ public ConversationManager2 setupConversation(String cid)
{
if (!asynchronous)
{
@@ -175,7 +176,7 @@
return Container.instance().services().get(ContextLifecycle.class).getConversationContext();
}
- public ConversationManager teardownConversation()
+ public ConversationManager2 teardownConversation()
{
log.trace(CLEANING_UP_CONVERSATION, conversation);
if (conversation.isTransient())
@@ -275,10 +276,15 @@
}
}
- public ConversationManager destroyAllConversations()
+ public ConversationManager2 destroyAllConversations()
{
log.debug(DESTROY_ALL_LRC, "session ended");
log.trace(LRC_COUNT, managedConversations.size());
+ if (conversation.getResumedId() != null)
+ {
+ // Already destroyed when context destroyed
+ managedConversations.remove(conversation.getResumedId());
+ }
for (ManagedConversation managedConversation : managedConversations.values())
{
log.debug(DESTROY_LRC, managedConversation, "session ended");
@@ -288,15 +294,16 @@
return this;
}
- public ConversationManager activateContext()
+ public ConversationManager2 setupContext()
{
- Container.instance().services().get(ContextLifecycle.class).activateConversationContext();
+ Container.instance().services().get(ContextLifecycle.class).setupConversationContext();
return this;
}
- public ConversationManager deactivateContext()
+ public ConversationManager2 teardownContext()
{
- Container.instance().services().get(ContextLifecycle.class).deactivateConversationContext();
+ Container.instance().services().get(ContextLifecycle.class).teardownConversationContext();
+ destroyAllConversations();
return this;
}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java 2010-03-03 13:31:43 UTC (rev 5992)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationImpl.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -52,7 +52,7 @@
private static final LocLogger log = loggerFactory().getLogger(CONVERSATION);
@Inject
- private ConversationManager conversationManager;
+ private ConversationManager2 conversationManager;
private String id;
private boolean _transient = true;
@@ -79,7 +79,7 @@
*
* @param conversation The old conversation
*/
- protected ConversationImpl(Conversation conversation, ConversationManager conversationManager)
+ protected ConversationImpl(Conversation conversation, ConversationManager2 conversationManager)
{
id = conversation.getId();
_transient = conversation.isTransient();
@@ -88,7 +88,7 @@
this.conversationManager = conversationManager;
}
- public static ConversationImpl of(Conversation conversation, ConversationManager conversationManager)
+ public static ConversationImpl of(Conversation conversation, ConversationManager2 conversationManager)
{
return new ConversationImpl(conversation, conversationManager);
}
@@ -220,7 +220,7 @@
return resumedId;
}
- public ConversationImpl unProxy(ConversationManager conversationManager)
+ public ConversationImpl unProxy(ConversationManager2 conversationManager)
{
return new ConversationImpl(this, conversationManager);
}
Deleted: core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManager.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManager.java 2010-03-03 13:31:43 UTC (rev 5992)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManager.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -1,96 +0,0 @@
-package org.jboss.weld.conversation;
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2010, Red Hat, Inc., 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.
- */
-
-import java.util.Map;
-
-import javax.enterprise.context.Conversation;
-
-public interface ConversationManager
-{
- /**
- * Checks the state of the conversation context
- *
- * @return true if the conversation context is active, false otherwise
- */
- public abstract boolean isContextActive();
-
- /**
- * Activates the conversation context
- *
- * @return The conversation manager
- *
- * @throws IllegalStateException if the context is already active
- */
- public abstract ConversationManager activateContext();
-
- /**
- * Deactivates the conversation context
- *
- * @return The conversation manager
- *
- * @throws IllegalStateException if the context is already deactive
- */
- public abstract ConversationManager deactivateContext();
-
- /**
- * Resumes a long running conversation. If the cid is null, nothing is done and the current
- * transient conversation is resumed
- *
- *
- * @param cid The conversation id to restore
- * @return The conversation manager
- * @throws NonexistentConversationException If the non-transient conversation is not known
- * @throws BusyConversationException If the conversation is locked and not released while waiting
- * @throws IllegalStateException if the conversation context is not active
- */
-
- public abstract ConversationManager setupConversation(String cid);
-
- /**
- * Destroys the current conversation if it's transient. Stores it for conversation
- * propagation if it's non-transient
- *
- * @return The conversation manager
- * @throws IllegalStateException if the conversation context is not active
- */
- public abstract ConversationManager teardownConversation();
-
- /**
- * Gets the current non-transient conversations
- *
- * @return The conversations, mapped by id
- * @throws IllegalStateException if the conversation context is not active
- */
- public abstract Map<String, Conversation> getConversations();
-
- /**
- * Returns a new, session-unique conversation ID
- *
- * @return The conversation id
- * @throws IllegalStateException if the conversation context is not active
- */
- public abstract String generateConversationId();
-
- /**
- * Destroys all non-transient conversations
- *
- * @return The conversation manager
- */
- public abstract ConversationManager destroyAllConversations();
-
-}
Copied: core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManager2.java (from rev 5968, core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManager.java)
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManager2.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManager2.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -0,0 +1,89 @@
+package org.jboss.weld.conversation;
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., 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.
+ */
+
+import java.util.Map;
+
+import javax.enterprise.context.Conversation;
+
+public interface ConversationManager2
+{
+ /**
+ * Checks the state of the conversation context
+ *
+ * @return true if the conversation context is active, false otherwise
+ */
+ public abstract boolean isContextActive();
+
+ /**
+ * Sets up and activates the conversation context
+ *
+ * @return The conversation manager
+ *
+ * @throws IllegalStateException if the context is already active
+ */
+ public abstract ConversationManager2 setupContext();
+
+ /**
+ * Destroys the conversations and deactivates the conversation context
+ *
+ * @return The conversation manager
+ *
+ * @throws IllegalStateException if the context is already deactive
+ */
+ public abstract ConversationManager2 teardownContext();
+
+ /**
+ * Resumes a long running conversation. If the cid is null, nothing is done and the current
+ * transient conversation is resumed
+ *
+ *
+ * @param cid The conversation id to restore
+ * @return The conversation manager
+ * @throws NonexistentConversationException If the non-transient conversation is not known
+ * @throws BusyConversationException If the conversation is locked and not released while waiting
+ * @throws IllegalStateException if the conversation context is not active
+ */
+
+ public abstract ConversationManager2 setupConversation(String cid);
+
+ /**
+ * Destroys the current conversation if it's transient. Stores it for conversation
+ * propagation if it's non-transient
+ *
+ * @return The conversation manager
+ * @throws IllegalStateException if the conversation context is not active
+ */
+ public abstract ConversationManager2 teardownConversation();
+
+ /**
+ * Gets the current non-transient conversations
+ *
+ * @return The conversations, mapped by id
+ * @throws IllegalStateException if the conversation context is not active
+ */
+ public abstract Map<String, Conversation> getConversations();
+
+ /**
+ * Returns a new, session-unique conversation ID
+ *
+ * @return The conversation id
+ * @throws IllegalStateException if the conversation context is not active
+ */
+ public abstract String generateConversationId();
+
+}
Added: core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManagerAdapter.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManagerAdapter.java (rev 0)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/ConversationManagerAdapter.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -0,0 +1,44 @@
+package org.jboss.weld.conversation;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.enterprise.context.Conversation;
+import javax.enterprise.context.SessionScoped;
+import javax.inject.Inject;
+
+@SessionScoped
+public class ConversationManagerAdapter implements ConversationManager
+{
+
+ public ConversationManagerAdapter()
+ {
+ }
+
+ @Inject
+ private ConversationManager2 conversationManager;
+
+ public void beginOrRestoreConversation(String cid)
+ {
+ conversationManager.setupConversation(cid);
+ }
+
+ public void cleanupConversation()
+ {
+ conversationManager.teardownConversation();
+ }
+
+ public void destroyAllConversations()
+ {
+ conversationManager.teardownContext();
+ }
+
+ public Set<Conversation> getLongRunningConversations()
+ {
+ Set<Conversation> conversations = new HashSet<Conversation>();
+ conversations.addAll(conversationManager.getConversations().values());
+ return Collections.unmodifiableSet(conversations);
+ }
+
+}
Modified: core/trunk/impl/src/main/java/org/jboss/weld/conversation/ManagedConversation.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/conversation/ManagedConversation.java 2010-03-03 13:31:43 UTC (rev 5992)
+++ core/trunk/impl/src/main/java/org/jboss/weld/conversation/ManagedConversation.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -127,9 +127,7 @@
{
cancelTermination();
}
- ConversationContext terminationContext = new ConversationContext();
- terminationContext.setBeanStore(beanStore);
- terminationContext.destroy();
+ ConversationContext.destroyBeanStore(beanStore);
}
/**
Modified: core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java 2010-03-03 13:31:43 UTC (rev 5992)
+++ core/trunk/impl/src/main/java/org/jboss/weld/jsf/WeldPhaseListener.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -35,7 +35,7 @@
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;
-import org.jboss.weld.conversation.ConversationManager;
+import org.jboss.weld.conversation.ConversationManager2;
import org.slf4j.cal10n.LocLogger;
/**
@@ -64,9 +64,9 @@
private static final LocLogger log = loggerFactory().getLogger(JSF);
- private ConversationManager conversationManager;
+ private ConversationManager2 conversationManager;
- private ConversationManager getConversationManager()
+ private ConversationManager2 getConversationManager()
{
if (conversationManager == null)
{
Modified: core/trunk/impl/src/main/java/org/jboss/weld/servlet/BeanProvider.java
===================================================================
--- core/trunk/impl/src/main/java/org/jboss/weld/servlet/BeanProvider.java 2010-03-03 13:31:43 UTC (rev 5992)
+++ core/trunk/impl/src/main/java/org/jboss/weld/servlet/BeanProvider.java 2010-03-03 18:47:14 UTC (rev 5993)
@@ -24,7 +24,7 @@
import org.jboss.weld.conversation.ConversationIdName;
import org.jboss.weld.conversation.ConversationImpl;
-import org.jboss.weld.conversation.ConversationManager;
+import org.jboss.weld.conversation.ConversationManager2;
import org.jboss.weld.manager.BeanManagerImpl;
public class BeanProvider
@@ -39,11 +39,11 @@
}
- public static ConversationManager conversationManager(ServletContext servletContext)
+ public static ConversationManager2 conversationManager(ServletContext servletContext)
{
BeanManagerImpl beanManager = getModuleBeanManager(servletContext);
- Bean<?> bean = beanManager.resolve(beanManager.getBeans(ConversationManager.class));
- return (ConversationManager) beanManager.getReference(bean, ConversationManager.class, beanManager.createCreationalContext(bean));
+ Bean<?> bean = beanManager.resolve(beanManager.getBeans(ConversationManager2.class));
+ return (ConversationManager2) beanManager.getReference(bean, ConversationManager2.class, beanManager.createCreationalContext(bean));
}
public static HttpSessionManager httpSessionManager(ServletContext servletContext)
14 years, 1 month
Weld SVN: r5992 - in ftest: archetypes and 14 other directories.
by weld-commits@lists.jboss.org
Author: mgencur(a)redhat.com
Date: 2010-03-03 08:31:43 -0500 (Wed, 03 Mar 2010)
New Revision: 5992
Added:
ftest/archetypes/
ftest/archetypes/branches/
ftest/archetypes/tags/
ftest/archetypes/trunk/
ftest/archetypes/trunk/pom.xml
ftest/archetypes/trunk/src/
ftest/archetypes/trunk/src/main/
ftest/archetypes/trunk/src/main/java/
ftest/archetypes/trunk/src/main/java/org/
ftest/archetypes/trunk/src/main/java/org/jboss/
ftest/archetypes/trunk/src/main/java/org/jboss/weld/
ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/
ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/
ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/
ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/
ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/JeeMinimalTest.java
ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/
ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/
ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/
ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/ServletMinimalTest.java
Log:
first part of testsuite for automatic testing of weld archetypes
Added: ftest/archetypes/trunk/pom.xml
===================================================================
--- ftest/archetypes/trunk/pom.xml (rev 0)
+++ ftest/archetypes/trunk/pom.xml 2010-03-03 13:31:43 UTC (rev 5992)
@@ -0,0 +1,27 @@
+<?xml version="1.0"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.jboss.weld.examples.ftest</groupId>
+ <artifactId>ftest-parent</artifactId>
+ <version>0.1</version>
+ </parent>
+
+ <groupId>org.jboss.weld.examples.ftest</groupId>
+ <artifactId>ftest-archetypes</artifactId>
+ <version>0.1</version>
+ <packaging>jar</packaging>
+ <name>Weld Archetypes Ftest: Weld JSF Servlet Minimal</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld.examples.ftest</groupId>
+ <artifactId>ftest-common</artifactId>
+ <version>0.1</version>
+ </dependency>
+ </dependencies>
+
+</project>
+
Added: ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/JeeMinimalTest.java
===================================================================
--- ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/JeeMinimalTest.java (rev 0)
+++ ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/jeeminimal/test/selenium/JeeMinimalTest.java 2010-03-03 13:31:43 UTC (rev 5992)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.weld.archetype.jeeminimal.test.selenium;
+
+import static org.testng.Assert.assertTrue;
+import org.jboss.weld.example.common.test.selenium.WeldSeleniumTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests Weld JSF JEE Minimal archetypes from Weld
+ *
+ * @author Martin Gencur
+ *
+ */
+public class JeeMinimalTest extends WeldSeleniumTest
+{
+ protected String MAIN_PAGE = "/home.jsf";
+ protected String TITLE = "Hello World!";
+ protected String TEXT1 = "Bean Validation examples";
+ protected String TEXT2 = "Find out more";
+ protected String TEXT3 = "Documentation";
+ protected String TEXT4 = "Weld is the reference implementation of CDI";
+
+ protected String INPUT_LETTERS = "id=bv:letters";
+ protected String INPUT_NUMBERS = "id=bv:numbers";
+ protected String INPUT_EMAIL = "id=bv:email";
+ protected String INPUT_CHECK_BUTTON = "id=bv:check";
+
+ protected String NOT_EMPTY_MESSAGE = "may not be empty";
+ protected String NUMBERS_MESSAGE = "numeric value out of bounds (<2 digits>.<0 digits> expected)";
+ protected String ONLY_LETTERS_MESSAGE = "must contain only letters";
+
+ protected String INVALID_EMAIL_MESSAGE = "not a well-formed email address";
+
+ @BeforeMethod(dependsOnGroups = "seleniumSetUp")
+ public void open()
+ {
+ browser.open(contextPath + MAIN_PAGE);
+ browser.waitForPageToLoad();
+ }
+
+ @Test
+ public void homePageLoadTest()
+ {
+ assertTrue(browser.isTextPresent(TITLE), "Page should contain title");
+ assertTrue(browser.isTextPresent(TEXT1), "Page should contain: " + TEXT1);
+ assertTrue(browser.isTextPresent(TEXT2), "Page should contain: " + TEXT2);
+ assertTrue(browser.isTextPresent(TEXT3), "Page should contain: " + TEXT3);
+ assertTrue(browser.isTextPresent(TEXT4), "Page should contain: " + TEXT4);
+ }
+
+ @Test(dependsOnMethods = { "homePageLoadTest" })
+ public void sendEmptyFormTest()
+ {
+ browser.clickAndWait(INPUT_CHECK_BUTTON);
+ assertTrue(browser.isTextPresent(NOT_EMPTY_MESSAGE), "Page should contain: " + NOT_EMPTY_MESSAGE);
+ //assertTrue(!browser.isTextPresent(NUMBERS_MESSAGE), "Page shouldn't contain: " + NUMBERS_MESSAGE);
+ }
+
+ @Test(dependsOnMethods = { "homePageLoadTest" })
+ public void sendWrongValuesTest()
+ {
+ browser.type(INPUT_LETTERS, "hi32guys");
+ browser.type(INPUT_NUMBERS, "6546");
+ browser.type(INPUT_EMAIL, "smithAndWessonCom");
+
+ browser.clickAndWait(INPUT_CHECK_BUTTON);
+
+ assertTrue(browser.isTextPresent(ONLY_LETTERS_MESSAGE), "Page should contain: " + ONLY_LETTERS_MESSAGE);
+ assertTrue(browser.isTextPresent(NUMBERS_MESSAGE), "Page should contain: " + NUMBERS_MESSAGE);
+ assertTrue(browser.isTextPresent(INVALID_EMAIL_MESSAGE), "Page should contain: " + INVALID_EMAIL_MESSAGE);
+ }
+
+ @Test(dependsOnMethods = { "homePageLoadTest" })
+ public void sendRightValuesTest()
+ {
+ browser.type(INPUT_LETTERS, "hithirtytwoguys");
+ browser.type(INPUT_NUMBERS, "65");
+ browser.type(INPUT_EMAIL, "smith(a)wesson.com");
+
+ browser.clickAndWait(INPUT_CHECK_BUTTON);
+
+ assertTrue(!browser.isTextPresent(ONLY_LETTERS_MESSAGE), "Page shouldn't contain error messages");
+ assertTrue(!browser.isTextPresent(NUMBERS_MESSAGE), "Page shouldn't contain error messages");
+ assertTrue(!browser.isTextPresent(INVALID_EMAIL_MESSAGE), "Page shouldn't contain error messages");
+ }
+}
Added: ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/ServletMinimalTest.java
===================================================================
--- ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/ServletMinimalTest.java (rev 0)
+++ ftest/archetypes/trunk/src/main/java/org/jboss/weld/archetype/servletminimal/test/selenium/ServletMinimalTest.java 2010-03-03 13:31:43 UTC (rev 5992)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.weld.archetype.servletminimal.test.selenium;
+
+import static org.testng.Assert.assertTrue;
+import org.jboss.weld.example.common.test.selenium.WeldSeleniumTest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * Tests Weld JSF Servlet archetypes from Weld
+ *
+ * @author Martin Gencur
+ *
+ */
+public class ServletMinimalTest extends WeldSeleniumTest
+{
+ protected String MAIN_PAGE = "/home.jsf";
+ protected String TITLE = "Hello World!";
+ protected String TEXT1 = "Bean Validation examples";
+ protected String TEXT2 = "Find out more";
+ protected String TEXT3 = "Documentation";
+ protected String TEXT4 = "Weld is the reference implementation of CDI";
+
+ protected String INPUT_LETTERS = "id=bv:letters";
+ protected String INPUT_NUMBERS = "id=bv:numbers";
+ protected String INPUT_EMAIL = "id=bv:email";
+ protected String INPUT_CHECK_BUTTON = "id=bv:check";
+
+ protected String NOT_EMPTY_MESSAGE = "may not be empty";
+ protected String NUMBERS_MESSAGE = "numeric value out of bounds (<2 digits>.<0 digits> expected)";
+ protected String ONLY_LETTERS_MESSAGE = "must contain only letters";
+
+ protected String INVALID_EMAIL_MESSAGE = "\"{value}\" is not a valid email address";
+
+ @BeforeMethod(dependsOnGroups = "seleniumSetUp")
+ public void open()
+ {
+ browser.open(contextPath + MAIN_PAGE);
+ browser.waitForPageToLoad();
+ }
+
+ @Test
+ public void homePageLoadTest()
+ {
+ assertTrue(browser.isTextPresent(TITLE), "Page should contain title");
+ assertTrue(browser.isTextPresent(TEXT1), "Page should contain: " + TEXT1);
+ assertTrue(browser.isTextPresent(TEXT2), "Page should contain: " + TEXT2);
+ assertTrue(browser.isTextPresent(TEXT3), "Page should contain: " + TEXT3);
+ assertTrue(browser.isTextPresent(TEXT4), "Page should contain: " + TEXT4);
+ }
+
+ @Test(dependsOnMethods = { "homePageLoadTest" })
+ public void sendEmptyFormTest()
+ {
+ browser.clickAndWait(INPUT_CHECK_BUTTON);
+ assertTrue(browser.isTextPresent(NOT_EMPTY_MESSAGE), "Page should contain: " + NOT_EMPTY_MESSAGE);
+ //assertTrue(!browser.isTextPresent(NUMBERS_MESSAGE), "Page shouldn't contain: " + NUMBERS_MESSAGE);
+ }
+
+ @Test(dependsOnMethods = { "homePageLoadTest" })
+ public void sendWrongValuesTest()
+ {
+ browser.type(INPUT_LETTERS, "hi32guys");
+ browser.type(INPUT_NUMBERS, "6546");
+ browser.type(INPUT_EMAIL, "smithAndWessonCom");
+
+ browser.clickAndWait(INPUT_CHECK_BUTTON);
+
+ assertTrue(browser.isTextPresent(ONLY_LETTERS_MESSAGE), "Page should contain: " + ONLY_LETTERS_MESSAGE);
+ assertTrue(browser.isTextPresent(NUMBERS_MESSAGE), "Page should contain: " + NUMBERS_MESSAGE);
+ assertTrue(browser.isTextPresent(INVALID_EMAIL_MESSAGE), "Page should contain: " + INVALID_EMAIL_MESSAGE);
+ }
+
+ @Test(dependsOnMethods = { "homePageLoadTest" })
+ public void sendRightValuesTest()
+ {
+ browser.type(INPUT_LETTERS, "hithirtytwoguys");
+ browser.type(INPUT_NUMBERS, "65");
+ browser.type(INPUT_EMAIL, "smith(a)wesson.com");
+
+ browser.clickAndWait(INPUT_CHECK_BUTTON);
+
+ assertTrue(!browser.isTextPresent(ONLY_LETTERS_MESSAGE), "Page shouldn't contain error messages");
+ assertTrue(!browser.isTextPresent(NUMBERS_MESSAGE), "Page shouldn't contain error messages");
+ assertTrue(!browser.isTextPresent(INVALID_EMAIL_MESSAGE), "Page shouldn't contain error messages");
+ }
+}
14 years, 1 month
Weld SVN: r5991 - in archetypes/trunk: jsf/jee and 8 other directories.
by weld-commits@lists.jboss.org
Author: mgencur(a)redhat.com
Date: 2010-03-03 08:24:11 -0500 (Wed, 03 Mar 2010)
New Revision: 5991
Added:
archetypes/trunk/jsf/jee-minimal/src/test/
archetypes/trunk/jsf/jee-minimal/src/test/selenium/
archetypes/trunk/jsf/jee-minimal/src/test/selenium/testsuite.xml
archetypes/trunk/jsf/servlet-minimal/src/test/
archetypes/trunk/jsf/servlet-minimal/src/test/selenium/
archetypes/trunk/jsf/servlet-minimal/src/test/selenium/testsuite.xml
Modified:
archetypes/trunk/jsf/jee-minimal/pom.xml
archetypes/trunk/jsf/jee/pom.xml
archetypes/trunk/jsf/servlet-minimal/pom.xml
archetypes/trunk/pom.xml
Log:
first part of testsuite for automatic testing of weld archetypes
Modified: archetypes/trunk/jsf/jee/pom.xml
===================================================================
--- archetypes/trunk/jsf/jee/pom.xml 2010-03-03 13:10:45 UTC (rev 5990)
+++ archetypes/trunk/jsf/jee/pom.xml 2010-03-03 13:24:11 UTC (rev 5991)
@@ -31,4 +31,7 @@
</plugin>
</plugins>
</build>
+
+
+
</project>
Modified: archetypes/trunk/jsf/jee-minimal/pom.xml
===================================================================
--- archetypes/trunk/jsf/jee-minimal/pom.xml 2010-03-03 13:10:45 UTC (rev 5990)
+++ archetypes/trunk/jsf/jee-minimal/pom.xml 2010-03-03 13:24:11 UTC (rev 5991)
@@ -31,4 +31,196 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>ftest-jboss</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+
+ <properties>
+ <ftest.artifact>ftest-archetypes</ftest.artifact>
+ <ftest.version>0.1${ftest.version.discriminator}</ftest.version>
+ <selenium.browser.url>http://localhost:8080</selenium.browser.url>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld.examples.ftest</groupId>
+ <artifactId>${ftest.artifact}</artifactId>
+ <version>${ftest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>selenium-maven-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>failsafe-maven-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+
+ <executions>
+ <!-- remove a project generated earlier -->
+ <execution>
+ <id>remove-old-project</id>
+ <phase>process-sources</phase>
+ <configuration>
+ <tasks>
+ <echo message="Removing old project" />
+ <delete dir="${java.io.tmpdir}/${project.artifactId}" failonerror="false"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <!-- tomcat:run has to be executed in background otherwise it would block further maven execution -->
+ <execution>
+ <id>wait-for-project</id>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <tasks>
+ <property name="url.to.wait" value="http://localhost:8080/${project.artifactId}" />
+ <echo message="Waiting for application at ${url.to.wait} using jboss container" />
+ <waitfor maxwait="${application.deploy.timeout}" maxwaitunit="second">
+ <http url="${url.to.wait}" errorsBeginAt="404" />
+ </waitfor>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+
+ <executions>
+ <!-- generate project using weld archetypes -->
+ <execution>
+ <id>generate-project-artifacts</id>
+ <phase>generate-resources</phase>
+
+ <configuration>
+ <executable>mvn</executable>
+ <workingDirectory>${java.io.tmpdir}</workingDirectory>
+ <arguments>
+ <argument>archetype:generate</argument>
+ <argument>-DinteractiveMode=n</argument>
+ <argument>-DarchetypeArtifactId=${project.artifactId}</argument>
+ <argument>-DarchetypeGroupId=org.jboss.weld.archetypes</argument>
+ <argument>-DarchetypeVersion=${archetype.test.version}</argument>
+ <argument>-DgroupId=com.mycompany</argument>
+ <argument>-DartifactId=${project.artifactId}</argument>
+ <argument>-Dmaven.repo.local=${maven.private.repo}/</argument>
+ </arguments>
+ </configuration>
+
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+
+ <!-- just compile generated project -->
+ <execution>
+ <id>package-project</id>
+ <phase>compile</phase>
+
+ <configuration>
+ <executable>mvn</executable>
+ <workingDirectory>${java.io.tmpdir}/${project.artifactId}</workingDirectory>
+ <arguments>
+ <argument>package</argument>
+ <argument>-Dmaven.repo.local=${maven.private.repo}/</argument>
+ </arguments>
+ </configuration>
+
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+
+ <!-- deploy -->
+ <execution>
+ <id>deploy-project</id>
+ <phase>compile</phase>
+
+ <configuration>
+ <executable>mvn</executable>
+ <workingDirectory>${java.io.tmpdir}/${project.artifactId}</workingDirectory>
+ <arguments>
+ <argument>jboss:hard-deploy</argument>
+ <argument>-Dmaven.repo.local=${maven.private.repo}/</argument>
+ </arguments>
+ </configuration>
+
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+
+ <!-- run unit tests -->
+ <execution>
+ <id>run-unit-tests</id>
+ <phase>integration-test</phase>
+
+ <configuration>
+ <executable>mvn</executable>
+ <workingDirectory>${java.io.tmpdir}/${project.artifactId}</workingDirectory>
+ <arguments>
+ <argument>test</argument>
+ <argument>-Dmaven.repo.local=${maven.private.repo}/</argument>
+ </arguments>
+ </configuration>
+
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+
+ <!-- undeploy -->
+ <execution>
+ <id>undeploy-project</id>
+ <phase>post-integration-test</phase>
+
+ <configuration>
+ <executable>mvn</executable>
+ <workingDirectory>${java.io.tmpdir}/${project.artifactId}</workingDirectory>
+ <arguments>
+ <argument>jboss:hard-undeploy</argument>
+ <argument>-Dmaven.repo.local=${maven.private.repo}/</argument>
+ </arguments>
+ </configuration>
+
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Added: archetypes/trunk/jsf/jee-minimal/src/test/selenium/testsuite.xml
===================================================================
--- archetypes/trunk/jsf/jee-minimal/src/test/selenium/testsuite.xml (rev 0)
+++ archetypes/trunk/jsf/jee-minimal/src/test/selenium/testsuite.xml 2010-03-03 13:24:11 UTC (rev 5991)
@@ -0,0 +1,29 @@
+
+ <!--
+ JBoss, Home of Professional Open Source Copyright 2008, Red Hat
+ Middleware LLC, and individual contributors by the @authors tag. See
+ the copyright.txt in the distribution for a full listing of individual
+ contributors. This is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version. This software is
+ distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not, write
+ to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="Weld JSF JEE Minimal archetype test" verbose="2" parallel="false">
+ <listeners>
+ <listener class-name="org.jboss.weld.example.common.test.selenium.WeldFunctionalTestListener" />
+ </listeners>
+ <test name="JEE Minimal">
+ <parameter name="example.context.path" value="/weld-jsf-jee-minimal" />
+ <packages>
+ <package name="org.jboss.weld.archetype.jeeminimal.test.selenium" />
+ </packages>
+ </test>
+</suite>
Modified: archetypes/trunk/jsf/servlet-minimal/pom.xml
===================================================================
--- archetypes/trunk/jsf/servlet-minimal/pom.xml 2010-03-03 13:10:45 UTC (rev 5990)
+++ archetypes/trunk/jsf/servlet-minimal/pom.xml 2010-03-03 13:24:11 UTC (rev 5991)
@@ -32,4 +32,178 @@
</plugin>
</plugins>
</build>
+
+ <profiles>
+ <profile>
+ <id>ftest-embedded</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+
+ <properties>
+ <ftest.artifact>ftest-archetypes</ftest.artifact>
+ <ftest.version>0.1${ftest.version.discriminator}</ftest.version>
+ <selenium.browser.url>http://localhost:9090</selenium.browser.url>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.weld.examples.ftest</groupId>
+ <artifactId>${ftest.artifact}</artifactId>
+ <version>${ftest.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>selenium-maven-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>failsafe-maven-plugin</artifactId>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!-- remove a project generated earlier -->
+ <execution>
+ <id>remove-old-project</id>
+ <phase>process-sources</phase>
+ <configuration>
+ <tasks>
+ <echo message="Removing old project" />
+ <delete dir="${java.io.tmpdir}/${project.artifactId}" failonerror="false"/>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <!-- tomcat:run has to be executed in background otherwise it would block further maven execution -->
+ <execution>
+ <id>deploy-project</id>
+ <phase>pre-integration-test</phase>
+ <configuration>
+ <tasks>
+ <exec dir="${java.io.tmpdir}/${project.artifactId}" executable="mvn" spawn="true">
+ <arg value="${container}:run"/>
+ <arg value="-Dmaven.repo.local=${maven.private.repo}/"/>
+ </exec>
+
+ <property name="url.to.wait" value="http://localhost:9090/${project.artifactId}" />
+ <echo message="Waiting for application at ${url.to.wait} using ${container} container" />
+ <waitfor maxwait="${application.deploy.timeout}" maxwaitunit="second">
+ <http url="${url.to.wait}" errorsBeginAt="404" />
+ </waitfor>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <!-- killing container running in background -->
+ <execution>
+ <id>stop-container</id>
+ <phase>post-integration-test</phase>
+ <configuration>
+ <tasks>
+ <exec dir="${java.io.tmpdir}/${project.artifactId}" executable="bash">
+ <arg value="-c"/>
+ <arg value="ps -eaf --columns 1200 | grep ${container}:run | grep -v grep | awk '{ print $$2; }' | xargs kill"/>
+ </exec>
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <executions>
+ <!-- generate project using weld archetypes -->
+ <execution>
+ <id>generate-project-artifacts</id>
+ <phase>generate-resources</phase>
+
+ <configuration>
+ <executable>mvn</executable>
+ <workingDirectory>${java.io.tmpdir}</workingDirectory>
+ <arguments>
+ <argument>archetype:generate</argument>
+ <argument>-DinteractiveMode=n</argument>
+ <argument>-DarchetypeArtifactId=${project.artifactId}</argument>
+ <argument>-DarchetypeGroupId=org.jboss.weld.archetypes</argument>
+ <argument>-DarchetypeVersion=${archetype.test.version}</argument>
+ <argument>-DgroupId=com.mycompany</argument>
+ <argument>-DartifactId=${project.artifactId}</argument>
+ <argument>-Dmaven.repo.local=${maven.private.repo}/</argument>
+ </arguments>
+ </configuration>
+
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+
+ <!-- just compile generated project -->
+ <execution>
+ <id>compile-project</id>
+ <phase>compile</phase>
+
+ <configuration>
+ <executable>mvn</executable>
+ <workingDirectory>${java.io.tmpdir}/${project.artifactId}</workingDirectory>
+ <arguments>
+ <argument>compile</argument>
+ <argument>-Dmaven.repo.local=${maven.private.repo}/</argument>
+ </arguments>
+ </configuration>
+
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+
+ <!-- run unit tests -->
+ <execution>
+ <id>run-unit-tests</id>
+ <phase>integration-test</phase>
+
+ <configuration>
+ <executable>mvn</executable>
+ <workingDirectory>${java.io.tmpdir}/${project.artifactId}</workingDirectory>
+ <arguments>
+ <argument>test</argument>
+ <argument>-Dmaven.repo.local=${maven.private.repo}/</argument>
+ </arguments>
+ </configuration>
+
+ <goals>
+ <goal>exec</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
Added: archetypes/trunk/jsf/servlet-minimal/src/test/selenium/testsuite.xml
===================================================================
--- archetypes/trunk/jsf/servlet-minimal/src/test/selenium/testsuite.xml (rev 0)
+++ archetypes/trunk/jsf/servlet-minimal/src/test/selenium/testsuite.xml 2010-03-03 13:24:11 UTC (rev 5991)
@@ -0,0 +1,29 @@
+
+ <!--
+ JBoss, Home of Professional Open Source Copyright 2008, Red Hat
+ Middleware LLC, and individual contributors by the @authors tag. See
+ the copyright.txt in the distribution for a full listing of individual
+ contributors. This is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version. This software is
+ distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
+ License for more details. You should have received a copy of the GNU
+ Lesser General Public License along with this software; if not, write
+ to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ Boston, MA 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ -->
+<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
+<suite name="Weld JSF Servlet Minimal archetype test" verbose="2" parallel="false">
+ <listeners>
+ <listener class-name="org.jboss.weld.example.common.test.selenium.WeldFunctionalTestListener" />
+ </listeners>
+ <test name="ServletMinimal">
+ <parameter name="example.context.path" value="/weld-jsf-servlet-minimal" />
+ <packages>
+ <package name="org.jboss.weld.archetype.servletminimal.test.selenium" />
+ </packages>
+ </test>
+</suite>
Modified: archetypes/trunk/pom.xml
===================================================================
--- archetypes/trunk/pom.xml 2010-03-03 13:10:45 UTC (rev 5990)
+++ archetypes/trunk/pom.xml 2010-03-03 13:24:11 UTC (rev 5991)
@@ -67,6 +67,26 @@
<module>jsf/jee-minimal</module>
<module>jsf/jee</module>
</modules>
+
+ <properties>
+ <testng.version>5.10</testng.version>
+ <selenium.java.client.version>1.0.1</selenium.java.client.version>
+ <selenium.maven.plugin.version>1.0</selenium.maven.plugin.version>
+ <maven.antrun.plugin.version>1.3</maven.antrun.plugin.version>
+ <failsafe.maven.plugin.version>2.4.3-alpha-1</failsafe.maven.plugin.version>
+ <exec.maven.plugin.version>1.1</exec.maven.plugin.version>
+ <ant.junit.version>1.6.2</ant.junit.version>
+ <ftest.version.discriminator />
+ <selenium.browser>*firefoxproxy</selenium.browser>
+ <selenium.server.port>14444</selenium.server.port>
+ <selenium.server.host>localhost</selenium.server.host>
+ <selenium.speed>0</selenium.speed>
+ <selenium.timeout>30000</selenium.timeout>
+ <selenium.debug>false</selenium.debug>
+ <application.deploy.timeout>600</application.deploy.timeout>
+ <archetype.test.version>1.0.0-BETA1</archetype.test.version>
+
+ </properties>
<!-- SCM and distribution management -->
<scm>
@@ -74,4 +94,395 @@
<developerConnection>scm:svn:https://svn.jboss.org/repos/weld/archetypes/trunk</developerConnection>
<url>http://fisheye.jboss.org/browse/weld/archetypes/trunk</url>
</scm>
+
+ <profiles>
+ <profile>
+ <id>ftest-embedded</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+
+ <properties>
+ <maven.private.repo>${java.io.tmpdir}/maven_private_repo</maven.private.repo>
+ <ftest.testsuite>testsuite.xml</ftest.testsuite>
+ <container>tomcat</container> <!-- default is tomcat but jetty can be chosen by -Dcontainer=jetty -->
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.seleniumhq.selenium.client-drivers</groupId>
+ <artifactId>selenium-java-client-driver</artifactId>
+ <version>${selenium.java.client.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+ <!-- get functional tests from ftest artifact -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-ftest</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/ftest</outputDirectory>
+ <stripVersion>true</stripVersion>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.weld.examples.ftest</groupId>
+ <artifactId>${ftest.artifact}</artifactId>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- start Selenium server -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>selenium-maven-plugin</artifactId>
+ <version>${selenium.maven.plugin.version}</version>
+ <executions>
+ <execution>
+ <id>start-selenium</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start-server</goal>
+ </goals>
+ <configuration>
+ <background>true</background>
+ <port>${selenium.server.port}</port>
+ <logOutput>true</logOutput>
+ <logFile>${project.build.directory}/selenium/selenium-server.log</logFile>
+ <browserSideLog>${selenium.debug}</browserSideLog>
+ <debug>${selenium.debug}</debug>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- stop Selenium -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>${maven.antrun.plugin.version}</version>
+ <executions>
+ <!-- deploy application to farm directory and waiting for the application to be ready -->
+ <execution>
+ <id>prepare-private-local-repo</id>
+ <phase>process-sources</phase>
+ <configuration>
+ <tasks>
+
+ <property name="tmpdir" value="${maven.private.repo}"/>
+ <delete dir="${tmpdir}" failonerror="false"/>
+ <mkdir dir="${tmpdir}"/>
+
+ <copy todir="${tmpdir}" overwrite="true">
+ <fileset dir="${user.home}/.m2/repository/org/jboss/weld/archetypes">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <!-- this ant script runs testng natively -->
+ <execution>
+ <id>stop-selenium</id>
+ <phase>post-integration-test</phase>
+ <configuration>
+ <tasks>
+ <echo message="Undeploying application..." />
+ <get taskname="selenium-shutdown" src="http://${selenium.server.host}:${selenium.server.port}/selenium-server/driver/?cmd=shutDownSeleniumServer" ignoreerrors="true" dest="${project.build.directory}/selenium.stop.msg" />
+ <echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>${exec.maven.plugin.version}</version>
+ </plugin>
+
+ <!-- run functional tests -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>failsafe-maven-plugin</artifactId>
+ <version>${failsafe.maven.plugin.version}</version>
+ <configuration>
+ <testClassesDirectory>${project.build.directory}/ftest</testClassesDirectory>
+ <suiteXmlFiles>
+ <suiteXmlFile>src/test/selenium/${ftest.testsuite}</suiteXmlFile>
+ </suiteXmlFiles>
+ <argLine>-Xmx748m</argLine>
+ <forkMode>once</forkMode>
+ <systemProperties>
+ <property>
+ <name>selenium.server.port</name>
+ <value>${selenium.server.port}</value>
+ </property>
+ <property>
+ <name>selenium.server.host</name>
+ <value>${selenium.server.host}</value>
+ </property>
+ <property>
+ <name>selenium.browser</name>
+ <value>${selenium.browser}</value>
+ </property>
+ <property>
+ <name>selenium.browser.url</name>
+ <value>${selenium.browser.url}</value>
+ </property>
+ <property>
+ <name>selenium.speed</name>
+ <value>${selenium.speed}</value>
+ </property>
+ <property>
+ <name>selenium.timeout</name>
+ <value>${selenium.timeout}</value>
+ </property>
+ <property>
+ <name>basedir</name>
+ <value>${basedir}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>verify</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+
+ <profile>
+ <id>ftest-jboss</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+
+ <properties>
+ <maven.private.repo>${java.io.tmpdir}/maven_private_repo</maven.private.repo>
+ <ftest.testsuite>testsuite.xml</ftest.testsuite>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.seleniumhq.selenium.client-drivers</groupId>
+ <artifactId>selenium-java-client-driver</artifactId>
+ <version>${selenium.java.client.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <pluginManagement>
+ <plugins>
+
+ <!-- get functional tests from ftest artifact -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-ftest</id>
+ <phase>process-sources</phase>
+ <goals>
+ <goal>copy</goal>
+ </goals>
+ <configuration>
+ <outputDirectory>${project.build.directory}/ftest</outputDirectory>
+ <stripVersion>true</stripVersion>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.weld.examples.ftest</groupId>
+ <artifactId>${ftest.artifact}</artifactId>
+ <overWrite>true</overWrite>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- start Selenium server -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>selenium-maven-plugin</artifactId>
+ <version>${selenium.maven.plugin.version}</version>
+ <executions>
+ <execution>
+ <id>start-selenium</id>
+ <phase>pre-integration-test</phase>
+ <goals>
+ <goal>start-server</goal>
+ </goals>
+ <configuration>
+ <background>true</background>
+ <port>${selenium.server.port}</port>
+ <logOutput>true</logOutput>
+ <logFile>${project.build.directory}/selenium/selenium-server.log</logFile>
+ <browserSideLog>${selenium.debug}</browserSideLog>
+ <debug>${selenium.debug}</debug>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- stop Selenium -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <version>${maven.antrun.plugin.version}</version>
+ <executions>
+ <!-- deploy application to farm directory and waiting for the application to be ready -->
+ <execution>
+ <id>prepare-private-local-repo</id>
+ <phase>process-sources</phase>
+ <configuration>
+ <tasks>
+
+ <property name="tmpdir" value="${maven.private.repo}"/>
+ <delete dir="${tmpdir}" failonerror="false"/>
+ <mkdir dir="${tmpdir}"/>
+
+ <copy todir="${tmpdir}" overwrite="true">
+ <fileset dir="${user.home}/.m2/repository/org/jboss/weld/archetypes">
+ <include name="**/*"/>
+ </fileset>
+ </copy>
+
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+
+ <!-- this ant script runs testng natively -->
+ <execution>
+ <id>stop-selenium</id>
+ <phase>post-integration-test</phase>
+ <configuration>
+ <tasks>
+ <echo message="Undeploying application..." />
+ <get taskname="selenium-shutdown" src="http://${selenium.server.host}:${selenium.server.port}/selenium-server/driver/?cmd=shutDownSeleniumServer" ignoreerrors="true" dest="${project.build.directory}/selenium.stop.msg" />
+ <echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
+ </tasks>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <version>${exec.maven.plugin.version}</version>
+ </plugin>
+
+ <!-- run functional tests -->
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>failsafe-maven-plugin</artifactId>
+ <version>${failsafe.maven.plugin.version}</version>
+ <configuration>
+ <testClassesDirectory>${project.build.directory}/ftest</testClassesDirectory>
+ <suiteXmlFiles>
+ <suiteXmlFile>src/test/selenium/${ftest.testsuite}</suiteXmlFile>
+ </suiteXmlFiles>
+ <argLine>-Xmx748m</argLine>
+ <forkMode>once</forkMode>
+ <systemProperties>
+ <property>
+ <name>selenium.server.port</name>
+ <value>${selenium.server.port}</value>
+ </property>
+ <property>
+ <name>selenium.server.host</name>
+ <value>${selenium.server.host}</value>
+ </property>
+ <property>
+ <name>selenium.browser</name>
+ <value>${selenium.browser}</value>
+ </property>
+ <property>
+ <name>selenium.browser.url</name>
+ <value>${selenium.browser.url}</value>
+ </property>
+ <property>
+ <name>selenium.speed</name>
+ <value>${selenium.speed}</value>
+ </property>
+ <property>
+ <name>selenium.timeout</name>
+ <value>${selenium.timeout}</value>
+ </property>
+ <property>
+ <name>basedir</name>
+ <value>${basedir}</value>
+ </property>
+ </systemProperties>
+ </configuration>
+ <executions>
+ <execution>
+ <id>integration-test</id>
+ <phase>integration-test</phase>
+ <goals>
+ <goal>integration-test</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>verify</id>
+ <phase>verify</phase>
+ <goals>
+ <goal>verify</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ </plugins>
+ </pluginManagement>
+ </build>
+ </profile>
+ </profiles>
</project>
14 years, 1 month