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: LogParserTest.java,v $ 19 Created on $Date: 2003/08/21 09:44:51 $ 20 */ 21 package net.sf.bloof.test.cvsplugin; 22 23 import net.sf.bloof.scm.ScmRevision; 24 import net.sf.bloof.scm.cvsplugin.LogParser; 25 import net.sf.bloof.scm.cvsplugin.RevisionIterator; 26 27 import java.io.StringReader; 28 import java.util.NoSuchElementException; 29 30 import junit.framework.TestCase; 31 32 /*** 33 * 34 * @author Lukasz Pekacki <pekacki@users.sourceforge.net> 35 * @version $Id: LogParserTest.java,v 1.5 2003/08/21 09:44:51 pekacki Exp $ 36 */ 37 public class LogParserTest extends TestCase { 38 /*** 39 * Parses a default log file 40 */ 41 public void testDefaultFileEntry() { 42 String logString = getDefaultFileHead() + getDefaultRevision() + getFileDelim(); 43 StringReader sRead = new StringReader(logString); 44 RevisionIterator rIter = new RevisionIterator(sRead); 45 assertEquals(true, rIter.hasNext()); 46 ScmRevision revision = rIter.getNext(); 47 assertNotNull(revision); 48 49 } 50 /*** 51 * Parses a default log file 52 */ 53 public void testDefaultRemoteFileEntry() { 54 String logString = getDefaultRemoteFileAndRevision() + getFileDelim(); 55 StringReader sRead = new StringReader(logString); 56 RevisionIterator rIter = new RevisionIterator(sRead); 57 assertEquals(true, rIter.hasNext()); 58 ScmRevision revision = rIter.getNext(); 59 assertNotNull(revision); 60 61 } 62 /*** 63 * Parses a log file with a file that has no revisions 64 */ 65 public void testNoSelectedRevisionsFileEntry() { 66 String logString = getNoSelectedRevisionsFileHead() + getFileDelim(); 67 StringReader sRead = new StringReader(logString); 68 RevisionIterator rIter = new RevisionIterator(sRead); 69 assertEquals(false, rIter.hasNext()); 70 try { 71 ScmRevision revision = rIter.getNext(); 72 fail("This revision should no exist:" + revision); 73 } catch (NoSuchElementException ne) { 74 // do nothing 75 } 76 77 } 78 private String getDefaultFileHead() { 79 String result = ""; 80 result += "RCS file: /cvsroot/b/bl/bloof/bloof/bloof,v\n"; 81 result += "Working file: testfile\n"; 82 result += "head: 1.3\n"; 83 result += "branch:\n"; 84 result += "locks: strict\n"; 85 result += "access list:\n"; 86 result += "symbolic names:\n"; 87 result += "keyword substitution: kv\n"; 88 result += "total revisions: 1; selected revisions: 1\n"; 89 result += "description:\n"; 90 result += LogParser.REV_DELIM; 91 result += "\n"; 92 return result; 93 } 94 95 private String getDefaultRevision() { 96 String result = ""; 97 result += "revision 1.1\n"; 98 result += "date: 2003/01/21 04:11:34; author: fums; state: Exp;\n"; 99 result += "description text\n"; 100 return result; 101 } 102 private String getFileDelim() { 103 return LogParser.FILE_DELIM + "\n"; 104 } 105 106 private String getNoSelectedRevisionsFileHead() { 107 String result = ""; 108 result += "RCS file: /cvsroot/b/bl/bloof/bloof/bloof,v\n"; 109 result += "Working file: testfile\n"; 110 result += "head: 1.3\n"; 111 result += "branch:\n"; 112 result += "locks: strict\n"; 113 result += "access list:\n"; 114 result += "symbolic names:\n"; 115 result += "keyword substitution: kv\n"; 116 result += "total revisions: 1; selected revisions: 0\n"; 117 result += "description:\n"; 118 result += LogParser.REV_DELIM; 119 result += "\n"; 120 return result; 121 } 122 123 private String getDefaultRemoteFileAndRevision() { 124 String result = ""; 125 result += "M RCS file: /cvsroot/b/bl/bloof/bloof/bloof,v\n"; 126 result += "M Working file: testfile\n"; 127 result += "M head: 1.3\n"; 128 result += "M branch:\n"; 129 result += "M locks: strict\n"; 130 result += "M access list:\n"; 131 result += "M symbolic names:\n"; 132 result += "M keyword substitution: kv\n"; 133 result += "M total revisions: 1; selected revisions: 1\n"; 134 result += "M description:\n"; 135 result += "M " + LogParser.REV_DELIM; 136 result += "\n"; 137 result += "M revision 1.1\n"; 138 result += "M date: 2003/01/21 04:11:34; author: fums; state: Exp;\n"; 139 result += "M description text\n"; 140 141 return result; 142 } 143 144 }

This page was automatically generated by Maven