[seam-commits] Seam SVN: r12362 - modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Thu Apr 1 17:37:35 EDT 2010
Author: tsurdilovic
Date: 2010-04-01 17:37:35 -0400 (Thu, 01 Apr 2010)
New Revision: 12362
Modified:
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseTest.java
Log:
added bean manager
Modified: modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseTest.java
===================================================================
--- modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseTest.java 2010-04-01 20:03:51 UTC (rev 12361)
+++ modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseTest.java 2010-04-01 21:37:35 UTC (rev 12362)
@@ -4,6 +4,9 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.util.AnnotationLiteral;
import javax.inject.Inject;
import org.drools.KnowledgeBase;
@@ -11,6 +14,7 @@
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.drools.KnowledgeBaseProducer;
import org.jboss.seam.drools.config.KnowledgeBaseConfig;
+import org.jboss.seam.drools.qualifier.KBaseConfig;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
@@ -25,7 +29,6 @@
{
return Archives.create("test.jar", JavaArchive.class)
.addPackages(true, KnowledgeBaseProducer.class.getPackage())
- .addClass(KBaseBean.class)
.addResource(KBaseTest.class.getPackage().getName().replaceAll("\\.", "/") + "/kbasetest.drl")
.addResource(KBaseTest.class.getPackage().getName().replaceAll("\\.", "/") + "/kbuilderconfig.properties")
.addResource(KBaseTest.class.getPackage().getName().replaceAll("\\.", "/") + "/kbaseconfig.properties")
@@ -33,22 +36,41 @@
ArchivePaths.create("beans.xml"));
}
- @Inject KBaseBean kbasebean;
+ @Inject BeanManager manager;
- @Test
- public void testKBaseBean() {
- assertNotNull(kbasebean);
+ @Test
+ public void testManager() {
+ assertNotNull(manager);
}
@Test
public void testKBaseConfig() {
- assertNotNull(kbasebean.getKbaseconfig());
+ Bean<KnowledgeBaseConfig> knowledgeBaseConfigBean = (Bean<KnowledgeBaseConfig>)
+ manager.getBeans(KnowledgeBaseConfig.class, new KBaseConfigBinding("kbaseconfig1")).iterator().next();
+
+ KnowledgeBaseConfig kbaseConfig = (KnowledgeBaseConfig) manager.getReference(knowledgeBaseConfigBean, KnowledgeBaseConfig.class, manager.createCreationalContext(knowledgeBaseConfigBean));
+
+ assertNotNull(kbaseConfig);
+ System.out.println("**** " + kbaseConfig.getEventListeners());
}
//@Test
public void testKBase() {
- assertNotNull(kbasebean.getKbase());
- System.out.println("********* KBASE: " + kbasebean.getKbase());
+ //assertNotNull(kbasebean.getKbase());
+ //System.out.println("********* KBASE: " + kbasebean.getKbase());
}
+
+ static class KBaseConfigBinding extends AnnotationLiteral<KBaseConfig> implements KBaseConfig
+ {
+ private String value = null;
+ public KBaseConfigBinding(String value)
+ {
+ this.value = value;
+ }
+
+ public String name() {
+ return value;
+ }
+ }
}
More information about the seam-commits
mailing list