Author: dan.j.allen
Date: 2010-04-01 19:30:31 -0400 (Thu, 01 Apr 2010)
New Revision: 12367
Added:
modules/drools/trunk/core/src/test/resources/META-INF/
modules/drools/trunk/core/src/test/resources/META-INF/beans.xml
Modified:
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseTest.java
Log:
fix test
use beans.xml from /META-INF/beans.xml
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
23:30:04 UTC (rev 12366)
+++
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseTest.java 2010-04-01
23:30:31 UTC (rev 12367)
@@ -1,15 +1,13 @@
package org.jboss.seam.drools.kbase;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Instance;
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 junit.framework.Assert;
-import org.drools.KnowledgeBase;
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.drools.KnowledgeBaseProducer;
@@ -27,49 +25,38 @@
@Deployment
public static JavaArchive createTestArchive()
{
+ String pkgPath = KBaseTest.class.getPackage().getName().replaceAll("\\.",
"/");
return Archives.create("test.jar", JavaArchive.class)
.addPackages(true, KnowledgeBaseProducer.class.getPackage())
- .addResource(KBaseTest.class.getPackage().getName().replaceAll("\\.",
"/") + "/kbasetest.drl")
- .addResource(KBaseTest.class.getPackage().getName().replaceAll("\\.",
"/") + "/kbuilderconfig.properties")
- .addResource(KBaseTest.class.getPackage().getName().replaceAll("\\.",
"/") + "/kbaseconfig.properties")
-
.addManifestResource(KBaseTest.class.getPackage().getName().replaceAll("\\.",
"/") + "/KBaseTest-beans.xml",
- ArchivePaths.create("beans.xml"));
+ .addResource(pkgPath + "/kbasetest.drl")
+ .addResource(pkgPath + "/kbuilderconfig.properties")
+ .addResource(pkgPath + "/kbaseconfig.properties")
+ .addManifestResource("META-INF/beans.xml",
ArchivePaths.create("beans.xml"));
+ // the XML bean config module doesn't pick up the beans.xml unless it's
located at src/test/resources/META-INF/beans.xml
+ //.addManifestResource(pkgPath + "/KBaseTest-beans.xml",
ArchivePaths.create("beans.xml"));
}
-
- @Inject BeanManager manager;
+
+ @Inject @Any Instance<KnowledgeBaseConfig> kbaseConfigResolver;
+ @Inject @KBaseConfig(name = "kbaseconfig1") KnowledgeBaseConfig config;
@Test
- public void testManager() {
- assertNotNull(manager);
- }
-
- @Test
public void testKBaseConfig() {
- 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));
-
+ Assert.assertFalse(kbaseConfigResolver.select(new
KBaseConfigBinding("kbaseconfig1")).isUnsatisfied());
+ KnowledgeBaseConfig kbaseConfig = kbaseConfigResolver.select(new
KBaseConfigBinding("kbaseconfig1")).get();
assertNotNull(kbaseConfig);
System.out.println("**** " + kbaseConfig.getEventListeners());
}
- //@Test
- public void testKBase() {
- //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)
+ private String name = null;
+ public KBaseConfigBinding(String name)
{
- this.value = value;
+ this.name = name;
}
public String name() {
- return value;
+ return name;
}
}
}
Added: modules/drools/trunk/core/src/test/resources/META-INF/beans.xml
===================================================================
--- modules/drools/trunk/core/src/test/resources/META-INF/beans.xml
(rev 0)
+++ modules/drools/trunk/core/src/test/resources/META-INF/beans.xml 2010-04-01 23:30:31
UTC (rev 12367)
@@ -0,0 +1,35 @@
+<beans
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:s="urn:java:seam:core"
+ xmlns:drools="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+ xmlns:drools-qualifier="urn:java:org.jboss.seam.drools.qualifier"
+ xmlns:drools-test="urn:java:org.jboss.seam.drools.kbase">
+
+ <drools:KnowledgeBaseConfig>
+ <s:overrides/>
+ <drools-qualifier:KBaseConfig name="kbaseconfig1" />
+ <drools:knowledgeBuilderConfig>kbuilderconfig.properties</drools:knowledgeBuilderConfig>
+ <drools:knowledgeBaseConfig>kbaseconfig.properties</drools:knowledgeBaseConfig>
+ <drools:ruleResources>
+ <s:value>classpath:kbasetest.drl:DRL</s:value>
+ </drools:ruleResources>
+ <drools:eventListeners>
+ <s:value>org.drools.event.knowledgebase.DefaultKnowledgeBaseEventListener
+ </s:value>
+ </drools:eventListeners>
+ </drools:KnowledgeBaseConfig>
+
+ <drools:KnowledgeBaseProducer>
+ <s:specializes />
+ <drools:produceKBase>
+ <drools-qualifier:KBase name="kbase1" />
+ <s:parameters>
+ <drools:KnowledgeBaseConfig>
+ <s:Inject />
+ <drools-qualifier:KBaseConfig name="kbaseconfig1" />
+ </drools:KnowledgeBaseConfig>
+ </s:parameters>
+ </drools:produceKBase>
+ </drools:KnowledgeBaseProducer>
+
+</beans>
\ No newline at end of file