Github user ahgittin commented on a diff in the pull request:
https://github.com/apache/brooklyn-server/pull/560#discussion_r103746212
--- 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 --
really? javadoc says `File(String pathname)`, no indication that it should
accept a URI. but i haven't tried.
in any case i think the extract is a better pattern than assuming resources
are in `classes/` dir on filesystem -- wdyt?
---
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 [email protected] or file a JIRA ticket
with INFRA.
---