Skip to content

Commit

Permalink
[KIE-1339] fix Drools reproducible build also when running the comple…
Browse files Browse the repository at this point in the history
…te test-suite
  • Loading branch information
mariofusco committed Jun 20, 2024
1 parent 974628b commit 65a28fb
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.drools.core.util;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
Expand All @@ -35,6 +36,7 @@
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;

import org.junit.AfterClass;
import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;
Expand All @@ -52,6 +54,16 @@ public class KeyStoreHelperTest {
private static final String KEY_PASSWORD = "keypwd";
private static final String KEY_PHRASE = "secretkey";

@AfterClass
public static void cleanup() {
try {
new File(KEYSTORE_JCEKS_FILENAME).delete();
} catch (Exception e) {
// ignore
}

}

@Test
public void testSignDataWithPrivateKey() throws UnsupportedEncodingException,
UnrecoverableKeyException,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.drools.example.api.defaultkiesessionfromfile;

import java.io.File;
import java.io.PrintStream;

import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
Expand All @@ -26,9 +29,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.PrintStream;


public class DefaultKieSessionFromFileExample {

Expand Down Expand Up @@ -69,8 +69,7 @@ public static File getFile(String exampleName) {
File folder = new File("drools-examples-api").getAbsoluteFile();
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -80,14 +79,13 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
throw new RuntimeException("The target folder does not exist, please build project " + exampleName + " first");
}

for (String str : targetFolder.list()) {
if (str.startsWith(exampleName) && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
if (str.startsWith(exampleName) && str.endsWith(".jar") && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
return new File(targetFolder, str);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@
*/
package org.drools.example.api.defaultkiesessionfromfile;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintStream;

import org.junit.Test;
import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
import org.kie.api.runtime.KieContainer;
import org.kie.api.runtime.KieSession;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintStream;

import static org.junit.Assert.assertEquals;

public class DefaultKieSessionFromByteArrayExampleTest {
Expand Down Expand Up @@ -105,8 +105,7 @@ public static File getFile(String exampleName) {
File folder = new File("drools-examples-api").getAbsoluteFile();
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -116,8 +115,7 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
throw new RuntimeException("The target folder does not exist, please build project " + exampleName + " first");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.drools.example.api.kiemodulefrommultiplefiles;

import java.io.File;
import java.io.PrintStream;

import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
Expand All @@ -27,9 +30,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.PrintStream;


public class KieModuleFromMultipleFilesExample {

Expand Down Expand Up @@ -76,8 +76,7 @@ public static File getFile(String exampleName) {
File folder = new File( KieModuleFromMultipleFilesExample.class.getProtectionDomain().getCodeSource().getLocation().getPath() );
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -87,14 +86,13 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
throw new RuntimeException("The target folder does not exist, please build project " + exampleName + " first");
}

for (String str : targetFolder.list()) {
if (str.startsWith(exampleName) && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
if (str.startsWith(exampleName) && str.endsWith(".jar") && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
return new File(targetFolder, str);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.drools.example.api.kiemodulemodel;

import java.io.File;
import java.io.PrintStream;

import org.drools.base.util.Drools;
import org.kie.api.KieServices;
import org.kie.api.builder.KieBuilder;
Expand All @@ -31,9 +34,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.PrintStream;

public class KieModuleModelExample {

private static final Logger LOG = LoggerFactory.getLogger(KieModuleModelExample.class);
Expand Down Expand Up @@ -115,8 +115,7 @@ public static File getFile(String exampleName) {
File folder = new File("drools-examples-api").getAbsoluteFile();
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -126,14 +125,13 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
throw new RuntimeException("The target folder does not exist, please build project " + exampleName + " first");
}

for (String str : targetFolder.list()) {
if (str.startsWith(exampleName) && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
if (str.startsWith(exampleName) && str.endsWith(".jar") && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
return new File(targetFolder, str);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
*/
package org.drools.example.api.namedkiesessionfromfile;

import java.io.File;
import java.io.PrintStream;

import org.kie.api.KieServices;
import org.kie.api.builder.KieModule;
import org.kie.api.builder.KieRepository;
Expand All @@ -26,9 +29,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.PrintStream;


public class NamedKieSessionFromFileExample {

Expand Down Expand Up @@ -69,8 +69,7 @@ public static File getFile(String exampleName) {
File folder = new File("drools-examples-api").getAbsoluteFile();
File exampleFolder = null;
while (folder != null) {
exampleFolder = new File(folder,
exampleName);
exampleFolder = new File(folder, exampleName);
if (exampleFolder.exists()) {
break;
}
Expand All @@ -80,14 +79,13 @@ public static File getFile(String exampleName) {

if (exampleFolder != null) {

File targetFolder = new File(exampleFolder,
"target");
File targetFolder = new File(exampleFolder, "target");
if (!targetFolder.exists()) {
throw new RuntimeException("The target folder does not exist, please build project " + exampleName + " first");
}

for (String str : targetFolder.list()) {
if (str.startsWith(exampleName) && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
if (str.startsWith(exampleName) && str.endsWith(".jar") && !str.endsWith("-sources.jar") && !str.endsWith("-tests.jar") && !str.endsWith("-javadoc.jar")) {
return new File(targetFolder, str);
}
}
Expand Down

0 comments on commit 65a28fb

Please sign in to comment.