Examples of InMemoryFileSystem


Examples of com.google.devtools.moe.client.testing.InMemoryFileSystem

  /**
   * Bookkeeping for codebases the same at head, different at migrated revs.
   */
  public void testHeadsEquivalent() throws Exception {
    InMemoryFileSystem fileSystem = new InMemoryFileSystem(ImmutableMap.of(
        "/path/to/db", "{\"equivalences\":[], \"migrations\":[]}",
        "/dummy/codebase/int/1/file", "1",
        "/dummy/codebase/pub/1/file", "1 (equivalent)",
        "/dummy/codebase/int/migrated_from/file", "migrated_from",
        "/dummy/codebase/pub/migrated_to/", "dir (different)"
        ));
    AppContext.RUN.fileSystem = fileSystem;

    BookkeepingDirective d = new BookkeepingDirective();
    d.getFlags().configFilename = "moe_config.txt";
    d.getFlags().dbLocation = DB_FILE.getAbsolutePath();

    expectDiffs();

    control.replay();
    assertEquals(0, d.perform());
    control.verify();

    // expected db at end of call to bookkeep
    DbStorage dbStorage = new DbStorage();
    dbStorage.addEquivalence(new Equivalence(new Revision("1", "int"), new Revision("1", "pub")));
    dbStorage.addMigration(new SubmittedMigration(
        new Revision("migrated_from", "int"), new Revision("migrated_to", "pub")));
    FileDb expectedDb = new FileDb(dbStorage);

    assertEquals(expectedDb.toJsonString(), fileSystem.fileToString(DB_FILE));
  }
View Full Code Here

Examples of com.google.devtools.moe.client.testing.InMemoryFileSystem

  /**
   * Bookkeeping for codebases different at head and migrated revs.
   */
  public void testOneSubmittedMigration_nonEquivalent() throws Exception {
    InMemoryFileSystem fileSystem = new InMemoryFileSystem(ImmutableMap.of(
        "/path/to/db", "{\"equivalences\":[], \"migrations\":[]}",
        "/dummy/codebase/int/1/file", "1",
        "/dummy/codebase/pub/1/", "empty dir (different)",
        "/dummy/codebase/int/migrated_from/file", "migrated_from",
        "/dummy/codebase/pub/migrated_to/", "empty dir (different)"
        ));
    AppContext.RUN.fileSystem = fileSystem;

    BookkeepingDirective d = new BookkeepingDirective();
    d.getFlags().configFilename = "moe_config.txt";
    d.getFlags().dbLocation = DB_FILE.getAbsolutePath();

    expectDiffs();

    control.replay();
    assertEquals(0, d.perform());
    control.verify();

    // expected db at end of call to bookkeep
    DbStorage dbStorage = new DbStorage();
    dbStorage.addMigration(new SubmittedMigration(
        new Revision("migrated_from", "int"), new Revision("migrated_to", "pub")));
    FileDb expectedDb = new FileDb(dbStorage);

    assertEquals(expectedDb.toJsonString(), fileSystem.fileToString(DB_FILE));
  }
View Full Code Here

Examples of com.google.devtools.moe.client.testing.InMemoryFileSystem

  /**
   * Bookkeeping for codebases different at head and equivalent at migrated revs.
   */
  public void testOneSubmittedMigration_equivalent() throws Exception {
    InMemoryFileSystem fileSystem = new InMemoryFileSystem(ImmutableMap.of(
        "/path/to/db", "{\"equivalences\":[], \"migrations\":[]}",
        "/dummy/codebase/int/1/file", "1",
        "/dummy/codebase/pub/1/", "empty dir (different)",
        "/dummy/codebase/int/migrated_from/file", "migrated_from",
        "/dummy/codebase/pub/migrated_to/file", "migrated_to (equivalent)"
        ));
    AppContext.RUN.fileSystem = fileSystem;

    BookkeepingDirective d = new BookkeepingDirective();
    d.getFlags().configFilename = "moe_config.txt";
    d.getFlags().dbLocation = DB_FILE.getAbsolutePath();

    expectDiffs();

    control.replay();
    assertEquals(0, d.perform());
    control.verify();

    // expected db at end of call to bookkeep
    DbStorage dbStorage = new DbStorage();
    dbStorage.addEquivalence(new Equivalence(
        new Revision("migrated_from", "int"), new Revision("migrated_to", "pub")));
    dbStorage.addMigration(new SubmittedMigration(
        new Revision("migrated_from", "int"), new Revision("migrated_to", "pub")));
    FileDb expectedDb = new FileDb(dbStorage);

    assertEquals(expectedDb.toJsonString(), fileSystem.fileToString(DB_FILE));
  }
View Full Code Here

