Package org.apache.hadoop.fs.FileSystemTestHelper

Examples of org.apache.hadoop.fs.FileSystemTestHelper.MockFileSystem


    try {
      Path TEST_ROOT_DIR = new Path("target");
      binaryTokenFile = FileSystem.getLocal(conf).makeQualified(
        new Path(TEST_ROOT_DIR, "tokenFile")).toUri().getPath();

      MockFileSystem fs1 = createFileSystemForServiceName("service1");
      MockFileSystem fs2 = createFileSystemForServiceName("service2");
      MockFileSystem fs3 = createFileSystemForServiceName("service3");

      // get the tokens for fs1 & fs2 and write out to binary creds file
      Credentials creds = new Credentials();
      Token<?> token1 = fs1.getDelegationToken(renewer);
      Token<?> token2 = fs2.getDelegationToken(renewer);
View Full Code Here


    }
  }

  private MockFileSystem createFileSystemForServiceName(final String service)
      throws IOException {
    MockFileSystem mockFs = new MockFileSystem();
    when(mockFs.getCanonicalServiceName()).thenReturn(service);
    when(mockFs.getDelegationToken(any(String.class))).thenAnswer(
        new Answer<Token<?>>() {
          int unique = 0;
          @Override
          public Token<?> answer(InvocationOnMock invocation) throws Throwable {
            Token<?> token = new Token<TokenIdentifier>();
View Full Code Here

public class TestFileSystemTokens {
  private static String renewer = "renewer!";

  @Test
  public void testFsWithNoToken() throws Exception {
    MockFileSystem fs = createFileSystemForServiceName(null)
    Credentials credentials = new Credentials();
   
    fs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(fs, false);
    assertEquals(0, credentials.numberOfTokens());
  }
View Full Code Here

  }
 
  @Test
  public void testFsWithToken() throws Exception {
    Text service = new Text("singleTokenFs");
    MockFileSystem fs = createFileSystemForServiceName(service);
    Credentials credentials = new Credentials();
   
    fs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(fs, true);
   
    assertEquals(1, credentials.numberOfTokens());
    assertNotNull(credentials.getToken(service));
  }
View Full Code Here

  @Test
  public void testFsWithTokenExists() throws Exception {
    Credentials credentials = new Credentials();
    Text service = new Text("singleTokenFs");
    MockFileSystem fs = createFileSystemForServiceName(service);
    Token<?> token = mock(Token.class);
    credentials.addToken(service, token);
   
    fs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(fs, false);
   
    assertEquals(1, credentials.numberOfTokens());
    assertSame(token, credentials.getToken(service));
  }
View Full Code Here

  public void testFsWithChildTokens() throws Exception {
    Credentials credentials = new Credentials();
    Text service1 = new Text("singleTokenFs1");
    Text service2 = new Text("singleTokenFs2");

    MockFileSystem fs1 = createFileSystemForServiceName(service1);
    MockFileSystem fs2 = createFileSystemForServiceName(service2);
    MockFileSystem fs3 = createFileSystemForServiceName(null);
    MockFileSystem multiFs =
        createFileSystemForServiceName(null, fs1, fs2, fs3);
   
    multiFs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(multiFs, false); // has no tokens of own, only child tokens
    verifyTokenFetch(fs1, true);
    verifyTokenFetch(fs2, true);
    verifyTokenFetch(fs3, false);
   
View Full Code Here

  @Test
  public void testFsWithDuplicateChildren() throws Exception {
    Credentials credentials = new Credentials();
    Text service = new Text("singleTokenFs1");

    MockFileSystem fs = createFileSystemForServiceName(service);
    MockFileSystem multiFs =
        createFileSystemForServiceName(null, fs, new FilterFileSystem(fs));
   
    multiFs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(multiFs, false);
    verifyTokenFetch(fs, true);
   
    assertEquals(1, credentials.numberOfTokens());
    assertNotNull(credentials.getToken(service));
View Full Code Here

    Credentials credentials = new Credentials();
    Text service = new Text("singleTokenFs1");
    Token<?> token = mock(Token.class);
    credentials.addToken(service, token);

    MockFileSystem fs = createFileSystemForServiceName(service);
    MockFileSystem multiFs =
        createFileSystemForServiceName(null, fs, new FilterFileSystem(fs));
   
    multiFs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(multiFs, false);
    verifyTokenFetch(fs, false);
   
    assertEquals(1, credentials.numberOfTokens());
    assertSame(token, credentials.getToken(service));
View Full Code Here

    Text service1 = new Text("singleTokenFs1");
    Text service2 = new Text("singleTokenFs2");
    Token<?> token = mock(Token.class);
    credentials.addToken(service2, token);

    MockFileSystem fs1 = createFileSystemForServiceName(service1);
    MockFileSystem fs2 = createFileSystemForServiceName(service2);
    MockFileSystem fs3 = createFileSystemForServiceName(null);
    MockFileSystem multiFs = createFileSystemForServiceName(null, fs1, fs2, fs3);
   
    multiFs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(multiFs, false);
    verifyTokenFetch(fs1, true);
    verifyTokenFetch(fs2, false); // we had added its token to credentials
    verifyTokenFetch(fs3, false);
   
View Full Code Here

    Text service2 = new Text("singleTokenFs2");
    Text myService = new Text("multiTokenFs");
    Token<?> token = mock(Token.class);
    credentials.addToken(service2, token);

    MockFileSystem fs1 = createFileSystemForServiceName(service1);
    MockFileSystem fs2 = createFileSystemForServiceName(service2);
    MockFileSystem multiFs = createFileSystemForServiceName(myService, fs1, fs2);
   
    multiFs.addDelegationTokens(renewer, credentials);
    verifyTokenFetch(multiFs, true); // its own token and also of its children
    verifyTokenFetch(fs1, true);
    verifyTokenFetch(fs2, false)// we had added its token to credentials
   
    assertEquals(3, credentials.numberOfTokens());
View Full Code Here

TOP

Related Classes of org.apache.hadoop.fs.FileSystemTestHelper.MockFileSystem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.