[seam-commits] Seam SVN: r12533 - in modules/drools/trunk/impl/src/test: java/org/jboss/seam/drools/test/flow and 5 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Apr 20 15:48:44 EDT 2010
Author: tsurdilovic
Date: 2010-04-20 15:48:43 -0400 (Tue, 20 Apr 2010)
New Revision: 12533
Added:
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTestFilter.java
modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/Person.java
modules/drools/trunk/impl/src/test/resources/META-INF/TestWorkDefinitions.conf
modules/drools/trunk/impl/src/test/resources/META-INF/drools.rulebase.conf
modules/drools/trunk/impl/src/test/resources/icons/
modules/drools/trunk/impl/src/test/resources/icons/seamlogo.png
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/FlowTest-beans.xml
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/flowtest.drl
modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/flowtest.rf
Log:
added simple flow test.
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTest.java 2010-04-20 19:48:43 UTC (rev 12533)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt 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.seam.drools.test.flow;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertNotSame;
+
+import java.util.ArrayList;
+
+import javax.enterprise.inject.Default;
+import javax.inject.Inject;
+
+import org.drools.runtime.StatefulKnowledgeSession;
+import org.jboss.arquillian.api.Deployment;
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.seam.drools.KnowledgeBaseProducer;
+import org.jboss.seam.drools.qualifiers.config.DefaultConfig;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.Archives;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.jboss.weld.extensions.resources.ResourceProvider;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+ at RunWith(Arquillian.class)
+public class FlowTest
+{
+ @Deployment
+ public static JavaArchive createTestArchive()
+ {
+ String pkgPath = FlowTest.class.getPackage().getName().replaceAll("\\.", "/");
+ JavaArchive archive = Archives.create("test.jar", JavaArchive.class)
+ .addPackages(true, new FlowTestFilter(), KnowledgeBaseProducer.class.getPackage())
+ .addPackages(true, ResourceProvider.class.getPackage())
+ .addClass(Person.class)
+ .addResource(pkgPath + "/flowtest.drl", ArchivePaths.create("flowtest.drl"))
+ .addResource(pkgPath + "/flowtest.rf", ArchivePaths.create("flowtest.rf"))
+ //.addResource(pkgPath + "/kbuilderconfig.properties", ArchivePaths.create("kbuilderconfig.properties"))
+ //.addResource(pkgPath + "/kbaseconfig.properties", ArchivePaths.create("kbaseconfig.properties"))
+ .addManifestResource(pkgPath + "/FlowTest-beans.xml", ArchivePaths.create("beans.xml"));
+ //System.out.println(archive.toString(Formatters.VERBOSE));
+ return archive;
+ }
+
+ @Inject @Default @DefaultConfig StatefulKnowledgeSession ksession;
+
+ @SuppressWarnings("unchecked")
+ @Test
+ public void testFlow() {
+ assertNotNull(ksession);
+ ksession.setGlobal("errors", new ArrayList<String>());
+ ksession.insert(new Person("Tihomir", ""));
+
+ ksession.startProcess("validationflow");
+ ksession.fireAllRules();
+
+ assertTrue( ((ArrayList<String>) ksession.getGlobal("errors")).size() == 1 );
+ assertTrue(((ArrayList<String>) ksession.getGlobal("errors")).get(0).equals("You must enter a Telephone Number"));
+
+
+ }
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTestFilter.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTestFilter.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/FlowTestFilter.java 2010-04-20 19:48:43 UTC (rev 12533)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt 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.seam.drools.test.flow;
+
+import org.jboss.shrinkwrap.api.Filter;
+
+public class FlowTestFilter implements Filter<Class<?>>
+{
+
+ public boolean include(Class<?> clazz)
+ {
+ // exclude classes in all other test packages except your own
+ if(clazz.getPackage().getName().startsWith("org.jboss.seam.drools.test")
+ && !clazz.getPackage().getName().equals(FlowTestFilter.class.getPackage().getName())) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+
+}
Added: modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/Person.java
===================================================================
--- modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/Person.java (rev 0)
+++ modules/drools/trunk/impl/src/test/java/org/jboss/seam/drools/test/flow/Person.java 2010-04-20 19:48:43 UTC (rev 12533)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt 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.seam.drools.test.flow;
+
+public class Person
+{
+ private String name;
+ private String telephoneNumber;
+
+ public Person(String name, String telphoneNumber) {
+ this.name = name;
+ this.telephoneNumber = telphoneNumber;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+ public String getTelephoneNumber()
+ {
+ return telephoneNumber;
+ }
+ public void setTelephoneNumber(String telephoneNumber)
+ {
+ this.telephoneNumber = telephoneNumber;
+ }
+
+
+}
Added: modules/drools/trunk/impl/src/test/resources/META-INF/TestWorkDefinitions.conf
===================================================================
--- modules/drools/trunk/impl/src/test/resources/META-INF/TestWorkDefinitions.conf (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/META-INF/TestWorkDefinitions.conf 2010-04-20 19:48:43 UTC (rev 12533)
@@ -0,0 +1,15 @@
+import org.drools.process.core.datatype.impl.type.StringDataType;
+[
+ // the Notification work item
+ [
+ "name" : "Notification",
+ "parameters" : [
+ "Message" : new StringDataType(),
+ "From" : new StringDataType(),
+ "To" : new StringDataType(),
+ "Priority" : new StringDataType(),
+ ],
+ "displayName" : "Notification",
+ "icon" : "icons/seamlogo.gif"
+ ]
+]
\ No newline at end of file
Added: modules/drools/trunk/impl/src/test/resources/META-INF/drools.rulebase.conf
===================================================================
--- modules/drools/trunk/impl/src/test/resources/META-INF/drools.rulebase.conf (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/META-INF/drools.rulebase.conf 2010-04-20 19:48:43 UTC (rev 12533)
@@ -0,0 +1 @@
+drools.workDefinitions = TestWorkDefinitions.conf
\ No newline at end of file
Added: modules/drools/trunk/impl/src/test/resources/icons/seamlogo.png
===================================================================
(Binary files differ)
Property changes on: modules/drools/trunk/impl/src/test/resources/icons/seamlogo.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/FlowTest-beans.xml
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/FlowTest-beans.xml (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/FlowTest-beans.xml 2010-04-20 19:48:43 UTC (rev 12533)
@@ -0,0 +1,35 @@
+<!--
+JBoss, Home of Professional Open Source
+Copyright ${year}, Red Hat, Inc., and individual contributors
+by the @authors tag. See the copyright.txt 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.
+-->
+<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:d="urn:java:org.jboss.seam.drools:org.jboss.seam.drools.config"
+ xmlns:test="urn:java:org.jboss.seam.drools.test.ksession">
+
+ <d:DefaultRuleResources>
+ <s:specializes/>
+ <d:resources>
+ <s:value>classpath;flowtest.drl;DRL</s:value>
+ <s:value>classpath;flowtest.rf;DRF</s:value>
+ </d:resources>
+ </d:DefaultRuleResources>
+
+</beans>
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/flowtest.drl
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/flowtest.drl (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/flowtest.drl 2010-04-20 19:48:43 UTC (rev 12533)
@@ -0,0 +1,21 @@
+package org.jboss.seam.drools.test.flow
+
+import org.jboss.seam.drools.test.flow.Person;
+
+global java.util.ArrayList errors;
+
+rule "Person Name Validation"
+ruleflow-group "datavalidation"
+when
+ Person(name == "")
+then
+ errors.add("You must enter a Person Name");
+end
+
+rule "Person Phone Number Validation"
+ruleflow-group "datavalidation"
+when
+ Person(telephoneNumber == "")
+then
+ errors.add("You must enter a Telephone Number");
+end
\ No newline at end of file
Added: modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/flowtest.rf
===================================================================
--- modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/flowtest.rf (rev 0)
+++ modules/drools/trunk/impl/src/test/resources/org/jboss/seam/drools/test/flow/flowtest.rf 2010-04-20 19:48:43 UTC (rev 12533)
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<process xmlns="http://drools.org/drools-5.0/process"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
+ xs:schemaLocation="http://drools.org/drools-5.0/process drools-processes-5.0.xsd"
+ type="RuleFlow" name="validationflow" id="validationflow" package-name="org.jboss.seam.drools.test.flow" >
+
+ <header>
+ </header>
+
+ <nodes>
+ <start id="1" name="Start" x="16" y="16" width="48" height="48" />
+ <end id="2" name="End" x="208" y="20" width="80" height="40" />
+ <ruleSet id="3" name="Validation" x="96" y="20" width="80" height="40" ruleFlowGroup="datavalidation" />
+ </nodes>
+
+ <connections>
+ <connection from="3" to="2" />
+ <connection from="1" to="3" />
+ </connections>
+
+</process>
\ No newline at end of file
More information about the seam-commits
mailing list