Search in sources :

Example 1 with Email

use of org.jvnet.hudson.test.Email in project maven-plugin by jenkinsci.

the class AbstractMaven3xBuildTest method testMavenWithDependencyVersionInEnvVar.

@Test
@Email("https://groups.google.com/d/msg/hudson-users/Xhw00UopVN0/FA9YqDAIsSYJ")
public void testMavenWithDependencyVersionInEnvVar() throws Exception {
    MavenModuleSet m = j.jenkins.createProject(MavenModuleSet.class, "p");
    MavenInstallation mavenInstallation = configureMaven3x();
    ParametersDefinitionProperty parametersDefinitionProperty = new ParametersDefinitionProperty(new StringParameterDefinition("JUNITVERSION", "3.8.2"));
    m.addProperty(parametersDefinitionProperty);
    m.setMaven(mavenInstallation.getName());
    m.getReporters().add(new TestReporter());
    m.setScm(new ExtractResourceSCM(getClass().getResource("envars-maven-project.zip")));
    m.setGoals("clean test-compile -Dmaven.compiler.target=1.8 -Dmaven.compiler.source=1.8");
    MavenModuleSetBuild mmsb = j.buildAndAssertSuccess(m);
    assertFalse(mmsb.getProject().getModules().isEmpty());
}
Also used : MavenInstallation(hudson.tasks.Maven.MavenInstallation) StringParameterDefinition(hudson.model.StringParameterDefinition) ParametersDefinitionProperty(hudson.model.ParametersDefinitionProperty) ExtractResourceSCM(org.jvnet.hudson.test.ExtractResourceSCM) Email(org.jvnet.hudson.test.Email) Test(org.junit.Test)

Example 2 with Email

use of org.jvnet.hudson.test.Email in project jenkins by jenkinsci.

the class HudsonTest method computerConfigureLink.

/**
 * Configure link from "/computer/(built-in)/" should work.
 */
@Test
@Email("http://www.nabble.com/Master-slave-refactor-td21361880.html")
public void computerConfigureLink() throws Exception {
    HtmlPage page = j.createWebClient().goTo("computer/(built-in)/configure");
    j.submit(page.getFormByName("config"));
}
Also used : HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Email(org.jvnet.hudson.test.Email) SmokeTest(org.jvnet.hudson.test.SmokeTest) SearchTest(hudson.search.SearchTest) Test(org.junit.Test)

Example 3 with Email

use of org.jvnet.hudson.test.Email in project jenkins by jenkinsci.

the class HudsonTest method simpleConfigSubmit.

/**
 * Performs a very basic round-trip of a non-empty system configuration screen.
 * This makes sure that the structured form submission is working (to some limited extent.)
 */
@Test
@LocalData
@Email("http://www.nabble.com/Hudson.configure-calling-deprecated-Descriptor.configure-td19051815.html")
public void simpleConfigSubmit() throws Exception {
    // just load the page and resubmit
    HtmlPage configPage = j.createWebClient().goTo("configure");
    HtmlForm form = configPage.getFormByName("config");
    j.submit(form);
    // Load tools page and resubmit too
    HtmlPage toolsConfigPage = j.createWebClient().goTo("configureTools");
    HtmlForm toolsForm = toolsConfigPage.getFormByName("config");
    j.submit(toolsForm);
    // make sure all the pieces are intact
    assertEquals(2, j.jenkins.getNumExecutors());
    assertSame(Mode.NORMAL, j.jenkins.getMode());
    assertSame(SecurityRealm.NO_AUTHENTICATION, j.jenkins.getSecurityRealm());
    assertSame(AuthorizationStrategy.UNSECURED, j.jenkins.getAuthorizationStrategy());
    assertEquals(5, j.jenkins.getQuietPeriod());
    List<JDK> jdks = j.jenkins.getJDKs();
    // Hudson adds one more
    assertEquals(3, jdks.size());
    assertJDK(jdks.get(0), "jdk1", "/tmp");
    assertJDK(jdks.get(1), "jdk2", "/tmp");
    AntInstallation[] ants = j.jenkins.getDescriptorByType(Ant.DescriptorImpl.class).getInstallations();
    assertEquals(2, ants.length);
    assertAnt(ants[0], "ant1", "/tmp");
    assertAnt(ants[1], "ant2", "/tmp");
}
Also used : HtmlForm(com.gargoylesoftware.htmlunit.html.HtmlForm) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) AntInstallation(hudson.tasks.Ant.AntInstallation) LocalData(org.jvnet.hudson.test.recipes.LocalData) Email(org.jvnet.hudson.test.Email) SmokeTest(org.jvnet.hudson.test.SmokeTest) SearchTest(hudson.search.SearchTest) Test(org.junit.Test)

Example 4 with Email

use of org.jvnet.hudson.test.Email in project jenkins by jenkinsci.

the class HudsonTest method deleteHudsonComputer.

