Skip to content

HADOOP-19550. Migrate ViewFileSystemBaseTest to Junit 5 #7646

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: trunk
Choose a base branch
from
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 @@ -18,10 +18,6 @@
package org.apache.hadoop.fs.viewfs;


import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.io.IOException;
import java.net.URI;

Expand All @@ -32,11 +28,17 @@
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import static org.apache.hadoop.fs.FileSystem.TRASH_PREFIX;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

import org.apache.hadoop.security.UserGroupInformation;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -54,7 +56,7 @@ public class TestViewFileSystemLocalFileSystem extends ViewFileSystemBaseTest {
LoggerFactory.getLogger(TestViewFileSystemLocalFileSystem.class);

@Override
@Before
@BeforeEach
public void setUp() throws Exception {
// create the test root on local_fs
fsTarget = FileSystem.getLocal(new Configuration());
Expand Down Expand Up @@ -96,10 +98,10 @@ public void testNflyWriteSimple() throws IOException {
FileSystem lfs = FileSystem.getLocal(testConf);
for (final URI testUri : testUris) {
final Path testFile = new Path(new Path(testUri), testFileName);
assertTrue(testFile + " should exist!", lfs.exists(testFile));
assertTrue(lfs.exists(testFile), testFile + " should exist!");
final FSDataInputStream fsdis = lfs.open(testFile);
try {
assertEquals("Wrong file content", testString, fsdis.readUTF());
assertEquals(fsdis.readUTF(), testString, "Wrong file content");
} finally {
fsdis.close();
}
Expand All @@ -122,14 +124,14 @@ public void testNflyInvalidMinReplication() throws Exception {
FileSystem.get(URI.create("viewfs://mt/"), conf);
fail("Expected bad minReplication exception.");
} catch (IOException ioe) {
assertTrue("No minReplication message",
ioe.getMessage().contains("Minimum replication"));
assertTrue(ioe.getMessage().contains("Minimum replication"),
"No minReplication message");
}
}


@Override
@After
@AfterEach
public void tearDown() throws Exception {
fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);
super.tearDown();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
import org.apache.hadoop.fs.Path;
import static org.apache.hadoop.fs.FileSystem.TRASH_PREFIX;
import org.apache.hadoop.security.UserGroupInformation;

import java.io.IOException;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

/**
*
Expand All @@ -45,7 +46,7 @@ public class TestViewFileSystemWithAuthorityLocalFileSystem extends ViewFileSyst
URI schemeWithAuthority;

@Override
@Before
@BeforeEach
public void setUp() throws Exception {
// create the test root on local_fs
fsTarget = FileSystem.getLocal(new Configuration());
Expand All @@ -59,7 +60,7 @@ public void setUp() throws Exception {
}

@Override
@After
@AfterEach
public void tearDown() throws Exception {
fsTarget.delete(fileSystemTestHelper.getTestRootPath(fsTarget), true);
super.tearDown();
Expand All @@ -75,16 +76,15 @@ Path getTrashRootInFallBackFS() throws IOException {
@Override
@Test
public void testBasicPaths() {
Assert.assertEquals(schemeWithAuthority,
fsView.getUri());
Assert.assertEquals(fsView.makeQualified(
new Path("/user/" + System.getProperty("user.name"))),
fsView.getWorkingDirectory());
Assert.assertEquals(fsView.makeQualified(
new Path("/user/" + System.getProperty("user.name"))),
fsView.getHomeDirectory());
Assert.assertEquals(
new Path("/foo/bar").makeQualified(schemeWithAuthority, null),
fsView.makeQualified(new Path("/foo/bar")));
Assertions.assertEquals(fsView.getUri(), schemeWithAuthority);
Assertions.assertEquals(fsView.getWorkingDirectory(),
fsView.makeQualified(
new Path("/user/" + System.getProperty("user.name"))));
Assertions.assertEquals(fsView.getHomeDirectory(),
fsView.makeQualified(
new Path("/user/" + System.getProperty("user.name"))));
Assertions.assertEquals(
fsView.makeQualified(new Path("/foo/bar")),
new Path("/foo/bar").makeQualified(schemeWithAuthority, null));
}
}
Loading