diff --git a/nexus/nexus-test-harness/nexus-test-harness-its/pom.xml b/nexus/nexus-test-harness/nexus-test-harness-its/pom.xml index 894e0688c8..3416696385 100644 --- a/nexus/nexus-test-harness/nexus-test-harness-its/pom.xml +++ b/nexus/nexus-test-harness/nexus-test-harness-its/pom.xml @@ -295,6 +295,14 @@ + + + org.sonatype.sisu.pr + sisu-pr-testutil + 1.5-SNAPSHOT + test + + diff --git a/nexus/nexus-test-harness/nexus-test-harness-its/resources/nexus3082/files/jira-mock.db b/nexus/nexus-test-harness/nexus-test-harness-its/resources/nexus3082/files/jira-mock.db new file mode 100644 index 0000000000..a4c6d39879 --- /dev/null +++ b/nexus/nexus-test-harness/nexus-test-harness-its/resources/nexus3082/files/jira-mock.db @@ -0,0 +1,538 @@ + + + + + + + SBOX + + + + #attributes + + + + + + + id + 10266 + + + projectUrl + + + + #attributes + + + + description + + + + name + Sandbox + + + lead + brianf + + + key + SBOX + + + url + https://issues.sonatype.org/browse/SBOX + + + + + + + + + + SBOX + + + + name + Nexus + + + id + 10482 + + + + + + + + SBOX + + + + sequence + 1 + + + releaseDate + 2011-03-31 00:00:00.0 + + + released + false + + + id + 11101 + + + name + 1 + + + archived + false + + + + + sequence + 2 + + + releaseDate + 2012-03-31 00:00:00.0 + + + released + false + + + id + 11102 + + + name + 2 + + + archived + false + + + + + + + + + name + Bug + + + icon + https://issues.sonatype.org/images/icons/bug.gif + + + description + A problem which impairs or prevents the functions of the product. + + + subTask + false + + + id + 1 + + + + + name + New Feature + + + icon + https://issues.sonatype.org/images/icons/newfeature.gif + + + description + A new feature of the product, which has yet to be developed. + + + subTask + false + + + id + 2 + + + + + name + Task + + + icon + https://issues.sonatype.org/images/icons/task.gif + + + description + A task that needs to be done. + + + subTask + false + + + id + 3 + + + + + name + Improvement + + + icon + https://issues.sonatype.org/images/icons/improvement.gif + + + description + An improvement or enhancement to an existing feature or task. + + + subTask + false + + + id + 4 + + + + + name + User Story + + + icon + http://www.sonatype.com/~brianf/jira/tan-green-user.gif + + + description + + + + subTask + false + + + id + 6 + + + + + name + Deliverable + + + icon + https://issues.sonatype.org/images/icons/sales.gif + + + description + Artifact hand-off identifies source/sink, date, and form + + + subTask + false + + + id + 9 + + + + + name + General Question + + + icon + https://issues.sonatype.org/images/icons/undefined.gif + + + description + questions about product and feature + + + subTask + false + + + id + 16 + + + + + name + Problem + + + icon + https://issues.sonatype.org/images/icons/bug.gif + + + description + Technical Support Request + + + subTask + false + + + id + 17 + + + + + name + Documentation + + + icon + https://issues.sonatype.org/images/icons/genericissue.gif + + + description + + + + subTask + false + + + id + 20 + + + + + name + New Project + + + icon + https://issues.sonatype.org/images/icons/newfeature.gif + + + description + Add a new project to the repository + + + subTask + false + + + id + 21 + + + + + name + Blog + + + icon + https://issues.sonatype.org/images/icons/documentation.gif + + + description + + + + subTask + false + + + id + 23 + + + + + name + Video + + + icon + https://issues.sonatype.org/images/icons/newfeature.gif + + + description + + + + subTask + false + + + id + 24 + + + + + name + Epic + + + icon + https://issues.sonatype.org/download/resources/com.pyxis.greenhopper.jira:greenhopper-webactions/images/ico_epic.png + + + description + A big user story that needs to be broken down. + + + subTask + false + + + id + 25 + + + + + + + color + #cc0000 + + + name + Blocker + + + icon + https://issues.sonatype.org/images/icons/priority_blocker.gif + + + description + Blocks development and/or testing work, production could not run. + + + id + 1 + + + + + color + #ff0000 + + + name + Critical + + + icon + https://issues.sonatype.org/images/icons/priority_critical.gif + + + description + Crashes, loss of data, severe memory leak. + + + id + 2 + + + + + color + #009900 + + + name + Major + + + icon + https://issues.sonatype.org/images/icons/priority_major.gif + + + description + Major loss of function. + + + id + 3 + + + + + color + #006600 + + + name + Minor + + + icon + https://issues.sonatype.org/images/icons/priority_minor.gif + + + description + Minor loss of function, or other problem where easy workaround is present. + + + id + 4 + + + + + color + #003300 + + + name + Trivial + + + icon + https://issues.sonatype.org/images/icons/priority_trivial.gif + + + description + Cosmetic problem like misspelt words or misaligned text. + + + id + 5 + + + + + + version + 4.3 + + + + \ No newline at end of file diff --git a/nexus/nexus-test-harness/nexus-test-harness-its/resources/nexus3082/test-config/nexus.xml b/nexus/nexus-test-harness/nexus-test-harness-its/resources/nexus3082/test-config/nexus.xml index efe31dc88d..a42c5d68c1 100644 --- a/nexus/nexus-test-harness/nexus-test-harness-its/resources/nexus3082/test-config/nexus.xml +++ b/nexus/nexus-test-harness/nexus-test-harness-its/resources/nexus3082/test-config/nexus.xml @@ -117,7 +117,7 @@ system@nexus.org - https://issues.sonatype.org + http://localhost:${webproxy-server-port} SBOX diff --git a/nexus/nexus-test-harness/nexus-test-harness-its/src/test/java/org/sonatype/nexus/integrationtests/nexus3082/Nexus3082GenerateProblemReportIT.java b/nexus/nexus-test-harness/nexus-test-harness-its/src/test/java/org/sonatype/nexus/integrationtests/nexus3082/Nexus3082GenerateProblemReportIT.java index 9eb97426af..e91d265965 100644 --- a/nexus/nexus-test-harness/nexus-test-harness-its/src/test/java/org/sonatype/nexus/integrationtests/nexus3082/Nexus3082GenerateProblemReportIT.java +++ b/nexus/nexus-test-harness/nexus-test-harness-its/src/test/java/org/sonatype/nexus/integrationtests/nexus3082/Nexus3082GenerateProblemReportIT.java @@ -12,15 +12,61 @@ */ package org.sonatype.nexus.integrationtests.nexus3082; +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import com.google.common.collect.Lists; +import com.google.common.io.CharStreams; +import com.google.common.io.Closeables; +import com.google.common.io.Files; +import com.google.common.io.InputSupplier; +import com.google.common.io.Resources; +import org.sonatype.jira.AttachmentHandler; +import org.sonatype.jira.mock.MockAttachmentHandler; +import org.sonatype.jira.mock.StubJira; +import org.sonatype.jira.test.JiraXmlRpcTestServlet; import org.sonatype.nexus.integrationtests.AbstractNexusIntegrationTest; import org.sonatype.nexus.rest.model.ErrorReportResponse; import org.sonatype.nexus.test.utils.ErrorReportUtil; +import org.sonatype.nexus.test.utils.TestProperties; +import org.sonatype.tests.http.server.api.Behaviour; +import org.sonatype.tests.http.server.fluent.Server; +import org.sonatype.tests.http.server.jetty.impl.JettyServerProvider; import org.testng.Assert; +import org.testng.annotations.AfterMethod; +import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; public class Nexus3082GenerateProblemReportIT extends AbstractNexusIntegrationTest { + + private JettyServerProvider server; + + @BeforeMethod + public void setupJiraMock() + throws Exception + { + setupMockJira(); + } + + @AfterMethod + public void shutdownJiraMock() + throws Exception + { + if ( server != null ) + { + server.stop(); + } + } + @Test public void generateReport() throws Exception @@ -32,6 +78,37 @@ public void generateReport() Assert.assertNotNull( response.getData().getJiraUrl() ); } + private void setupMockJira() + throws Exception + { + + final int port = Integer.parseInt( TestProperties.getString( "webproxy-server-port" ) ); + + setupJiraMock( "jira-mock.db", port ); + } + + private void setupJiraMock( String dbName, int port ) + throws Exception + { + final File mockDb = getTestFile( dbName ); + + 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 handlers = Arrays.asList( handler ); + server = new JettyServerProvider(); + server.setPort( port ); + server.addServlet( new JiraXmlRpcTestServlet( mock, server.getUrl(), handlers ) ); + server.start(); + } + @Test public void generateReportWithFailure() throws Exception