Examples of com.google.gxp.compiler.fs.InMemoryFileSystem

   */
  protected final FileRef createSchemaFile(String name, String contents)
      throws Exception {
    // create in memory file
    String pkgDir = getPackage().replace('.', '/');
    InMemoryFileSystem schemaFs = new InMemoryFileSystem();
    String sourceName = "/" + pkgDir + "/" + name + ".xml";
    source = schemaFs.parseFilename(sourceName);

    // write GXP
    Writer writer = source.openWriter(Charsets.US_ASCII);
    writer.write(contents);
    writer.close();
View Full Code Here

Examples of com.google.gxp.compiler.fs.InMemoryFileSystem

  private FileSystem sourcePathFs;

  @Override
  public void setUp() throws Exception {
    super.setUp();
    sourcePathFs = new InMemoryFileSystem();
    addFileToSourceFs("/foo", "[file /foo]");
    addFileToSourceFs("/bar", "[file /bar]");
  }
View Full Code Here

Examples of com.google.gxp.compiler.fs.InMemoryFileSystem

    assertEquals(Severity.INFO, alertPolicy.getSeverity(INFO_ALERT));
    assertEquals(Severity.ERROR, alertPolicy.getSeverity(I18N_ALERT));
  }

  public void testParameterFile() throws Exception {
    InMemoryFileSystem inMemory = new InMemoryFileSystem();
    FileRef parameterFile = inMemory.parseFilename("/here/params");
    Writer out = parameterFile.openWriter();
    out.write("--help");
    out.close();
    GxpcFlags flags = new GxpcFlags(inMemory, inMemory.parseFilename("/here"), "@params");
    assertTrue(flags.showHelp());
  }
View Full Code Here

Examples of com.google.gxp.compiler.fs.InMemoryFileSystem

    GxpcFlags flags = new GxpcFlags(inMemory, inMemory.parseFilename("/here"), "@params");
    assertTrue(flags.showHelp());
  }

  public void testParameterFileIsUtf8() throws Exception {
    InMemoryFileSystem inMemory = new InMemoryFileSystem();
    FileRef parameterFile = inMemory.parseFilename("/here/params");
    Writer out = parameterFile.openWriter(Charsets.UTF_8);
    out.write("--output /here/\u00F6"); // An oe umlaut.
    out.close();
    GxpcFlags flags = new GxpcFlags(inMemory, inMemory.parseFilename("/here"), "@params");
    assertEquals("/here/\u00F6", flags.getAllowedOutputFiles().iterator().next().toFilename());
  }
View Full Code Here

Examples of com.google.gxp.compiler.fs.InMemoryFileSystem

   */
  protected final FileRef createSchemaFile(String name, String contents)
      throws Exception {
    // create in memory file
    String pkgDir = getPackage().replace('.', '/');
    InMemoryFileSystem schemaFs = new InMemoryFileSystem();
    String sourceName = "/" + pkgDir + "/" + name + ".xml";
    source = schemaFs.parseFilename(sourceName);

    // write GXP
    Writer writer = source.openWriter(Charsets.US_ASCII);
    writer.write(contents);
    writer.close();
View Full Code Here

Examples of org.apache.hadoop.fs.InMemoryFileSystem

 
  // cehck that the checksum file is deleted for Checksum file system.
  public void testDeletionOfCheckSum() throws Exception {
    Configuration conf = new Configuration();
    URI uri = URI.create("ramfs://mapoutput" + "_tmp");
    InMemoryFileSystem inMemFs =  (InMemoryFileSystem)FileSystem.get(uri, conf);
    Path testPath = new Path("/file_1");
    inMemFs.reserveSpaceWithCheckSum(testPath, 1024);
    FSDataOutputStream fout = inMemFs.create(testPath);
    fout.write("testing".getBytes());
    fout.close();
    assertTrue("checksum exists", inMemFs.exists(inMemFs.getChecksumFile(testPath)));
    inMemFs.delete(testPath, true);
    assertTrue("checksum deleted", !inMemFs.exists(inMemFs.getChecksumFile(testPath)));
    // check for directories getting deleted.
    testPath = new Path("/tesdir/file_1");
    inMemFs.reserveSpaceWithCheckSum(testPath, 1024);
    fout = inMemFs.create(testPath);
    fout.write("testing".getBytes());
    fout.close();
    testPath = new Path("/testdir/file_2");
    inMemFs.reserveSpaceWithCheckSum(testPath, 1024);
    fout = inMemFs.create(testPath);
    fout.write("testing".getBytes());
    fout.close();
    inMemFs.delete(testPath, true);
    assertTrue("nothing in the namespace", inMemFs.listStatus(new Path("/")).length == 0);
  }
View Full Code Here

Examples of org.apache.hadoop.fs.InMemoryFileSystem

 
  // cehck that the checksum file is deleted for Checksum file system.
  public void testDeletionOfCheckSum() throws Exception {
    Configuration conf = new Configuration();
    URI uri = URI.create("ramfs://mapoutput" + "_tmp");
    InMemoryFileSystem inMemFs =  (InMemoryFileSystem)FileSystem.get(uri, conf);
    Path testPath = new Path("/file_1");
    inMemFs.reserveSpaceWithCheckSum(testPath, 1024);
    FSDataOutputStream fout = inMemFs.create(testPath);
    fout.write("testing".getBytes());
    fout.close();
    assertTrue("checksum exists", inMemFs.exists(inMemFs.getChecksumFile(testPath)));
    inMemFs.delete(testPath, true);
    assertTrue("checksum deleted", !inMemFs.exists(inMemFs.getChecksumFile(testPath)));
    // check for directories getting deleted.
    testPath = new Path("/tesdir/file_1");
    inMemFs.reserveSpaceWithCheckSum(testPath, 1024);
    fout = inMemFs.create(testPath);
    fout.write("testing".getBytes());
    fout.close();
    testPath = new Path("/testdir/file_2");
    inMemFs.reserveSpaceWithCheckSum(testPath, 1024);
    fout = inMemFs.create(testPath);
    fout.write("testing".getBytes());
    fout.close();
    inMemFs.delete(testPath, true);
    assertTrue("nothing in the namespace", inMemFs.listStatus(new Path("/")).length == 0);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.