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
4 changes: 2 additions & 2 deletions jimfs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@

<!-- Test dependencies -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
package com.google.common.jimfs;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.google.common.collect.ImmutableMap;
import java.io.IOException;
import java.nio.file.attribute.FileAttributeView;
import java.util.Map;
import java.util.Set;
import org.junit.Before;
import org.junit.jupiter.api.BeforeEach;

/**
* Abstract base class for tests of individual {@link AttributeProvider} implementations.
Expand Down Expand Up @@ -56,7 +56,7 @@ public File lookup() throws IOException {
};
}

@Before
@BeforeEach
public void setUp() {
this.provider = createProvider();
this.file = Directory.create(0, fileTimeSource.now());
Expand Down Expand Up @@ -115,21 +115,15 @@ protected void assertSetAndGetSucceedsOnCreate(String attribute, Object value) {
assertSetAndGetSucceeds(attribute, value, true);
}

@SuppressWarnings("EmptyCatchBlock")
protected void assertSetFails(String attribute, Object value) {
try {
provider.set(file, provider.name(), attribute, value, false);
fail();
} catch (IllegalArgumentException expected) {
}
assertThrows(
IllegalArgumentException.class,
() -> provider.set(file, provider.name(), attribute, value, false));
}

@SuppressWarnings("EmptyCatchBlock")
protected void assertSetFailsOnCreate(String attribute, Object value) {
try {
provider.set(file, provider.name(), attribute, value, true);
fail();
} catch (UnsupportedOperationException expected) {
}
assertThrows(
UnsupportedOperationException.class,
() -> provider.set(file, provider.name(), attribute, value, true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.google.common.jimfs;

import org.junit.Test;
import org.junit.jupiter.api.Test;

/** @author Colin Decker */
public abstract class AbstractGlobMatcherTest extends AbstractPathMatcherTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,20 @@
import java.nio.file.Path;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import org.junit.After;
import org.junit.Before;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;

