From d5dd4b853cb494eeb2925e7cf0c3e9999e89079e Mon Sep 17 00:00:00 2001 From: kohsuke Date: Tue, 16 Jun 2009 01:15:20 +0000 Subject: [PATCH] Moving remaining pieces and really removing SVNKit from the core dependency. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@18926 71c3de6d-444a-0410-be80-ed276b4c234a --- core/pom.xml | 5 - .../scm/FilterSVNAuthenticationManager.java | 64 ----- .../org/jvnet/hudson/test/HudsonTestCase.java | 16 +- .../java/hudson/scm/SubversionSCMTest.java | 272 ------------------ .../hudson/tasks/junit/CaseResultTest.java | 33 ++- 5 files changed, 23 insertions(+), 367 deletions(-) delete mode 100644 core/src/main/java/hudson/scm/FilterSVNAuthenticationManager.java delete mode 100644 test/src/test/java/hudson/scm/SubversionSCMTest.java diff --git a/core/pom.xml b/core/pom.xml index 4b1f88eaee..3b00c1201b 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -323,11 +323,6 @@ THE SOFTWARE. jna-posix 1.0.1 - - org.jvnet.hudson.svnkit - svnkit - 1.3.0-hudson-1 - org.kohsuke trilead-putty-extension diff --git a/core/src/main/java/hudson/scm/FilterSVNAuthenticationManager.java b/core/src/main/java/hudson/scm/FilterSVNAuthenticationManager.java deleted file mode 100644 index 8b7d7a5112..0000000000 --- a/core/src/main/java/hudson/scm/FilterSVNAuthenticationManager.java +++ /dev/null @@ -1,64 +0,0 @@ -package hudson.scm; - -import org.tmatesoft.svn.core.auth.ISVNAuthenticationManager; -import org.tmatesoft.svn.core.auth.ISVNAuthenticationProvider; -import org.tmatesoft.svn.core.auth.ISVNProxyManager; -import org.tmatesoft.svn.core.auth.SVNAuthentication; -import org.tmatesoft.svn.core.SVNURL; -import org.tmatesoft.svn.core.SVNException; -import org.tmatesoft.svn.core.SVNErrorMessage; -import org.tmatesoft.svn.core.io.SVNRepository; - -import javax.net.ssl.TrustManager; - -/** - * {@link ISVNAuthenticationManager} filter. Useful for customizing the behavior by delegation. - * @author Kohsuke Kawaguchi - */ -public class FilterSVNAuthenticationManager implements ISVNAuthenticationManager { - protected ISVNAuthenticationManager core; - - public FilterSVNAuthenticationManager(ISVNAuthenticationManager core) { - this.core = core; - } - - public void setAuthenticationProvider(ISVNAuthenticationProvider provider) { - core.setAuthenticationProvider(provider); - } - - public ISVNProxyManager getProxyManager(SVNURL url) throws SVNException { - return core.getProxyManager(url); - } - - public TrustManager getTrustManager(SVNURL url) throws SVNException { - return core.getTrustManager(url); - } - - public SVNAuthentication getFirstAuthentication(String kind, String realm, SVNURL url) throws SVNException { - return core.getFirstAuthentication(kind, realm, url); - } - - public SVNAuthentication getNextAuthentication(String kind, String realm, SVNURL url) throws SVNException { - return core.getNextAuthentication(kind, realm, url); - } - - public void acknowledgeAuthentication(boolean accepted, String kind, String realm, SVNErrorMessage errorMessage, SVNAuthentication authentication) throws SVNException { - core.acknowledgeAuthentication(accepted, kind, realm, errorMessage, authentication); - } - - public void acknowledgeTrustManager(TrustManager manager) { - core.acknowledgeTrustManager(manager); - } - - public boolean isAuthenticationForced() { - return core.isAuthenticationForced(); - } - - public int getReadTimeout(SVNRepository repository) { - return core.getReadTimeout(repository); - } - - public int getConnectTimeout(SVNRepository repository) { - return core.getConnectTimeout(repository); - } -} diff --git a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java index 0222931633..c4e4f1b5cf 100644 --- a/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java +++ b/test/src/main/java/org/jvnet/hudson/test/HudsonTestCase.java @@ -53,7 +53,6 @@ import hudson.model.UpdateCenter; import hudson.model.AbstractProject; import hudson.model.UpdateCenter.UpdateCenterConfiguration; import hudson.model.Node.Mode; -import hudson.scm.SubversionSCM; import hudson.security.csrf.CrumbIssuer; import hudson.security.csrf.CrumbIssuerDescriptor; import hudson.slaves.CommandLauncher; @@ -122,7 +121,6 @@ import org.mortbay.jetty.webapp.WebAppContext; import org.mortbay.jetty.webapp.WebXmlConfiguration; import org.mozilla.javascript.Context; import org.mozilla.javascript.ContextFactory; -import org.tmatesoft.svn.core.SVNException; import org.w3c.css.sac.CSSException; import org.w3c.css.sac.CSSParseException; import org.w3c.css.sac.ErrorHandler; @@ -320,13 +318,13 @@ public abstract class HudsonTestCase extends TestCase { return realm; } - /** - * Sets guest credentials to access java.net Subversion repo. - */ - protected void setJavaNetCredential() throws SVNException, IOException { - // set the credential to access svn.dev.java.net - hudson.getDescriptorByType(SubversionSCM.DescriptorImpl.class).postCredential("https://svn.dev.java.net/svn/hudson/","guest","",null,new PrintWriter(new NullStream())); - } +// /** +// * Sets guest credentials to access java.net Subversion repo. +// */ +// protected void setJavaNetCredential() throws SVNException, IOException { +// // set the credential to access svn.dev.java.net +// hudson.getDescriptorByType(SubversionSCM.DescriptorImpl.class).postCredential("https://svn.dev.java.net/svn/hudson/","guest","",null,new PrintWriter(new NullStream())); +// } /** * Locates Maven2 and configure that as the only Maven in the system. diff --git a/test/src/test/java/hudson/scm/SubversionSCMTest.java b/test/src/test/java/hudson/scm/SubversionSCMTest.java deleted file mode 100644 index 126a866163..0000000000 --- a/test/src/test/java/hudson/scm/SubversionSCMTest.java +++ /dev/null @@ -1,272 +0,0 @@ -/* - * The MIT License - * - * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi, Bruce Chapman, Yahoo! Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - */ -package hudson.scm; - -import com.gargoylesoftware.htmlunit.ElementNotFoundException; -import com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException; -import com.gargoylesoftware.htmlunit.html.HtmlAnchor; -import com.gargoylesoftware.htmlunit.html.HtmlForm; -import com.gargoylesoftware.htmlunit.html.HtmlPage; -import hudson.FilePath; -import hudson.Launcher; -import hudson.scm.browsers.Sventon; -import hudson.scm.SubversionSCM.ModuleLocation; -import hudson.util.NullStream; -import hudson.model.*; -import java.io.FileWriter; -import java.io.PrintWriter; -import java.io.IOException; -import java.util.Map; -import java.net.URL; - -import org.dom4j.Document; -import org.dom4j.io.DOMReader; -import org.jvnet.hudson.test.Bug; -import org.jvnet.hudson.test.Email; -import org.jvnet.hudson.test.HudsonHomeLoader.CopyExisting; -import org.jvnet.hudson.test.HudsonTestCase; -import org.jvnet.hudson.test.recipes.PresetData; -import static org.jvnet.hudson.test.recipes.PresetData.DataSet.ANONYMOUS_READONLY; -import org.tmatesoft.svn.core.SVNException; - -/** - * @author Kohsuke Kawaguchi - */ -public class SubversionSCMTest extends HudsonTestCase { - @PresetData(ANONYMOUS_READONLY) - @Bug(2380) - public void testTaggingPermission() throws Exception { - // create a build - FreeStyleProject p = createFreeStyleProject(); - p.setScm(loadSvnRepo()); - FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserCause()).get(); - System.out.println(b.getLog()); - assertBuildStatus(Result.SUCCESS,b); - - SubversionTagAction action = b.getAction(SubversionTagAction.class); - assertFalse(b.hasPermission(action.getPermission())); - - WebClient wc = new WebClient(); - HtmlPage html = wc.getPage(b); - - // make sure there's no link to the 'tag this build' - Document dom = new DOMReader().read(html); - assertNull(dom.selectSingleNode("//A[text()='Tag this build']")); - for( HtmlAnchor a : html.getAnchors() ) - assertFalse(a.getHrefAttribute().contains("/tagBuild/")); - - // and no tag form on tagBuild page - html = wc.getPage(b,"tagBuild/"); - try { - html.getFormByName("tag"); - fail("should not have been found"); - } catch (ElementNotFoundException e) { - } - - // and that tagging would fail - try { - wc.getPage(b,"tagBuild/submit?name0=test&Submit=Tag"); - fail("should have been denied"); - } catch (FailingHttpStatusCodeException e) { - // make sure the request is denied - assertEquals(e.getResponse().getStatusCode(),403); - } - - // now login as alice and make sure that the tagging would succeed - wc = new WebClient(); - wc.login("alice","alice"); - html = wc.getPage(b,"tagBuild/"); - HtmlForm form = html.getFormByName("tag"); - submit(form); - } - - /** - * Loads a test Subversion repository into a temporary directory, and creates {@link SubversionSCM} for it. - */ - private SubversionSCM loadSvnRepo() throws Exception { - return new SubversionSCM("file://" + new CopyExisting(getClass().getResource("/svn-repo.zip")).allocate().toURI().toURL().getPath() + "trunk/a"); - } - - @Email("http://www.nabble.com/Hudson-1.266-and-1.267%3A-Subversion-authentication-broken--td21156950.html") - public void testHttpsCheckOut() throws Exception { - setJavaNetCredential(); - FreeStyleProject p = createFreeStyleProject(); - p.setScm(new SubversionSCM( - new String[]{"https://svn.dev.java.net/svn/hudson/trunk/hudson/test-projects/trivial-ant"}, - new String[]{null}, - true, null, null - )); - - FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserCause()).get(); - System.out.println(b.getLog()); - assertBuildStatus(Result.SUCCESS,b); - assertTrue(p.getWorkspace().child("trivial-ant/build.xml").exists()); - } - - @Email("http://www.nabble.com/Hudson-1.266-and-1.267%3A-Subversion-authentication-broken--td21156950.html") - public void testHttpCheckOut() throws Exception { - FreeStyleProject p = createFreeStyleProject(); - p.setScm(new SubversionSCM( - new String[]{"http://svn.codehaus.org/plexus/tags/JASF_INIT/plexus-avalon-components/jasf/"}, - new String[]{null}, - true, null, null - )); - - FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserCause()).get(); - System.out.println(b.getLog()); - assertBuildStatus(Result.SUCCESS,b); - assertTrue(p.getWorkspace().child("jasf/maven.xml").exists()); - } - - /** - * Tests the "URL@REV" format in SVN URL. - */ - @Bug(262) - public void testRevisionedCheckout() throws Exception { - setJavaNetCredential(); - FreeStyleProject p = createFreeStyleProject(); - p.setScm(new SubversionSCM( - new String[]{"https://svn.dev.java.net/svn/hudson/trunk/hudson/test-projects/trivial-ant@13000"}, - new String[]{null}, - true, null, null - )); - - FreeStyleBuild b = p.scheduleBuild2(0, new Cause.UserCause()).get(); - System.out.println(b.getLog()); - assertTrue(b.getLog().contains("At revision 13000")); - assertBuildStatus(Result.SUCCESS,b); - - b = p.scheduleBuild2(0, new Cause.UserCause()).get(); - System.out.println(b.getLog()); - assertTrue(b.getLog().contains("At revision 13000")); - assertBuildStatus(Result.SUCCESS,b); - } - - /** - * {@link SubversionSCM#pollChanges(AbstractProject, Launcher, FilePath, TaskListener)} should notice - * if the workspace and the current configuration is inconsistent and schedule a new build. - */ - @Email("http://www.nabble.com/Proper-way-to-switch---relocate-SVN-tree---tt21173306.html") - public void testPollingAfterRelocation() throws Exception { - // fetch the current workspace - FreeStyleProject p = createFreeStyleProject(); - p.setScm(loadSvnRepo()); - p.scheduleBuild2(0, new Cause.UserCause()).get(); - - // as a baseline, this shouldn't detect any change - TaskListener listener = createTaskListener(); - assertFalse(p.pollSCMChanges(listener)); - - // now switch the repository to a new one. - // this time the polling should indicate that we need a new build - p.setScm(loadSvnRepo()); - assertTrue(p.pollSCMChanges(listener)); - - // build it once again to switch - p.scheduleBuild2(0, new Cause.UserCause()).get(); - - // then no more change should be detected - assertFalse(p.pollSCMChanges(listener)); - } - - public void testURLWithVariable() throws Exception { - FreeStyleProject p = createFreeStyleProject(); - String url = "http://svn.codehaus.org/plexus/tags/JASF_INIT/plexus-avalon-components/jasf/"; - p.setScm(new SubversionSCM( - new String[]{"$REPO" + url.substring(10)}, - new String[]{null}, - true, null, null - )); - - String var = url.substring(0, 10); - - FreeStyleBuild b = p.scheduleBuild2(0, new Cause.LegacyCodeCause(), - new ParametersAction(new StringParameterValue("REPO", var))).get(); - System.out.println(b.getLog()); - assertBuildStatus(Result.SUCCESS,b); - assertTrue(p.getWorkspace().child("jasf/maven.xml").exists()); - } - - /** - * Test that multiple repository URLs are all polled. - */ - @Bug(3168) - public void testPollMultipleRepositories() throws Exception { - // fetch the current workspaces - FreeStyleProject p = createFreeStyleProject(); - String svnBase = "file://" + new CopyExisting(getClass().getResource("/svn-repo.zip")).allocate().toURI().toURL().getPath(); - p.setScm(new SubversionSCM( - new String[] { svnBase + "trunk/a", svnBase + "branches" }, - new String[] { null, null }, true, null, null)); - AbstractBuild build = p.scheduleBuild2(0, new Cause.UserCause()).get(); - - // as a baseline, this shouldn't detect any change - TaskListener listener = createTaskListener(); - assertFalse(p.pollSCMChanges(listener)); - - // Force older "current revision" for each repository, make sure both are detected - Map revInfo = SubversionSCM.parseRevisionFile(build); - for (String outOfDateItem : new String[] { "branches", "trunk/a" }) { - FileWriter out = new FileWriter(SubversionSCM.getRevisionFile(build)); - for (Map.Entry entry : revInfo.entrySet()) { - out.write(entry.getKey()); - out.write('/'); - out.write(Long.toString( - entry.getValue().longValue() - (entry.getKey().endsWith(outOfDateItem) ? 1 : 0))); - out.write('\n'); - } - out.close(); - - // now the polling should indicate that we need a new build - assertTrue("change was not detected!", p.pollSCMChanges(listener)); - } - } - - public void testConfigRoundtrip() throws Exception { - FreeStyleProject p = createFreeStyleProject(); - - SubversionSCM scm = new SubversionSCM(new String[]{"a","b"},new String[]{"c","d"},true,new Sventon(new URL("http://www.sun.com/"),"test"),"exclude"); - p.setScm(scm); - submit(new WebClient().getPage(p,"configure").getFormByName("config")); - verify(scm,(SubversionSCM)p.getScm()); - - scm = new SubversionSCM(new String[]{"a"},new String[]{"c"},false,null,""); - p.setScm(scm); - submit(new WebClient().getPage(p,"configure").getFormByName("config")); - verify(scm,(SubversionSCM)p.getScm()); - } - - private void verify(SubversionSCM lhs, SubversionSCM rhs) { - ModuleLocation[] ll = lhs.getLocations(); - ModuleLocation[] rl = rhs.getLocations(); - assertEquals(ll.length, rl.length); - for(int i=0; i t = b.getTestResultAction(); - assertSame(1,t.getFailCount()); - CaseResult tc = t.getFailedTests().get(0); - assertTrue(tc.getStderr().contains("stderr")); - assertTrue(tc.getStdout().contains("stdout")); - } +// /** +// * Verifies that Hudson can capture the stdout/stderr output from Maven surefire. +// */ +// public void testSurefireOutput() throws Exception { +// setJavaNetCredential(); +// configureDefaultMaven(); +// +// MavenModuleSet p = createMavenProject(); +// p.setScm(new SubversionSCM("https://svn.dev.java.net/svn/hudson/trunk/hudson/test-projects/junit-failure@16411")); +// MavenModuleSetBuild b = assertBuildStatus(UNSTABLE,p.scheduleBuild2(0).get()); +// AbstractTestResultAction t = b.getTestResultAction(); +// assertSame(1,t.getFailCount()); +// CaseResult tc = t.getFailedTests().get(0); +// assertTrue(tc.getStderr().contains("stderr")); +// assertTrue(tc.getStdout().contains("stdout")); +// } @Email("http://www.nabble.com/NPE-%28Fatal%3A-Null%29-in-recording-junit-test-results-td23562964.html") public void testIssue20090516() throws Exception {