1 /** 2 * @copyright 3 * ==================================================================== 4 * Licensed to the Apache Software Foundation (ASF) under one 5 * or more contributor license agreements. See the NOTICE file 6 * distributed with this work for additional information 7 * regarding copyright ownership. The ASF licenses this file 8 * to you under the Apache License, Version 2.0 (the 9 * "License"); you may not use this file except in compliance 10 * with the License. You may obtain a copy of the License at 11 * 12 * http://www.apache.org/licenses/LICENSE-2.0 13 * 14 * Unless required by applicable law or agreed to in writing, 15 * software distributed under the License is distributed on an 16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 * KIND, either express or implied. See the License for the 18 * specific language governing permissions and limitations 19 * under the License. 20 * ==================================================================== 21 * @endcopyright 22 */ 23 package org.tigris.subversion.javahl; 24 25 import java.io.File; 26 import java.io.IOException; 27 28 import org.tigris.subversion.javahl.Revision; 29 import org.tigris.subversion.javahl.SubversionException; 30 31 /** 32 * This class is used for testing the SVNAdmin class 33 * 34 * More methodes for testing are still needed 35 */ 36 public class SVNAdminTests extends SVNTests 37 { 38 /** 39 * Base name of all our tests. 40 */ 41 public final static String testName = "admin_test"; 42 SVNAdminTests()43 public SVNAdminTests() 44 { 45 init(); 46 } 47 SVNAdminTests(String name)48 public SVNAdminTests(String name) 49 { 50 super(name); 51 init(); 52 } 53 54 /** 55 * Initialize the testBaseName and the testCounter, if this is the 56 * first test of this class. 57 */ init()58 private void init() 59 { 60 if (!testName.equals(testBaseName)) 61 { 62 testCounter = 0; 63 testBaseName = testName; 64 } 65 } 66 67 /** 68 * Test the basic SVNAdmin.create functionality 69 * @throws SubversionException 70 */ testCreate()71 public void testCreate() 72 throws SubversionException, IOException 73 { 74 OneTest thisTest = new OneTest(false); 75 assertTrue("repository exists", thisTest.getRepository().exists()); 76 } 77 testSetRevProp()78 public void testSetRevProp() 79 throws SubversionException, IOException 80 { 81 OneTest thisTest = new OneTest(false); 82 final String MSG = "Initial repository creation"; 83 admin.setRevProp(thisTest.getRepositoryPath(), Revision.getInstance(0), 84 "svn:log", MSG, false, false); 85 PropertyData[] pdata = client.revProperties( 86 makeReposUrl(thisTest.getRepository()), 87 Revision.getInstance(0)); 88 assertNotNull("expect non null rev props"); 89 String logMessage = null; 90 for (int i = 0; i < pdata.length; i++) 91 { 92 if ("svn:log".equals(pdata[i].getName())) 93 { 94 logMessage = pdata[i].getValue(); 95 break; 96 } 97 } 98 assertEquals("expect rev prop change to take effect", MSG, logMessage); 99 } testLoadRepo()100 public void testLoadRepo() 101 throws SubversionException, IOException 102 { 103 /* Make sure SVNAdmin.load() works, with a repo dump file known 104 * to provoke bug 2979 105 */ 106 // makes repos with nothing in it 107 OneTest thisTest = new OneTest(false,false); 108 // verify zero revisions in new repos 109 String repoUrl = makeReposUrl(thisTest.getRepository()); 110 final Info2[] infoHolder = new Info2[1]; 111 InfoCallback mycallback = new InfoCallback() 112 { 113 public void singleInfo(Info2 info) 114 { 115 infoHolder[0] = info; 116 } 117 }; 118 client.info2(repoUrl, Revision.HEAD, Revision.HEAD, 119 Depth.immediates, null, mycallback); 120 assertNotNull("expect info callback", infoHolder[0]); 121 assertEquals("expect zero revisions in new repository", 122 0L, infoHolder[0].getLastChangedRev()); 123 124 // locate dump file in test environment 125 String testSrcdir = System.getProperty("test.srcdir", 126 "subversion/bindings/javahl"); 127 File dump = new File(testSrcdir, "tests/data/issue2979.dump"); 128 InputInterface input = new FileInputer(dump); 129 OutputInterface loadLog = new IgnoreOutputer(); 130 admin.load(thisTest.getRepositoryPath(), 131 input, loadLog, true, true, null); 132 // should have two revs after the load 133 infoHolder[0] = null; 134 client.info2(repoUrl, Revision.HEAD, Revision.HEAD, 135 Depth.immediates, null, mycallback); 136 assertEquals("expect two revisions after load()", 137 2L, infoHolder[0].getLastChangedRev()); 138 // verify that the repos is faithful rep. of the dump file, 139 // e.g., correct author 140 assertEquals("expect 'svn4ant' as author of r2", 141 "svn4ant", infoHolder[0].getLastChangedAuthor()); 142 } 143 } 144