osunix / opengrok-trunk

mirror of opengrok

Clone this repository (size: 5.0 MB): HTTPS / SSH
$ hg clone http://hg.pathscale.com/opengrok-trunk
commit 733: 3616765d4af6
parent 732: 903de59722d2
branch: default
Start testing Razor, and fix a history parse bug that the test found
Jorg...@sun.com
19 months ago

Changed (Δ3.9 KB):

Up to file-list src/org/opensolaris/opengrok/history/RazorHistoryParser.java:

@@ -45,7 +45,7 @@ public class RazorHistoryParser implemen
45
45
    private final static SimpleDateFormat DATE_TIME_FORMAT =
46
46
            new SimpleDateFormat("yyyy/MM/dd,hh:mm:ss", Locale.US);
47
47
    private final static Pattern ACTION_TYPE_PATTERN =
48
            Pattern.compile("^(INTRODUCE|CHECK-OUT|CHECK-IN|UN-CHECK-OUT|RENAME|EDIT_PROPS|ALTERED|CHECK-POINT|REVERT|INTRODUCE_AND_EDIT|BRANCH|BUMP|MERGE-CHECK-IN|PROMOTE)\\s+(.*)\\s+([\\.0-9]+)?\\s+(.*)\\s+(.*)\\s*$");
48
            Pattern.compile("^(INTRODUCE|CHECK-OUT|CHECK-IN|UN-CHECK-OUT|RENAME|EDIT_PROPS|ALTERED|CHECK-POINT|REVERT|INTRODUCE_AND_EDIT|BRANCH|BUMP|MERGE-CHECK-IN|PROMOTE)\\s+(\\S*)\\s+([\\.0-9]+)?\\s+(\\S*)\\s+(\\S*)\\s*$");
49
49
    private final static Pattern ADDITIONAL_INFO_PATTERN =
50
50
            Pattern.compile("^##(TITLE|NOTES|AUDIT|ISSUE):\\s+(.*)\\s*$");
51
51
    private final static boolean DUMP_HISTORY_ENTRY_ADDITIONS = false;
@@ -85,7 +85,7 @@ public class RazorHistoryParser implemen
85
85
    }
86
86
87
87
    @SuppressWarnings("PMD.ConfusingTernary")
88
    private History parseContents(BufferedReader contents) throws IOException {
88
    protected History parseContents(BufferedReader contents) throws IOException {
89
89
        String line;
90
90
91
91
        ArrayList<HistoryEntry> entries = new ArrayList<HistoryEntry>();

Up to file-list test/org/opensolaris/opengrok/history/RazorHistoryParserTest.java:

1
/*
2
 * To change this template, choose Tools | Templates
3
 * and open the template in the editor.
4
 */
5
6
package org.opensolaris.opengrok.history;
7
8
import java.io.BufferedReader;
9
import java.io.StringReader;
10
import java.util.Calendar;
11
import java.util.GregorianCalendar;
12
import org.junit.After;
13
import org.junit.AfterClass;
14
import org.junit.Before;
15
import org.junit.BeforeClass;
16
import org.junit.Test;
17
import static org.junit.Assert.*;
18
19
/**
20
 *
21
 * @author austvik
22
 */
23
public class RazorHistoryParserTest {
24
25
    RazorHistoryParser instance;
26
27
    public RazorHistoryParserTest() {
28
    }
29
30
    @BeforeClass
31
    public static void setUpClass() throws Exception {
32
    }
33
34
    @AfterClass
35
    public static void tearDownClass() throws Exception {
36
    }
37
38
    @Before
39
    public void setUp() {
40
        instance = new RazorHistoryParser();
41
    }
42
43
    @After
44
    public void tearDown() {
45
        instance = null;
46
    }
47
48
    /**
49
     * Test of parse method, of class RazorHistoryParser.
50
     */
51
    @Test
52
    public void testParseEmpty() throws Exception {
53
        String output = "";
54
        History result = instance.parseContents(new BufferedReader(new StringReader(output)));
55
        assertEquals(0, result.getHistoryEntries().size());
56
    }
57
58
    /**
59
     * Test of parse method, of class RazorHistoryParser.
60
     */
61
    @Test
62
    public void testParse() throws Exception {
63
        String user1 = "auser";
64
        String user2 = "otheruser";
65
        String date1 = "2009/01/23,05:56:24";
66
        String date2 = "2010/04/13,15:36:25";
67
        String date3 = "2010/05/13,15:16:26";
68
69
        String output = "INTRODUCE       " + user1 + "   1.1     Active  " + date1 + "\n" +
70
                "##TITLE:  Introduced file\n" +
71
                "##ISSUE:        I...-..3     ++ISSUES++\n" +
72
                "\n" +
73
                "CHECK-OUT       " + user2 + "   1.1     Active  " + date2 + "\n" +
74
                "##TITLE:  Built with gmake CC=gcc CFLAGS='-std=c99 -Wall -O2'\n" +
75
                "##NOTES: CHECKED OUT TO: /fileserver/sandbox/pbray/OpenGrokSampleRepository\n" +
76
                "##AUDIT: " + user2 + " " + date2 + " 1.1 Active CHECKED OUT TO: /fileserver/sandbox/pbray/OpenGrokSampleRepository/SimpleCProgram-BinaryRelease/sparc/testsprog \n" +
77
                "#The initial release was built with debugging support.\n" +
78
                "#This is not appropriate for the production environment.\n" +
79
                "##ISSUE:        I...-..5     ++ISSUES++\n" +
80
                "\n" +
81
                "EDIT_PROPS      " + user1 + "   1.1     Active  " + date2 + "\n" +
82
                "##TITLE:  Edit file properties\n" +
83
                "\n" +
84
                "CHECK-IN        " + user1 + "   1.2     Active  " + date3 + "\n" +
85
                "##TITLE:  Built with gmake CC=gcc CFLAGS='-std=c99 -Wall -O2'\n" +
86
                "##NOTES: CHECKED IN FROM: /fileserver/sandbox/pbray/OpenGrokSampleRepository\n" +
87
                "##AUDIT: " + user1 + " " + date3 + " 1.2 Active CHECKED IN FROM: /fileserver/sandbox/pbray/OpenGrokSampleRepository/SimpleCProgram-BinaryRelease/sparc/testsprog \n" +
88
                "#The initial release was built with debugging support.\n" +
89
                "#This is not appropriate for the production environment.\n" +
90
                "#\n" +
91
                "##ISSUE:        I...-..5     ++ISSUES++\n\n";
92
        History result = instance.parseContents(new BufferedReader(new StringReader(output)));
93
        assertEquals(2, result.getHistoryEntries().size());
94
        HistoryEntry h1 = result.getHistoryEntries().get(0);
95
        Calendar cal = new GregorianCalendar();
96
        cal.setTime(h1.getDate());
97
        assertEquals(2009, cal.get(Calendar.YEAR));
98
        assertEquals(23, cal.get(Calendar.DAY_OF_MONTH));
99
        assertEquals(5, cal.get(Calendar.HOUR));
100
        assertEquals(56, cal.get(Calendar.MINUTE));
101
        assertEquals(24, cal.get(Calendar.SECOND));
102
        assertEquals(user1, h1.getAuthor());
103
        assertTrue(h1.isActive());
104
    }
105
106
}