public void run() { status = "started"; File mavenProject = getTestFile("pom.xml").getParentFile(); System.setProperty("maven.home", TestProperties.getString("maven.instance")); Verifier verifier; try { verifier = new Verifier(mavenProject.getAbsolutePath(), false); status = "verifierCreated"; } catch (VerificationException e) { status = "failCreation" + e.getMessage(); return; } File mavenRepository = new File(TestProperties.getString("maven.local.repo")); verifier.setLocalRepo(mavenRepository.getAbsolutePath()); verifier.resetStreams(); List<String> options = new ArrayList<String>(); options.add("-X"); options.add("-Dmaven.repo.local=" + mavenRepository.getAbsolutePath()); options.add("-s " + getOverridableFile("settings.xml")); verifier.setCliOptions(options); status = "pre-execute"; try { verifier.executeGoal("dependency:resolve"); status = "executed"; } catch (VerificationException e) { status = "failExecute" + e.getMessage(); } }
@BeforeMethod public void cleanRepo() throws IOException { AbstractMavenNexusIT.cleanRepository( new File(TestProperties.getString("maven.local.repo")), getTestId()); AbstractMavenNexusIT.cleanRepository( new File(TestProperties.getString("maven.local.repo")), "nxcm281"); }
protected void copyTestResources() throws IOException { File source = new File(TestProperties.getString("test.resources.source.folder"), getTestId()); if (!source.exists()) { return; } File destination = new File(TestProperties.getString("test.resources.folder"), getTestId()); FileTestingUtils.interpolationDirectoryCopy(source, destination, TestProperties.getAll()); }
static { nexusApplicationPort = TestProperties.getInteger("nexus.application.port"); nexusControlPort = TestProperties.getInteger("nexus.control.port"); nexusBaseDir = TestProperties.getString("nexus.base.dir"); nexusWorkDir = TestProperties.getString("nexus.work.dir"); WORK_CONF_DIR = nexusWorkDir + "/conf"; nexusLogDir = TestProperties.getString("nexus.log.dir"); nexusBaseUrl = TestProperties.getString("nexus.base.url"); baseNexusUrl = nexusBaseUrl; }
@Test public void downloadWithPermition() throws Exception { AbstractMavenNexusIT.cleanRepository( new File(TestProperties.getString("maven.local.repo")), getTestId()); TestContainer.getInstance().getTestContext().useAdminForRequests(); replaceUserRole(TEST_USER_NAME, "nx-admin"); download(); }
public static File getResource(String resource) { log.debug("Looking for resource: " + resource); // URL classURL = Thread.currentThread().getContextClassLoader().getResource( resource ); File rootDir = new File(TestProperties.getString("test.resources.folder")); File file = new File(rootDir, resource); if (!file.exists()) { return null; } log.debug("found: " + file); return file; }
private void updateLog4j(File log4jFile) throws IOException { EnhancedProperties properties = new EnhancedProperties(); if (log4jFile.exists()) { FileInputStream input = new FileInputStream(log4jFile); properties.load(input); IOUtil.close(input); } attachPropertiesToLog(properties); String newFileName = this.getTestId() + "/test-config/log4j.properties"; File newLog4JFile = new File(TestProperties.getString("test.resources.folder"), newFileName); newLog4JFile.getParentFile().mkdirs(); FileOutputStream output = new FileOutputStream(newLog4JFile); try { properties.store(output); } finally { IOUtil.close(output); } }
@Override protected void copyTestResources() throws IOException { super.copyTestResources(); String proxyRepoBaseUrl = TestProperties.getString("proxy.repo.base.url"); Assert.assertTrue(proxyRepoBaseUrl.startsWith("http://")); replaceInFile( "target/nexus/proxy-repo/p2repowithftpmirror/artifacts.xml", "${proxy-repo-base-url}", proxyRepoBaseUrl); replaceInFile( "target/nexus/proxy-repo/p2repowithftpmirror/mirrors.xml", "${proxy-repo-base-url}", proxyRepoBaseUrl); replaceInFile( "target/nexus/proxy-repo/p2repowithftpmirror/mirrors.xml", "${ftp-proxy-repo-base-url}", "ftp" + proxyRepoBaseUrl.substring(4)); }
private void setupMockJira() throws Exception { final int port = Integer.parseInt(TestProperties.getString("jira-server-port")); final File mockDb = getTestFile("jira-mock.db"); StubJira mock = new StubJira(); mock.setDatabase(Files.toString(mockDb, Charset.forName("utf-8"))); // we have to give a real version (set in DB and here), because either nexus freaks out // otherwise MockAttachmentHandler handler = new MockAttachmentHandler(); handler.setSupportedVersion("4.3"); handler.setMock(mock); List<AttachmentHandler> handlers = Arrays.<AttachmentHandler>asList(handler); server = new JettyServerProvider(); server.setPort(port); server.addServlet(new JiraXmlRpcTestServlet(mock, server.getUrl(), handlers)); server.start(); }
@Override public void copyTestResources() throws IOException { super.copyTestResources(); final String proxyRepoBaseUrl = TestProperties.getString("proxy.repo.base.url"); replaceInFile( localStorageDir + "/meclipse0393/memberrepo1/artifacts.xml", "${proxy-repo-base-url}", proxyRepoBaseUrl); replaceInFile( localStorageDir + "/meclipse0393/memberrepo2/artifacts.xml", "${proxy-repo-base-url}", proxyRepoBaseUrl); replaceInFile( localStorageDir + "/meclipse0393/memberrepo1/mirrors.xml", "${proxy-repo-base-url}", proxyRepoBaseUrl); replaceInFile( localStorageDir + "/meclipse0393/memberrepo2/mirrors.xml", "${proxy-repo-base-url}", proxyRepoBaseUrl); }
private String createUrl(String targetRepoId) { return "http:////localhost:" + TestProperties.getString("nexus.application.port") + "/nexus/content/repositories/" + targetRepoId; }