Search in sources :

Example 16 with PathData

use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.

the class TestIname method applyGlobMixedCase.

// test a matching glob pattern (different case)
@Test
public void applyGlobMixedCase() throws IOException {
    setup("n*e");
    PathData item = new PathData("/directory/path/NaMe", mockFs.getConf());
    assertEquals(Result.PASS, name.apply(item, -1));
}
Also used : PathData(org.apache.hadoop.fs.shell.PathData) Test(org.junit.Test)

Example 17 with PathData

use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.

the class TestIname method applyGlob.

// test a matching glob pattern (same case)
@Test
public void applyGlob() throws IOException {
    setup("n*e");
    PathData item = new PathData("/directory/path/name", mockFs.getConf());
    assertEquals(Result.PASS, name.apply(item, -1));
}
Also used : PathData(org.apache.hadoop.fs.shell.PathData) Test(org.junit.Test)

Example 18 with PathData

use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.

the class TestAnd method testFailSecond.

// test the second expression failing
@Test
public void testFailSecond() throws IOException {
    And and = new And();
    PathData pathData = mock(PathData.class);
    Expression first = mock(Expression.class);
    when(first.apply(pathData, -1)).thenReturn(Result.PASS);
    Expression second = mock(Expression.class);
    when(second.apply(pathData, -1)).thenReturn(Result.FAIL);
    Deque<Expression> children = new LinkedList<Expression>();
    children.add(second);
    children.add(first);
    and.addChildren(children);
    assertEquals(Result.FAIL, and.apply(pathData, -1));
    verify(first).apply(pathData, -1);
    verify(second).apply(pathData, -1);
    verifyNoMoreInteractions(first);
    verifyNoMoreInteractions(second);
}
Also used : PathData(org.apache.hadoop.fs.shell.PathData) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 19 with PathData

use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.

the class TestAnd method testStopFail.

// test first expression stopping and second failing
@Test
public void testStopFail() throws IOException {
    And and = new And();
    PathData pathData = mock(PathData.class);
    Expression first = mock(Expression.class);
    when(first.apply(pathData, -1)).thenReturn(Result.STOP);
    Expression second = mock(Expression.class);
    when(second.apply(pathData, -1)).thenReturn(Result.FAIL);
    Deque<Expression> children = new LinkedList<Expression>();
    children.add(second);
    children.add(first);
    and.addChildren(children);
    assertEquals(Result.STOP.combine(Result.FAIL), and.apply(pathData, -1));
    verify(first).apply(pathData, -1);
    verify(second).apply(pathData, -1);
    verifyNoMoreInteractions(first);
    verifyNoMoreInteractions(second);
}
Also used : PathData(org.apache.hadoop.fs.shell.PathData) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 20 with PathData

use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.

the class TestAnd method testPass.

// test all expressions passing
@Test
public void testPass() throws IOException {
    And and = new And();
    PathData pathData = mock(PathData.class);
    Expression first = mock(Expression.class);
    when(first.apply(pathData, -1)).thenReturn(Result.PASS);
    Expression second = mock(Expression.class);
    when(second.apply(pathData, -1)).thenReturn(Result.PASS);
    Deque<Expression> children = new LinkedList<Expression>();
    children.add(second);
    children.add(first);
    and.addChildren(children);
    assertEquals(Result.PASS, and.apply(pathData, -1));
    verify(first).apply(pathData, -1);
    verify(second).apply(pathData, -1);
    verifyNoMoreInteractions(first);
    verifyNoMoreInteractions(second);
}
Also used : PathData(org.apache.hadoop.fs.shell.PathData) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

PathData (org.apache.hadoop.fs.shell.PathData)32 Test (org.junit.Test)31 PrintStream (java.io.PrintStream)11 BaseExpression (org.apache.hadoop.fs.shell.find.BaseExpression)9 Expression (org.apache.hadoop.fs.shell.find.Expression)9 Find (org.apache.hadoop.fs.shell.find.Find)9 InOrder (org.mockito.InOrder)9 LinkedList (java.util.LinkedList)7 FileStatus (org.apache.hadoop.fs.FileStatus)1 Path (org.apache.hadoop.fs.Path)1