コード例 #1
0
  @Test
  public void testListNestedSingleTextAsset() {

    Repository repository = new VFSRepository(producer.getIoService());
    ((VFSRepository) repository).setDescriptor(descriptor);
    boolean rootFolderExists = repository.directoryExists("/processes/nested");
    assertTrue(rootFolderExists);

    Collection<Asset> assets = repository.listAssets("/processes/nested");
    assertNotNull(assets);
    assertEquals(1, assets.size());
    Asset<String> asset = assets.iterator().next();

    assertEquals("bpmn2", asset.getAssetType());
    assertEquals("BPMN2-UserTask.bpmn2", asset.getFullName());
    assertEquals("BPMN2-UserTask", asset.getName());
    assertEquals("/processes/nested", asset.getAssetLocation());
  }
コード例 #2
0
  @Test
  public void testListSingleBinaryAsset() {

    Repository repository = new VFSRepository(producer.getIoService());
    ((VFSRepository) repository).setDescriptor(descriptor);
    boolean rootFolderExists = repository.directoryExists("/images");
    assertTrue(rootFolderExists);

    Collection<Asset> assets = repository.listAssets("/images");
    assertNotNull(assets);
    assertEquals(1, assets.size());
    Asset<String> asset = assets.iterator().next();

    assertEquals("png", asset.getAssetType());
    assertEquals("release-process.png", asset.getFullName());
    assertEquals("release-process", asset.getName());
    assertEquals("/images", asset.getAssetLocation());
  }
コード例 #3
0
  @Test
  public void testUpdateAsset() throws Exception {

    Repository repository =
        new VFSRepository(fileSystem, producer.getIoService(), producer.getActiveFileSystems());
    ((VFSRepository) repository).init();
    profile.setRepository(repository);
    AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text);
    builder
        .content("custom editors content")
        .type("bpmn2")
        .name("testprocess")
        .location("/defaultPackage");
    String id = repository.createAsset(builder.getAsset());

    // setup parameters
    Map<String, String> params = new HashMap<String, String>();

    params.put("profile", "jbpm");
    params.put("action", "updateasset");
    params.put("assetid", id);
    params.put("assetcontent", "testprocess");
    params.put("", "");

    boolean processAssetExists = repository.assetExists("/defaultPackage/testprocess.bpmn2");
    assertTrue(processAssetExists);

    AssetServiceServlet assetServiceServlet = new AssetServiceServlet();
    assetServiceServlet.setProfile(profile);

    assetServiceServlet.init(new TestServletConfig(new TestServletContext(repository)));
    TestHttpServletResponse response = new TestHttpServletResponse();
    assetServiceServlet.doPost(new TestHttpServletRequest(params), response);

    String jsonResponse = new String(response.getContent());
    assertNotNull(jsonResponse);

    processAssetExists = repository.assetExists(id);
    assertTrue(processAssetExists);

    Asset<String> processAsset = repository.loadAsset(id);
    assertEquals("testprocess\n", processAsset.getAssetContent());
  }
コード例 #4
0
  @Test
  public void testAssetExists() throws NoSuchFileException {

    Repository repository = new VFSRepository(producer.getIoService());
    ((VFSRepository) repository).setDescriptor(descriptor);
    Collection<Asset> assets = repository.listAssets("/");
    assertNotNull(assets);
    for (Asset aset : assets) {
      System.out.println(aset.getAssetLocation() + " " + aset.getFullName());
    }
    assertEquals(0, assets.size());

    AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text);
    builder.content("simple content").type("txt").name("test").location("/");

    String id = repository.createAsset(builder.getAsset());

    assertNotNull(id);

    boolean assetExists = repository.assetExists(id);
    assertTrue(assetExists);
  }
コード例 #5
0
  @Test
  public void testLoadAssetFromPath() throws NoSuchFileException {

    Repository repository = new VFSRepository(producer.getIoService());
    ((VFSRepository) repository).setDescriptor(descriptor);
    Asset<String> asset = repository.loadAssetFromPath("/processes/BPMN2-ScriptTask.bpmn2");

    assertEquals("bpmn2", asset.getAssetType());
    assertEquals("BPMN2-ScriptTask", asset.getName());
    assertEquals("BPMN2-ScriptTask.bpmn2", asset.getFullName());
    assertEquals("/processes", asset.getAssetLocation());
    assertNotNull(asset.getAssetContent());
    System.out.print(asset.getUniqueId());
  }
コード例 #6
0
  @Test
  public void testStoreSingleTextAsset() throws NoSuchFileException {

    Repository repository = new VFSRepository(producer.getIoService());
    ((VFSRepository) repository).setDescriptor(descriptor);
    Collection<Asset> assets = repository.listAssets("/");
    assertNotNull(assets);
    assertEquals(0, assets.size());

    AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Text);
    builder.content("simple content").type("txt").name("test").location("/");

    String id = repository.createAsset(builder.getAsset());

    assertNotNull(id);

    Asset<String> asset = repository.loadAsset(id);

    assertEquals("txt", asset.getAssetType());
    assertEquals("test", asset.getName());
    assertEquals("test.txt", asset.getFullName());
    assertEquals("/", asset.getAssetLocation());
    assertEquals("simple content", asset.getAssetContent());
  }
コード例 #7
0
  @Test
  public void testStoreSingleBinaryAssetSpaceInName() throws NoSuchFileException {

    Repository repository = new VFSRepository(producer.getIoService());
    ((VFSRepository) repository).setDescriptor(descriptor);
    Collection<Asset> assets = repository.listAssets("/");
    assertNotNull(assets);
    assertEquals(0, assets.size());

    AssetBuilder builder = AssetBuilderFactory.getAssetBuilder(Asset.AssetType.Byte);
    builder.content("simple content".getBytes()).type("png").name("test asset").location("/");

    String id = repository.createAsset(builder.getAsset());

    assertNotNull(id);

    Asset<byte[]> asset = repository.loadAsset(id);

    assertEquals("png", asset.getAssetType());
    assertEquals("test asset", asset.getName());
    assertEquals("test asset.png", asset.getFullName());
    assertEquals("/", asset.getAssetLocation());
    assertFalse(asset.getAssetContent().length == 0);
  }