package hudson.plugins.perforce;

import hudson.model.FreeStyleProject;
import hudson.plugins.perforce.browsers.P4Web;
import org.apache.commons.beanutils.PropertyUtils;
import org.jvnet.hudson.test.HudsonTestCase;

import java.beans.PropertyDescriptor;
import java.net.URL;

import com.gargoylesoftware.htmlunit.WebClient;

/**
 * @author Kohsuke Kawaguchi
 */
public class PerforceSCMTest extends HudsonTestCase {
    /**
     * Makes sure that the configuration survives the round-trip.
     */
    public void testConfigRoundtrip() throws Exception {
        FreeStyleProject p = createFreeStyleProject();
        P4Web browser = new P4Web(new URL("http://localhost/"));
        PerforceSCM scm = new PerforceSCM("user", "pass", "client", "port", "path", "exe", "sysRoot", "sysDrive", "label", true, true, true, 0, browser);
        p.setScm(scm);

        // config roundtrip
        submit(new WebClient().getPage(p,"configure").getFormByName("config"));

        // verify that the data is intact
        assertEqualBeans(scm,p.getScm(),"p4User,p4Passwd,p4Client,p4Port,projectPath,p4Exe,p4SysRoot,p4SysDrive,p4Label,forceSync,updateView,renameClient,firstChange");
        assertEqualBeans(scm.getBrowser(),p.getScm().getBrowser(),"URL");
    }
  
}

@@ -25,17 +25,19 @@
 erforce;
-%0A
+%0D%0A%0D
 %0Aimport 
@@ -66,16 +66,17 @@
 Project;
+%0D
 %0Aimport 
@@ -118,218 +118,86 @@
 Web;
-%0Aimport org.apache.commons.beanutils.PropertyUtils;%0Aimport org.jvnet.hudson.test.HudsonTestCase;%0A%0Aimport java.beans.PropertyDescriptor;%0Aimport java.net.URL;%0A%0Aimport com.gargoylesoftware.htmlunit.WebClient;%0A
+%0D%0Aimport org.jvnet.hudson.test.HudsonTestCase;%0D%0A%0D%0Aimport java.net.URL;%0D%0A%0D
 %0A/**
+%0D
 %0A * 
@@ -225,12 +225,14 @@
 uchi
+%0D
 %0A */
+%0D
 %0Apub
@@ -285,16 +285,17 @@
 se %7B
+%0D
 %0A    /**
 %0A   
@@ -290,16 +290,17 @@
 %0A    /**
+%0D
 %0A     * 
@@ -361,16 +361,17 @@
 rip.
+%0D
 %0A     */
 %0A   
@@ -366,16 +366,17 @@
 %0A     */
+%0D
 %0A    pub
@@ -424,16 +424,17 @@
 eption %7B
+%0D
 %0A       
@@ -480,16 +480,17 @@
 oject();
+%0D
 %0A       
@@ -546,16 +546,17 @@
 ost/%22));
+%0D
 %0A       
@@ -590,16 +590,28 @@
 orceSCM(
+%0D%0A        %09%09
 %22user%22, 
@@ -662,16 +662,28 @@
 sRoot%22, 
+%0D%0A        %09%09
 %22sysDriv
@@ -725,16 +725,17 @@
 rowser);
+%0D
 %0A       
@@ -749,17 +749,19 @@
 cm(scm);
-%0A
+%0D%0A%0D
 %0A       
@@ -780,16 +780,17 @@
 oundtrip
+%0D
 %0A       
@@ -861,17 +861,19 @@
 nfig%22));
-%0A
+%0D%0A%0D
 %0A       
@@ -906,16 +906,25 @@
 s intact
+        %0D
 %0A       
@@ -956,16 +956,28 @@
 etScm(),
+%0D%0A        %09%09
 %22p4User,
@@ -1005,20 +1005,8 @@
 ort,
-projectPath,
 p4Ex
@@ -1028,16 +1028,32 @@
 ysDrive,
+%22 +%0D%0A        %09%09%22
 p4Label,
@@ -1100,16 +1100,17 @@
 hange%22);
+%0D
 %0A       
@@ -1179,16 +1179,16 @@
 L%22);
+%0D
 %0A    %7D
-%0A  
+%0D
 %0A%7D
+%0D
 %0A

fix test unable to test projectPath on the roundTrip