01: /**
02: * @copyright
03: * ====================================================================
04: * Copyright (c) 2003-2004 CollabNet. All rights reserved.
05: *
06: * This software is licensed as described in the file COPYING, which
07: * you should have received as part of this distribution. The terms
08: * are also available at http://subversion.tigris.org/license-1.html.
09: * 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: */package org.tigris.subversion.javahl.tests;
18:
19: import junit.framework.TestCase;
20: import org.tigris.subversion.javahl.SVNAdmin;
21: import java.io.File;
22:
23: /**
24: * This class is used for testing the SVNAdmin class
25: *
26: * More methodes for testing are still needed
27: */
28: public class SVNAdminTests extends TestCase {
29: /**
30: * the objects, which is going to be tested
31: */
32: SVNAdmin testee;
33:
34: /**
35: * setup the test
36: * @throws Exception
37: */
38: protected void setUp() throws Exception {
39: super .setUp();
40: testee = new SVNAdmin();
41: }
42:
43: /**
44: * cleanp after the test
45: * @throws Exception
46: */
47: protected void tearDown() throws Exception {
48: testee.dispose();
49: super .tearDown();
50: }
51:
52: /**
53: * Test the basic SVNAdmin.create functionality
54: * @throws Throwable
55: */
56: public void testCreate() throws Throwable {
57: testee.create("testrep", false, false, null, SVNAdmin.BDB);
58: assertTrue("repository exists", new File("testrep").exists());
59: removeRepository("testrep");
60: assertFalse("repository deleted", new File("testrep").exists());
61: }
62:
63: /**
64: * remove a rempositryl
65: * @param pathName path name of the repository
66: * @throws Exception
67: */
68: protected void removeRepository(String pathName) throws Exception {
69: File masterDir = new File(pathName);
70: removeDirOrFile(masterDir);
71: }
72:
73: /**
74: * remove a file or a directory with its content
75: * @param file the file or directory to be removed
76: */
77: private void removeDirOrFile(File file) {
78: if (!file.exists()) {
79: return;
80: }
81: if (file.isDirectory()) {
82: File[] content = file.listFiles();
83: for (int i = 0; i < content.length; i++)
84: removeDirOrFile(content[i]);
85: file.delete();
86: } else
87: file.delete();
88: }
89: }
|