Пример #1
0
 @Test
 public void testStandardNonOkHandlePipelinesErrors() throws Exception {
   withApp(
       new AppRunnable() {
         public void run(App app) throws Exception {
           try {
             janvil.addDownstream(app.getName(), app.getName());
             fail();
           } catch (JanvilRuntimeException e) {
             assertEquals(e.getMessage(), "Downstream app cannot be recursive");
           }
         }
       });
 }
Пример #2
0
 @Test
 public void testCopyNoAccessToTargetApp() throws Exception {
   withApp(
       new AppRunnable() {
         public void run(App app) throws Exception {
           try {
             janvil.copy(app.getName(), "java", "no access to source");
             fail();
           } catch (JanvilRuntimeException e) {
             assertEquals(e.getMessage(), "No access to app java");
           }
         }
       });
 }
Пример #3
0
 @Test
 public void testReleaseInvalidUrl() throws Exception {
   withApp(
       new AppRunnable() {
         public void run(final App app) throws Exception {
           String invalidUrl = "http://example.com/invalid.tgz";
           try {
             janvil.release(app.getName(), invalidUrl, "testReleaseInvalidUrl");
             fail();
           } catch (JanvilRuntimeException e) {
             assertEquals(e.getMessage(), "Could not find " + invalidUrl);
           }
         }
       });
 }
Пример #4
0
  private void assertCopyOf(final String sourceAppName) throws Exception {
    withApp(
        new AppRunnable() {
          public void run(final App target) throws Exception {
            final Client testClient = Janvil.getClient(FIXED_LENGTH);
            testClient.addFilter(new LoggingFilter(System.out));
            final App source = herokuApi.getApp(sourceAppName);
            final List<Release> sourceReleases = herokuApi.listReleases(source.getName());
            final Release sourceLastRelease = sourceReleases.get(sourceReleases.size() - 1);
            final String sourceCommitHead = sourceLastRelease.getCommit();
            final Map<String, String> sourcePs = sourceLastRelease.getPSTable();
            final String sourceContent = getWebContent(testClient, source);

            // block copy until we have the initial releases in place on the target app to avoid
            // race conditions
            assertUntil(
                5,
                2000,
                new Runnable() {
                  public void run() {
                    int initialReleases = 2;
                    assertEquals(initialReleases, herokuApi.listReleases(target.getName()).size());
                  }
                });

            final String description = "copy";
            janvil.copy(source.getName(), target.getName(), description);

            assertBuildpackProvidedDescriptionEquals(source, herokuApi.getApp(target.getName()));

            final List<Release> targetReleases = herokuApi.listReleases(target.getName());
            final Release targetLastRelease = targetReleases.get(targetReleases.size() - 1);
            assertEquals(targetLastRelease.getDescription(), description);
            assertEquals(targetLastRelease.getCommit(), sourceCommitHead);
            assertEquals(targetLastRelease.getPSTable(), sourcePs);
            assertUntil(
                5,
                2000,
                new Runnable() {
                  public void run() {
                    assertEquals(getWebContent(testClient, target), sourceContent);
                  }
                });
          }

          private void assertBuildpackProvidedDescriptionEquals(App source, App target) {
            assertEquals(
                normalizeBuildpackDescription(target.getBuildpackProvidedDescription()),
                normalizeBuildpackDescription(source.getBuildpackProvidedDescription()));
          }

          private String normalizeBuildpackDescription(String buildpackProvidedDescription) {
            return buildpackProvidedDescription == null
                ? "(unknown)"
                : buildpackProvidedDescription;
          }

          private String getWebContent(Client testClient, App target) {
            return testClient.resource(target.getWebUrl()).get(String.class);
          }
        });
  }