Skip to content

Commit

Permalink
replace billasurf.jar with surf project
Browse files Browse the repository at this point in the history
  • Loading branch information
tkobayas committed Nov 6, 2024
1 parent 8d916ed commit 87dd19f
Show file tree
Hide file tree
Showing 15 changed files with 284 additions and 48 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -871,48 +871,6 @@ private void unsetPrivateKeyProperties() {
KeyStoreHelper.reInit();
}

/**
* In this case we are dealing with facts which are not on the systems classpath.
*/
@Test
public void testSerializabilityWithJarFacts() throws Exception {
MapBackedClassLoader loader = new MapBackedClassLoader( this.getClass().getClassLoader() );

JarInputStream jis = new JarInputStream( this.getClass().getResourceAsStream( "/billasurf.jar" ) );

JarEntry entry = null;
byte[] buf = new byte[1024];
int len = 0;
while ( (entry = jis.getNextJarEntry()) != null ) {
if ( !entry.isDirectory() ) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
while ( (len = jis.read( buf )) >= 0 ) {
out.write( buf,
0,
len );
}
loader.addResource( entry.getName(),
out.toByteArray() );
}
}

String drl = "package foo.bar \n" +
"import com.billasurf.Board\n" +
"rule 'MyGoodRule' \n dialect 'mvel' \n when " +
" Board() " +
"then \n" +
" System.err.println(42); \n" +
"end\n";


KnowledgeBuilderConfiguration kbuilderConf = KnowledgeBuilderFactory.newKnowledgeBuilderConfiguration(null, loader);

Collection<KiePackage> kpkgs = loadKnowledgePackagesFromString(kbuilderConf, drl);

kpkgs = SerializationHelper.serializeObject( kpkgs, loader );

}

@Test
public void testEmptyRule() throws Exception {
String rule = "package org.drools.compiler.test;\n";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
<version>1.0.0</version>
<packaging>jar</packaging>

<name>only-jar-pojo-not-kjar-no-kmodule</name>
<url>http://maven.apache.org</url>
<name>Drools :: Test Coverage :: Jar without kmodule.xml</name>

<properties>
<java.module.name>org.drools.compiler.integrationtests.only.jar.pojo.not.kjar.no.kmodule</java.module.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
</properties>

<modules>
<module>surf</module>
<module>only-jar-pojo-not-kjar-no-kmodule</module>
<module>test-compiler-integration-jars-setter-overload</module>
<module>test-compiler-integration-jars-with-invoker</module>
Expand Down
70 changes: 70 additions & 0 deletions drools-test-coverage/test-compiler-integration-jars/surf/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<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>org.drools.testcoverage</groupId>
<artifactId>surf</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>Drools :: Test Coverage :: Jar with simple pojo</name>

<properties>
<java.module.name>org.drools.compiler.integrationtests.surf</java.module.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>com.coderplus.maven.plugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<executions>
<execution>
<id>rename-file</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<sourceFile>${project.build.directory}/${project.build.finalName}.jar</sourceFile>
<destinationFile>${project.build.directory}/../../../test-compiler-integration/src/test/resources/${project.artifactId}.jar</destinationFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.example.surf;

public class Board {

private String type;
private String name;
private int cost;

public int getCost() {
return cost;
}

public void setCost(int cost) {
this.cost = cost;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.example.surf;

public class Person {

private String name;
private int age;

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<properties>
<java.module.name>org.drools.compiler.integrationtests.setter.overload</java.module.name>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,36 @@
<groupId>org.drools.testcoverage</groupId>
<artifactId>test-compiler-integration-jars-with-invoker</artifactId>

<name>test-compiler-integration-jars-with-invoker</name>
<name>Drools :: Test Coverage :: Jars for Compiler integration tests built by invoker</name>

<!-- This project is to build kjars using maven-invoker-plugin when we want to
use the project version kie-maven-plugin
and specify a fixed version (e.g. 1.0.0) for the kjar -->

<properties>
<java.module.name>org.drools.compiler.integrationtests.kie.project.simple</java.module.name>
<java.module.name>org.drools.compiler.integrationtests.jars.with.invoker</java.module.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>true</maven.deploy.skip>
<org.kie.version>${project.version}</org.kie.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.kie</groupId>
<artifactId>kie-maven-plugin</artifactId>
</dependency>
</dependencies>

<build>
<plugins>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<java.module.name>org.drools.compiler.integrationtests.kie.project.simple</java.module.name>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.deploy.skip>true</maven.deploy.skip>
<maven.compiler.release>17</maven.compiler.release>
</properties>

<build>
Expand Down
1 change: 1 addition & 0 deletions drools-test-coverage/test-compiler-integration/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# specific language governing permissions and limitations
# under the License.

surf.jar
kie-project-simple-1.0.0.jar
only-jar-pojo-not-kjar-no-kmodule-1.0.0.jar
test-compiler-integration-jars-setter-overload.jar
10 changes: 10 additions & 0 deletions drools-test-coverage/test-compiler-integration/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<artifactId>only-jar-pojo-not-kjar-no-kmodule</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.drools.testcoverage</groupId>
<artifactId>surf</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -121,6 +126,11 @@
<artifactId>only-jar-pojo-not-kjar-no-kmodule</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.drools.testcoverage</groupId>
<artifactId>surf</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.thoughtworks.xstream</groupId>
Expand Down
Loading

0 comments on commit 87dd19f

Please sign in to comment.