/** @author Colin Decker */
public abstract class AbstractJimfsIntegrationTest {

protected FileSystem fs;

@Before
@BeforeEach
public void setUp() throws IOException {
fs = createFileSystem();
}

@After
@AfterEach
public void tearDown() throws IOException {
fs.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

package com.google.common.jimfs;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import com.google.errorprone.annotations.CanIgnoreReturnValue;
import java.io.File;
Expand Down Expand Up @@ -54,11 +55,7 @@ public abstract class AbstractPathMatcherTest {
}

protected void assertSyntaxError(String pattern) {
try {
matcher(pattern);
fail();
} catch (PatternSyntaxException expected) {
}
assertThrows(PatternSyntaxException.class, () -> matcher(pattern));

try {
PathMatcher real = realMatcher(pattern);
Expand Down Expand Up @@ -88,12 +85,13 @@ protected final class PatternAsserter {
PatternAsserter matches(String... paths) {
for (String path : paths) {
assertTrue(
"matcher '" + matcher + "' did not match '" + path + "'", matcher.matches(fake(path)));
matcher.matches(fake(path)),
"matcher '" + matcher + "' did not match '" + path + "'");
if (realMatcher != null) {
Path realPath = Paths.get(path);
assertTrue(
"real matcher '" + realMatcher + "' did not match '" + realPath + "'",
realMatcher.matches(realPath));
realMatcher.matches(realPath),
"real matcher '" + realMatcher + "' did not match '" + realPath + "'");
}
}
return this;
Expand All @@ -103,13 +101,13 @@ PatternAsserter matches(String... paths) {
PatternAsserter doesNotMatch(String... paths) {
for (String path : paths) {
assertFalse(
"glob '" + matcher + "' should not have matched '" + path + "'",
matcher.matches(fake(path)));
matcher.matches(fake(path)),
"glob '" + matcher + "' should not have matched '" + path + "'");
if (realMatcher != null) {
Path realPath = Paths.get(path);
assertFalse(
"real matcher '" + realMatcher + "' matched '" + realPath + "'",
realMatcher.matches(realPath));
realMatcher.matches(realPath),
"real matcher '" + realMatcher + "' matched '" + realPath + "'");
}
}
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;
import static java.nio.file.StandardWatchEventKinds.OVERFLOW;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
Expand All @@ -37,22 +37,19 @@
import java.nio.file.Watchable;
import java.util.Arrays;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Tests for {@link AbstractWatchService}.
*
* @author Colin Decker
*/
@RunWith(JUnit4.class)
public class AbstractWatchServiceTest {

private AbstractWatchService watcher;

@Before
@BeforeEach
public void setUp() throws IOException {
watcher = new AbstractWatchService() {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import static java.nio.file.attribute.AclEntryPermission.APPEND_DATA;
import static java.nio.file.attribute.AclEntryPermission.DELETE;
import static java.nio.file.attribute.AclEntryType.ALLOW;
import static org.junit.Assert.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNotNull;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand All @@ -34,16 +34,13 @@
import java.nio.file.attribute.UserPrincipal;
import java.util.Map;
import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;

/**
* Tests for {@link AclAttributeProvider}.
*
* @author Colin Decker
*/
@RunWith(JUnit4.class)
public class AclAttributeProviderTest extends AbstractAttributeProviderTest<AclAttributeProvider> {

private static final UserPrincipal USER = createUserPrincipal("user");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package com.google.common.jimfs;

import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertThrows;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
Expand All @@ -28,24 +28,21 @@
import java.nio.file.attribute.FileTime;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
* Tests for {@link AttributeService}.
*
* @author Colin Decker
*/
@RunWith(JUnit4.class)
public class AttributeServiceTest {

private AttributeService service;

private final FakeFileTimeSource fileTimeSource = new FakeFileTimeSource();

@Before
@BeforeEach
public void setUp() {
ImmutableSet<AttributeProvider> providers =
ImmutableSet.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,13 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.util.Set;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;

/**
* Tests for {@link BasicAttributeProvider}.
*
* @author Colin Decker
*/
@RunWith(JUnit4.class)
public class BasicAttributeProviderTest
extends AbstractAttributeProviderTest<BasicAttributeProvider> {

Expand Down
11 changes: 4 additions & 7 deletions jimfs/src/test/java/com/google/common/jimfs/ClassLoaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package com.google.common.jimfs;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;

import com.google.common.base.MoreObjects;
import com.google.common.collect.ImmutableList;
Expand All @@ -31,9 +31,7 @@
import java.nio.file.Path;
import java.nio.file.spi.FileSystemProvider;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;

/**
* Tests behavior when user code loads Jimfs in a separate class loader from the system class loader
Expand All @@ -42,7 +40,6 @@
*
* @author Colin Decker
*/
@RunWith(JUnit4.class)
public class ClassLoaderTest {

@Test
Expand Down
34 changes: 12 additions & 22 deletions jimfs/src/test/java/com/google/common/jimfs/ConfigurationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
import static com.google.common.truth.Truth.assert_;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.assertThrows;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
Expand All @@ -38,17 +37,14 @@
import java.nio.file.Path;
import java.nio.file.WatchService;
import java.nio.file.attribute.PosixFilePermissions;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import org.junit.jupiter.api.Test;

/**
* Tests for {@link Configuration}, {@link Configuration.Builder} and file systems created from
* them.
*
* @author Colin Decker
*/
@RunWith(JUnit4.class)
public class ConfigurationTest {

private static PathSubject assertThatPath(Path path) {
Expand Down Expand Up @@ -268,11 +264,9 @@ public void testSettingRootsUnsupportedByPathType() {
}

private static void assertIllegalRoots(PathType type, String first, String... more) {
try {
Configuration.builder(type).setRoots(first, more); // wrong root
fail();
} catch (IllegalArgumentException expected) {
}
assertThrows(
IllegalArgumentException.class,
() -> Configuration.builder(type).setRoots(first, more)); // wrong root
}

@Test
Expand All @@ -296,17 +290,13 @@ public void testSettingNormalizationWhenNormalizationAlreadySet() {

private static void assertIllegalNormalizations(
PathNormalization first, PathNormalization... more) {
try {
Configuration.builder(PathType.unix()).setNameCanonicalNormalization(first, more);
fail();
} catch (IllegalArgumentException expected) {
}

try {
Configuration.builder(PathType.unix()).setNameDisplayNormalization(first, more);
fail();
} catch (IllegalArgumentException expected) {
}
assertThrows(
IllegalArgumentException.class,
() -> Configuration.builder(PathType.unix()).setNameCanonicalNormalization(first, more));

assertThrows(
IllegalArgumentException.class,
() -> Configuration.builder(PathType.unix()).setNameDisplayNormalization(first, more));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import java.net.URLClassLoader;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.junit.Test;
import org.junit.jupiter.api.Test;

/**
* A test that the {@code toPath} method of {@link SystemJimfsFileSystemProvider} handles the case
Expand Down
Loading