Skip to content
Merged
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 @@ -46,16 +46,17 @@
import org.apache.hadoop.util.JarFinder;
import org.apache.hadoop.util.ToolRunner;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.capacity.CapacitySchedulerConfiguration;
import org.junit.After;
import org.junit.Assert;
import static org.junit.Assert.*;
import static org.slf4j.LoggerFactory.getLogger;
import static org.assertj.core.api.Assertions.assertThat;

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.event.Level;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.slf4j.LoggerFactory.getLogger;

/**
* test {@link HadoopArchives}
*/
Expand Down Expand Up @@ -104,7 +105,7 @@ private static String createFile(Path root, FileSystem fs, byte[] fileContent, S
return sb.toString();
}

@Before
@BeforeEach
public void setUp() throws Exception {
conf = new Configuration();
conf.set(CapacitySchedulerConfiguration.PREFIX
Expand Down Expand Up @@ -133,7 +134,7 @@ public void setUp() throws Exception {
fileList.add(createFile(inputPath, fs, "c"));
}

@After
@AfterEach
public void tearDown() throws Exception {
if (dfscluster != null) {
dfscluster.shutdown();
Expand All @@ -155,7 +156,7 @@ public void testRelativePath() throws Exception {

// compare results:
final List<String> harPaths = lsr(shell, fullHarPathStr);
Assert.assertEquals(originalPaths, harPaths);
assertEquals(originalPaths, harPaths);
}

@Test
Expand All @@ -173,7 +174,7 @@ public void testRelativePathWitRepl() throws Exception {

// compare results:
final List<String> harPaths = lsr(shell, fullHarPathStr);
Assert.assertEquals(originalPaths, harPaths);
assertEquals(originalPaths, harPaths);
}

@Test
Expand All @@ -194,10 +195,10 @@ public void testOutputPathValidity() throws Exception {
createFile(archivePath, fs, harName);
final String[] args = { "-archiveName", harName, "-p", inputPathStr, "*",
archivePath.toString() };
Assert.assertEquals(-1, ToolRunner.run(har, args));
assertEquals(-1, ToolRunner.run(har, args));
String output = byteStream.toString();
final Path outputPath = new Path(archivePath, harName);
Assert.assertTrue(output.indexOf("Archive path: " + outputPath.toString()
assertTrue(output.indexOf("Archive path: " + outputPath.toString()
+ " already exists") != -1);

byteStream.reset();
Expand All @@ -207,9 +208,9 @@ public void testOutputPathValidity() throws Exception {
final Path archivePath2 = new Path(archivePath, "sub1");
final String[] args2 = { "-archiveName", harName, "-p", inputPathStr, "*",
archivePath2.toString() };
Assert.assertEquals(-1, ToolRunner.run(har, args2));
assertEquals(-1, ToolRunner.run(har, args2));
output = byteStream.toString();
Assert.assertTrue(output.indexOf("Destination " + archivePath2.toString()
assertTrue(output.indexOf("Destination " + archivePath2.toString()
+ " should be a directory but is a file") != -1);

System.setErr(stderr);
Expand Down Expand Up @@ -239,7 +240,7 @@ public void testPathWithSpaces() throws Exception {

// compare results
final List<String> harPaths = lsr(shell, fullHarPathStr);
Assert.assertEquals(originalPaths, harPaths);
assertEquals(originalPaths, harPaths);
}

@Test
Expand All @@ -258,7 +259,7 @@ public void testSingleFile() throws Exception {

// compare results:
final List<String> harPaths = lsr(shell, fullHarPathStr);
Assert.assertEquals(originalPaths, harPaths);
assertEquals(originalPaths, harPaths);
}

@Test
Expand All @@ -283,7 +284,7 @@ public void testGlobFiles() throws Exception {
// compare results:
final List<String> harPaths = lsr(shell, fullHarPathStr,
fullHarPathStr + "/" + glob);
Assert.assertEquals(originalPaths, harPaths);
assertEquals(originalPaths, harPaths);
}

private static List<String> lsr(final FsShell shell, String rootDir) throws Exception {
Expand All @@ -302,7 +303,7 @@ private static List<String> lsr(final FsShell shell, String rootDir,
System.setErr(out);
final String results;
try {
Assert.assertEquals(0, shell.run(new String[] { "-lsr", dir }));
assertEquals(0, shell.run(new String[]{"-lsr", dir}));
results = bytes.toString();
} finally {
IOUtils.closeStream(out);
Expand Down Expand Up @@ -605,7 +606,7 @@ private static byte[] readAllWithSeek(final int totalLength,
private static void expectSeekIOE(FSDataInputStream fsdis, long seekPos, String message) {
try {
fsdis.seek(seekPos);
assertTrue(message + " (Position = " + fsdis.getPos() + ")", false);
assertTrue(false, message + " (Position = " + fsdis.getPos() + ")");
} catch (IOException ioe) {
// okay
}
Expand Down Expand Up @@ -764,7 +765,7 @@ private String makeArchiveWithRepl() throws Exception {
while (listFiles.hasNext()) {
LocatedFileStatus next = listFiles.next();
if (!next.getPath().toString().endsWith("_SUCCESS")) {
assertEquals(next.getPath().toString(), 2, next.getReplication());
assertEquals(2, next.getReplication(), next.getPath().toString());
}
}
return fullHarPathStr;
Expand Down