Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parametrize inclusion of Eclipse-compatibility plugin in pom.xml
- Loading branch information
Showing
18 changed files
with
244 additions
and
0 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
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 |
---|---|---|
|
@@ -4,3 +4,4 @@ version=0.1-SNAPSHOT | |
groupId=archetype.it | ||
artifactId=basic | ||
droolsVersion=6.1.0.CR2 | ||
pomEclipseCompatible=true |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
src/test/resources/projects/integrationtestNoEclipse/archetype.properties
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,7 @@ | ||
#Sun Sep 07 11:34:37 CEST 2014 | ||
package=it.pkg | ||
version=0.1-SNAPSHOT | ||
groupId=archetype.it | ||
artifactId=basic | ||
droolsVersion=6.1.0.CR2 | ||
pomEclipseCompatible=false |
Empty file.
72 changes: 72 additions & 0 deletions
72
src/test/resources/projects/integrationtestNoEclipse/reference/pom.xml
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,72 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>archetype.it</groupId> | ||
<artifactId>basic</artifactId> | ||
<version>0.1-SNAPSHOT</version> | ||
<packaging>kjar</packaging> <!-- I can use all the src/test/resources correctly, thanks to resolved DROOLS-495 --> | ||
|
||
<name>basic</name> | ||
<url>http://drools.org</url> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<drools-version>6.1.0.CR2</drools-version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.drools</groupId> | ||
<artifactId>drools-bom</artifactId> | ||
<type>pom</type> | ||
<version>${drools-version}</version> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>org.drools</groupId> | ||
<artifactId>drools-compiler</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>junit</groupId> | ||
<artifactId>junit</artifactId> | ||
<version>4.11</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>1.7.2</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.kie</groupId> | ||
<artifactId>kie-maven-plugin</artifactId> | ||
<version>${drools-version}</version> | ||
<extensions>true</extensions> | ||
<!-- no more need of declaring 'object models' dependencies here, thanks to resolved DROOLS-373 --> | ||
</plugin> | ||
</plugins> | ||
|
||
</build> | ||
</project> |
34 changes: 34 additions & 0 deletions
34
...sources/projects/integrationtestNoEclipse/reference/src/main/java/it/pkg/Measurement.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,34 @@ | ||
package it.pkg; | ||
|
||
public class Measurement { | ||
private String id; | ||
private String val; | ||
|
||
public Measurement(String id, String val) { | ||
super(); | ||
this.id = id; | ||
this.val = val; | ||
} | ||
|
||
public String getId() { | ||
return id; | ||
} | ||
|
||
public String getVal() { | ||
return val; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder builder = new StringBuilder(); | ||
builder.append("Measurement ["); | ||
if (id != null) | ||
builder.append("id=").append(id).append(", "); | ||
if (val != null) | ||
builder.append("val=").append(val); | ||
builder.append("]"); | ||
return builder.toString(); | ||
} | ||
|
||
|
||
} |
4 changes: 4 additions & 0 deletions
4
...urces/projects/integrationtestNoEclipse/reference/src/main/resources/META-INF/kmodule.xml
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,4 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<kmodule xmlns="http://jboss.org/kie/6.0.0/kmodule"> | ||
<!-- see http://docs.jboss.org/drools/release/6.1.0.Final/drools-docs/html_single/index.html#d0e1112 --> | ||
</kmodule> |
18 changes: 18 additions & 0 deletions
18
src/test/resources/projects/integrationtestNoEclipse/reference/src/main/resources/rules.drl
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,18 @@ | ||
package it.pkg; | ||
|
||
global java.util.Set assertLast2m; | ||
|
||
declare Measurement | ||
@role(event) | ||
end | ||
|
||
rule "colors seen in the last 2 minutes" | ||
no-loop | ||
when | ||
accumulate ( Measurement( id == "color", $colorVal : val) over window:time(2m); | ||
$mySet : collectSet( $colorVal ) | ||
) | ||
then | ||
assertLast2m.clear(); | ||
assertLast2m.addAll($mySet); | ||
end |
86 changes: 86 additions & 0 deletions
86
.../resources/projects/integrationtestNoEclipse/reference/src/test/java/it/pkg/RuleTest.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,86 @@ | ||
package it.pkg; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.drools.core.time.SessionPseudoClock; | ||
import org.junit.Test; | ||
import org.kie.api.KieBase; | ||
import org.kie.api.KieBaseConfiguration; | ||
import org.kie.api.KieServices; | ||
import org.kie.api.builder.Message; | ||
import org.kie.api.builder.Results; | ||
import org.kie.api.conf.EventProcessingOption; | ||
import org.kie.api.definition.KiePackage; | ||
import org.kie.api.definition.rule.Rule; | ||
import org.kie.api.runtime.KieContainer; | ||
import org.kie.api.runtime.KieSession; | ||
import org.kie.api.runtime.KieSessionConfiguration; | ||
import org.kie.api.runtime.conf.ClockTypeOption; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class RuleTest { | ||
static final Logger LOG = LoggerFactory.getLogger(RuleTest.class); | ||
|
||
@Test | ||
public void test() { | ||
KieServices kieServices = KieServices.Factory.get(); | ||
|
||
KieContainer kContainer = kieServices.getKieClasspathContainer(); | ||
Results verifyResults = kContainer.verify(); | ||
for (Message m : verifyResults.getMessages()) { | ||
LOG.info("{}", m); | ||
} | ||
|
||
LOG.info("Creating kieBase with STREAM option"); | ||
KieBaseConfiguration kieBaseConf = kieServices.newKieBaseConfiguration(); | ||
kieBaseConf.setOption( EventProcessingOption.STREAM ); | ||
KieBase kieBase = kContainer.newKieBase(kieBaseConf); | ||
|
||
LOG.info("There should be rules: "); | ||
for ( KiePackage kp : kieBase.getKiePackages() ) { | ||
for (Rule rule : kp.getRules()) { | ||
LOG.info("kp " + kp + " rule " + rule.getName()); | ||
} | ||
} | ||
|
||
LOG.info("Creating kieSession"); | ||
KieSessionConfiguration config = kieServices.newKieSessionConfiguration(); | ||
config.setOption( ClockTypeOption.get("pseudo") ); | ||
KieSession session = kieBase.newKieSession(config, null); | ||
SessionPseudoClock clock = session.getSessionClock(); | ||
|
||
LOG.info("Populating globals"); | ||
Set<String> check = new HashSet<String>(); | ||
session.setGlobal("assertLast2m", check); | ||
|
||
LOG.info("Now running data"); | ||
|
||
clock.advanceTime(1, TimeUnit.MINUTES); | ||
Measurement mRed= new Measurement("color", "red"); | ||
session.insert(mRed); | ||
session.fireAllRules(); | ||
|
||
clock.advanceTime(1, TimeUnit.MINUTES); | ||
Measurement mGreen= new Measurement("color", "green"); | ||
session.insert(mGreen); | ||
session.fireAllRules(); | ||
|
||
clock.advanceTime(1, TimeUnit.MINUTES); | ||
Measurement mBlue= new Measurement("color", "blue"); | ||
session.insert(mBlue); | ||
session.fireAllRules(); | ||
|
||
LOG.info("Final checks"); | ||
|
||
assertEquals("Size of object in Working Memory is 2 for the last 2", 2, session.getObjects().size()); | ||
assertFalse("contains red", check.contains("red")); | ||
assertTrue("contains green", check.contains("green")); | ||
assertTrue("contains blue", check.contains("blue")); | ||
|
||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...resources/projects/integrationtestNoEclipse/reference/src/test/resources/log4j.properties
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,14 @@ | ||
log4j.rootLogger=INFO, A1 | ||
|
||
log4j.appender.A1=org.apache.log4j.ConsoleAppender | ||
log4j.appender.A1.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.A1.layout.ConversionPattern=%d %-5p [%c] (%t) %m%n | ||
|
||
log4j.appender.A2=org.apache.log4j.DailyRollingFileAppender | ||
log4j.appender.A2.File=basic.log | ||
log4j.appender.A2.DatePattern='.'yyyy-MM-dd | ||
log4j.appender.A2.layout=org.apache.log4j.PatternLayout | ||
log4j.appender.A2.layout.ConversionPattern=%d %-5p [%c] (%t) %m%n | ||
|
||
# Print only messages of level WARN or above in the package it.pkg. | ||
#log4j.logger.it.pkg=DEBUG |