Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[WELD-892] use case test; TODO fix and enable.
- Loading branch information
Showing
6 changed files
with
237 additions
and
3 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...base/src/main/java/org/jboss/weld/environment/servlet/test/lifecycle/HSCycleTestBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2011, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file 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.environment.servlet.test.lifecycle; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.asset.EmptyAsset; | ||
import org.jboss.shrinkwrap.api.asset.StringAsset; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.jboss.weld.environment.servlet.test.util.Deployments; | ||
import org.junit.Test; | ||
|
||
/** | ||
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a> | ||
*/ | ||
public class HSCycleTestBase { | ||
protected static WebArchive getBaseDeployment() { | ||
WebArchive war = ShrinkWrap.create(WebArchive.class); | ||
war.addPackage(HSCycleTestBase.class.getPackage()); | ||
String webXml = Deployments.extendDefaultWebXml(Deployments.toListener(HSListener.class.getName())); | ||
war.setWebXML(new StringAsset(webXml)); | ||
war.addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml"); | ||
return war; | ||
} | ||
|
||
@Test | ||
public void testNA() throws Exception { | ||
} | ||
|
||
public void XtestCycle(Pinger pinger) throws Exception { | ||
pinger.ping(); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
...ests/base/src/main/java/org/jboss/weld/environment/servlet/test/lifecycle/HSListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2011, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file 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.environment.servlet.test.lifecycle; | ||
|
||
import javax.enterprise.inject.spi.BeanManager; | ||
import javax.naming.Context; | ||
import javax.naming.InitialContext; | ||
import javax.naming.NamingException; | ||
import javax.servlet.http.HttpSessionEvent; | ||
import javax.servlet.http.HttpSessionListener; | ||
|
||
/** | ||
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a> | ||
*/ | ||
public class HSListener implements HttpSessionListener { | ||
|
||
private BeanManager getBeanManager() { | ||
Context context = null; | ||
try { | ||
context = new InitialContext(); | ||
return (BeanManager) context.lookup("java:comp/env/BeanManager"); | ||
} catch (NamingException e) { | ||
throw new RuntimeException(e); | ||
} finally { | ||
if (context != null) | ||
try { | ||
context.close(); | ||
} catch (NamingException ignored) { | ||
} | ||
} | ||
} | ||
|
||
public void sessionCreated(HttpSessionEvent se) { | ||
getBeanManager().fireEvent(se.getSession()); | ||
} | ||
|
||
public void sessionDestroyed(HttpSessionEvent se) { | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
.../tests/base/src/main/java/org/jboss/weld/environment/servlet/test/lifecycle/Observer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2011, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file 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.environment.servlet.test.lifecycle; | ||
|
||
import javax.enterprise.event.Observes; | ||
import javax.inject.Inject; | ||
import javax.servlet.http.HttpSession; | ||
|
||
/** | ||
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a> | ||
*/ | ||
public class Observer { | ||
@Inject | ||
Pinger pinger; | ||
|
||
public void newSession(@Observes HttpSession s) { | ||
pinger.ping(); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...et/tests/base/src/main/java/org/jboss/weld/environment/servlet/test/lifecycle/Pinger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2011, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file 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.environment.servlet.test.lifecycle; | ||
|
||
import javax.enterprise.context.SessionScoped; | ||
import java.io.Serializable; | ||
|
||
/** | ||
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a> | ||
*/ | ||
@SessionScoped | ||
public class Pinger implements Serializable { | ||
public void ping() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...s/tomcat/src/test/java/org/jboss/weld/environment/servlet/test/lifecycle/HSCycleTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2011, Red Hat, Inc., and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file 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.environment.servlet.test.lifecycle; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.jboss.weld.environment.servlet.test.util.TomcatDeployments; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* @author <a href="mailto:ales.justin@jboss.org">Ales Justin</a> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class HSCycleTest extends HSCycleTestBase { | ||
@Deployment | ||
public static WebArchive getDeployment() { | ||
WebArchive war = getBaseDeployment(); | ||
war.add(TomcatDeployments.CONTEXT_XML, "META-INF/context.xml"); | ||
System.out.println(war.toString(true)); | ||
return war; | ||
} | ||
} |