/**
 * Configure link from "/computer/(built-in)/" should work.
 */
@Test
@Email("http://www.nabble.com/Master-slave-refactor-td21361880.html")
public void deleteHudsonComputer() throws Exception {
    WebClient wc = j.createWebClient();
    HtmlPage page = wc.goTo("computer/(built-in)/");
    for (HtmlAnchor a : page.getAnchors()) {
        assertFalse(a.getHrefAttribute(), a.getHrefAttribute().endsWith("delete"));
    }
    wc.setThrowExceptionOnFailingStatusCode(false);
    // try to delete it by hitting the final URL directly
    WebRequest req = new WebRequest(new URL(wc.getContextPath() + "computer/(built-in)/doDelete"), HttpMethod.POST);
    page = wc.getPage(wc.addCrumb(req));
    assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, page.getWebResponse().getStatusCode());
    // the built-in computer object should be still here
    page = wc.goTo("computer/(built-in)/");
    assertEquals(HttpURLConnection.HTTP_OK, page.getWebResponse().getStatusCode());
}
Also used : HtmlAnchor(com.gargoylesoftware.htmlunit.html.HtmlAnchor) WebRequest(com.gargoylesoftware.htmlunit.WebRequest) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) WebClient(org.jvnet.hudson.test.JenkinsRule.WebClient) URL(java.net.URL) Email(org.jvnet.hudson.test.Email) SmokeTest(org.jvnet.hudson.test.SmokeTest) SearchTest(hudson.search.SearchTest) Test(org.junit.Test)

Example 5 with Email

use of org.jvnet.hudson.test.Email in project jenkins by jenkinsci.

the class JnlpAccessWithSecuredHudsonTest method anonymousCanAlwaysLoadJARs.

@PresetData(DataSet.NO_ANONYMOUS_READACCESS)
@Email("http://markmail.org/message/on4wkjdaldwi2atx")
@Test
public void anonymousCanAlwaysLoadJARs() throws Exception {
    ApiTokenTestHelper.enableLegacyBehavior();
    r.jenkins.setNodes(Collections.singletonList(createNewJnlpSlave("test")));
    JenkinsRule.WebClient wc = r.createWebClient();
    HtmlPage p = wc.withBasicApiToken(User.getById("alice", true)).goTo("computer/test/");
    // this fresh WebClient doesn't have a login cookie and represent JNLP launcher
    JenkinsRule.WebClient jnlpAgent = r.createWebClient();
    // parse the JNLP page into DOM to list up the jars.
    XmlPage jnlp = (XmlPage) wc.goTo("computer/test/jenkins-agent.jnlp", "application/x-java-jnlp-file");
    URL baseUrl = jnlp.getUrl();
    Document dom = new DOMReader().read(jnlp.getXmlDocument());
    for (Object jar : dom.selectNodes("//jar")) {
        URL url = new URL(baseUrl, ((Element) jar).attributeValue("href"));
        System.out.println(url);
        // now make sure that these URLs are unprotected
        Page jarResource = jnlpAgent.getPage(url);
        assertTrue(jarResource.getWebResponse().getContentType().toLowerCase(Locale.ENGLISH).startsWith("application/"));
    }
}
Also used : DOMReader(org.dom4j.io.DOMReader) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) XmlPage(com.gargoylesoftware.htmlunit.xml.XmlPage) XmlPage(com.gargoylesoftware.htmlunit.xml.XmlPage) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) Page(com.gargoylesoftware.htmlunit.Page) JenkinsRule(org.jvnet.hudson.test.JenkinsRule) Document(org.dom4j.Document) URL(java.net.URL) Email(org.jvnet.hudson.test.Email) PresetData(org.jvnet.hudson.test.recipes.PresetData) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)13 Email (org.jvnet.hudson.test.Email)13 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)5 XmlPage (com.gargoylesoftware.htmlunit.xml.XmlPage)4 FreeStyleBuild (hudson.model.FreeStyleBuild)4 SearchTest (hudson.search.SearchTest)3 SmokeTest (org.jvnet.hudson.test.SmokeTest)3 Page (com.gargoylesoftware.htmlunit.Page)2 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)2 ParametersDefinitionProperty (hudson.model.ParametersDefinitionProperty)2 StringParameterDefinition (hudson.model.StringParameterDefinition)2 MavenInstallation (hudson.tasks.Maven.MavenInstallation)2 URL (java.net.URL)2 ExtractResourceSCM (org.jvnet.hudson.test.ExtractResourceSCM)2 WebClient (org.jvnet.hudson.test.JenkinsRule.WebClient)2 WebRequest (com.gargoylesoftware.htmlunit.WebRequest)1 HtmlAnchor (com.gargoylesoftware.htmlunit.html.HtmlAnchor)1 Slave (hudson.model.Slave)1 AntInstallation (hudson.tasks.Ant.AntInstallation)1 Shell (hudson.tasks.Shell)1