You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by neykov <gi...@git.apache.org> on 2017/03/01 15:54:03 UTC

[GitHub] brooklyn-server pull request #560: Attempted non-determinate test fixes

Github user neykov commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/560#discussion_r103716892
  
    --- Diff: launcher/src/test/java/org/apache/brooklyn/launcher/CleanOrphanedLocationsIntegrationTest.java ---
    @@ -66,13 +72,26 @@
         private Set<ManagementContext> mgmts;
         private ManagementContext mgmt;
     
    +    private String copyResourcePathToTempPath(String resourcePath) {
    +        BundleMaker bm = new BundleMaker(ResourceUtils.create(this));
    +        bm.setDefaultClassForLoading(CleanOrphanedLocationsIntegrationTest.class);
    +        File jar = bm.createJarFromClasspathDir(resourcePath);
    +        File output = Os.newTempDir("brooklyn-test-resouce-from-"+resourcePath);
    +        try {
    +            ArchiveUtils.extractZip(new ZipFile(jar), output.getAbsolutePath());
    +            return output.getAbsolutePath();
    +        } catch (Exception e) {
    +            throw Exceptions.propagate(e);
    +        }
    +    }
    +    
         @BeforeMethod(alwaysRun = true)
         @Override
         public void setUp() throws Exception {
             super.setUp();
    -        persistenceDirWithOrphanedLocations = getClass().getResource(PERSISTED_STATE_PATH_WITH_ORPHANED_LOCATIONS).getFile();
    -        persistenceDirWithoutOrphanedLocations = getClass().getResource(PERSISTED_STATE_PATH_WITHOUT_ORPHANED_LOCATIONS).getFile();
    -        persistenceDirWithMultipleLocationsOccurrence = getClass().getResource(PERSISTED_STATE_PATH_WITH_MULTIPLE_LOCATIONS_OCCURRENCE).getFile();
    +        persistenceDirWithOrphanedLocations = copyResourcePathToTempPath(PERSISTED_STATE_PATH_WITH_ORPHANED_LOCATIONS);
    +        persistenceDirWithoutOrphanedLocations = copyResourcePathToTempPath(PERSISTED_STATE_PATH_WITHOUT_ORPHANED_LOCATIONS);
    +        persistenceDirWithMultipleLocationsOccurrence = copyResourcePathToTempPath(PERSISTED_STATE_PATH_WITH_MULTIPLE_LOCATIONS_OCCURRENCE);
    --- End diff --
    
    The proper way to escape the URL is `new File(url.toURI())`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---