Exemplo n.º 1
0
  public void testBasicSnapshotRelease() throws Exception {
    File fpom =
        IO.getFile(local, "commons-cli/commons-cli/1.4-SNAPSHOT/commons-cli-1.4-SNAPSHOT.pom");
    File rpom =
        IO.getFile(
            remote, "commons-cli/commons-cli/1.4-SNAPSHOT/commons-cli-1.4-19700101.000010.pom");
    Program program = Program.valueOf("commons-cli", "commons-cli");
    Revision revision = Program.valueOf("commons-cli", "commons-cli").version("1.4-SNAPSHOT");
    Archive apom = revision.archive("pom", null);
    assertFalse(fpom.exists());

    Release r = storage.release(revision);
    r.setBuild(10000, null);
    r.add("pom", null, new ByteArrayInputStream(new byte[0]));

    r.close();

    assertTrue(fpom.isFile());
    assertTrue(rpom.isFile());
  }
Exemplo n.º 2
0
  public void testImmutable() throws Exception {
    File fpom = IO.getFile(local, "commons-cli/commons-cli/1.2/commons-cli-1.2.pom");
    Program program = Program.valueOf("commons-cli", "commons-cli");
    Revision revision = Program.valueOf("commons-cli", "commons-cli").version("1.2");
    Archive apom = revision.archive("pom", null);
    assertFalse(fpom.exists());

    Archive rapom = storage.resolveSnapshot(apom);
    assertTrue(rapom.isResolved());
    assertEquals(rapom, apom);

    File f = storage.get(rapom).getValue();
    assertEquals(fpom, f);
    assertRecent(f);

    f.setLastModified(10000);
    f = storage.get(rapom).getValue();
    assertEquals(fpom, f);
    assertEquals(10000L, f.lastModified());
  }
Exemplo n.º 3
0
  public void testSnapshotCaches() throws Exception {
    File fpom =
        IO.getFile(local, "commons-cli/commons-cli/1.4-SNAPSHOT/commons-cli-1.4-SNAPSHOT.pom");
    Program program = Program.valueOf("commons-cli", "commons-cli");
    Revision revision = Program.valueOf("commons-cli", "commons-cli").version("1.4-SNAPSHOT");
    Archive apom = revision.archive("pom", null);
    assertFalse(fpom.exists());
    assertFalse(apom.isResolved());

    File f = storage.get(apom).getValue();
    assertEquals(fpom.getAbsolutePath(), f.getAbsolutePath());
    assertRecent(f);
    long flastModified = f.lastModified();
    Thread.sleep(1001);

    f = storage.get(apom).getValue();
    assertEquals(flastModified, f.lastModified());

    f.setLastModified(0);
    assertFalse(Math.abs(System.currentTimeMillis() - f.lastModified()) <= 2000);
    f = storage.get(apom).getValue();
    assertFalse(f.lastModified() != 0);
  }
Exemplo n.º 4
0
  public void testBasic() throws Exception {
    Program program = Program.valueOf("commons-cli", "commons-cli");
    List<Revision> revisions = storage.getRevisions(program);
    assertNotNull(revisions);
    assertEquals(3, revisions.size());
    Revision revision = program.version(new MavenVersion("1.4-SNAPSHOT"));
    assertTrue(revisions.contains(revision));

    List<Archive> snapshotArchives = storage.getSnapshotArchives(revision);
    assertNotNull(snapshotArchives);
    assertEquals(10, snapshotArchives.size());

    Archive archive = storage.getResolvedArchive(revision, "pom", null);
    assertNotNull(archive);
    assertEquals("1.4-20160119.062305-9", archive.snapshot.toString());

    File file = storage.get(archive).getValue();
    assertNotNull(file);
    assertEquals(10373L, file.length());
  }