Ejemplo n.º 1
0
  public void update(UpdateMemo memo) throws Exception {

    ArtifactData target = put(memo.best.urls.iterator().next());

    memo.current.version = new Version(memo.best.version);
    target.sync();
    memo.current.sha = target.sha;
    // memo.current.dependencies = target.dependencies;
    // memo.current.dependencies.add((new File(repoDir,
    // Hex.toHexString(target.sha))).getCanonicalPath());
    // memo.current.runbundles = target.runbundles;
    // memo.current.description = target.description;
    memo.current.time = target.time;

    if (memo.current instanceof ServiceData) {
      Service service = getService((ServiceData) memo.current);
      service.remove();
      createService((ServiceData) memo.current);
      IO.delete(new File(IO.getFile(serviceDir, memo.current.name), "data"));
      storeData(new File(IO.getFile(serviceDir, memo.current.name), "data"), memo.current);
    } else {
      platform.deleteCommand(memo.current);
      createCommand(memo.current, false);
      IO.delete(IO.getFile(commandDir, memo.current.name));
      storeData(IO.getFile(commandDir, memo.current.name), memo.current);
    }
  }
Ejemplo n.º 2
0
 @Override
 protected void tearDown() throws Exception {
   super.tearDown();
   framework.stop();
   IO.delete(tmp);
   Main.stop();
   IO.delete(IO.getFile("generated/cache"));
   IO.delete(IO.getFile("generated/storage"));
   framework.waitForStop(100000);
   super.tearDown();
 }
Ejemplo n.º 3
0
  @Override
  protected void tearDown() throws Exception {
    repo.close();
    IO.delete(tmp);

    super.tearDown();
  }
Ejemplo n.º 4
0
  public void testStructs() throws Exception {
    File tmp = new File("tmp");
    PersistentMap<X> pm = new PersistentMap<X>(new File(tmp, "simple"), X.class);
    try {
      X x = new X();
      x.abc = "def";
      x.def = 5;
      x.list.add("abc");
      assertNull(pm.put("abc", x));
      pm.close();

      PersistentMap<X> pm2 = new PersistentMap<X>(new File(tmp, "simple"), X.class);

      X x2 = pm2.get("abc");
      assertEquals("def", x2.abc);
      assertEquals(5, x2.def);

      pm2.remove("abc");

      assertEquals(0, pm2.size());

      pm2.close();
    } finally {
      pm.close();
      IO.delete(tmp);
    }
  }
Ejemplo n.º 5
0
  public void testSimple() throws Exception {
    File tmp = new File("tmp");
    PersistentMap<String> pm = new PersistentMap<String>(new File(tmp, "simple"), String.class);
    try {

      assertNull(pm.put("abc", "def"));
      assertEquals("def", pm.get("abc"));

      pm.close();

      PersistentMap<String> pm2 = new PersistentMap<String>(new File(tmp, "simple"), String.class);
      assertEquals("def", pm2.get("abc"));

      assertEquals(Arrays.asList("abc"), new ArrayList<String>(pm2.keySet()));

      for (Map.Entry<String, String> e : pm2.entrySet()) {
        e.setValue("XXX");
      }
      assertEquals("XXX", pm2.get("abc"));
      pm2.close();
    } finally {
      pm.close();
      IO.delete(tmp);
    }
  }
Ejemplo n.º 6
0
 @Override
 protected void tearDown() throws Exception {
   framework.stop();
   framework.waitForStop(10000);
   IO.delete(tmp);
   super.tearDown();
 }
Ejemplo n.º 7
0
 @Override
 public void close() throws IOException {
   File tempDir = null;
   synchronized (this) {
     if (checkedOut != null) tempDir = checkedOut.getWorkTree();
   }
   if (tempDir != null) IO.delete(tempDir);
 }
Ejemplo n.º 8
0
 /** Delete a cache entry */
 public boolean deleteCache(byte[] id) throws Exception {
   File dir = IO.getFile(cache, Hex.toHexString(id));
   if (dir.isDirectory()) {
     IO.delete(dir);
     return true;
   }
   return false;
 }
Ejemplo n.º 9
0
 @Override
 protected void setUp() throws Exception {
   super.setUp();
   reporter.setTrace(true);
   Config config = new Config();
   fnx = new FakeNexus(config, remote);
   fnx.start();
   IO.delete(remote);
   IO.delete(local);
   IO.copy(IO.getFile("testresources/mavenrepo"), remote);
   remote.mkdirs();
   local.mkdirs();
   repo =
       new MavenRemoteRepository(local, new HttpClient(), fnx.getBaseURI() + "/repo/", reporter);
   storage =
       new MavenRepository(
           local, "fnexus", this.repo, null, null, new ReporterAdapter(System.out), null);
 }
Ejemplo n.º 10
0
  @Override
  public void setUp() {
    System.setProperty("jpm4j.in.test", "true");

    tmp = IO.getFile("generated/tmp");
    IO.delete(tmp);
    tmp.mkdirs();

    repo = new Repository();
    Map<String, String> props = new HashMap<String, String>();
    props.put("location", new File(tmp, "loc").getAbsolutePath());
    props.put("index", new File(tmp, "index").getAbsolutePath());
    repo.setProperties(props);
  }
Ejemplo n.º 11
0
 private void doRoot(Project p, File root) throws IOException {
   if (!root.isFile()) {
     IO.delete(root);
     copy("rootpom.xml", "../pom.xml", p);
   }
 }
Ejemplo n.º 12
0
 public void tearDown() throws Exception {
   ws.close();
   IO.delete(tmp);
 }