Project

General

Profile

Patch #2114 » migration_trac_test.rb

Unit Tests - Karl Heinz Marbaise, 2008-11-07 16:12

 
1
# redMine - project management software
2
# Copyright (C) 2008  Karl Heinz Marbaise
3
#
4
# This program is free software; you can redistribute it and/or
5
# modify it under the terms of the GNU General Public License
6
# as published by the Free Software Foundation; either version 2
7
# of the License, or (at your option) any later version.
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
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17

    
18
require 'test/unit'
19
require File.dirname(__FILE__) + '/../../../../lib/tasks/trac/trac_migration'
20

    
21
  class TracMigrationTest < Test::Unit::TestCase
22

    
23
#    def setup
24
#      @trac = TracMigrate::TracWiki.new()
25
#    end
26
    
27
    # The following three test cases are related to issue #2023
28
    #   The construct {{{XYZ}}} indicated monospaced text.
29
    #   Currently we convert it into @Inline code@
30
    def test_activity_code_tags_10
31
      assert_equal("@XYZ@", TracMigrate::TracWiki.wiki("{{{XYZ}}}"))
32
    end
33
  
34
    #   This construct is valid and would produce the expected output in trac.
35
    #   The {{{ must be on a separate line and }}} as well.
36
    def test_activity_code_tags_20
37
      assert_equal("<pre>\nXYZ\n</pre>", TracMigrate::TracWiki.wiki("{{{\nXYZ\n}}}"))
38
    end
39
  
40
    def test_activity_code_tags_30
41
      assert_equal("<pre><code class=\"java\">public class test\n</code></pre>\n", TracMigrate::TracWiki.wiki("{{{\n\r#!java\n\rpublic class test\n\r}}}\n\r"))
42
    end
43
    
44
    def test_activity_code_tags_40
45
      wiki = <<END_OF_TEXT
46
{{{
47
#!java
48
JaGoSIGroup g = projectList.get("svntestproject");
49
HashMap<String, JaGoSIArtifactType> artifactTypeList = jg.getArtifactTypes(g);
50
}}}
51
END_OF_TEXT
52

    
53
      result = <<END_OF_TEXT
54
<pre><code class=\"java\">JaGoSIGroup g = projectList.get(\"svntestproject\");
55
[[HashMap]]<String, [[JaGoSIArtifactType]]> artifactTypeList = jg.getArtifactTypes(g);
56
</code></pre>
57
END_OF_TEXT
58
#TODO: There might be an error, cause the first text in Code JaGoSIGroup is not converted into [[JaGoSIGroup]]
59
      assert_equal(result, TracMigrate::TracWiki.wiki(wiki))
60
      
61

    
62
    end
63
    
64
    # manual break
65
    #   The official guide in trac says this is the only way.
66
    def test_activity_br_10
67
      assert_equal("\n", TracMigrate::TracWiki.wiki("[[BR]]"))
68
    end
69
  
70
    #   but the lower case variant is working too.
71
    def test_activity_br_11
72
      assert_equal("\n", TracMigrate::TracWiki.wiki("[[br]]"))
73
    end
74
    
75
    ## ------------------
76
    ## Code Highlightings
77
    ## ------------------
78
    def test_activity_highlighting_10
79
      assert_equal("_*HighlightingText*_", TracMigrate::TracWiki.wiki("'''''HighlightingText'''''"))
80
    end
81
  
82
    def test_activity_highlighting_20
83
      assert_equal("*HighlightingText*", TracMigrate::TracWiki.wiki("'''HighlightingText'''"))
84
    end
85
    
86
    def test_activity_highlighting_30
87
      assert_equal("_HighlightingText_", TracMigrate::TracWiki.wiki("''HighlightingText''"))
88
    end
89
    
90
    def test_activity_highlighting_40
91
      assert_equal("+HighlightingText+", TracMigrate::TracWiki.wiki("__HighlightingText__"))
92
    end
93
    
94
    # Milestones
95
    #   The following test cases are related to issue #2052
96
    def test_activity_milestone_10
97
      assert_equal("version:1.0.0", TracMigrate::TracWiki.wiki("milestone:1.0.0"))
98
    end
99
    
100
    def test_activity_milestone_20
101
      assert_equal('version:"1.0.0"', TracMigrate::TracWiki.wiki('milestone:"1.0.0"'))
102
    end
103
    
104
    def test_activity_milestone_30
105
      assert_equal('version:"0.1.0 Mercury"', TracMigrate::TracWiki.wiki('[milestone:"0.1.0 Mercury" Milestone 0.1.0 (Mercury)]'))
106
    end
107
    
108
    def test_activity_milestone_40
109
      assert_equal('version:"Test Milestone X"', TracMigrate::TracWiki.wiki('[milestone:"Test Milestone X"]'))
110
    end
111
  
112
    # Tickets (issue #2053)
113
    def test_activity_ticket_10
114
      assert_equal('#123', TracMigrate::TracWiki.wiki('ticket:123'))
