HADOOP-12989. Some tests in org.apache.hadoop.fs.shell.find occasionally time out. Contributed by Takashi Ohnishi.
(cherry picked from commit6e6b6dd5aa
) (cherry picked from commit5ae74507c0
)
This commit is contained in:
parent
302d499cf1
commit
71b7f1f85f
|
@ -26,12 +26,17 @@ import java.util.Deque;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|
||||||
import org.apache.hadoop.fs.shell.PathData;
|
import org.apache.hadoop.fs.shell.PathData;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestAnd {
|
public class TestAnd {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public Timeout globalTimeout = new Timeout(10000);
|
||||||
|
|
||||||
// test all expressions passing
|
// test all expressions passing
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testPass() throws IOException {
|
public void testPass() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
|
|
||||||
|
@ -56,7 +61,7 @@ public class TestAnd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the first expression failing
|
// test the first expression failing
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testFailFirst() throws IOException {
|
public void testFailFirst() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
|
|
||||||
|
@ -80,7 +85,7 @@ public class TestAnd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the second expression failing
|
// test the second expression failing
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testFailSecond() throws IOException {
|
public void testFailSecond() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
|
|
||||||
|
@ -105,7 +110,7 @@ public class TestAnd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test both expressions failing
|
// test both expressions failing
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testFailBoth() throws IOException {
|
public void testFailBoth() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
|
|
||||||
|
@ -129,7 +134,7 @@ public class TestAnd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the first expression stopping
|
// test the first expression stopping
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testStopFirst() throws IOException {
|
public void testStopFirst() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
|
|
||||||
|
@ -154,7 +159,7 @@ public class TestAnd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the second expression stopping
|
// test the second expression stopping
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testStopSecond() throws IOException {
|
public void testStopSecond() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
|
|
||||||
|
@ -179,7 +184,7 @@ public class TestAnd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test first expression stopping and second failing
|
// test first expression stopping and second failing
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testStopFail() throws IOException {
|
public void testStopFail() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
|
|
||||||
|
@ -204,7 +209,7 @@ public class TestAnd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test setOptions is called on child
|
// test setOptions is called on child
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testSetOptions() throws IOException {
|
public void testSetOptions() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
Expression first = mock(Expression.class);
|
Expression first = mock(Expression.class);
|
||||||
|
@ -224,7 +229,7 @@ public class TestAnd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test prepare is called on child
|
// test prepare is called on child
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testPrepare() throws IOException {
|
public void testPrepare() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
Expression first = mock(Expression.class);
|
Expression first = mock(Expression.class);
|
||||||
|
@ -243,7 +248,7 @@ public class TestAnd {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test finish is called on child
|
// test finish is called on child
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testFinish() throws IOException {
|
public void testFinish() throws IOException {
|
||||||
And and = new And();
|
And and = new And();
|
||||||
Expression first = mock(Expression.class);
|
Expression first = mock(Expression.class);
|
||||||
|
|
|
@ -26,12 +26,17 @@ import java.util.Deque;
|
||||||
import org.apache.hadoop.fs.shell.PathData;
|
import org.apache.hadoop.fs.shell.PathData;
|
||||||
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestFilterExpression {
|
public class TestFilterExpression {
|
||||||
private Expression expr;
|
private Expression expr;
|
||||||
private FilterExpression test;
|
private FilterExpression test;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public Timeout globalTimeout = new Timeout(10000);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setup() {
|
public void setup() {
|
||||||
expr = mock(Expression.class);
|
expr = mock(Expression.class);
|
||||||
|
@ -40,13 +45,13 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that the child expression is correctly set
|
// test that the child expression is correctly set
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void expression() throws IOException {
|
public void expression() throws IOException {
|
||||||
assertEquals(expr, test.expression);
|
assertEquals(expr, test.expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that setOptions method is called
|
// test that setOptions method is called
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void setOptions() throws IOException {
|
public void setOptions() throws IOException {
|
||||||
FindOptions options = mock(FindOptions.class);
|
FindOptions options = mock(FindOptions.class);
|
||||||
test.setOptions(options);
|
test.setOptions(options);
|
||||||
|
@ -55,7 +60,7 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the apply method is called and the result returned
|
// test the apply method is called and the result returned
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void apply() throws IOException {
|
public void apply() throws IOException {
|
||||||
PathData item = mock(PathData.class);
|
PathData item = mock(PathData.class);
|
||||||
when(expr.apply(item, -1)).thenReturn(Result.PASS).thenReturn(Result.FAIL);
|
when(expr.apply(item, -1)).thenReturn(Result.PASS).thenReturn(Result.FAIL);
|
||||||
|
@ -66,7 +71,7 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that the finish method is called
|
// test that the finish method is called
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void finish() throws IOException {
|
public void finish() throws IOException {
|
||||||
test.finish();
|
test.finish();
|
||||||
verify(expr).finish();
|
verify(expr).finish();
|
||||||
|
@ -74,7 +79,7 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that the getUsage method is called
|
// test that the getUsage method is called
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void getUsage() {
|
public void getUsage() {
|
||||||
String[] usage = new String[] { "Usage 1", "Usage 2", "Usage 3" };
|
String[] usage = new String[] { "Usage 1", "Usage 2", "Usage 3" };
|
||||||
when(expr.getUsage()).thenReturn(usage);
|
when(expr.getUsage()).thenReturn(usage);
|
||||||
|
@ -84,7 +89,7 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that the getHelp method is called
|
// test that the getHelp method is called
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void getHelp() {
|
public void getHelp() {
|
||||||
String[] help = new String[] { "Help 1", "Help 2", "Help 3" };
|
String[] help = new String[] { "Help 1", "Help 2", "Help 3" };
|
||||||
when(expr.getHelp()).thenReturn(help);
|
when(expr.getHelp()).thenReturn(help);
|
||||||
|
@ -94,7 +99,7 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that the isAction method is called
|
// test that the isAction method is called
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void isAction() {
|
public void isAction() {
|
||||||
when(expr.isAction()).thenReturn(true).thenReturn(false);
|
when(expr.isAction()).thenReturn(true).thenReturn(false);
|
||||||
assertTrue(test.isAction());
|
assertTrue(test.isAction());
|
||||||
|
@ -104,7 +109,7 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that the isOperator method is called
|
// test that the isOperator method is called
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void isOperator() {
|
public void isOperator() {
|
||||||
when(expr.isAction()).thenReturn(true).thenReturn(false);
|
when(expr.isAction()).thenReturn(true).thenReturn(false);
|
||||||
assertTrue(test.isAction());
|
assertTrue(test.isAction());
|
||||||
|
@ -114,7 +119,7 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that the getPrecedence method is called
|
// test that the getPrecedence method is called
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void getPrecedence() {
|
public void getPrecedence() {
|
||||||
int precedence = 12345;
|
int precedence = 12345;
|
||||||
when(expr.getPrecedence()).thenReturn(precedence);
|
when(expr.getPrecedence()).thenReturn(precedence);
|
||||||
|
@ -124,7 +129,7 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that the addChildren method is called
|
// test that the addChildren method is called
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void addChildren() {
|
public void addChildren() {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Deque<Expression> expressions = mock(Deque.class);
|
Deque<Expression> expressions = mock(Deque.class);
|
||||||
|
@ -134,7 +139,7 @@ public class TestFilterExpression {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test that the addArguments method is called
|
// test that the addArguments method is called
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void addArguments() {
|
public void addArguments() {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
Deque<String> args = mock(Deque.class);
|
Deque<String> args = mock(Deque.class);
|
||||||
|
|
|
@ -39,11 +39,12 @@ import org.apache.hadoop.fs.shell.find.FindOptions;
|
||||||
import org.apache.hadoop.fs.shell.find.Result;
|
import org.apache.hadoop.fs.shell.find.Result;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.rules.Timeout;
|
import org.junit.rules.Timeout;
|
||||||
|
import org.junit.Test;
|
||||||
import org.mockito.InOrder;
|
import org.mockito.InOrder;
|
||||||
|
|
||||||
public class TestFind {
|
public class TestFind {
|
||||||
|
|
||||||
@Rule
|
@Rule
|
||||||
public Timeout timeout = new Timeout(10000);
|
public Timeout timeout = new Timeout(10000);
|
||||||
|
|
||||||
|
|
|
@ -25,12 +25,17 @@ import java.io.IOException;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.shell.PathData;
|
import org.apache.hadoop.fs.shell.PathData;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestIname {
|
public class TestIname {
|
||||||
private FileSystem mockFs;
|
private FileSystem mockFs;
|
||||||
private Name.Iname name;
|
private Name.Iname name;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public Timeout globalTimeout = new Timeout(10000);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void resetMock() throws IOException {
|
public void resetMock() throws IOException {
|
||||||
mockFs = MockFileSystem.setup();
|
mockFs = MockFileSystem.setup();
|
||||||
|
@ -44,7 +49,7 @@ public class TestIname {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a matching name (same case)
|
// test a matching name (same case)
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyMatch() throws IOException {
|
public void applyMatch() throws IOException {
|
||||||
setup("name");
|
setup("name");
|
||||||
PathData item = new PathData("/directory/path/name", mockFs.getConf());
|
PathData item = new PathData("/directory/path/name", mockFs.getConf());
|
||||||
|
@ -52,7 +57,7 @@ public class TestIname {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a non-matching name
|
// test a non-matching name
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyNotMatch() throws IOException {
|
public void applyNotMatch() throws IOException {
|
||||||
setup("name");
|
setup("name");
|
||||||
PathData item = new PathData("/directory/path/notname", mockFs.getConf());
|
PathData item = new PathData("/directory/path/notname", mockFs.getConf());
|
||||||
|
@ -60,7 +65,7 @@ public class TestIname {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a matching name (different case)
|
// test a matching name (different case)
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyMixedCase() throws IOException {
|
public void applyMixedCase() throws IOException {
|
||||||
setup("name");
|
setup("name");
|
||||||
PathData item = new PathData("/directory/path/NaMe", mockFs.getConf());
|
PathData item = new PathData("/directory/path/NaMe", mockFs.getConf());
|
||||||
|
@ -68,7 +73,7 @@ public class TestIname {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a matching glob pattern (same case)
|
// test a matching glob pattern (same case)
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyGlob() throws IOException {
|
public void applyGlob() throws IOException {
|
||||||
setup("n*e");
|
setup("n*e");
|
||||||
PathData item = new PathData("/directory/path/name", mockFs.getConf());
|
PathData item = new PathData("/directory/path/name", mockFs.getConf());
|
||||||
|
@ -76,7 +81,7 @@ public class TestIname {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a matching glob pattern (different case)
|
// test a matching glob pattern (different case)
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyGlobMixedCase() throws IOException {
|
public void applyGlobMixedCase() throws IOException {
|
||||||
setup("n*e");
|
setup("n*e");
|
||||||
PathData item = new PathData("/directory/path/NaMe", mockFs.getConf());
|
PathData item = new PathData("/directory/path/NaMe", mockFs.getConf());
|
||||||
|
@ -84,7 +89,7 @@ public class TestIname {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a non-matching glob pattern
|
// test a non-matching glob pattern
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyGlobNotMatch() throws IOException {
|
public void applyGlobNotMatch() throws IOException {
|
||||||
setup("n*e");
|
setup("n*e");
|
||||||
PathData item = new PathData("/directory/path/notmatch", mockFs.getConf());
|
PathData item = new PathData("/directory/path/notmatch", mockFs.getConf());
|
||||||
|
|
|
@ -25,12 +25,17 @@ import java.io.IOException;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.apache.hadoop.fs.shell.PathData;
|
import org.apache.hadoop.fs.shell.PathData;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestName {
|
public class TestName {
|
||||||
private FileSystem mockFs;
|
private FileSystem mockFs;
|
||||||
private Name name;
|
private Name name;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public Timeout globalTimeout = new Timeout(10000);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void resetMock() throws IOException {
|
public void resetMock() throws IOException {
|
||||||
mockFs = MockFileSystem.setup();
|
mockFs = MockFileSystem.setup();
|
||||||
|
@ -44,7 +49,7 @@ public class TestName {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a matching name
|
// test a matching name
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyMatch() throws IOException {
|
public void applyMatch() throws IOException {
|
||||||
setup("name");
|
setup("name");
|
||||||
PathData item = new PathData("/directory/path/name", mockFs.getConf());
|
PathData item = new PathData("/directory/path/name", mockFs.getConf());
|
||||||
|
@ -52,7 +57,7 @@ public class TestName {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a non-matching name
|
// test a non-matching name
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyNotMatch() throws IOException {
|
public void applyNotMatch() throws IOException {
|
||||||
setup("name");
|
setup("name");
|
||||||
PathData item = new PathData("/directory/path/notname", mockFs.getConf());
|
PathData item = new PathData("/directory/path/notname", mockFs.getConf());
|
||||||
|
@ -60,7 +65,7 @@ public class TestName {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a different case name
|
// test a different case name
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyMixedCase() throws IOException {
|
public void applyMixedCase() throws IOException {
|
||||||
setup("name");
|
setup("name");
|
||||||
PathData item = new PathData("/directory/path/NaMe", mockFs.getConf());
|
PathData item = new PathData("/directory/path/NaMe", mockFs.getConf());
|
||||||
|
@ -68,7 +73,7 @@ public class TestName {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a matching glob pattern
|
// test a matching glob pattern
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyGlob() throws IOException {
|
public void applyGlob() throws IOException {
|
||||||
setup("n*e");
|
setup("n*e");
|
||||||
PathData item = new PathData("/directory/path/name", mockFs.getConf());
|
PathData item = new PathData("/directory/path/name", mockFs.getConf());
|
||||||
|
@ -76,7 +81,7 @@ public class TestName {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a glob pattern with different case
|
// test a glob pattern with different case
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyGlobMixedCase() throws IOException {
|
public void applyGlobMixedCase() throws IOException {
|
||||||
setup("n*e");
|
setup("n*e");
|
||||||
PathData item = new PathData("/directory/path/NaMe", mockFs.getConf());
|
PathData item = new PathData("/directory/path/NaMe", mockFs.getConf());
|
||||||
|
@ -84,7 +89,7 @@ public class TestName {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test a non-matching glob pattern
|
// test a non-matching glob pattern
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void applyGlobNotMatch() throws IOException {
|
public void applyGlobNotMatch() throws IOException {
|
||||||
setup("n*e");
|
setup("n*e");
|
||||||
PathData item = new PathData("/directory/path/notmatch", mockFs.getConf());
|
PathData item = new PathData("/directory/path/notmatch", mockFs.getConf());
|
||||||
|
|
|
@ -23,23 +23,28 @@ import static org.mockito.Mockito.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.hadoop.fs.shell.PathData;
|
import org.apache.hadoop.fs.shell.PathData;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestPrint {
|
public class TestPrint {
|
||||||
private FileSystem mockFs;
|
private FileSystem mockFs;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public Timeout globalTimeout = new Timeout(10000);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void resetMock() throws IOException {
|
public void resetMock() throws IOException {
|
||||||
mockFs = MockFileSystem.setup();
|
mockFs = MockFileSystem.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the full path is printed to stdout
|
// test the full path is printed to stdout
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testPrint() throws IOException {
|
public void testPrint() throws IOException {
|
||||||
Print print = new Print();
|
Print print = new Print();
|
||||||
PrintStream out = mock(PrintStream.class);
|
PrintStream out = mock(PrintStream.class);
|
||||||
|
|
|
@ -23,23 +23,28 @@ import static org.mockito.Mockito.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.apache.hadoop.fs.shell.PathData;
|
import org.apache.hadoop.fs.shell.PathData;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestPrint0 {
|
public class TestPrint0 {
|
||||||
private FileSystem mockFs;
|
private FileSystem mockFs;
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public Timeout globalTimeout = new Timeout(10000);
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void resetMock() throws IOException {
|
public void resetMock() throws IOException {
|
||||||
mockFs = MockFileSystem.setup();
|
mockFs = MockFileSystem.setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the full path is printed to stdout with a '\0'
|
// test the full path is printed to stdout with a '\0'
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testPrint() throws IOException {
|
public void testPrint() throws IOException {
|
||||||
Print.Print0 print = new Print.Print0();
|
Print.Print0 print = new Print.Print0();
|
||||||
PrintStream out = mock(PrintStream.class);
|
PrintStream out = mock(PrintStream.class);
|
||||||
|
|
|
@ -19,12 +19,17 @@ package org.apache.hadoop.fs.shell.find;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.rules.Timeout;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
public class TestResult {
|
public class TestResult {
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public Timeout globalTimeout = new Timeout(10000);
|
||||||
|
|
||||||
// test the PASS value
|
// test the PASS value
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testPass() {
|
public void testPass() {
|
||||||
Result result = Result.PASS;
|
Result result = Result.PASS;
|
||||||
assertTrue(result.isPass());
|
assertTrue(result.isPass());
|
||||||
|
@ -32,7 +37,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the FAIL value
|
// test the FAIL value
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testFail() {
|
public void testFail() {
|
||||||
Result result = Result.FAIL;
|
Result result = Result.FAIL;
|
||||||
assertFalse(result.isPass());
|
assertFalse(result.isPass());
|
||||||
|
@ -40,7 +45,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the STOP value
|
// test the STOP value
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void testStop() {
|
public void testStop() {
|
||||||
Result result = Result.STOP;
|
Result result = Result.STOP;
|
||||||
assertTrue(result.isPass());
|
assertTrue(result.isPass());
|
||||||
|
@ -48,7 +53,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test combine method with two PASSes
|
// test combine method with two PASSes
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void combinePassPass() {
|
public void combinePassPass() {
|
||||||
Result result = Result.PASS.combine(Result.PASS);
|
Result result = Result.PASS.combine(Result.PASS);
|
||||||
assertTrue(result.isPass());
|
assertTrue(result.isPass());
|
||||||
|
@ -56,7 +61,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the combine method with a PASS and a FAIL
|
// test the combine method with a PASS and a FAIL
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void combinePassFail() {
|
public void combinePassFail() {
|
||||||
Result result = Result.PASS.combine(Result.FAIL);
|
Result result = Result.PASS.combine(Result.FAIL);
|
||||||
assertFalse(result.isPass());
|
assertFalse(result.isPass());
|
||||||
|
@ -64,7 +69,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the combine method with a FAIL and a PASS
|
// test the combine method with a FAIL and a PASS
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void combineFailPass() {
|
public void combineFailPass() {
|
||||||
Result result = Result.FAIL.combine(Result.PASS);
|
Result result = Result.FAIL.combine(Result.PASS);
|
||||||
assertFalse(result.isPass());
|
assertFalse(result.isPass());
|
||||||
|
@ -72,7 +77,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the combine method with two FAILs
|
// test the combine method with two FAILs
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void combineFailFail() {
|
public void combineFailFail() {
|
||||||
Result result = Result.FAIL.combine(Result.FAIL);
|
Result result = Result.FAIL.combine(Result.FAIL);
|
||||||
assertFalse(result.isPass());
|
assertFalse(result.isPass());
|
||||||
|
@ -80,7 +85,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the combine method with a PASS and STOP
|
// test the combine method with a PASS and STOP
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void combinePassStop() {
|
public void combinePassStop() {
|
||||||
Result result = Result.PASS.combine(Result.STOP);
|
Result result = Result.PASS.combine(Result.STOP);
|
||||||
assertTrue(result.isPass());
|
assertTrue(result.isPass());
|
||||||
|
@ -88,7 +93,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the combine method with a STOP and FAIL
|
// test the combine method with a STOP and FAIL
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void combineStopFail() {
|
public void combineStopFail() {
|
||||||
Result result = Result.STOP.combine(Result.FAIL);
|
Result result = Result.STOP.combine(Result.FAIL);
|
||||||
assertFalse(result.isPass());
|
assertFalse(result.isPass());
|
||||||
|
@ -96,7 +101,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the combine method with a STOP and a PASS
|
// test the combine method with a STOP and a PASS
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void combineStopPass() {
|
public void combineStopPass() {
|
||||||
Result result = Result.STOP.combine(Result.PASS);
|
Result result = Result.STOP.combine(Result.PASS);
|
||||||
assertTrue(result.isPass());
|
assertTrue(result.isPass());
|
||||||
|
@ -104,7 +109,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the combine method with a FAIL and a STOP
|
// test the combine method with a FAIL and a STOP
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void combineFailStop() {
|
public void combineFailStop() {
|
||||||
Result result = Result.FAIL.combine(Result.STOP);
|
Result result = Result.FAIL.combine(Result.STOP);
|
||||||
assertFalse(result.isPass());
|
assertFalse(result.isPass());
|
||||||
|
@ -112,7 +117,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the negation of PASS
|
// test the negation of PASS
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void negatePass() {
|
public void negatePass() {
|
||||||
Result result = Result.PASS.negate();
|
Result result = Result.PASS.negate();
|
||||||
assertFalse(result.isPass());
|
assertFalse(result.isPass());
|
||||||
|
@ -120,7 +125,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the negation of FAIL
|
// test the negation of FAIL
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void negateFail() {
|
public void negateFail() {
|
||||||
Result result = Result.FAIL.negate();
|
Result result = Result.FAIL.negate();
|
||||||
assertTrue(result.isPass());
|
assertTrue(result.isPass());
|
||||||
|
@ -128,7 +133,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test the negation of STOP
|
// test the negation of STOP
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void negateStop() {
|
public void negateStop() {
|
||||||
Result result = Result.STOP.negate();
|
Result result = Result.STOP.negate();
|
||||||
assertFalse(result.isPass());
|
assertFalse(result.isPass());
|
||||||
|
@ -136,7 +141,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test equals with two PASSes
|
// test equals with two PASSes
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void equalsPass() {
|
public void equalsPass() {
|
||||||
Result one = Result.PASS;
|
Result one = Result.PASS;
|
||||||
Result two = Result.PASS.combine(Result.PASS);
|
Result two = Result.PASS.combine(Result.PASS);
|
||||||
|
@ -144,7 +149,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test equals with two FAILs
|
// test equals with two FAILs
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void equalsFail() {
|
public void equalsFail() {
|
||||||
Result one = Result.FAIL;
|
Result one = Result.FAIL;
|
||||||
Result two = Result.FAIL.combine(Result.FAIL);
|
Result two = Result.FAIL.combine(Result.FAIL);
|
||||||
|
@ -152,7 +157,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test equals with two STOPS
|
// test equals with two STOPS
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void equalsStop() {
|
public void equalsStop() {
|
||||||
Result one = Result.STOP;
|
Result one = Result.STOP;
|
||||||
Result two = Result.STOP.combine(Result.STOP);
|
Result two = Result.STOP.combine(Result.STOP);
|
||||||
|
@ -160,7 +165,7 @@ public class TestResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
// test all combinations of not equals
|
// test all combinations of not equals
|
||||||
@Test(timeout = 1000)
|
@Test
|
||||||
public void notEquals() {
|
public void notEquals() {
|
||||||
assertFalse(Result.PASS.equals(Result.FAIL));
|
assertFalse(Result.PASS.equals(Result.FAIL));
|
||||||
assertFalse(Result.PASS.equals(Result.STOP));
|
assertFalse(Result.PASS.equals(Result.STOP));
|
||||||
|
|
Loading…
Reference in New Issue