HADOOP-16512. [hadoop-tools] Fix order of actual and expected expression in assert statements
Signed-off-by: Akira Ajisaka <aajisaka@apache.org>
This commit is contained in:
parent
022fe5f5b2
commit
14cd969b6e
@ -92,6 +92,11 @@
|
|||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.slf4j.LoggerFactory.getLogger;
|
import static org.slf4j.LoggerFactory.getLogger;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -400,7 +401,7 @@ public void testReadFileContent() throws Exception {
|
|||||||
readFileCount++;
|
readFileCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assertEquals(fileList.size(), readFileCount);
|
assertThat(fileList.size()).isEqualTo(readFileCount);
|
||||||
} finally {
|
} finally {
|
||||||
harFileSystem.close();
|
harFileSystem.close();
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,11 @@
|
|||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
import org.junit.AfterClass;
|
import org.junit.AfterClass;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -205,8 +206,8 @@ public void testBuildListing() {
|
|||||||
Assert.fail("Duplicates not detected");
|
Assert.fail("Duplicates not detected");
|
||||||
} catch (DuplicateFileException ignore) {
|
} catch (DuplicateFileException ignore) {
|
||||||
}
|
}
|
||||||
Assert.assertEquals(listing.getBytesToCopy(), 10);
|
assertThat(listing.getBytesToCopy()).isEqualTo(10);
|
||||||
Assert.assertEquals(listing.getNumberOfPaths(), 3);
|
assertThat(listing.getNumberOfPaths()).isEqualTo(3);
|
||||||
TestDistCpUtils.delete(fs, "/tmp");
|
TestDistCpUtils.delete(fs, "/tmp");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
package org.apache.hadoop.tools;
|
package org.apache.hadoop.tools;
|
||||||
|
|
||||||
import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
|
import static org.apache.hadoop.test.GenericTestUtils.assertExceptionContains;
|
||||||
|
import static org.assertj.core.api.Assertions.within;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -106,14 +108,14 @@ public void testParsebandwidth() {
|
|||||||
DistCpOptions options = OptionsParser.parse(new String[] {
|
DistCpOptions options = OptionsParser.parse(new String[] {
|
||||||
"hdfs://localhost:8020/source/first",
|
"hdfs://localhost:8020/source/first",
|
||||||
"hdfs://localhost:8020/target/"});
|
"hdfs://localhost:8020/target/"});
|
||||||
Assert.assertEquals(options.getMapBandwidth(), 0, DELTA);
|
assertThat(options.getMapBandwidth()).isCloseTo(0f, within(DELTA));
|
||||||
|
|
||||||
options = OptionsParser.parse(new String[] {
|
options = OptionsParser.parse(new String[] {
|
||||||
"-bandwidth",
|
"-bandwidth",
|
||||||
"11.2",
|
"11.2",
|
||||||
"hdfs://localhost:8020/source/first",
|
"hdfs://localhost:8020/source/first",
|
||||||
"hdfs://localhost:8020/target/"});
|
"hdfs://localhost:8020/target/"});
|
||||||
Assert.assertEquals(options.getMapBandwidth(), 11.2, DELTA);
|
assertThat(options.getMapBandwidth()).isCloseTo(11.2f, within(DELTA));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected=IllegalArgumentException.class)
|
@Test(expected=IllegalArgumentException.class)
|
||||||
@ -256,21 +258,21 @@ public void testParseMaps() {
|
|||||||
DistCpOptions options = OptionsParser.parse(new String[] {
|
DistCpOptions options = OptionsParser.parse(new String[] {
|
||||||
"hdfs://localhost:8020/source/first",
|
"hdfs://localhost:8020/source/first",
|
||||||
"hdfs://localhost:8020/target/"});
|
"hdfs://localhost:8020/target/"});
|
||||||
Assert.assertEquals(options.getMaxMaps(), DistCpConstants.DEFAULT_MAPS);
|
assertThat(options.getMaxMaps()).isEqualTo(DistCpConstants.DEFAULT_MAPS);
|
||||||
|
|
||||||
options = OptionsParser.parse(new String[] {
|
options = OptionsParser.parse(new String[] {
|
||||||
"-m",
|
"-m",
|
||||||
"1",
|
"1",
|
||||||
"hdfs://localhost:8020/source/first",
|
"hdfs://localhost:8020/source/first",
|
||||||
"hdfs://localhost:8020/target/"});
|
"hdfs://localhost:8020/target/"});
|
||||||
Assert.assertEquals(options.getMaxMaps(), 1);
|
assertThat(options.getMaxMaps()).isEqualTo(1);
|
||||||
|
|
||||||
options = OptionsParser.parse(new String[] {
|
options = OptionsParser.parse(new String[] {
|
||||||
"-m",
|
"-m",
|
||||||
"0",
|
"0",
|
||||||
"hdfs://localhost:8020/source/first",
|
"hdfs://localhost:8020/source/first",
|
||||||
"hdfs://localhost:8020/target/"});
|
"hdfs://localhost:8020/target/"});
|
||||||
Assert.assertEquals(options.getMaxMaps(), 1);
|
assertThat(options.getMaxMaps()).isEqualTo(1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
OptionsParser.parse(new String[] {
|
OptionsParser.parse(new String[] {
|
||||||
@ -389,13 +391,13 @@ public void testCopyStrategy() {
|
|||||||
"-f",
|
"-f",
|
||||||
"hdfs://localhost:8020/source/first",
|
"hdfs://localhost:8020/source/first",
|
||||||
"hdfs://localhost:8020/target/"});
|
"hdfs://localhost:8020/target/"});
|
||||||
Assert.assertEquals(options.getCopyStrategy(), "dynamic");
|
assertThat(options.getCopyStrategy()).isEqualTo("dynamic");
|
||||||
|
|
||||||
options = OptionsParser.parse(new String[] {
|
options = OptionsParser.parse(new String[] {
|
||||||
"-f",
|
"-f",
|
||||||
"hdfs://localhost:8020/source/first",
|
"hdfs://localhost:8020/source/first",
|
||||||
"hdfs://localhost:8020/target/"});
|
"hdfs://localhost:8020/target/"});
|
||||||
Assert.assertEquals(options.getCopyStrategy(), DistCpConstants.UNIFORMSIZE);
|
assertThat(options.getCopyStrategy()).isEqualTo(DistCpConstants.UNIFORMSIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -563,7 +565,7 @@ public void testOptionsAppendToConf() {
|
|||||||
conf = new Configuration();
|
conf = new Configuration();
|
||||||
Assert.assertFalse(conf.getBoolean(DistCpOptionSwitch.SYNC_FOLDERS.getConfigLabel(), false));
|
Assert.assertFalse(conf.getBoolean(DistCpOptionSwitch.SYNC_FOLDERS.getConfigLabel(), false));
|
||||||
Assert.assertFalse(conf.getBoolean(DistCpOptionSwitch.DELETE_MISSING.getConfigLabel(), false));
|
Assert.assertFalse(conf.getBoolean(DistCpOptionSwitch.DELETE_MISSING.getConfigLabel(), false));
|
||||||
Assert.assertEquals(conf.get(DistCpOptionSwitch.PRESERVE_STATUS.getConfigLabel()), null);
|
assertThat(conf.get(DistCpOptionSwitch.PRESERVE_STATUS.getConfigLabel())).isNull();
|
||||||
options = OptionsParser.parse(new String[] {
|
options = OptionsParser.parse(new String[] {
|
||||||
"-update",
|
"-update",
|
||||||
"-delete",
|
"-delete",
|
||||||
@ -575,8 +577,9 @@ public void testOptionsAppendToConf() {
|
|||||||
options.appendToConf(conf);
|
options.appendToConf(conf);
|
||||||
Assert.assertTrue(conf.getBoolean(DistCpOptionSwitch.SYNC_FOLDERS.getConfigLabel(), false));
|
Assert.assertTrue(conf.getBoolean(DistCpOptionSwitch.SYNC_FOLDERS.getConfigLabel(), false));
|
||||||
Assert.assertTrue(conf.getBoolean(DistCpOptionSwitch.DELETE_MISSING.getConfigLabel(), false));
|
Assert.assertTrue(conf.getBoolean(DistCpOptionSwitch.DELETE_MISSING.getConfigLabel(), false));
|
||||||
Assert.assertEquals(conf.get(DistCpOptionSwitch.PRESERVE_STATUS.getConfigLabel()), "U");
|
assertThat(conf.get(DistCpOptionSwitch.PRESERVE_STATUS.getConfigLabel())).isEqualTo("U");
|
||||||
Assert.assertEquals(conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1), 11.2, DELTA);
|
assertThat(conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1))
|
||||||
|
.isCloseTo(11.2f, within(DELTA));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -588,9 +591,8 @@ public void testOptionsAppendToConfDoesntOverwriteBandwidth() {
|
|||||||
"hdfs://localhost:8020/source/first",
|
"hdfs://localhost:8020/source/first",
|
||||||
"hdfs://localhost:8020/target/"});
|
"hdfs://localhost:8020/target/"});
|
||||||
options.appendToConf(conf);
|
options.appendToConf(conf);
|
||||||
Assert.assertEquals(
|
assertThat(conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1))
|
||||||
conf.getFloat(DistCpOptionSwitch.BANDWIDTH.getConfigLabel(), -1), -1.0,
|
.isCloseTo(-1.0f,within(DELTA));
|
||||||
DELTA);
|
|
||||||
|
|
||||||
conf = new Configuration();
|
conf = new Configuration();
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
@ -800,6 +802,6 @@ public void testExclusionsOption() {
|
|||||||
"/tmp/filters.txt",
|
"/tmp/filters.txt",
|
||||||
"hdfs://localhost:8020/source/first",
|
"hdfs://localhost:8020/source/first",
|
||||||
"hdfs://localhost:8020/target/"});
|
"hdfs://localhost:8020/target/"});
|
||||||
Assert.assertEquals(options.getFiltersFile(), "/tmp/filters.txt");
|
assertThat(options.getFiltersFile()).isEqualTo("/tmp/filters.txt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
import static org.apache.hadoop.test.MetricsAsserts.assertCounter;
|
import static org.apache.hadoop.test.MetricsAsserts.assertCounter;
|
||||||
import static org.apache.hadoop.test.MetricsAsserts.getLongCounter;
|
import static org.apache.hadoop.test.MetricsAsserts.getLongCounter;
|
||||||
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
|
import static org.apache.hadoop.test.MetricsAsserts.getMetrics;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
public class TestCopyMapper {
|
public class TestCopyMapper {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TestCopyMapper.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TestCopyMapper.class);
|
||||||
@ -769,7 +770,7 @@ public Integer run() {
|
|||||||
new CopyListingFileStatus(tmpFS.getFileStatus(
|
new CopyListingFileStatus(tmpFS.getFileStatus(
|
||||||
new Path(SOURCE_PATH + "/src/file"))),
|
new Path(SOURCE_PATH + "/src/file"))),
|
||||||
context);
|
context);
|
||||||
Assert.assertEquals(stubContext.getWriter().values().size(), 1);
|
assertThat(stubContext.getWriter().values().size()).isEqualTo(1);
|
||||||
Assert.assertTrue(stubContext.getWriter().values().get(0).toString().startsWith("SKIP"));
|
Assert.assertTrue(stubContext.getWriter().values().get(0).toString().startsWith("SKIP"));
|
||||||
Assert.assertTrue(stubContext.getWriter().values().get(0).toString().
|
Assert.assertTrue(stubContext.getWriter().values().get(0).toString().
|
||||||
contains(SOURCE_PATH + "/src/file"));
|
contains(SOURCE_PATH + "/src/file"));
|
||||||
|
@ -67,6 +67,7 @@
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
public class TestDistCpUtils {
|
public class TestDistCpUtils {
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(TestDistCpUtils.class);
|
private static final Logger LOG = LoggerFactory.getLogger(TestDistCpUtils.class);
|
||||||
@ -98,39 +99,39 @@ public static void destroy() {
|
|||||||
public void testGetRelativePathRoot() {
|
public void testGetRelativePathRoot() {
|
||||||
Path root = new Path("/");
|
Path root = new Path("/");
|
||||||
Path child = new Path("/a");
|
Path child = new Path("/a");
|
||||||
Assert.assertEquals(DistCpUtils.getRelativePath(root, child), "/a");
|
assertThat(DistCpUtils.getRelativePath(root, child)).isEqualTo("/a");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetRelativePath() {
|
public void testGetRelativePath() {
|
||||||
Path root = new Path("/tmp/abc");
|
Path root = new Path("/tmp/abc");
|
||||||
Path child = new Path("/tmp/abc/xyz/file");
|
Path child = new Path("/tmp/abc/xyz/file");
|
||||||
Assert.assertEquals(DistCpUtils.getRelativePath(root, child), "/xyz/file");
|
assertThat(DistCpUtils.getRelativePath(root, child)).isEqualTo("/xyz/file");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPackAttributes() {
|
public void testPackAttributes() {
|
||||||
EnumSet<FileAttribute> attributes = EnumSet.noneOf(FileAttribute.class);
|
EnumSet<FileAttribute> attributes = EnumSet.noneOf(FileAttribute.class);
|
||||||
Assert.assertEquals(DistCpUtils.packAttributes(attributes), "");
|
assertThat(DistCpUtils.packAttributes(attributes)).isEqualTo("");
|
||||||
|
|
||||||
attributes.add(FileAttribute.REPLICATION);
|
attributes.add(FileAttribute.REPLICATION);
|
||||||
Assert.assertEquals(DistCpUtils.packAttributes(attributes), "R");
|
assertThat(DistCpUtils.packAttributes(attributes)).isEqualTo("R");
|
||||||
|
|
||||||
attributes.add(FileAttribute.BLOCKSIZE);
|
attributes.add(FileAttribute.BLOCKSIZE);
|
||||||
Assert.assertEquals(DistCpUtils.packAttributes(attributes), "RB");
|
assertThat(DistCpUtils.packAttributes(attributes)).isEqualTo("RB");
|
||||||
|
|
||||||
attributes.add(FileAttribute.USER);
|
attributes.add(FileAttribute.USER);
|
||||||
attributes.add(FileAttribute.CHECKSUMTYPE);
|
attributes.add(FileAttribute.CHECKSUMTYPE);
|
||||||
Assert.assertEquals(DistCpUtils.packAttributes(attributes), "RBUC");
|
assertThat(DistCpUtils.packAttributes(attributes)).isEqualTo("RBUC");
|
||||||
|
|
||||||
attributes.add(FileAttribute.GROUP);
|
attributes.add(FileAttribute.GROUP);
|
||||||
Assert.assertEquals(DistCpUtils.packAttributes(attributes), "RBUGC");
|
assertThat(DistCpUtils.packAttributes(attributes)).isEqualTo("RBUGC");
|
||||||
|
|
||||||
attributes.add(FileAttribute.PERMISSION);
|
attributes.add(FileAttribute.PERMISSION);
|
||||||
Assert.assertEquals(DistCpUtils.packAttributes(attributes), "RBUGPC");
|
assertThat(DistCpUtils.packAttributes(attributes)).isEqualTo("RBUGPC");
|
||||||
|
|
||||||
attributes.add(FileAttribute.TIMES);
|
attributes.add(FileAttribute.TIMES);
|
||||||
Assert.assertEquals(DistCpUtils.packAttributes(attributes), "RBUGPCT");
|
assertThat(DistCpUtils.packAttributes(attributes)).isEqualTo("RBUGPCT");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -111,5 +111,10 @@
|
|||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.assertj</groupId>
|
||||||
|
<artifactId>assertj-core</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
@ -42,11 +42,11 @@
|
|||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tests that the KafkaSink properly formats the Kafka message.
|
* This tests that the KafkaSink properly formats the Kafka message.
|
||||||
@ -147,7 +147,7 @@ public void visit(MetricsVisitor visitor) {
|
|||||||
if (LOG.isDebugEnabled()) {
|
if (LOG.isDebugEnabled()) {
|
||||||
LOG.debug("kafka result: " + jsonResult);
|
LOG.debug("kafka result: " + jsonResult);
|
||||||
}
|
}
|
||||||
assertEquals(jsonLines.toString(), jsonResult);
|
assertThat(jsonLines.toString()).isEqualTo(jsonResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder recordToJson(MetricsRecord record) {
|
StringBuilder recordToJson(MetricsRecord record) {
|
||||||
|
Loading…
Reference in New Issue
Block a user