Skip to content

Commit 30405f5

Browse files
committed
update
1 parent 41844a5 commit 30405f5

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapred/TestTableSnapshotInputFormat.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.apache.hadoop.mapred.Reporter;
4747
import org.apache.hadoop.mapred.RunningJob;
4848
import org.apache.hadoop.mapred.lib.NullOutputFormat;
49+
import org.junit.jupiter.api.BeforeEach;
4950
import org.junit.jupiter.api.Disabled;
5051
import org.junit.jupiter.api.Tag;
5152
import org.junit.jupiter.api.Test;
@@ -60,6 +61,13 @@ public class TestTableSnapshotInputFormat extends TableSnapshotInputFormatTestBa
6061
private static final String COLUMNS =
6162
Bytes.toString(FAMILIES[0]) + " " + Bytes.toString(FAMILIES[1]);
6263

64+
private String methodName;
65+
66+
@BeforeEach
67+
public void beforeEach(TestInfo testInfo) {
68+
methodName = testInfo.getTestMethod().get().getName();
69+
}
70+
6371
@Override
6472
protected byte[] getStartRow() {
6573
return aaa;
@@ -99,8 +107,8 @@ public void close() {
99107
}
100108

101109
@Test
102-
public void testInitTableSnapshotMapperJobConfig(TestInfo testInfo) throws Exception {
103-
final TableName tableName = TableName.valueOf(testInfo.getTestMethod().get().getName());
110+
public void testInitTableSnapshotMapperJobConfig() throws Exception {
111+
final TableName tableName = TableName.valueOf(methodName);
104112
String snapshotName = "foo";
105113

106114
try {
@@ -160,7 +168,7 @@ public void testRestoreSnapshotDoesNotCreateBackRefLinksInit(TableName tableName
160168
@Override
161169
protected void testWithMockedMapReduce(HBaseTestingUtil util, String snapshotName, int numRegions,
162170
int numSplitsPerRegion, int expectedNumSplits, boolean setLocalityEnabledTo) throws Exception {
163-
final TableName tableName = TableName.valueOf("testWithMockedMapReduce");
171+
final TableName tableName = TableName.valueOf(methodName);
164172
try {
165173
createTableAndSnapshot(util, tableName, snapshotName, getStartRow(), getEndRow(), numRegions);
166174

hbase-mapreduce/src/test/java/org/apache/hadoop/hbase/mapreduce/TestImportTsvParser.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -203,19 +203,8 @@ public void testTsvParserInvalidTimestamp() throws BadTsvLineException {
203203
assertEquals(1, parser.getTimestampKeyColumnIndex());
204204
byte[] line = Bytes.toBytes("rowkey\ttimestamp\tval_a");
205205
ParsedLine parsed = parser.parse(line, line.length);
206-
assertEquals(-1, parsed.getTimestamp(-1));
207-
// The original test expected BadTsvLineException, but the code above doesn't seem to trigger it explicitly
208-
// unless parsed.getTimestamp(-1) throws it or checkParsing does.
209-
// However, looking at the original code:
210-
// @Test(expected = BadTsvLineException.class)
211-
// public void testTsvParserInvalidTimestamp() ...
212-
// So it MUST throw.
213-
// Let's wrap the part that is expected to throw.
214-
// It seems getTimestamp() or checkParsing() might throw if timestamp is invalid string?
215-
// "timestamp" string cannot be parsed as long. So getTimestamp will throw NumberFormatException?
216-
// Wait, TsvParser likely throws BadTsvLineException on bad timestamp format.
217-
// Let's assume parsed.getTimestamp(-1) throws it.
218206
assertThrows(BadTsvLineException.class, () -> parsed.getTimestamp(-1));
207+
checkParsing(parsed, Splitter.on("\t").split(Bytes.toString(line)));
219208
}
220209

221210
@Test

0 commit comments

Comments
 (0)