-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathverify.bsh
151 lines (137 loc) · 6.32 KB
/
verify.bsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import java.io.*;
import java.util.*;
import java.util.regex.*;
import org.codehaus.plexus.util.*;
try
{
File siteDir = new File( basedir, "target/site" );
if ( !siteDir.isDirectory() )
{
System.out.println( "Site directory not existent: " + siteDir );
return false;
}
String[] reports = { "index", // <report>index</report>
"summary", // <report>summary</report>
"licenses", // <report>licenses</report>
"team", // <report>team</report>
"scm", // <report>scm</report>
"issue-management", // <report>issue-management</report>
"mailing-lists", // <report>mailing-lists</report>
"dependency-info", // <report>dependency-info</report>
"dependency-management", // <report>dependency-management</report>
"dependencies", // <report>dependencies</report>
"dependency-convergence", // <report>dependency-convergence</report>
"ci-management", // <report>ci-management</report>
"plugin-management", // <report>plugin-management</report>
"plugins", // <report>plugins</report>
"distribution-management" // <report>distribution-management</report>
};
String info = FileUtils.fileRead( new File( siteDir, "project-info.html"), "UTF-8" );
int index1 = 10;
int index2 = 10;
String previousReportLink;
// MPIR-182: verify order of reports
for ( String report : reports )
{
File reportFile = new File( siteDir, report + ".html" );
if ( !reportFile.isFile() )
{
System.out.println( "Report file not existent: " + reportFile );
return false;
}
String link = "<a href=\"" + reportFile.getName() + "\"";
int i1 = info.indexOf( link );
int i2 = info.indexOf( link, i1 + 1 );
if ( i1 < index1 )
{
System.out.println( "Wrong order for first report link: expected " + previousReportLink + " -> " + link + ", but found " + i1 + " < " + index1 );
System.out.println( " previous report link: " + info.substring( index1 - 10, index1 + 70 ) );
System.out.println( " actual report link: " + info.substring( i1 - 10, i1 + 70 ) );
return false;
}
if ( i2 < index2 )
{
System.out.println( "Wrong order for second report link: expected " + previousReportLink + " -> " + link + ", but found " + i2 + " < " + index2 );
System.out.println( " previous report link: " + info.substring( index2 - 10, index2 + 70 ) );
System.out.println( " actual report link: " + info.substring( i2 - 10, i2 + 70 ) );
return false;
}
index1 = i1;
index2 = i2;
previousReportLink = link;
}
File mailinglists = new File( siteDir, "mailing-lists.html");
String content = FileUtils.fileRead( mailinglists, "UTF-8" );
if ( !content.contains( "mail list intro text foo" ) )
{
System.err.println( "mailing-lists.html doesn't contain mail list intro text foo" );
return false;
}
mailinglists = new File( siteDir, "de/mailing-lists.html");
content = FileUtils.fileRead( mailinglists, "UTF-8" );
if ( !content.contains( "mail list intro text foo ("de")" ) )
{
System.err.println( "de/mailing-lists.html doesn't contain mail list intro text foo (\"de\")" );
return false;
}
mailinglists = new File( siteDir, "fr/mailing-lists.html");
content = FileUtils.fileRead( mailinglists, "UTF-8" );
if ( !content.contains( "mail list intro text foo ("fr")" ) )
{
System.err.println( "fr/mailing-lists.html doesn't contain mail list intro text foo (\"fr\")" );
return false;
}
mailinglists = new File( siteDir, "sv/mailing-lists.html");
content = FileUtils.fileRead( mailinglists, "UTF-8" );
if ( !content.contains( "mail list intro text foo" ) )
{
System.err.println( "sv/mailing-lists.html doesn't contain mail list intro text foo" );
return false;
}
File dependencies = new File( siteDir, "dependencies.html");
content = FileUtils.fileRead( dependencies, "UTF-8" );
if ( !content.contains( "doxia-core-1.2.jar" ) )
{
System.err.println( "dependencies.html doesn't contain doxia-core-1.2.jar" );
return false;
}
// MPIR-216: dependency with range
File dependencyMgmt = new File( siteDir, "dependency-management.html");
content = FileUtils.fileRead( dependencyMgmt, "UTF-8" );
if ( !content.contains( "https://maven.apache.org/doxia/doxia/doxia-sink-api/" ) )
{
System.err.println( "MPIR-216: dependency-management doesn't contain doxia-sink-api url https://maven.apache.org/doxia/doxia/doxia-sink-api/" );
return false;
}
File dependencyConvergence = new File( siteDir, "dependency-convergence.html");
content = FileUtils.fileRead( dependencyConvergence, "UTF-8" );
if ( !content.contains( "You do not have 100% convergence." ) )
{
System.err.println( "dependency-convergence not rendered correctly" );
return false;
}
}
catch ( Throwable t )
{
t.printStackTrace();
return false;
}
return true;