Skip to content

Commit

Permalink
Merge pull request #8 from whitesource/BS/Feat/versioning
Browse files Browse the repository at this point in the history
Refactored to use Java 8 instead of 11
  • Loading branch information
BenShmuely authored Aug 17, 2021
2 parents ec6bdff + 9b067b8 commit 5340e33
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
28 changes: 15 additions & 13 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.whitesource</groupId>
<artifactId>curekit</artifactId>
<version>1.0.2</version>
<version>1.0.3</version>

<name>curekit</name>
<description>A repository containing code security remediation solutions used by WhiteSource Cure</description>
Expand Down Expand Up @@ -37,10 +37,12 @@
<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version>
<java.version>1.8</java.version>

<!-- Plugins Version -->
<maven.compiler.version>3.8.1</maven.compiler.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.version>3.6.1</maven.compiler.version>
<maven.surefire.version>3.0.0-M3</maven.surefire.version>
<nexus.staging.maven.version>1.6.7</nexus.staging.maven.version>
<maven.source.version>2.2.1</maven.source.version>
Expand All @@ -60,14 +62,14 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<release>${java.version}</release>
</configuration>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-compiler-plugin</artifactId>-->
<!-- <version>${maven.compiler.version}</version>-->
<!-- <configuration>-->
<!-- <release>${java.version}</release>-->
<!-- </configuration>-->
<!-- </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down Expand Up @@ -189,9 +191,9 @@

<profiles>
<profile>
<id>jdk-11-config</id>
<id>jdk-8-config</id>
<activation>
<jdk>11</jdk>
<jdk>8</jdk>
</activation>
<properties>
<javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Remediation Solver static class written by WhiteSource with the community ❤. Here you can find
* wrapper functions to secure unsafe operations in your code.
*/
public class FileUtils {
public class FileUtilities {

/**
* Checking if a specific file is in his relevant folder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

class FileUtilsTest {
class FileUtilitiesTest {

@Test
void isFileInDir_outside_successfullyWithResult() throws IOException {
Path sourcePath = Paths.get("src").toAbsolutePath();
Path cwd = Paths.get("").toAbsolutePath();

boolean isOutside = FileUtils.isFileOutsideDir(cwd.toString(), sourcePath.toString());
boolean isOutside = FileUtilities.isFileOutsideDir(cwd.toString(), sourcePath.toString());
Assertions.assertTrue(isOutside);
}

Expand All @@ -23,35 +23,35 @@ void isFileInDir_inside_successfullyWithResult() throws IOException {
Path sourcePath = Paths.get("src").toAbsolutePath();
Path cwd = Paths.get("").toAbsolutePath();

boolean isOutside = FileUtils.isFileOutsideDir(sourcePath.toString(), cwd.toString());
boolean isOutside = FileUtilities.isFileOutsideDir(sourcePath.toString(), cwd.toString());
Assertions.assertFalse(isOutside);
}

@Test
void isFileInDir_null_successfully() {
Assertions.assertThrows(
NullPointerException.class, () -> FileUtils.isFileOutsideDir(null, null));
NullPointerException.class, () -> FileUtilities.isFileOutsideDir(null, null));

Assertions.assertThrows(
NullPointerException.class,
() -> FileUtils.isFileOutsideDir("file-path-place-holder", null));
() -> FileUtilities.isFileOutsideDir("file-path-place-holder", null));

Assertions.assertThrows(
NullPointerException.class,
() -> FileUtils.isFileOutsideDir(null, "base-dir-place-holder"));
() -> FileUtilities.isFileOutsideDir(null, "base-dir-place-holder"));
}

@Test
void normalize_validInput_successfullyWithResult() throws IOException {
String validInput = "./In/../Valid/Un/../Normalized/./Path";
String expectedResult = "Valid" + File.separator + "Normalized" + File.separator + "Path";

String actualResult = FileUtils.normalize(validInput);
String actualResult = FileUtilities.normalize(validInput);
Assertions.assertEquals(expectedResult, actualResult);
}

@Test
void normalize_null_successfully() {
Assertions.assertNull(FileUtils.normalize(null));
Assertions.assertNull(FileUtilities.normalize(null));
}
}

0 comments on commit 5340e33

Please sign in to comment.