01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.tools.ant.taskdefs.cvslib;
19:
20: import junit.framework.TestCase;
21:
22: import java.util.Calendar;
23: import java.util.Locale;
24: import java.util.TimeZone;
25: import java.util.Date;
26:
27: /**
28: * Minimal test of the parser implementation
29: */
30: public class ChangeLogParserTest extends TestCase {
31:
32: protected ChangeLogParser parser = new ChangeLogParser();
33:
34: public void testOldCvsFormat() throws Exception {
35: parser.stdout("Working file: build.xml");
36: parser.stdout("revision 1.475");
37: parser
38: .stdout("date: 2004/06/05 16:10:32; author: somebody; state: Exp; lines: +2 -2");
39: parser.stdout("I have done something. I swear.");
40: parser
41: .stdout("=============================================================================");
42: CVSEntry[] entries = parser.getEntrySetAsArray();
43: assertEquals("somebody", entries[0].getAuthor());
44: Calendar cal = Calendar.getInstance(
45: TimeZone.getTimeZone("UTC"), Locale.US);
46: cal.set(Calendar.MILLISECOND, 0);
47: cal.set(2004, Calendar.JUNE, 5, 16, 10, 32);
48: Date date = cal.getTime();
49: assertEquals(date, entries[0].getDate());
50: }
51:
52: public void testCvs112Format() throws Exception {
53: parser.stdout("Working file: build.xml");
54: parser.stdout("revision 1.475");
55: parser
56: .stdout("date: 2004-06-05 16:10:32 +0000; author: somebody; state: Exp; lines: +2 -2");
57: parser.stdout("I have done something. I swear.");
58: parser
59: .stdout("=============================================================================");
60: CVSEntry[] entries = parser.getEntrySetAsArray();
61: assertEquals("somebody", entries[0].getAuthor());
62: Calendar cal = Calendar.getInstance(
63: TimeZone.getTimeZone("UTC"), Locale.US);
64: cal.set(Calendar.MILLISECOND, 0);
65: cal.set(2004, Calendar.JUNE, 5, 16, 10, 32);
66: Date date = cal.getTime();
67: assertEquals(date, entries[0].getDate());
68: }
69: }
|