115
    end
116
  
117
    def test_activity_ticket_11
118
      assert_equal('#123', TracMigrate::TracWiki.wiki('#123'))
119
    end
120
    
121
    def test_activity_ticket_20
122
      assert_equal('#123', TracMigrate::TracWiki.wiki('[ticket:123]'))
123
    end
124
  
125
    def test_activity_ticket_30
126
      assert_equal('"this":/issues/show/123', TracMigrate::TracWiki.wiki('[ticket:123 this]'))
127
    end
128
  
129
    # Tables (issue #2054)
130
    def test_activity_tables_10
131
      assert_equal(
132
        '|Column1|Column2|Column3|', 
133
        TracMigrate::TracWiki.wiki('||Column1||Column2||Column3||')
134
      )
135
    end
136
  
137
    # Tables (issue #2089)
138
    def test_activity_mailto_10
139
      assert_equal('user@test.de', TracMigrate::TracWiki.wiki('[mailto:user@test.de]'))
140
    end
141
    def test_activity_mailto_20
142
      assert_equal(
143
        '"The new text":mailto:user@test.de', 
144
        TracMigrate::TracWiki.wiki('[mailto:user@test.de The new text]')
145
      )
146
    end
147
  
148
    #source - tag (issue #2068)
149
    def test_activity_source_10
150
      assert_equal(
151
        'source:/tags/JAGOSI-0.0.10/jagosiapi/src/main/java/com/soebes/jagosi/api/JaGoSI.java#L143', 
152
        TracMigrate::TracWiki.wiki('[source:/tags/JAGOSI-0.0.10/jagosiapi/src/main/java/com/soebes/jagosi/api/JaGoSI.java@latest#L143 Line 143]')
153
      )
154
    end
155
    def test_activity_source_20
156
      assert_equal(
157
        '"Ant Task":/repositories/browse/trunk/jagosiant',
158
        TracMigrate::TracWiki.wiki('[source:trunk/jagosiant Ant Task]')
159
      )
160
    end
161
    
162
    def test_activity_source_30
163
      assert_equal(
164
        'source:tags/JAGOSI-0.0.10',
165
        TracMigrate::TracWiki.wiki('source:tags/JAGOSI-0.0.10')
166
      )
167
    end
168
  
169
    def test_activity_wiki_10
170
      assert_equal(
171
        '[[RepositoryQuestions|Have you ever put such questions to your repository]]',
172
        TracMigrate::TracWiki.wiki('[wiki:RepositoryQuestions Have you ever put such questions to your repository?]')
173
      )
174
    end
175
  
176
    def test_activity_wiki_20
177
      assert_equal(
178
        '* -Scan a whole repository-', 
179
        TracMigrate::TracWiki.wiki(' * ~~Scan a whole repository~~')
180
      )
181
    end
182
  
183
    def test_activity_wiki_30
184
      assert_equal(
185
        '* -[[Configuration|Cron like automation]] to scan repositories-.', 
186
        TracMigrate::TracWiki.wiki(' * ~~[wiki:Configuration Cron like automation] to scan repositories~~.')
187
      )
188
    end
189
    
190
    # This is based on Issue #1843
191
    def test_activiate_wiki_40
192
      assert_equal(
193
        '[[String WikiString]]',
194
        TracMigrate::TracWiki.wiki('[wiki:"String WikiString"]')
195
      )
196
    end
197
  
198
    def test_activity_changeset_10
199
      assert_equal('r123', TracMigrate::TracWiki.wiki('r123'))
200
    end
201
    def test_activity_changeset_20
202
      assert_equal('r123', TracMigrate::TracWiki.wiki('[123]'))
203
    end
204
    def test_activity_changeset_30
205
      assert_equal('r123', TracMigrate::TracWiki.wiki('changeset:123'))
206
    end
207

    
208
    # This is based on Issue #2146
209
    def test_activity_attachment_10
210
      assert_equal('attachment:JaGoSIAPI-0.0.10.jar', TracMigrate::TracWiki.wiki('[attachment:JaGoSIAPI-0.0.10.jar]'))
211
    end
212
    def test_activity_attachment_11
213
      assert_equal('attachment:JaGoSIAPI-0.0.10.jar', TracMigrate::TracWiki.wiki('attachment:JaGoSIAPI-0.0.10.jar'))
214
    end
215
    def test_activity_attachment_20
216
      assert_equal('"This is Text":attachment:JaGoSIAPI-0.0.10.jar', TracMigrate::TracWiki.wiki('[attachment:JaGoSIAPI-0.0.10.jar This is Text]'))
217
    end
218

    
219
    def test_activity_integration_10
220
      assert_equal(
221
        'version:"XXX"+Test+version:"Test Milestone X"', 
222
        TracMigrate::TracWiki.wiki('[milestone:"XXX"]__Test__[milestone:"Test Milestone X"]')
223
      )
224
    end
225
  end
226

    
(3-3/5)