* workspace is opened. From this new workspace, we read back the entities we committed before. Then, we check if this
* has indeed led to a new version of the software for this target.
*/
public void testDeployBundlesToTarget() throws Exception {
Gson gson = new Gson();
Client c = Client.create();
c.getProperties().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, false);
File b1 = new File("b1.jar");
File b2 = new File("b2.jar");
File b3 = new File("b3.jar");
createBundleOnDisk(b1, "b1", "1.0.0");
createBundleOnDisk(b2, "b2", "1.0.0");
createBundleOnDisk(b3, "b3", "1.0.0");
b1.deleteOnExit();
b2.deleteOnExit();
b3.deleteOnExit();
WebResource w1 = createWorkspace(c);
WebResource a1 = createBundle(c, w1, "a1", "b1", "1.0.0", b1.toURI().toURL().toString(), BundleHelper.MIMETYPE);
WebResource a2 = createBundle(c, w1, "a2", "b2", "1.0.0", b2.toURI().toURL().toString(), BundleHelper.MIMETYPE);
WebResource a3 = createBundle(c, w1, "a3", "b3", "1.0.0", b3.toURI().toURL().toString(), BundleHelper.MIMETYPE);
assertEntitiesExist(a1, a2, a3);
WebResource a1f1 = createAssociationA2F(c, w1, "artifact2feature", "a1", "f1");
WebResource a2f2 = createAssociationA2F(c, w1, "artifact2feature", "a2", "f2");
WebResource a3f3 = createAssociationA2F(c, w1, "artifact2feature", "a3", "f3");
assertEntitiesExist(a1f1, a2f2, a3f3);
WebResource f1 = createFeature(c, w1, "f1");
WebResource f2 = createFeature(c, w1, "f2");
WebResource f3 = createFeature(c, w1, "f3");
assertEntitiesExist(f1, f2, f3);
WebResource f1d1 = createAssociationF2D(c, w1, "feature2distribution", "f1", "d1");
WebResource f2d1 = createAssociationF2D(c, w1, "feature2distribution", "f2", "d1");
WebResource f3d1 = createAssociationF2D(c, w1, "feature2distribution", "f3", "d1");
assertEntitiesExist(f1d1, f2d1, f3d1);
WebResource d1 = createDistribution(c, w1, "d1");
assertEntitiesExist(d1);
WebResource d1t1 = createAssociationD2T(c, w1, "distribution2target", "d1", "t1");
assertEntitiesExist(d1t1);
WebResource t1 = createTarget(c, w1, "t1");
assertEntitiesExist(t1);
w1.post();
w1.delete();
WebResource w2 = createWorkspace(c);
assertResources(gson, w2, "artifact", 3);
assertResources(gson, w2, "artifact2feature", 3);
assertResources(gson, w2, "feature", 3);
assertResources(gson, w2, "feature2distribution", 3);
assertResources(gson, w2, "distribution", 1);
assertResources(gson, w2, "distribution2target", 1);
assertResources(gson, w2, "target", 1);
w2.delete();
WebResource t1versions = c.resource("http://localhost:8080/deployment/t1/versions");
assertEquals("1.0.0\n", t1versions.get(String.class));
}