-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FORGE-673 - FKLJSDF(*#$ YES! Arquillian test harness for Forge 2.0 is…
… ALIVE
- Loading branch information
1 parent
4f5daf6
commit fa51917
Showing
8 changed files
with
141 additions
and
39 deletions.
There are no files selected for viewing
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
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
31 changes: 31 additions & 0 deletions
31
...an-forge-managed/src/main/java/org/jboss/forge/arquillian/runner/BeanManagerProducer.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,31 @@ | ||
package org.jboss.forge.arquillian.runner; | ||
|
||
import javax.enterprise.inject.spi.BeanManager; | ||
|
||
import org.jboss.arquillian.core.api.InstanceProducer; | ||
import org.jboss.arquillian.core.api.annotation.ApplicationScoped; | ||
import org.jboss.arquillian.core.api.annotation.Inject; | ||
import org.jboss.arquillian.core.api.annotation.Observes; | ||
import org.jboss.arquillian.test.spi.event.suite.BeforeSuite; | ||
import org.jboss.arquillian.testenricher.cdi.container.CDIExtension; | ||
|
||
/** | ||
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a> | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
*/ | ||
public class BeanManagerProducer | ||
{ | ||
@Inject | ||
@ApplicationScoped | ||
private InstanceProducer<BeanManager> beanManagerProducer; | ||
|
||
public void findBeanManager(@Observes BeforeSuite context) | ||
{ | ||
BeanManager beanManager = CDIExtension.getBeanManager(); | ||
if (beanManager != null) | ||
beanManagerProducer.set(beanManager); | ||
else | ||
throw new IllegalStateException("Could not locate BeanManager"); | ||
} | ||
|
||
} |
22 changes: 22 additions & 0 deletions
22
...src/main/java/org/jboss/forge/arquillian/runner/CDIEnricherRemoteExtensionWorkaround.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,22 @@ | ||
package org.jboss.forge.arquillian.runner; | ||
|
||
import org.jboss.arquillian.container.test.spi.RemoteLoadableExtension; | ||
|
||
/** | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
*/ | ||
public class CDIEnricherRemoteExtensionWorkaround implements RemoteLoadableExtension | ||
{ | ||
@Override | ||
public void register(ExtensionBuilder builder) | ||
{ | ||
if (Validate.classExists("javax.enterprise.inject.spi.BeanManager")) | ||
{ | ||
builder.observer(BeanManagerProducer.class); | ||
} | ||
else | ||
{ | ||
throw new IllegalStateException("Test not being deployed to a valid CDI environment"); | ||
} | ||
} | ||
} |
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
55 changes: 44 additions & 11 deletions
55
forge-example-plugin/src/main/java/org/example/SimpleService.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 |
---|---|---|
@@ -1,33 +1,66 @@ | ||
package org.example; | ||
|
||
import java.io.IOException; | ||
import java.net.URL; | ||
import java.util.Enumeration; | ||
|
||
import javax.enterprise.event.Observes; | ||
import javax.inject.Singleton; | ||
|
||
import org.jboss.forge.container.event.PostStartup; | ||
import org.jboss.forge.container.event.PreShutdown; | ||
import org.jboss.forge.container.event.Shutdown; | ||
import org.jboss.forge.container.event.Startup; | ||
import org.jboss.forge.container.services.Remote; | ||
|
||
/** | ||
* @author <a href="mailto:lincolnbaxter@gmail.com">Lincoln Baxter, III</a> | ||
*/ | ||
@Remote | ||
@Singleton | ||
public class SimpleService | ||
{ | ||
private boolean startupObserved; | ||
private boolean postStartupObserved; | ||
private boolean preShutdownObserved; | ||
private boolean shutdownObserved; | ||
|
||
public void startup(@Observes Startup event) throws IOException | ||
{ | ||
startupObserved = true; | ||
} | ||
|
||
public void postStartup(@Observes PostStartup event) throws IOException | ||
{ | ||
System.out.println("SimpleService has been started, and says hello!"); | ||
postStartupObserved = true; | ||
} | ||
|
||
Enumeration<URL> resources = Thread.currentThread().getContextClassLoader() | ||
.getResources("META-INF/services/javax.enterprise.inject.spi.Extension"); | ||
while (resources.hasMoreElements()) | ||
{ | ||
System.out.println(resources.nextElement().toString()); | ||
} | ||
public void preShutdown(@Observes PreShutdown event) | ||
{ | ||
preShutdownObserved = true; | ||
} | ||
|
||
public void shutdown(@Observes Shutdown event) throws IOException | ||
{ | ||
shutdownObserved = true; | ||
} | ||
|
||
public void preShutdown(@Observes PreShutdown event) | ||
public boolean isStartupObserved() | ||
{ | ||
System.out.println("SimpleService will shut down, and says goodbye!"); | ||
return startupObserved; | ||
} | ||
|
||
public boolean isPostStartupObserved() | ||
{ | ||
return postStartupObserved; | ||
} | ||
|
||
public boolean isPreShutdownObserved() | ||
{ | ||
return preShutdownObserved; | ||
} | ||
|
||
public boolean isShutdownObserved() | ||
{ | ||
return shutdownObserved; | ||
} | ||
|
||
} |
1 change: 0 additions & 1 deletion
1
...example-plugin/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
This file was deleted.
Oops, something went wrong.
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