Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,47 +29,47 @@ protected AbstractResourceAttributesTCK() {}
protected abstract PlexusIoResourceAttributes newAttributes(String mode);

@Test
final void testSetOctalModeString_OwnerModes() {
final void setOctalModeStringOwnerModes() {
verifyStringOctalModeSet("700", new boolean[] {true, true, true, false, false, false, false, false, false});
verifyStringOctalModeSet("600", new boolean[] {true, true, false, false, false, false, false, false, false});
verifyStringOctalModeSet("400", new boolean[] {true, false, false, false, false, false, false, false, false});
verifyStringOctalModeSet("200", new boolean[] {false, true, false, false, false, false, false, false, false});
}

@Test
final void testSetOctalModeString_GroupModes() {
final void setOctalModeStringGroupModes() {
verifyStringOctalModeSet("070", new boolean[] {false, false, false, true, true, true, false, false, false});
verifyStringOctalModeSet("060", new boolean[] {false, false, false, true, true, false, false, false, false});
verifyStringOctalModeSet("040", new boolean[] {false, false, false, true, false, false, false, false, false});
verifyStringOctalModeSet("020", new boolean[] {false, false, false, false, true, false, false, false, false});
}

@Test
final void testSetOctalModeString_WorldModes() {
final void setOctalModeStringWorldModes() {
verifyStringOctalModeSet("007", new boolean[] {false, false, false, false, false, false, true, true, true});
verifyStringOctalModeSet("006", new boolean[] {false, false, false, false, false, false, true, true, false});
verifyStringOctalModeSet("004", new boolean[] {false, false, false, false, false, false, true, false, false});
verifyStringOctalModeSet("002", new boolean[] {false, false, false, false, false, false, false, true, false});
}

@Test
final void testSetOctalMode_OwnerModes() {
final void setOctalModeOwnerModes() {
verifyOctalModeSet("700", new boolean[] {true, true, true, false, false, false, false, false, false});
verifyOctalModeSet("600", new boolean[] {true, true, false, false, false, false, false, false, false});
verifyOctalModeSet("400", new boolean[] {true, false, false, false, false, false, false, false, false});
verifyOctalModeSet("200", new boolean[] {false, true, false, false, false, false, false, false, false});
}

@Test
final void testSetOctalMode_GroupModes() {
final void setOctalModeGroupModes() {
verifyOctalModeSet("070", new boolean[] {false, false, false, true, true, true, false, false, false});
verifyOctalModeSet("060", new boolean[] {false, false, false, true, true, false, false, false, false});
verifyOctalModeSet("040", new boolean[] {false, false, false, true, false, false, false, false, false});
verifyOctalModeSet("020", new boolean[] {false, false, false, false, true, false, false, false, false});
}

@Test
final void testSetOctalMode_WorldModes() {
final void setOctalModeWorldModes() {
verifyOctalModeSet("007", new boolean[] {false, false, false, false, false, false, true, true, true});
verifyOctalModeSet("006", new boolean[] {false, false, false, false, false, false, true, true, false});
verifyOctalModeSet("004", new boolean[] {false, false, false, false, false, false, true, false, false});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.codehaus.plexus.components.io.attributes;

import java.io.File;
import java.io.IOException;
import java.nio.file.attribute.PosixFilePermission;
import java.util.Set;

Expand All @@ -17,25 +16,25 @@
* @author Kristian Rosenvold
*/
@SuppressWarnings("OctalInteger")
public class AttributeUtilsTest {
class AttributeUtilsTest {
@Test
void testMiscPatterns() {
void miscPatterns() {
final Set<PosixFilePermission> permissions = AttributeUtils.getPermissions(0124);
assertTrue(permissions.contains(PosixFilePermission.OWNER_EXECUTE));
assertTrue(permissions.contains(PosixFilePermission.GROUP_WRITE));
assertTrue(permissions.contains(PosixFilePermission.OTHERS_READ));
}

@Test
void testMorePatterns() {
void morePatterns() {
final Set<PosixFilePermission> permissions = AttributeUtils.getPermissions(0241);
assertTrue(permissions.contains(PosixFilePermission.OWNER_WRITE));
assertTrue(permissions.contains(PosixFilePermission.GROUP_READ));
assertTrue(permissions.contains(PosixFilePermission.OTHERS_EXECUTE));
}

@Test
void testEvenMorePatterns() {
void evenMorePatterns() {
final Set<PosixFilePermission> permissions = AttributeUtils.getPermissions(0412);
assertTrue(permissions.contains(PosixFilePermission.OWNER_READ));
assertTrue(permissions.contains(PosixFilePermission.GROUP_EXECUTE));
Expand All @@ -50,7 +49,7 @@ void test777() {

@Test
@DisabledOnOs(OS.WINDOWS)
void testChmodBackAndForth() throws IOException {
void chmodBackAndForth() throws Exception {
final File bxx = File.createTempFile("bxx", "ff");
AttributeUtils.chmod(bxx, 0422);
PlexusIoResourceAttributes firstAttrs = new FileAttributes(bxx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;

import org.junit.jupiter.api.Test;
Expand All @@ -29,17 +28,17 @@
/**
* @author Kristian Rosenvold
*/
public class FileAttributesTest {
class FileAttributesTest {
@Test
@DisabledOnOs(OS.WINDOWS)
void testGetPosixFileAttributes() throws Exception {
void getPosixFileAttributes() throws Exception {
File file = new File(".");
PlexusIoResourceAttributes fa = new FileAttributes(file);
assertNotNull(fa);
}

@Test
void testFileAttributesHandlesIOException() throws IOException {
void fileAttributesHandlesIOException() throws Exception {
// Test that FileAttributes can be constructed for a regular file
// even if ownership information is not available (e.g., WSL2 mapped network drives)
File tempFile = Files.createTempFile("plexus-io-test", ".tmp").toFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
*/

import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.NoSuchFileException;
import java.util.Map;

import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
import org.junit.jupiter.api.Test;
Expand All @@ -34,11 +32,11 @@
import static org.junit.jupiter.api.Assertions.*;

@SuppressWarnings("OctalInteger")
public class PlexusIoResourceAttributeUtilsTest {
class PlexusIoResourceAttributeUtilsTest {

@Test
@DisabledOnOs(OS.WINDOWS)
void testGetAttributesForThisTestClass() throws IOException {
void getAttributesForThisTestClass() throws Exception {
URL resource = Thread.currentThread()
.getContextClassLoader()
.getResource(getClass().getName().replace('.', '/') + ".class");
Expand All @@ -62,7 +60,7 @@ void testGetAttributesForThisTestClass() throws IOException {

@Test
@DisabledOnOs(OS.WINDOWS)
void testDirectory() throws IOException, CommandLineException {
void directory() throws Exception {
URL resource = Thread.currentThread()
.getContextClassLoader()
.getResource(getClass().getName().replace('.', '/') + ".class");
Expand Down Expand Up @@ -100,7 +98,7 @@ void testDirectory() throws IOException, CommandLineException {

@Test
@DisabledOnOs(OS.WINDOWS)
void testSrcResource() throws IOException {
void srcResource() throws Exception {
File dir = new File("src/test/resources/symlinks");
final Map<String, PlexusIoResourceAttributes> fileAttributesByPathScreenScrape =
PlexusIoResourceAttributeUtils.getFileAttributesByPath(dir, true);
Expand All @@ -115,15 +113,14 @@ void testSrcResource() throws IOException {
}

@Test
void testNonExistingDirectory() {
assertThrows(NoSuchFileException.class, () -> {
File dir = new File("src/test/noSuchDirectory");
PlexusIoResourceAttributeUtils.getFileAttributesByPath(dir, true);
});
void nonExistingDirectory() {
File dir = new File("src/test/noSuchDirectory");
assertThrows(NoSuchFileException.class, () ->
PlexusIoResourceAttributeUtils.getFileAttributesByPath(dir, true));
}

@Test
void testMergeAttributesWithNullBase() {
void mergeAttributesWithNullBase() {
PlexusIoResourceAttributes override = new SimpleResourceAttributes(1001, "myUser", 1001, "test", 0);
PlexusIoResourceAttributes defaults = new SimpleResourceAttributes(1000, "defaultUser", 1000, "defaultTest", 0);

Expand All @@ -135,7 +132,7 @@ void testMergeAttributesWithNullBase() {
}

@Test
void testMergeAttributesWithNullOverrideGroup() {
void mergeAttributesWithNullOverrideGroup() {
final PlexusIoResourceAttributes override = new SimpleResourceAttributes(1001, "myUser", -1, null, 0);
final PlexusIoResourceAttributes defaults =
new SimpleResourceAttributes(1000, "defaultUser", 1000, "defaultGroup", 0);
Expand All @@ -148,7 +145,7 @@ void testMergeAttributesWithNullOverrideGroup() {
}

@Test
void testMergeAttributesOverride() {
void mergeAttributesOverride() {
final PlexusIoResourceAttributes blank = new SimpleResourceAttributes();
final PlexusIoResourceAttributes invalid = new SimpleResourceAttributes(-1, null, -1, null, -1);
final PlexusIoResourceAttributes override =
Expand Down Expand Up @@ -250,15 +247,15 @@ void testMergeAttributesOverride() {
}

@Test
void testFileAttributesGeneric() throws IOException {
void fileAttributesGeneric() throws Exception {
PlexusIoResourceAttributes attrs = getFileAttributes(new File("src/test/resources/symlinks/src/fileW.txt"));
assertFalse(attrs.isSymbolicLink());
assertTrue(StringUtils.isNotEmpty(attrs.getUserName()));
}

@Test
@DisabledOnOs(OS.WINDOWS)
void testFileAttributes() throws IOException {
void fileAttributes() throws Exception {
PlexusIoResourceAttributes attrs = getFileAttributes(new File("src/test/resources/symlinks/src/fileW.txt"));
assertFalse(attrs.isSymbolicLink());
assertTrue(StringUtils.isNotEmpty(attrs.getUserName()));
Expand All @@ -268,7 +265,7 @@ void testFileAttributes() throws IOException {
}

@Test
void testMergeAttributesDefault() {
void mergeAttributesDefault() {
final PlexusIoResourceAttributes blank = new SimpleResourceAttributes(null, null, null, null, 0);
final PlexusIoResourceAttributes invalid = new SimpleResourceAttributes(-1, null, -1, null, -1);
final PlexusIoResourceAttributes defaults =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
import org.junit.jupiter.api.Test;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class SymlinkUtilsTest {
class SymlinkUtilsTest {
final File target = new File("target/symlinkCapabilities");

final String expected = "This is a filed that we'll be symlinking to\n";

@BeforeEach
public void setup() throws IOException {
void setup() throws IOException {
FileUtils.deleteDirectory(target);
Files.createDirectories(target.toPath());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* Test case for the various file mappers.
*/
@PlexusTest
public class FileMapperTest {
class FileMapperTest {
@Inject
PlexusContainer container;

Expand Down Expand Up @@ -85,7 +85,7 @@ protected void testFileMapper(FileMapper pMapper, String[] pInput, String[] pOut
};

@Test
void testIdentityMapper() throws Exception {
void identityMapper() throws Exception {
final String[] results = getIdentityResults();
testFileMapper(new IdentityMapper(), SAMPLES, results);
}
Expand All @@ -98,15 +98,15 @@ private String[] getIdentityResults() {
}

@Test
void testDefaultMapper() throws Exception {
void defaultMapper() throws Exception {
final String[] results = getIdentityResults();
testFileMapper(container.lookup(FileMapper.class), SAMPLES, results);
testFileMapper(container.lookup(FileMapper.class, IdentityMapper.ROLE_HINT), SAMPLES, results);
testFileMapper(container.lookup(FileMapper.class), SAMPLES, results);
}

@Test
void testFileExtensionMapper() throws Exception {
void fileExtensionMapper() throws Exception {
final String[] results = getIdentityResults();
for (int i = 2; i <= 10; i += 2) {
results[i] += ".png";
Expand All @@ -127,7 +127,7 @@ private void testFileExtensionMapper(final String[] results, final FileExtension
}

@Test
void testFlattenMapper() throws Exception {
void flattenMapper() throws Exception {
final String[] results = getIdentityResults();
results[4] = results[6] = results[8] = results[10] = results[2];
results[5] = results[7] = results[9] = results[11] = results[3];
Expand All @@ -141,7 +141,7 @@ private void testMergeMapper(String pTargetName, String[] pResults, MergeFileMap
}

@Test
void testMergeMapper() throws Exception {
void mergeMapper() throws Exception {
final String[] results = getIdentityResults();
final String targetName = "zgh";
for (int i = 2; i < results.length; i++) {
Expand All @@ -153,7 +153,7 @@ void testMergeMapper() throws Exception {
}

@Test
void testPrefixMapper() throws Exception {
void prefixMapper() throws Exception {
final String prefix = "x7Rtf";
final String[] results = getIdentityResults();
testFileMapper(new PrefixFileMapper(), SAMPLES, results);
Expand All @@ -172,7 +172,7 @@ void testPrefixMapper() throws Exception {
}

@Test
void testSuffixMapper() throws Exception {
void suffixMapper() throws Exception {
final String suffix = "suffix";
String[] samples = Arrays.copyOf(SAMPLES, SAMPLES.length + 2);
samples[samples.length - 2] = "archive.tar.gz";
Expand Down Expand Up @@ -208,7 +208,7 @@ private RegExpFileMapper configure(RegExpFileMapper pMapper, String pPattern, St
}

@Test
void testRegExpFileMapper() throws Exception {
void regExpFileMapper() throws Exception {
final String[] results = getIdentityResults();
results[3] = "xyz.jpg";
results[5] = "b/xyz.jpg";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* Test case for implementations of {@link FileSelector}.
*/
@PlexusTest
public class FileSelectorTest {
class FileSelectorTest {

@Inject
PlexusContainer container;
Expand Down Expand Up @@ -80,7 +80,7 @@ private boolean[] getAllTrues() {
}

@Test
void testAllFilesFileSelector() throws Exception {
void allFilesFileSelector() throws Exception {
testFileSelector(new AllFilesFileSelector());
testFileSelector((AllFilesFileSelector) container.lookup(FileSelector.class));
testFileSelector((AllFilesFileSelector) container.lookup(FileSelector.class, AllFilesFileSelector.ROLE_HINT));
Expand Down Expand Up @@ -114,14 +114,14 @@ protected void testFileSelector(IncludeExcludeFileSelector pSelector) throws Exc
}

@Test
void testIncludeExcludeFileSelector() throws Exception {
void includeExcludeFileSelector() throws Exception {
testFileSelector(new IncludeExcludeFileSelector());
testFileSelector((IncludeExcludeFileSelector)
container.lookup(FileSelector.class, IncludeExcludeFileSelector.ROLE_HINT));
}

@Test
void testIncludeExcludeFileSelector_SetExcludes() {
void includeExcludeFileSelectorSetExcludes() {
IncludeExcludeFileSelector selector = new IncludeExcludeFileSelector();

// Test that the setExcludes method does not modify the excludes.
Expand Down
Loading