~svn/ubuntu/raring/subversion/ppa

« back to all changes in this revision

Viewing changes to subversion/bindings/java/javahl/src/org/tigris/subversion/javahl/tests/SVNAdminTests.java

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-12-05 01:26:14 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051205012614-qom4xfypgtsqc2xq
Tags: 1.2.3dfsg1-3ubuntu1
Merge with the final Debian release of 1.2.3dfsg1-3, bringing in
fixes to the clean target, better documentation of the libdb4.3
upgrade and build fixes to work with swig1.3_1.3.27.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * @copyright
 
3
 * ====================================================================
 
4
 * Copyright (c) 2003-2004 CollabNet.  All rights reserved.
 
5
 *
 
6
 * This software is licensed as described in the file COPYING, which
 
7
 * you should have received as part of this distribution.  The terms
 
8
 * are also available at http://subversion.tigris.org/license-1.html.
 
9
 * If newer versions of this license are posted there, you may use a
 
10
 * newer version instead, at your option.
 
11
 *
 
12
 * This software consists of voluntary contributions made by many
 
13
 * individuals.  For exact contribution history, see the revision
 
14
 * history and logs, available at http://subversion.tigris.org/.
 
15
 * ====================================================================
 
16
 * @endcopyright
 
17
 */
 
18
package org.tigris.subversion.javahl.tests;
 
19
 
 
20
import junit.framework.TestCase;
 
21
import org.tigris.subversion.javahl.SVNAdmin;
 
22
import java.io.File;
 
23
 
 
24
/**
 
25
 * This class is used for testing the SVNAdmin class
 
26
 *
 
27
 * More methodes for testing are still needed
 
28
 */
 
29
public class SVNAdminTests extends TestCase
 
30
{
 
31
    /**
 
32
     * the objects, which is going to be tested
 
33
     */
 
34
    SVNAdmin testee;
 
35
    /**
 
36
     * setup the test
 
37
     * @throws Exception
 
38
     */
 
39
    protected void setUp() throws Exception
 
40
    {
 
41
        super.setUp();
 
42
        testee = new SVNAdmin();
 
43
    }
 
44
 
 
45
    /**
 
46
     * cleanp after the test
 
47
     * @throws Exception
 
48
     */
 
49
    protected void tearDown() throws Exception
 
50
    {
 
51
        testee.dispose();
 
52
        super.tearDown();
 
53
    }
 
54
 
 
55
    /**
 
56
     * Test the basic SVNAdmin.create functionality
 
57
     * @throws Throwable
 
58
     */
 
59
    public void testCreate() throws Throwable
 
60
    {
 
61
        testee.create("testrep", false, false, null, SVNAdmin.BDB);
 
62
        assertTrue("repository exists", new File("testrep").exists());
 
63
        removeRepository("testrep");
 
64
        assertFalse("repository deleted", new File("testrep").exists());
 
65
    }
 
66
 
 
67
    /**
 
68
     * remove a rempositryl
 
69
     * @param pathName      path name of the repository
 
70
     * @throws Exception
 
71
     */
 
72
    protected void removeRepository(String pathName) throws Exception
 
73
    {
 
74
        File masterDir = new File(pathName);
 
75
        removeDirOrFile(masterDir);
 
76
    }
 
77
 
 
78
    /**
 
79
     * remove a file or a directory with its content
 
80
     * @param file  the file or directory to be removed
 
81
     */
 
82
    private void removeDirOrFile(File file)
 
83
    {
 
84
        if(!file.exists())
 
85
        {
 
86
            return;
 
87
        }
 
88
        if(file.isDirectory())
 
89
        {
 
90
            File[] content = file.listFiles();
 
91
            for(int i = 0; i < content.length; i++)
 
92
                removeDirOrFile(content[i]);
 
93
            file.delete();
 
94
        }
 
95
        else
 
96
            file.delete();
 
97
    }
 
98
}