示例#1
0
  @Test
  public void testRemoveCookbook() throws IOException {
    Long testAccountId = Long.valueOf(2);
    Long testAppId = Long.valueOf(2);

    File accountDirectory = new File(cookbookDestinationRoot + "/" + testAccountId);
    ensureFileNotExists(accountDirectory);

    File cookbookInput = new File("src/test/resources/test-xlc-fds");
    File cookbookTarget =
        new File(
            cookbookDestinationRoot + "/" + testAccountId + "/" + testAppId + "/" + "test-xlc-fds");

    ApplicationModel application =
        ApplicationModelBuilder.newInstance().accountId(testAccountId).appId(testAppId).build();
    CookbookModel cookbook =
        CookbookModelBuilder.newInstance().application(application).name("test-xlc-fds").build();

    givenCookbookExists(cookbook);
    givenCookbookFileExists(cookbookInput, cookbookTarget);

    assertTrue(cookbookTarget.exists());
    manager.removeCookbook(1L);
    assertFalse(cookbookTarget.exists());

    ensureFileNotExists(accountDirectory);
  }
示例#2
0
  @Test
  public void testGetApplicationCookbooks() {
    Long testAppId = Long.valueOf(3);

    CookbookModel testCookbook = CookbookModelBuilder.newInstance().name("test-cookbook").build();
    Set<CookbookModel> testCookbooks = new HashSet<CookbookModel>(Arrays.asList(testCookbook));
    ApplicationModel application =
        ApplicationModelBuilder.newInstance().cookbooks(testCookbooks).build();
    givenApplicationExists(application);

    Cookbooks cookbooks = manager.getApplicationCookbooks(testAppId);
    assertNotNull(cookbooks);
    assertNotNull(cookbooks.getCookbook());
    assertFalse(cookbooks.getCookbook().isEmpty());
  }
示例#3
0
  @Test
  public void testGenerateCookbooksArchive() throws IOException {
    Long testAccountId = Long.valueOf(4);
    Long testAppId = Long.valueOf(4);
    Long testVcId = Long.valueOf(4);

    File vcDirectory = new File(vcCookbookDestinationRoot + "/" + testVcId);
    ensureFileNotExists(vcDirectory);

    File accountDirectory = new File(cookbookDestinationRoot + "/" + testAccountId);
    ensureFileNotExists(accountDirectory);

    File cookbookInput = new File("src/test/resources/test-xlc-fds");
    File cookbookTarget =
        new File(
            cookbookDestinationRoot + "/" + testAccountId + "/" + testAppId + "/" + "test-xlc-fds");

    CookbookModel cookbookModel = CookbookModelBuilder.newInstance().name("test-xlc-fds").build();
    Set<CookbookModel> cookbooks = new HashSet<CookbookModel>(Arrays.asList(cookbookModel));
    ApplicationModel appModel =
        ApplicationModelBuilder.newInstance()
            .accountId(testAccountId)
            .appId(testAppId)
            .cookbooks(cookbooks)
            .build();
    cookbookModel.setApplication(appModel);
    VirtualClusterModel vcModel = VirtualClusterModelBuilder.newInstance().build();

    givenApplicationExists(appModel);
    givenCookbookExists(cookbookModel);
    givenCookbookFileExists(cookbookInput, cookbookTarget);
    givenVirtualClusterExists(vcModel);

    Application startingApplication = ApplicationBuilder.newInstance().id(testAppId).build();
    VirtualCluster startingVirtualCluster =
        VirtualClusterBuilder.newInstance().id(testVcId).build();
    String url =
        manager.generateCookbooksArchive(
            Arrays.asList(startingApplication), startingVirtualCluster);

    File outputFile =
        new File(vcCookbookDestinationRoot + "/" + testVcId + "/" + cookbooksArchiveName);
    assertTrue(outputFile.exists());
    assertEquals(vcCookbookUrlBase + testVcId + "/" + cookbooksArchiveName, url);

    ensureFileNotExists(vcDirectory);
  }
示例#4
0
  @Test
  public void testCreateCookbook() throws Exception {
    Long testAccountId = Long.valueOf(1);
    Long testAppId = Long.valueOf(1);
    givenApplicationExists(
        ApplicationModelBuilder.newInstance().accountId(testAccountId).appId(testAppId).build());

    InputStream testInputStream = new FileInputStream("src/test/resources/cookbook.tar.gz");
    Cookbook cookbook = CookbookBuilder.newInstance().name("cookbook.tar.gz").build();

    File accountDirectory = new File(cookbookDestinationRoot + "/" + testAccountId);
    ensureFileNotExists(accountDirectory);

    manager.createCookbook(testAppId, cookbook, testInputStream);
    File outputFile =
        new File(cookbookDestinationRoot + "/" + testAccountId + "/" + testAppId + "/xlc-fds");
    assertTrue(outputFile.exists());

    ensureFileNotExists(accountDirectory);
  }