private FileListProvider execute(String scriptPath, String... arguments) throws IOException {
    List<String> command = new ArrayList<String>();
    command.add(new File(framework.getHome(), scriptPath).getAbsolutePath());
    Collections.addAll(command, arguments);

    Map<String, String> env = new HashMap<String, String>();
    env.put("ASAKUSA_HOME", framework.getHome().getAbsolutePath());

    return new ProcessFileListProvider(command, env);
  }
  /**
   * Creates a new cache with some deleted values.
   *
   * @throws Exception if failed
   */
  @Test
  public void create_deleted() throws Exception {
    CacheInfo info =
        new CacheInfo(
            "a",
            "id",
            calendar("2011-12-13 14:15:16"),
            "EXAMPLE",
            Collections.singleton("COL"),
            "com.example.Model",
            123L);
    framework.deployLibrary(TestDataModel.class, "batchapps/tbatch/lib/jobflow-tflow.jar");
    CacheStorage storage = new CacheStorage(getConfiguration(), getTargetUri());
    try {
      storage.putPatchCacheInfo(info);
      ModelOutput<TestDataModel> output = create(storage, storage.getPatchContents("0"));
      try {
        TestDataModel model = new TestDataModel();
        for (int i = 0; i < 100; i++) {
          model.systemId.set(i);
          model.deleted.set(i % 10 != 0);
          output.write(model);
        }
      } finally {
        output.close();
      }

      execute(CacheBuildClient.SUBCOMMAND_CREATE);
      assertThat(storage.getHeadCacheInfo(), is(info));

      List<TestDataModel> results = collect(storage, storage.getHeadContents("*"));
      assertThat(results.size(), is(10));
      for (int i = 0; i < 10; i++) {
        assertThat(results.get(i).systemId.get(), is(i * 10L));
      }
    } finally {
      storage.close();
    }
  }
  /**
   * Update a cache.
   *
   * @throws Exception if failed
   */
  @Test
  public void update_delete() throws Exception {
    CacheInfo info =
        new CacheInfo(
            "a",
            "id",
            calendar("2011-12-13 14:15:16"),
            "EXAMPLE",
            Collections.singleton("COL"),
            "com.example.Model",
            123L);
    framework.deployLibrary(TestDataModel.class, "batchapps/tbatch/lib/jobflow-tflow.jar");
    CacheStorage storage = new CacheStorage(getConfiguration(), getTargetUri());
    try {
      storage.putPatchCacheInfo(info);
      ModelOutput<TestDataModel> head = create(storage, storage.getHeadContents("0"));
      try {
        TestDataModel model = new TestDataModel();
        for (int i = 0; i < 10; i++) {
          model.systemId.set(i);
          model.value.set("HEAD");
          model.deleted.set(false);
          head.write(model);
        }
      } finally {
        head.close();
      }
      ModelOutput<TestDataModel> patch = create(storage, storage.getPatchContents("0"));
      try {
        TestDataModel model = new TestDataModel();
        for (int i = 0; i < 10; i += 2) {
          model.systemId.set(i);
          model.value.set("NEXT");
          model.deleted.set(i % 4 == 0);
          patch.write(model);
        }
      } finally {
        patch.close();
      }

      execute(CacheBuildClient.SUBCOMMAND_UPDATE);
      assertThat(storage.getHeadCacheInfo(), is(info));

      List<TestDataModel> results = collect(storage, storage.getHeadContents("*"));
      assertThat(results.size(), is(7));
      assertThat(results.get(0).systemId.get(), is(1L));
      assertThat(results.get(0).value.toString(), is("HEAD"));
      assertThat(results.get(1).systemId.get(), is(2L));
      assertThat(results.get(1).value.toString(), is("NEXT"));
      assertThat(results.get(2).systemId.get(), is(3L));
      assertThat(results.get(2).value.toString(), is("HEAD"));
      assertThat(results.get(3).systemId.get(), is(5L));
      assertThat(results.get(3).value.toString(), is("HEAD"));
      assertThat(results.get(4).systemId.get(), is(6L));
      assertThat(results.get(4).value.toString(), is("NEXT"));
      assertThat(results.get(5).systemId.get(), is(7L));
      assertThat(results.get(5).value.toString(), is("HEAD"));
      assertThat(results.get(6).systemId.get(), is(9L));
      assertThat(results.get(6).value.toString(), is("HEAD"));
    } finally {
      storage.close();
    }
  }