1 /* 2 Bloof - visualize the evolution of your software project 3 Copyright ( C ) 2003 Lukasz Pekacki <lukasz@pekacki.de> 4 http://bloof.sf.net/ 5 6 This program is free software; you can redistribute it and/or modify it 7 under the terms of the GNU General Public License. 8 9 This program is distributed in the hope that it will be useful, 10 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 GNU General Public License for more details. 13 14 You should have received a copy of the GNU General Public License along with 15 this program; if not, write to the Free Software Foundation, Inc., 16 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 18 $RCSfile: DatabaseTest.java,v $ 19 Created on $Date: 2003/09/06 08:35:09 $ 20 */ 21 package net.sf.bloof.test.db; 22 23 import net.sf.bloof.scm.cvsplugin.CvsAccess; 24 import net.sf.bloof.scm.cvsplugin.CvsPlugin; 25 import net.sf.bloof.scm.cvsplugin.LogParser; 26 import net.sf.bloof.scm.cvsplugin.RevisionIterator; 27 import net.sf.bloof.Bloof; 28 import net.sf.bloof.db.Database; 29 import net.sf.bloof.db.McKoiControl; 30 import net.sf.bloof.scm.ScmAccessException; 31 import net.sf.bloof.scm.ScmRevisionIterator; 32 33 import java.io.IOException; 34 import java.io.StringReader; 35 import java.sql.Connection; 36 import java.sql.SQLException; 37 38 import junit.framework.TestCase; 39 40 /*** 41 * Test class for the database access 42 * @author Lukasz Pekacki <pekacki@users.sourceforge.net> 43 * @version $Id: DatabaseTest.java,v 1.11 2003/09/06 08:35:09 pekacki Exp $ 44 */ 45 public class DatabaseTest extends TestCase { 46 47 /*** 48 * Constructor for TestDatabase. 49 * @param aArg x 50 */ 51 public DatabaseTest(String aArg) { 52 super(aArg); 53 } 54 /*** 55 * Method Database. 56 */ 57 public void testLocalDatabase() { 58 Connection c = null; 59 Database db = null; 60 try { 61 c = McKoiControl.create(Bloof.INTERNAL_DATABASE); 62 } catch (SQLException e) { 63 fail("Start of internal Database failed." + e.toString()); 64 } catch (IOException e) { 65 fail("Start of internal Database failed." + e.toString()); 66 } 67 assertNotNull(c); 68 try { 69 db = new Database(c); 70 Bloof.setDatabase(db); 71 } catch (SQLException e) { 72 fail("Connection to Database failed." + e.toString()); 73 } 74 CvsAccess access = CvsPlugin.MINI_LOG; 75 CvsPlugin cvsPlugin = new CvsPlugin(); 76 ScmRevisionIterator revisonIter = null; 77 try { 78 revisonIter = cvsPlugin.getRevisions(access); 79 } catch (ScmAccessException e) { 80 fail("Could not access cvs server." + e.toString()); 81 } 82 try { 83 db.populateDatabase(revisonIter); 84 } catch (SQLException e) { 85 fail("Population of Database failed." + e.toString()); 86 } 87 88 try { 89 /* give internal database a chance to shut down */ 90 Thread.sleep(2000); 91 } catch (InterruptedException e) { 92 // do nothing 93 } 94 } 95 96 /*** 97 * fasel 98 */ 99 public void testDuplicateLog() { 100 Database db = null; 101 Connection c = null; 102 try { 103 c = McKoiControl.create(Bloof.INTERNAL_DATABASE); 104 } catch (SQLException e) { 105 fail("Start of internal Database failed." + e.toString()); 106 } catch (IOException e) { 107 fail("Start of internal Database failed." + e.toString()); 108 } 109 assertNotNull(c); 110 try { 111 db = new Database(c); 112 Bloof.setDatabase(db); 113 } catch (SQLException e) { 114 fail("Connection to Database failed." + e.toString()); 115 } 116 ScmRevisionIterator revisonIter = null; 117 revisonIter = new RevisionIterator(new StringReader(getDuplicateLogFile())); 118 try { 119 db.populateDatabase(revisonIter); 120 } catch (SQLException e) { 121 fail("Population of Database failed." + e.toString()); 122 } 123 124 try { 125 /* give internal database a chance to shut down */ 126 Thread.sleep(2000); 127 } catch (InterruptedException e) { 128 // do nothing 129 } 130 } 131 private String getDuplicateLogFile() { 132 String result = ""; 133 result += "RCS file: /cvsroot/b/bl/bloof/bloof/BLoof,v\n"; 134 result += "Working file: testfile\n"; 135 result += "head: 1.3\n"; 136 result += "branch:\n"; 137 result += "locks: strict\n"; 138 result += "access list:\n"; 139 result += "symbolic names:\n"; 140 result += "keyword substitution: kv\n"; 141 result += "total revisions: 1; selected revisions: 1\n"; 142 result += "description:\n"; 143 result += LogParser.REV_DELIM; 144 result += "\n"; 145 result += "revision 1.1\n"; 146 result += "date: 2003/01/21 04:11:34; author: fums; state: Exp;\n"; 147 result += "description text\n"; 148 result += LogParser.FILE_DELIM; 149 result += "\n"; 150 result += "RCS file: /cvsroot/b/bl/bloof/bloof/bloof,v\n"; 151 result += "Working file: testfile\n"; 152 result += "head: 1.3\n"; 153 result += "branch:\n"; 154 result += "locks: strict\n"; 155 result += "access list:\n"; 156 result += "symbolic names:\n"; 157 result += "keyword substitution: kv\n"; 158 result += "total revisions: 1; selected revisions: 1\n"; 159 result += "description:\n"; 160 result += LogParser.REV_DELIM; 161 result += "\n"; 162 result += "revision 1.1\n"; 163 result += "date: 2003/01/21 04:11:34; author: fums; state: Exp;\n"; 164 result += "description text\n"; 165 result += LogParser.FILE_DELIM; 166 result += "\n"; 167 168 return result; 169 } 170 171 }

This page was automatically generated by Maven