Skip to content

Commit

Permalink
chore: JUnit5 test classes and methods should have default package vi…
Browse files Browse the repository at this point in the history
…sibility (#747)
  • Loading branch information
steve-todorov authored Jul 29, 2023
1 parent ec2da03 commit c74f268
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 54 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,11 @@ jobs:
if: ${{ matrix.os == 'ubuntu-latest' && matrix.java == '11' }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
S3FS_PUBLISH_SONAR_LOGIN: ${{ secrets.SONAR_TOKEN }}
S3FS_PUBLISH_SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
S3FS_PUBLISH_SONAR_BRANCH: ${{ github.event_name == 'pull_request_target' && '' || github.head_ref || github.ref_name }}
S3FS_PUBLISH_SONAR_PR_NUMBER: ${{ env.PR_NUMBER }}
S3FS_PUBLISH_SONAR_PR_BRANCH: ${{ github.event.pull_request.head.ref }}
S3FS_PUBLISH_SONAR_PR_BASE: ${{ github.event.pull_request.base.ref }}
run: ./gradlew sonar
continue-on-error: true

Expand Down
17 changes: 16 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,23 @@ sonarqube {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.projectKey", "carlspring_s3fs-nio")
property("sonar.organization", "carlspring")
property("sonar.login", project.findProperty("s3fs.publish.sonar.login") ?: System.getenv("S3FS_PUBLISH_SONAR_LOGIN") ?: System.getenv("SONAR_TOKEN") as String)
property("sonar.token", project.findProperty("s3fs.publish.sonar.token") ?: System.getenv("S3FS_PUBLISH_SONAR_TOKEN") ?: System.getenv("SONAR_TOKEN") as String)
property("sonar.java.target", java.targetCompatibility)

val branch = project.findProperty("s3fs.publish.sonar.branch") ?: System.getenv("S3FS_PUBLISH_SONAR_BRANCH")
val prNumber = project.findProperty("s3fs.publish.sonar.pr.number") ?: System.getenv("S3FS_PUBLISH_SONAR_PR_NUMBER")
val prBranch = project.findProperty("s3fs.publish.sonar.pr.branch") ?: System.getenv("S3FS_PUBLISH_SONAR_PR_BRANCH")
val prBase = project.findProperty("s3fs.publish.sonar.pr.base") ?: System.getenv("S3FS_PUBLISH_SONAR_PR_BASE")

if(branch != "") {
property("sonar.branch.name", branch)
} else if(prNumber != "") {
property("sonar.pullrequest.key", prNumber)
property("sonar.pullrequest.branch", prBranch)
property("sonar.pullrequest.base", prBase)
} else {
property("sonar.branch.name", "undefined-branch")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
import static org.junit.jupiter.api.Assertions.assertEquals;


public class AttributesUtilsTest
class AttributesUtilsTest
{

@Test
public void filterAll()
void filterAll()
{

final String key = "key";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.spy;

public class CacheTest
class CacheTest
{


@Test
public void cacheIsInclusive()
void cacheIsInclusive()
{
Cache cache = spy(new Cache());

Expand All @@ -29,7 +28,7 @@ public void cacheIsInclusive()
}

@Test
public void outOfTime()
void outOfTime()
{
Cache cache = spy(new Cache());

Expand All @@ -44,7 +43,7 @@ public void outOfTime()
}

@Test
public void infinite()
void infinite()
{
Cache cache = spy(new Cache());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class S3FileAttributesTest
class S3FileAttributesTest
{


@Test
public void toStringPrintsBasicInfo()
void toStringPrintsBasicInfo()
{
final String key = "a key";
final FileTime fileTime = FileTime.from(100, TimeUnit.SECONDS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void getParent()
}

@Test
public void normalize()
void normalize()
{
assertEquals(forPath("/bucket"), forPath("/bucket").normalize());
assertEquals(forPath("/bucket/"), forPath("/bucket/").normalize());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class FileStoreTest
class FileStoreTest
{

FileSystem fs;
Expand Down Expand Up @@ -40,7 +40,7 @@ public void close()
}

@Test
public void getFileStore()
void getFileStore()
{
System.out.println("Default:");
System.out.println("-------");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

public class PathSpecTest
class PathSpecTest
{

FileSystem fs;
Expand Down Expand Up @@ -44,7 +44,7 @@ public void close()
// first and more

@Test
public void firstAndMore()
void firstAndMore()
{
assertEquals(fs.getPath("/dir", "dir", "file"), fs.getPath("/dir", "dir/file"));
assertEquals(fs.getPath("/dir/dir/file"), fs.getPath("/dir", "dir/file"));
Expand All @@ -53,152 +53,152 @@ public void firstAndMore()
// absolute relative

@Test
public void relative()
void relative()
{
assertFalse(get("file").isAbsolute());
}

@Test
public void absolute()
void absolute()
{
assertTrue(get("/file/file2").isAbsolute());
}

// test starts with

@Test
public void startsWith()
void startsWith()
{
assertTrue(get("/file/file1").startsWith(get("/file")));
}

@Test
public void startsWithBlank()
void startsWithBlank()
{
assertFalse(get("/file").startsWith(get("")));
}

@Test
public void startsWithBlankRelative()
void startsWithBlankRelative()
{
assertFalse(get("file1").startsWith(get("")));
}

@Test
public void startsWithBlankBlank()
void startsWithBlankBlank()
{
assertTrue(get("").startsWith(get("")));
}

@Test
public void startsWithRelativeVsAbsolute()
void startsWithRelativeVsAbsolute()
{
assertFalse(get("/file/file1").startsWith(get("file")));
}

@Test
public void startsWithFalse()
void startsWithFalse()
{
assertFalse(get("/file/file1").startsWith(get("/file/file1/file2")));
assertTrue(get("/file/file1/file2").startsWith(get("/file/file1")));
}

@Test
public void startsWithNotNormalize()
void startsWithNotNormalize()
{
assertFalse(get("/file/file1/file2").startsWith(get("/file/file1/../")));
}

@Test
public void startsWithNormalize()
void startsWithNormalize()
{
assertTrue(get("/file/file1/file2").startsWith(get("/file/file1/../").normalize()));
}

@Test
public void startsWithRelative()
void startsWithRelative()
{
assertTrue(get("file/file1").startsWith(get("file")));
}

@Test
public void startsWithString()
void startsWithString()
{
assertTrue(get("/file/file1").startsWith("/file"));
}

// ends with

@Test
public void endsWithAbsoluteRelative()
void endsWithAbsoluteRelative()
{
assertTrue(get("/file/file1").endsWith(get("file1")));
}

@Test
public void endsWithAbsoluteAbsolute()
void endsWithAbsoluteAbsolute()
{
assertTrue(get("/file/file1").endsWith(get("/file/file1")));
}

@Test
public void endsWithRelativeRelative()
void endsWithRelativeRelative()
{
assertTrue(get("file/file1").endsWith(get("file1")));
}

@Test
public void endsWithRelativeAbsolute()
void endsWithRelativeAbsolute()
{
assertFalse(get("file/file1").endsWith(get("/file")));
}

@Test
public void endsWithDifferentFileSystem()
void endsWithDifferentFileSystem()
{
assertFalse(get("/file/file1").endsWith(Paths.get("/file/file1")));
}

@Test
public void endsWithBlankRelativeAbsolute()
void endsWithBlankRelativeAbsolute()
{
assertFalse(get("").endsWith(get("/bucket")));
}

@Test
public void endsWithBlankBlank()
void endsWithBlankBlank()
{
assertTrue(get("").endsWith(get("")));
}

@Test
public void endsWithRelativeBlankAbsolute()
void endsWithRelativeBlankAbsolute()
{
assertFalse(get("/bucket/file1").endsWith(get("")));
}

@Test
public void endsWithRelativeBlankRelative()
void endsWithRelativeBlankRelative()
{
assertFalse(get("file1").endsWith(get("")));
}

@Test
public void getParentNull()
void getParentNull()
{
assertNull(get("/").getParent());
}

@Test
public void getParentWindowsNull()
void getParentWindowsNull()
{
assertNull(fsWindows.getPath("C://").getParent());
}

// file name

@Test
public void getFileName()
void getFileName()
throws IOException
{
try (FileSystem windows = MemoryFileSystemBuilder.newWindows().build("widows"))
Expand All @@ -212,7 +212,7 @@ public void getFileName()
}

@Test
public void getFileNameRootIsNull()
void getFileNameRootIsNull()
{
Path fileNameRoot = fs.getRootDirectories().iterator().next().getFileName();

Expand All @@ -222,13 +222,13 @@ public void getFileNameRootIsNull()
// root

@Test
public void getRootReturnBucket()
void getRootReturnBucket()
{
assertEquals(get("/"), get("/dir/dir/file").getRoot());
}

@Test
public void fileWithSameNameAsDir()
void fileWithSameNameAsDir()
throws IOException
{
// We're expecting an exception here to be thrown
Expand All @@ -241,7 +241,7 @@ public void fileWithSameNameAsDir()
}

@Test
public void dirWithSameNameAsFile()
void dirWithSameNameAsFile()
{
// We're expecting an exception here to be thrown
Exception exception = assertThrows(FileAlreadyExistsException.class, () -> {
Expand All @@ -253,21 +253,21 @@ public void dirWithSameNameAsFile()
}

@Test
public void createDirWithoutEndSlash()
void createDirWithoutEndSlash()
throws IOException
{
Path dir = Files.createDirectory(fs.getPath("/tmp"));
Files.isDirectory(dir);
}

@Test
public void getRootRelativeReturnNull()
void getRootRelativeReturnNull()
{
assertNull(get("dir/file").getRoot());
}

@Test
public void getRoot()
void getRoot()
{
System.out.println("Default:");
System.out.println("-------");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class ProviderSpecTest
class ProviderSpecTest
{

FileSystem fs;
Expand Down
Loading

0 comments on commit c74f268

Please sign in to comment.