Merge lp:~james-page/ubuntu/oneiric/testng/fix-ftbfs into lp:ubuntu/oneiric/testng

Proposed by James Page
Status: Merged
Merge reported by: James Page
Merged at revision: not available
Proposed branch: lp:~james-page/ubuntu/oneiric/testng/fix-ftbfs
Merge into: lp:ubuntu/oneiric/testng
Diff against target: 287 lines (+200/-5)
7 files modified
.pc/applied-patches (+1/-0)
.pc/debian/junitconvertor-test-fix.diff/test/src/test/converter/JUnitConverterTest.java (+130/-0)
debian/changelog (+9/-0)
debian/control (+2/-1)
debian/patches/debian/junitconvertor-test-fix.diff (+52/-0)
debian/patches/series (+1/-0)
test/src/test/converter/JUnitConverterTest.java (+5/-4)
To merge this branch: bzr merge lp:~james-page/ubuntu/oneiric/testng/fix-ftbfs
Reviewer Review Type Date Requested Status
Matthias Klose Approve
Ubuntu branches Pending
Review via email: mp+76196@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Matthias Klose (doko) wrote :

thanks, looks fine!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.pc/applied-patches'
2--- .pc/applied-patches 2010-08-16 10:52:51 +0000
3+++ .pc/applied-patches 2011-09-20 11:36:30 +0000
4@@ -6,3 +6,4 @@
5 features/qdox-1.9.diff
6 features/scope-qdox-bsh.diff
7 features/threadsafe-collections-in-tests.diff
8+debian/junitconvertor-test-fix.diff
9
10=== added directory '.pc/debian/junitconvertor-test-fix.diff'
11=== added directory '.pc/debian/junitconvertor-test-fix.diff/test'
12=== added directory '.pc/debian/junitconvertor-test-fix.diff/test/src'
13=== added directory '.pc/debian/junitconvertor-test-fix.diff/test/src/test'
14=== added directory '.pc/debian/junitconvertor-test-fix.diff/test/src/test/converter'
15=== added file '.pc/debian/junitconvertor-test-fix.diff/test/src/test/converter/JUnitConverterTest.java'
16--- .pc/debian/junitconvertor-test-fix.diff/test/src/test/converter/JUnitConverterTest.java 1970-01-01 00:00:00 +0000
17+++ .pc/debian/junitconvertor-test-fix.diff/test/src/test/converter/JUnitConverterTest.java 2011-09-20 11:36:30 +0000
18@@ -0,0 +1,130 @@
19+package test.converter;
20+
21+import org.testng.Assert;
22+import org.testng.JUnitConverter;
23+import org.testng.annotations.Test;
24+
25+import java.io.BufferedReader;
26+import java.io.File;
27+import java.io.FileNotFoundException;
28+import java.io.FileReader;
29+import java.io.IOException;
30+import java.util.ArrayList;
31+import java.util.Arrays;
32+import java.util.List;
33+import java.util.regex.Pattern;
34+
35+public class JUnitConverterTest {
36+
37+ /**
38+ *
39+ * @param fileName The filename to parse
40+ * @param regexp The regular expression
41+ * @param resultLines An out parameter that will contain all the lines
42+ * that matched the regexp
43+ * @return A List<Integer> containing the lines of all the matches
44+ *
45+ * Note that the size() of the returned valuewill always be equal to
46+ * result.size() at the end of this function.
47+ */
48+ static public List grep(File fileName, String regexp, List resultLines) {
49+ List resultLineNumbers = new ArrayList();
50+ try {
51+ BufferedReader fr = new BufferedReader(new FileReader(fileName));
52+ String line = fr.readLine();
53+ int currentLine = 0;
54+ Pattern p = Pattern.compile(".*" + regexp + ".*");
55+
56+ while (null != line) {
57+// ppp("COMPARING " + p + " TO @@@" + line + "@@@");
58+ if (p.matcher(line).matches()) {
59+ resultLines.add(line);
60+ resultLineNumbers.add(currentLine);
61+ }
62+
63+ line = fr.readLine();
64+ currentLine++;
65+ }
66+ }
67+ catch (FileNotFoundException e) {
68+ e.printStackTrace();
69+ }
70+ catch (IOException e) {
71+ e.printStackTrace();
72+ }
73+
74+ return resultLineNumbers;
75+
76+ }
77+
78+ public static void ppp(String s) {
79+ System.out.println("[JUnitConverterTest] " + s);
80+ }
81+
82+ /**
83+ * @param fileName
84+ * @param tag
85+ * @param annotationType
86+ * @param expected A list of line numbers where the tag is expected
87+ * to be present
88+ */
89+ private void runTest(File sourceDir, String packageName, String fileName, String tag,
90+ String annotationType, List expected)
91+ {
92+ String outputDir = System.getProperty("java.io.tmpdir");
93+ String packageDir = packageName.replace('.', File.separatorChar);
94+ List args = new ArrayList();
95+ args.add("-quiet");
96+ args.add(annotationType);
97+ args.add("-srcdir");
98+ args.add(sourceDir.getAbsolutePath());
99+ args.add("-d");
100+ args.add(outputDir);
101+ String[] argv = (String[]) args.toArray(new String[args.size()]);
102+ JUnitConverter.main(argv);
103+
104+ List resultLines = new ArrayList();
105+ File file = new File(outputDir, packageDir + File.separatorChar + fileName);
106+ List actualLineNumbers = grep(file, tag, resultLines);
107+ Assert.assertEquals(actualLineNumbers, expected, file + "\n tag:" + tag);
108+
109+ }
110+
111+ private void runJavaDocTest(File sourcePath, String pkg, String fileName, List[] expected) {
112+ runTest(sourcePath, pkg, fileName, "@testng.test", "-javadoc", expected[0]);
113+ runTest(sourcePath, pkg, fileName, "@testng.before-method", "-javadoc", expected[1]);
114+ runTest(sourcePath, pkg, fileName, "@testng.after-method", "-javadoc", expected[2]);
115+ }
116+
117+ private void runAnnotationTest(File sourcePath, String pkg, String fileName, List[] expected) {
118+ runTest(sourcePath, pkg, fileName, "@Test", "-annotation", expected[0]);
119+ runTest(sourcePath, pkg, fileName, "@BeforeMethod", "-annotation", expected[1]);
120+ runTest(sourcePath, pkg, fileName, "@AfterMethod", "-annotation", expected[2]);
121+ }
122+
123+ @Test(parameters = { "source-directory" })
124+ public void testAnnotations(String dir) {
125+ runAnnotationTest(new File(dir), "test.converter", "ConverterSample1.java",
126+ new List[] { Arrays.asList(23, 30, 35), Arrays.asList(9), Arrays.asList(18) });
127+ }
128+
129+ @Test(parameters = { "source-directory" })
130+ public void testAnnotationsNoPackage(String dir) {
131+ runAnnotationTest(new File(dir, "../../.."), "", "ConverterSample2.java",
132+ new List[] { Arrays.asList(23, 30, 35), Arrays.asList(9), Arrays.asList(18) });
133+ }
134+
135+ @Test(parameters = { "source-directory" })
136+ public void testJavaDoc(String dir) {
137+ runJavaDocTest(new File(dir), "test.converter", "ConverterSample1.java",
138+ new List[] { Arrays.asList(25, 34, 41), Arrays.asList(7), Arrays.asList(18) });
139+ }
140+
141+ @Test(parameters = { "source-directory" })
142+ public void testJavaDocNoPackage(String dir) {
143+ runJavaDocTest(new File(dir, "../../.."), "", "ConverterSample2.java",
144+ new List[] { Arrays.asList(25, 34, 41), Arrays.asList(7), Arrays.asList(18) });
145+ }
146+
147+
148+}
149
150=== modified file 'debian/changelog'
151--- debian/changelog 2010-11-12 09:09:59 +0000
152+++ debian/changelog 2011-09-20 11:36:30 +0000
153@@ -1,3 +1,12 @@
154+testng (5.11+dfsg-2ubuntu2) oneiric; urgency=low
155+
156+ * Fix FTBFS (LP: #829508):
157+ - d/patches/debian/junitconvertor-test-fix.diff: Switch from use of
158+ deprecated parameters attribute in @Test to using @Parameters to
159+ ensure that JUnitConvertor Test passes.
160+
161+ -- James Page <james.page@ubuntu.com> Tue, 20 Sep 2011 12:15:27 +0100
162+
163 testng (5.11+dfsg-2ubuntu1) natty; urgency=low
164
165 * debian/rules: updated to use ant-nodeps to fix FTBFS (LP: #674382)
166
167=== modified file 'debian/control'
168--- debian/control 2010-11-12 09:09:59 +0000
169+++ debian/control 2011-09-20 11:36:30 +0000
170@@ -1,7 +1,8 @@
171 Source: testng
172 Section: java
173 Priority: optional
174-Maintainer: Marcus Better <marcus@better.se>
175+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
176+XSBC-Original-Maintainer: Marcus Better <marcus@better.se>
177 Build-Depends: debhelper (>= 7.3.5), ant
178 Build-Depends-Indep: default-jdk, ant-optional, junit, bsh, libqdox-java (>= 1.9), libbackport-util-concurrent-java, maven-repo-helper
179 Standards-Version: 3.8.4
180
181=== added file 'debian/patches/debian/junitconvertor-test-fix.diff'
182--- debian/patches/debian/junitconvertor-test-fix.diff 1970-01-01 00:00:00 +0000
183+++ debian/patches/debian/junitconvertor-test-fix.diff 2011-09-20 11:36:30 +0000
184@@ -0,0 +1,52 @@
185+Description: Switches JUnitConverter test to use Parameters annotation to
186+ pickup source-directory for tests. This resolves a FTBFS seen in Ubuntu
187+ Oneiric but not in earlier releases and is present in the upstream release
188+ as well went build on Oneiric
189+ .
190+ This test is no longer executed in the next release of testng so not
191+ forwarding upstream.
192+Author: James Page <james.page@ubuntu.com>
193+Forwarded: not-needed
194+
195+Index: testng/test/src/test/converter/JUnitConverterTest.java
196+===================================================================
197+--- testng.orig/test/src/test/converter/JUnitConverterTest.java 2011-09-20 08:49:59.668342142 +0100
198++++ testng/test/src/test/converter/JUnitConverterTest.java 2011-09-20 08:51:09.178496996 +0100
199+@@ -3,6 +3,7 @@
200+ import org.testng.Assert;
201+ import org.testng.JUnitConverter;
202+ import org.testng.annotations.Test;
203++import org.testng.annotations.Parameters;
204+
205+ import java.io.BufferedReader;
206+ import java.io.File;
207+@@ -102,25 +103,25 @@
208+ runTest(sourcePath, pkg, fileName, "@AfterMethod", "-annotation", expected[2]);
209+ }
210+
211+- @Test(parameters = { "source-directory" })
212++ @Parameters({ "source-directory" })
213+ public void testAnnotations(String dir) {
214+ runAnnotationTest(new File(dir), "test.converter", "ConverterSample1.java",
215+ new List[] { Arrays.asList(23, 30, 35), Arrays.asList(9), Arrays.asList(18) });
216+ }
217+
218+- @Test(parameters = { "source-directory" })
219++ @Parameters({ "source-directory" })
220+ public void testAnnotationsNoPackage(String dir) {
221+ runAnnotationTest(new File(dir, "../../.."), "", "ConverterSample2.java",
222+ new List[] { Arrays.asList(23, 30, 35), Arrays.asList(9), Arrays.asList(18) });
223+ }
224+
225+- @Test(parameters = { "source-directory" })
226++ @Parameters({ "source-directory" })
227+ public void testJavaDoc(String dir) {
228+ runJavaDocTest(new File(dir), "test.converter", "ConverterSample1.java",
229+ new List[] { Arrays.asList(25, 34, 41), Arrays.asList(7), Arrays.asList(18) });
230+ }
231+
232+- @Test(parameters = { "source-directory" })
233++ @Parameters({ "source-directory" })
234+ public void testJavaDocNoPackage(String dir) {
235+ runJavaDocTest(new File(dir, "../../.."), "", "ConverterSample2.java",
236+ new List[] { Arrays.asList(25, 34, 41), Arrays.asList(7), Arrays.asList(18) });
237
238=== modified file 'debian/patches/series'
239--- debian/patches/series 2010-08-16 10:52:51 +0000
240+++ debian/patches/series 2011-09-20 11:36:30 +0000
241@@ -6,3 +6,4 @@
242 features/qdox-1.9.diff -p1
243 features/scope-qdox-bsh.diff -p1
244 features/threadsafe-collections-in-tests.diff -p1
245+debian/junitconvertor-test-fix.diff
246
247=== modified file 'test/src/test/converter/JUnitConverterTest.java'
248--- test/src/test/converter/JUnitConverterTest.java 2009-05-04 10:47:43 +0000
249+++ test/src/test/converter/JUnitConverterTest.java 2011-09-20 11:36:30 +0000
250@@ -3,6 +3,7 @@
251 import org.testng.Assert;
252 import org.testng.JUnitConverter;
253 import org.testng.annotations.Test;
254+import org.testng.annotations.Parameters;
255
256 import java.io.BufferedReader;
257 import java.io.File;
258@@ -102,25 +103,25 @@
259 runTest(sourcePath, pkg, fileName, "@AfterMethod", "-annotation", expected[2]);
260 }
261
262- @Test(parameters = { "source-directory" })
263+ @Parameters({ "source-directory" })
264 public void testAnnotations(String dir) {
265 runAnnotationTest(new File(dir), "test.converter", "ConverterSample1.java",
266 new List[] { Arrays.asList(23, 30, 35), Arrays.asList(9), Arrays.asList(18) });
267 }
268
269- @Test(parameters = { "source-directory" })
270+ @Parameters({ "source-directory" })
271 public void testAnnotationsNoPackage(String dir) {
272 runAnnotationTest(new File(dir, "../../.."), "", "ConverterSample2.java",
273 new List[] { Arrays.asList(23, 30, 35), Arrays.asList(9), Arrays.asList(18) });
274 }
275
276- @Test(parameters = { "source-directory" })
277+ @Parameters({ "source-directory" })
278 public void testJavaDoc(String dir) {
279 runJavaDocTest(new File(dir), "test.converter", "ConverterSample1.java",
280 new List[] { Arrays.asList(25, 34, 41), Arrays.asList(7), Arrays.asList(18) });
281 }
282
283- @Test(parameters = { "source-directory" })
284+ @Parameters({ "source-directory" })
285 public void testJavaDocNoPackage(String dir) {
286 runJavaDocTest(new File(dir, "../../.."), "", "ConverterSample2.java",
287 new List[] { Arrays.asList(25, 34, 41), Arrays.asList(7), Arrays.asList(18) });

Subscribers

People subscribed via source and target branches

to all changes: