protected void installUsingP2(final String repositoryURL, final String installIU, final String destination,
final Map<String, String> sysProps)
throws Exception
{
UserMessageUtil userUtil = new UserMessageUtil(getXMLXStream(), MediaType.APPLICATION_XML);
boolean wasAnonymousAdministrator = userUtil.isAnonymousAdministrator();
try {
userUtil.makeAnonymousAdministrator(true);
FileUtils.deleteDirectory(new File(destination));
String tempDirPath = System.getProperty("maven.test.tmpdir", System.getProperty("java.io.tmpdir"));
File testDir = new File(tempDirPath, getTestId() + "/run-p2/" + System.currentTimeMillis());
FileUtils.deleteDirectory(testDir);
final File basedir = ResourceExtractor.extractResourcePath(getClass(), "/run-p2", testDir, false);
final Verifier verifier = new Verifier(basedir.getAbsolutePath());
verifier.setLocalRepo(new File(TestContainer.getBasedir(), "target/maven/fake-repo").getAbsolutePath());
verifier.setSystemProperty("org.eclipse.ecf.provider.filetransfer.retrieve.readTimeout", "30000");
verifier.setSystemProperty("p2.installIU", installIU);
verifier.setSystemProperty("p2.destination", destination);
verifier.setSystemProperty("p2.metadataRepository", repositoryURL);
verifier.setSystemProperty("p2.artifactRepository", repositoryURL);
verifier.setSystemProperty("p2.profile", getTestId());
if (sysProps != null) {
for (Map.Entry<String, String> entry : sysProps.entrySet()) {
verifier.setSystemProperty(entry.getKey(), entry.getValue());
}
}
verifier.setLogFileName(getTestId() + "-maven-output.log");
verifier.addCliOption("-X");
verifier.executeGoals(Arrays.asList("verify"));
verifier.verifyErrorFreeLog();
verifier.resetStreams();
FileUtils.deleteDirectory(testDir);
}
finally {
userUtil.makeAnonymousAdministrator(wasAnonymousAdministrator);
}
}