/** This test unit is for testing a commit hook using the UUID */ @Bug(399165) @Test public void testPrebuiltCommitTrigger() throws Exception { hudson.setCrumbIssuer(null); // First create repository with 1 file and commit information SVNCommitInfo info = createSVNRepository(); assertNull(info.getErrorMessage()); assertEquals("Failed to create 1 revision.", 1, info.getNewRevision()); // Create freestyle project with SVN SCM. FreeStyleProject project = createFreeStyleProject(); project.setScm(new SubversionSCM("file:///tmp/399165")); SCMTrigger trigger = new SCMTrigger("0 */6 * * *"); project.addTrigger(trigger); trigger.start(project, true); // Execute build (This is critical for fixing eclipse bug: 399165) assertBuildStatusSuccess(project.scheduleBuild2(0)); // Commit a file again. info = createSecondCommit(); assertNull(info.getErrorMessage()); assertEquals("Failed to create second commit.", 2, info.getNewRevision()); // Create post-commit hook WebClient wc = new WebClient(); WebRequestSettings wr = new WebRequestSettings( new URL( getURL() + "subversion/" + repository.getRepositoryUUID(false) + "/notifyCommit"), HttpMethod.POST); wr.setRequestBody("A dirB/file2.txt"); wr.setAdditionalHeader("Content-Type", "text/plain;charset=UTF-8"); wr.setAdditionalHeader("X-Hudson-Subversion-Revision", "2"); WebConnection conn = wc.getWebConnection(); System.out.println(wr); WebResponse resp = conn.getResponse(wr); assertTrue(isGoodHttpStatus(resp.getStatusCode())); waitUntilNoActivity(); FreeStyleBuild b = project.getLastBuild(); assertNotNull(b); assertBuildStatus(Result.SUCCESS, b); assertEquals("Failed to execute a buid.", 2, b.getNumber()); }
@Test public void testCommitOfLockedFile() throws SVNException { final String fullFilePath = "Project/Prueba/Modify/prueba.txt"; final String filePath = "Prueba/Modify/prueba.txt"; final TestOptions options = TestOptions.getInstance(); final Sandbox sandbox = Sandbox.createWithCleanup(getClass().getSimpleName() + ".testModifyLocked", options); final SVNURL url = sandbox.createSvnRepository(); final CommitBuilder commitBuilder = new CommitBuilder(url); commitBuilder.addFile(fullFilePath); commitBuilder.commit(); // user paths relative to Project directory. SVNRepository repository = SVNRepositoryFactory.create(url.appendPath("Project", false)); repository.setAuthenticationManager(new BasicAuthenticationManager("user", "password")); final Map<String, Long> pathsToRevisions = new HashMap<String, Long>(); pathsToRevisions.put(filePath, 1l); repository.lock(pathsToRevisions, null, false, null); repository.closeSession(); // same user as one who owns the lock. repository.setAuthenticationManager(new BasicAuthenticationManager("user", "password")); final SVNLock lock = repository.getLock(filePath); Assert.assertNotNull(lock); Assert.assertNotNull(lock.getID()); Assert.assertEquals("user", lock.getOwner()); final Map<String, String> locks = new HashMap<String, String>(); try { tryCommit(filePath, repository, locks); Assert.fail(); } catch (SVNException e) { // no lock token. } locks.put(filePath, lock.getID()); SVNCommitInfo info = tryCommit(filePath, repository, locks); Assert.assertNotNull(info); Assert.assertEquals(2, info.getNewRevision()); }
private static Pair<SVNRevision, SVNURL> createRemoteFolder( final SvnVcs17 vcs, final SVNURL parent, final String folderName) throws SVNException { SVNURL url = parent.appendPath(folderName, false); final String urlText = url.toString(); final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator(); if (indicator != null) { indicator.checkCanceled(); indicator.setText(SvnBundle.message("share.directory.create.dir.progress.text", urlText)); } final SVNCommitInfo info = vcs.createCommitClient() .doMkDir( new SVNURL[] {url}, SvnBundle.message( "share.directory.commit.message", folderName, ApplicationNamesInfo.getInstance().getFullProductName())); return new Pair<SVNRevision, SVNURL>(SVNRevision.create(info.getNewRevision()), url); }