Author: tsurdilovic
Date: 2010-04-01 16:02:17 -0400 (Thu, 01 Apr 2010)
New Revision: 12360
Added:
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseBean.java
Modified:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManager.java
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManagerConfig.java
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManager.java
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManagerConfig.java
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseTest.java
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/KBaseTest-beans.xml
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/kbasetest.drl
Log:
added more tests
Modified:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-01
16:41:50 UTC (rev 12359)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/KnowledgeBaseProducer.java 2010-04-01
20:02:17 UTC (rev 12360)
@@ -34,9 +34,10 @@
private static final Logger log =
LoggerFactory.getLogger(KnowledgeBaseProducer.class);
@Inject BeanManager manager;
- @Produces @ApplicationScoped
+ @Produces //@ApplicationScoped
public KnowledgeBase produceKBase(KnowledgeBaseConfig kbaseConfig) throws Exception
{
+ System.out.println("***KBASEPRODUCER CONFIG IS: " + kbaseConfig);
KnowledgeBuilder kbuilder =
KnowledgeBuilderFactory.newKnowledgeBuilder(getKnowledgeBuilderConfiguration(kbaseConfig));
for (String nextResource : kbaseConfig.getRuleResources())
Modified:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManager.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManager.java 2010-04-01
16:41:50 UTC (rev 12359)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManager.java 2010-04-01
20:02:17 UTC (rev 12360)
@@ -37,7 +37,7 @@
*/
public class KnowledgeBaseManager
{
- private static final Logger log =
LoggerFactory.getLogger(KnowledgeBaseManager.class);
+ /** private static final Logger log =
LoggerFactory.getLogger(KnowledgeBaseManager.class);
private KnowledgeBaseManagerConfig kbaseManagerConfig;
@@ -49,8 +49,8 @@
this.kbaseManagerConfig = kbaseManagerConfig;
}
- @Produces
- @ApplicationScoped
+ //@Produces
+ //@ApplicationScoped
public KnowledgeBase createKBase() throws Exception
{
KnowledgeBase kbase;
@@ -84,10 +84,10 @@
return kbase;
}
- public void disposeKBase(@Disposes KnowledgeBase kbase)
- {
- kbase = null;
- }
+ //public void disposeKBase(@Disposes KnowledgeBase kbase)
+ //{
+ // kbase = null;
+ // }
private void addEventListener(org.drools.KnowledgeBase kbase, String eventListener) {
try {
@@ -204,4 +204,4 @@
}
return kbaseconfig;
}
-}
\ No newline at end of file
+**/}
\ No newline at end of file
Modified:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManagerConfig.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManagerConfig.java 2010-04-01
16:41:50 UTC (rev 12359)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeBaseManagerConfig.java 2010-04-01
20:02:17 UTC (rev 12360)
@@ -10,7 +10,7 @@
*/
public class KnowledgeBaseManagerConfig
{
- private static final Pattern DIVIDER = Pattern.compile(";");
+ /** private static final Pattern DIVIDER = Pattern.compile(";");
private static final int RESOURCE_PATH = 0;
private static final int RESOURCE = 1;
private static final int RESOURCE_TYPE = 2;
@@ -113,4 +113,4 @@
-}
+**/ }
Modified:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManager.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManager.java 2010-04-01
16:41:50 UTC (rev 12359)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManager.java 2010-04-01
20:02:17 UTC (rev 12360)
@@ -39,7 +39,7 @@
*/
public class KnowledgeSessionManager
{
- private static final Logger log =
LoggerFactory.getLogger(KnowledgeSessionManager.class);
+ /** private static final Logger log =
LoggerFactory.getLogger(KnowledgeSessionManager.class);
private KnowledgeSessionManagerConfig ksessionManagerConfig;
private Map<Integer, KnowledgeRuntimeLogger> statefulKnowledgeLoggers = new
Hashtable<Integer, KnowledgeRuntimeLogger>();
@@ -53,8 +53,8 @@
this.ksessionManagerConfig = ksessionManagerConfig;
}
- @Produces
- @Any
+ //@Produces
+ //@Any
public StatefulKnowledgeSession getStatefulSession(InjectionPoint ip,
Instance<KnowledgeBase> kbase) throws Exception
{
StatefulKnowledgeSession ksession = kbase.select(ip.getQualifiers().toArray(new
Annotation[0])).get().newStatefulKnowledgeSession(getKSessionConfig(), null);
@@ -65,14 +65,14 @@
return ksession;
}
- public void disposeStatefulSession(@Disposes StatefulKnowledgeSession
statefulSession)
- {
- if (statefulKnowledgeLoggers.get(statefulSession.getId()) != null)
- {
- statefulKnowledgeLoggers.get(statefulSession.getId()).close();
- }
- statefulSession.dispose();
- }
+ //public void disposeStatefulSession(@Disposes StatefulKnowledgeSession
statefulSession)
+ //{
+ // if (statefulKnowledgeLoggers.get(statefulSession.getId()) != null)
+ // {
+ // statefulKnowledgeLoggers.get(statefulSession.getId()).close();
+ // }
+ // statefulSession.dispose();
+ // }
@Produces
@Any
@@ -183,4 +183,4 @@
}
-}
+**/}
Modified:
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManagerConfig.java
===================================================================
---
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManagerConfig.java 2010-04-01
16:41:50 UTC (rev 12359)
+++
modules/drools/trunk/core/src/main/java/org/jboss/seam/drools/old/KnowledgeSessionManagerConfig.java 2010-04-01
20:02:17 UTC (rev 12360)
@@ -10,7 +10,7 @@
*/
public class KnowledgeSessionManagerConfig
{
- private static final Pattern DIVIDER = Pattern.compile(";");
+ /** private static final Pattern DIVIDER = Pattern.compile(";");
private static final int WORKITEMHANDLER_NAME = 0;
private static final int WORKITEMHANDLER_TYPE = 1;
private static final int AUDIT_LOG_TYPE = 0;
@@ -103,4 +103,4 @@
this.knowledgeSessionConfigProp = knowledgeSessionConfigProp;
}
-}
+**/}
Added: modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseBean.java
===================================================================
--- modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseBean.java
(rev 0)
+++
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseBean.java 2010-04-01
20:02:17 UTC (rev 12360)
@@ -0,0 +1,28 @@
+package org.jboss.seam.drools.kbase;
+
+import org.drools.KnowledgeBase;
+import org.jboss.seam.drools.config.KnowledgeBaseConfig;
+
+public class KBaseBean
+{
+ private KnowledgeBaseConfig kbaseconfig;
+ private KnowledgeBase kbase;
+ public KnowledgeBaseConfig getKbaseconfig()
+ {
+ return kbaseconfig;
+ }
+ public void setKbaseconfig(KnowledgeBaseConfig kbaseconfig)
+ {
+ this.kbaseconfig = kbaseconfig;
+ }
+ public KnowledgeBase getKbase()
+ {
+ return kbase;
+ }
+ public void setKbase(KnowledgeBase kbase)
+ {
+ this.kbase = kbase;
+ }
+
+
+}
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
16:41:50 UTC (rev 12359)
+++
modules/drools/trunk/core/src/test/java/org/jboss/seam/drools/kbase/KBaseTest.java 2010-04-01
20:02:17 UTC (rev 12360)
@@ -10,7 +10,7 @@
import org.jboss.arquillian.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.seam.drools.KnowledgeBaseProducer;
-import org.jboss.seam.drools.qualifier.KBase;
+import org.jboss.seam.drools.config.KnowledgeBaseConfig;
import org.jboss.shrinkwrap.api.ArchivePaths;
import org.jboss.shrinkwrap.api.Archives;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
@@ -23,20 +23,32 @@
@Deployment
public static JavaArchive createTestArchive()
{
- return Archives.create("kbasetest.jar", JavaArchive.class)
+ 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")
.addManifestResource(KBaseTest.class.getPackage().getName().replaceAll("\\.",
"/") + "/KBaseTest-beans.xml",
ArchivePaths.create("beans.xml"));
}
+
+ @Inject KBaseBean kbasebean;
- @Inject @KBase(name="kbase1") KnowledgeBase kbase;
+ @Test
+ public void testBaseBase() {
+ assertNotNull(kbasebean);
+ }
@Test
+ public void testKBaseConfig() {
+ assertNotNull(kbasebean.getKbaseconfig());
+ }
+
+ //@Test
public void testKBase() {
- assertNotNull(kbase);
+ assertNotNull(kbasebean.getKbase());
+ System.out.println("********* KBASE: " + kbasebean.getKbase());
}
}
Modified:
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/KBaseTest-beans.xml
===================================================================
---
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/KBaseTest-beans.xml 2010-04-01
16:41:50 UTC (rev 12359)
+++
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/KBaseTest-beans.xml 2010-04-01
20:02:17 UTC (rev 12360)
@@ -1,31 +1,45 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<beans
xmlns="http://java.sun.com/xml/ns/javaee"
+<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"
- xmlns:drools-config="urn:java:org.jboss.seam.drools.config"
- xmlns:drools-qualifier="urn:java:org.jboss.seam.drools.qualifier">
-
- <drools-config:KnowledgeBaseConfig>
- <s:overrides/>
- <drools-qualifier:KBaseConfig name="kbaseconfig1"/>
-
<drools-config:knowledgeBuilderConfig>kbuilderconfig.properties</drools-config:knowledgeBuilderConfig>
-
<drools-config:knowledgeBaseConfig>kbaseconfig.properties</drools-config:knowledgeBaseConfig>
- <drools-config:ruleResources>
- <s:value>classpath:kbasetest.drl:DRL</s:value>
- </drools-config:ruleResources>
- <drools-config:eventListeners>
-
<s:value>org.drools.event.knowledgebase.DefaultKnowledgeBaseEventListener</s:value>
- </drools-config:eventListeners>
- </drools-config:KnowledgeBaseConfig>
-
- <drools:KnowledgeBaseProducer>
- <s:specializes/>
- <drools:produceKBase>
- <drools-qualifier:KBase name="kbase1"/>
- <s:Inject/>
- <drools-qualifier:KBaseConfig name="kbaseconfig1"/>
- </drools:produceKBase>
- </drools:KnowledgeBaseProducer>
-
+ 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>
+ <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>
+
+ <drools-test:KBaseBean>
+ <drools-test:kbaseconfig>
+ <drools-qualifier:KBaseConfig name="kbaseconfig1" />
+ <s:Inject/>
+ </drools-test:kbaseconfig>
+ <drools-test:kbase>
+ <drools-qualifier:KBase name="kbase1" />
+ <s:Inject/>
+ </drools-test:kbase>
+ </drools-test:KBaseBean>
+
</beans>
\ No newline at end of file
Modified:
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/kbasetest.drl
===================================================================
---
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/kbasetest.drl 2010-04-01
16:41:50 UTC (rev 12359)
+++
modules/drools/trunk/core/src/test/resources/org/jboss/seam/drools/kbase/kbasetest.drl 2010-04-01
20:02:17 UTC (rev 12360)
@@ -1,29 +1,6 @@
-#created on: Apr 1, 2010
package org.jboss.seam.drools.kbase
-#list any import classes here.
-
-
-
-#declare any global variables here
-
-
-
-
-rule "Your First Rule"
-
- when
- #conditions
+rule "dummy"
then
- #actions
-
+ System.out.println("in dummy action");
end
-
-rule "Your Second Rule"
- #include attributes such as "salience" here...
- when
- #conditions
- then
- #actions
-
-end