Projects >> hudson >>35b97d451c717d3f75b357b3caca347e1e65fe30

Chunk
Conflicting content
 */
package hudson.model;

<<<<<<< HEAD
import hudson.ExtensionList;
=======
import jenkins.util.xml.FilteredFunctionContext;
>>>>>>> 1887656c118784a4fd22435ea6868109f11b9df7
import jenkins.model.Jenkins;
import jenkins.security.SecureRequester;
Solution content
 */
package hudson.model;

import hudson.ExtensionList;
import jenkins.util.xml.FilteredFunctionContext;
import jenkins.model.Jenkins;
import jenkins.security.SecureRequester;
File
Api.java
Developer's decision
Concatenation
Kind of conflict
Import
Chunk
Conflicting content
import java.io.File;
import java.io.IOException;
import java.net.HttpURLConnection;
<<<<<<< HEAD

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;
=======
import org.jvnet.hudson.test.HudsonTestCase;
import org.jvnet.hudson.test.Bug;
import org.xml.sax.SAXException;
>>>>>>> 1887656c118784a4fd22435ea6868109f11b9df7

/**
 * @author Kohsuke Kawaguchi
Solution content
import java.io.File;
import java.net.HttpURLConnection;

import org.junit.Rule;
import org.junit.Test;
import org.jvnet.hudson.test.Issue;
import org.jvnet.hudson.test.JenkinsRule;

/**
 * @author Kohsuke Kawaguchi
File
ApiTest.java
Developer's decision
Version 1
Kind of conflict
Import
Chunk
Conflicting content
<<<<<<< HEAD
        j.createWebClient().goTo("api/xml?xpath=/*[1]", "application/xml");
    }
    @Test
    @Issue("JENKINS-3267")
    public void wrappedZeroItems() throws Exception {
        Page page = j.createWebClient().goTo("api/xml?wrapper=root&xpath=/hudson/nonexistent", "application/xml");
=======
    /**
     * Test that calling the XML API with the XPath document function fails.
     *
     * @throws Exception if so
     */
    //Issue("SECURITY-165")
    public void testXPathDocumentFunction() throws Exception {
        File f = new File(jenkins.getRootDir(), "queue.xml");
        WebClient client = createWebClient();

        try {
            client.goTo("api/xml?xpath=document(\"" + f.getAbsolutePath() + "\")", "application/xml");
            fail("Should become 500 error");
        } catch (com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException e) {
            String contentAsString = e.getResponse().getContentAsString();
            assertStringContains(
                    contentAsString,
                    "Illegal function: document");
        }
    }

    @Bug(3267)
    public void testWrappedZeroItems() throws Exception {
        Page page = new WebClient().goTo("api/xml?wrapper=root&xpath=/hudson/nonexistent", "application/xml");
>>>>>>> 1887656c118784a4fd22435ea6868109f11b9df7
        assertEquals("", page.getWebResponse().getContentAsString());
    }
Solution content
        j.createWebClient().goTo("api/xml?xpath=/*[1]", "application/xml");
    }

    @Test
    @Issue("JENKINS-3267")
    public void wrappedZeroItems() throws Exception {
        Page page = j.createWebClient().goTo("api/xml?wrapper=root&xpath=/hudson/nonexistent", "application/xml");
        assertEquals("", page.getWebResponse().getContentAsString());
    }

    /**
     * Test that calling the XML API with the XPath document function fails.
     *
     * @throws Exception if so
     */
    @Issue("SECURITY-165")
    @Test public void xPathDocumentFunction() throws Exception {
        File f = new File(j.jenkins.getRootDir(), "queue.xml");
        JenkinsRule.WebClient client = j.createWebClient();

        try {
            client.goTo("api/xml?xpath=document(\"" + f.getAbsolutePath() + "\")", "application/xml");
            fail("Should become 500 error");
        } catch (com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException e) {
            String contentAsString = e.getResponse().getContentAsString();
            j.assertStringContains(
                    contentAsString,
                    "Illegal function: document");
        }
    }

    @Test
    @Issue("JENKINS-3267")
    public void wrappedOneItem() throws Exception {
        Page page = j.createWebClient().goTo("api/xml?wrapper=root&xpath=/hudson/view/name", "application/xml");
        assertEquals("All", page.getWebResponse().getContentAsString());
    }

    @Test
    public void wrappedMultipleItems() throws Exception {
        j.createFreeStyleProject();
        j.createFreeStyleProject();
        Page page = j.createWebClient().goTo("api/xml?wrapper=root&xpath=/hudson/job/name", "application/xml");
        assertEquals("test0test1", page.getWebResponse().getContentAsString());
    }

    @Test
    public void unwrappedZeroItems() throws Exception {
        j.createWebClient().assertFails("api/xml?xpath=/hudson/nonexistent", HttpURLConnection.HTTP_NOT_FOUND);
    }

    @Test
    public void unwrappedOneItem() throws Exception {
        Page page = j.createWebClient().goTo("api/xml?xpath=/hudson/view/name", "application/xml");
        assertEquals("All", page.getWebResponse().getContentAsString());
    }

    @Test
    public void unwrappedLongString() throws Exception {
        j.jenkins.setSystemMessage("Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.");
        Page page = j.createWebClient().goTo("api/xml?xpath=/hudson/description", "application/xml");
        assertEquals(
                ""+j.jenkins.getSystemMessage()+"",
                page.getWebResponse().getContentAsString());
    }

    @Test
    public void unwrappedMultipleItems() throws Exception {
        j.createFreeStyleProject();
        j.createFreeStyleProject();
        j.createWebClient().assertFails("api/xml?xpath=/hudson/job/name", HttpURLConnection.HTTP_INTERNAL_ERROR);
    }
}
File
ApiTest.java
Developer's decision
Manual
Kind of conflict
Annotation
Comment
Method declaration
Method invocation
Method signature
Variable