|
Lines 10-17
Link Here
|
| 10 |
* IBM Corporation - code review and integration |
10 |
* IBM Corporation - code review and integration |
| 11 |
*******************************************************************************/ |
11 |
*******************************************************************************/ |
| 12 |
package org.eclipse.jdt.core.tests.compiler.regression; |
12 |
package org.eclipse.jdt.core.tests.compiler.regression; |
|
|
13 |
import java.io.ByteArrayInputStream; |
| 13 |
import java.io.IOException; |
14 |
import java.io.IOException; |
| 14 |
import java.io.StringReader; |
15 |
import java.io.InputStream; |
| 15 |
import java.util.List; |
16 |
import java.util.List; |
| 16 |
|
17 |
|
| 17 |
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer; |
18 |
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer; |
|
Lines 29-45
Link Here
|
| 29 |
} |
30 |
} |
| 30 |
public void testWithOneJar() throws IOException { |
31 |
public void testWithOneJar() throws IOException { |
| 31 |
String testWithOneJar = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\nBuild-Reference: Version toto"; |
32 |
String testWithOneJar = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\nBuild-Reference: Version toto"; |
| 32 |
StringReader reader = new StringReader(testWithOneJar); |
33 |
analyzeManifestContents(testWithOneJar); |
| 33 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 34 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
34 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 35 |
assertEquals("Wrong size", 1, jars.size()); |
35 |
assertEquals("Wrong size", 1, jars.size()); |
| 36 |
assertEquals(FIRST_JAR, jars.get(0)); |
36 |
assertEquals(FIRST_JAR, jars.get(0)); |
| 37 |
} |
37 |
} |
| 38 |
|
38 |
|
|
|
39 |
private void analyzeManifestContents(String contents) throws IOException { |
| 40 |
InputStream stream = new ByteArrayInputStream(contents.getBytes()); |
| 41 |
try { |
| 42 |
this.manifestAnalyzer.analyzeManifestContents(stream); |
| 43 |
} catch(IOException e) { |
| 44 |
stream.close(); |
| 45 |
} |
| 46 |
} |
| 39 |
public void testWithOneJarWithWiteSpace() throws IOException { |
47 |
public void testWithOneJarWithWiteSpace() throws IOException { |
| 40 |
String testWithOneJarWithWiteSpace = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + WHITESPACE + "\nBuild-Reference: Version toto"; |
48 |
String testWithOneJarWithWiteSpace = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + WHITESPACE + "\nBuild-Reference: Version toto"; |
| 41 |
StringReader reader = new StringReader(testWithOneJarWithWiteSpace); |
49 |
analyzeManifestContents(testWithOneJarWithWiteSpace); |
| 42 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 43 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
50 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 44 |
assertEquals("Wrong size", 1, jars.size()); |
51 |
assertEquals("Wrong size", 1, jars.size()); |
| 45 |
assertEquals(FIRST_JAR, jars.get(0)); |
52 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 47-54
Link Here
|
| 47 |
|
54 |
|
| 48 |
public void testWithSecondJarOnNextLine() throws IOException { |
55 |
public void testWithSecondJarOnNextLine() throws IOException { |
| 49 |
String testWithSecondJarOnNextLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\n"+ WHITESPACE + WHITESPACE +"secondJar.jar\nBuild-Reference: Version toto"; |
56 |
String testWithSecondJarOnNextLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\n"+ WHITESPACE + WHITESPACE +"secondJar.jar\nBuild-Reference: Version toto"; |
| 50 |
StringReader reader = new StringReader(testWithSecondJarOnNextLine); |
57 |
analyzeManifestContents(testWithSecondJarOnNextLine); |
| 51 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 52 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
58 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 53 |
assertEquals("Wrong size", 2, jars.size()); |
59 |
assertEquals("Wrong size", 2, jars.size()); |
| 54 |
assertEquals(FIRST_JAR, jars.get(0)); |
60 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 57-64
Link Here
|
| 57 |
|
63 |
|
| 58 |
public void testWithSecondJarOnTwoLine() throws IOException { |
64 |
public void testWithSecondJarOnTwoLine() throws IOException { |
| 59 |
String testWithSecondJarOnTwoLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + WHITESPACE + "second\n" + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto"; |
65 |
String testWithSecondJarOnTwoLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + WHITESPACE + "second\n" + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto"; |
| 60 |
StringReader reader = new StringReader(testWithSecondJarOnTwoLine); |
66 |
analyzeManifestContents(testWithSecondJarOnTwoLine); |
| 61 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 62 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
67 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 63 |
assertEquals("Wrong size", 2, jars.size()); |
68 |
assertEquals("Wrong size", 2, jars.size()); |
| 64 |
assertEquals(FIRST_JAR, jars.get(0)); |
69 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 67-74
Link Here
|
| 67 |
|
72 |
|
| 68 |
public void testWithSecondJarOnTwoLine2() throws IOException { |
73 |
public void testWithSecondJarOnTwoLine2() throws IOException { |
| 69 |
String testWithSecondJarOnTwoLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + WHITESPACE + "second\n" + WHITESPACE + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto"; |
74 |
String testWithSecondJarOnTwoLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + WHITESPACE + "second\n" + WHITESPACE + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto"; |
| 70 |
StringReader reader = new StringReader(testWithSecondJarOnTwoLine); |
75 |
analyzeManifestContents(testWithSecondJarOnTwoLine); |
| 71 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 72 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
76 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 73 |
assertEquals("Wrong size", 3, jars.size()); |
77 |
assertEquals("Wrong size", 3, jars.size()); |
| 74 |
assertEquals(FIRST_JAR, jars.get(0)); |
78 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 78-85
Link Here
|
| 78 |
|
82 |
|
| 79 |
public void testWithSecondJarOnTwoLine3() throws IOException { |
83 |
public void testWithSecondJarOnTwoLine3() throws IOException { |
| 80 |
String testWithSecondJarOnTwoLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + WHITESPACE + "second\n" + "Jar.jar\nBuild-Reference: Version toto"; |
84 |
String testWithSecondJarOnTwoLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + WHITESPACE + "second\n" + "Jar.jar\nBuild-Reference: Version toto"; |
| 81 |
StringReader reader = new StringReader(testWithSecondJarOnTwoLine); |
85 |
analyzeManifestContents(testWithSecondJarOnTwoLine); |
| 82 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 83 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
86 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 84 |
assertEquals("Wrong size", 2, jars.size()); |
87 |
assertEquals("Wrong size", 2, jars.size()); |
| 85 |
assertEquals(FIRST_JAR, jars.get(0)); |
88 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 88-95
Link Here
|
| 88 |
|
91 |
|
| 89 |
public void testWithSecondJarOnTwoLine4() throws IOException { |
92 |
public void testWithSecondJarOnTwoLine4() throws IOException { |
| 90 |
String testWithSecondJarOnTwoLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\n" + "second\n" + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto"; |
93 |
String testWithSecondJarOnTwoLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\n" + "second\n" + WHITESPACE + "Jar.jar\nBuild-Reference: Version toto"; |
| 91 |
StringReader reader = new StringReader(testWithSecondJarOnTwoLine); |
94 |
analyzeManifestContents(testWithSecondJarOnTwoLine); |
| 92 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 93 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
95 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 94 |
assertEquals("Wrong size", 1, jars.size()); |
96 |
assertEquals("Wrong size", 1, jars.size()); |
| 95 |
assertEquals(FIRST_JAR, jars.get(0)); |
97 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 97-104
Link Here
|
| 97 |
|
99 |
|
| 98 |
public void testWithSecondJarOnNextLine5() throws IOException { |
100 |
public void testWithSecondJarOnNextLine5() throws IOException { |
| 99 |
String testWithSecondJarOnNextLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\n"+ WHITESPACE + "secondJar.jar\nBuild-Reference: Version toto"; |
101 |
String testWithSecondJarOnNextLine = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + "\n"+ WHITESPACE + "secondJar.jar\nBuild-Reference: Version toto"; |
| 100 |
StringReader reader = new StringReader(testWithSecondJarOnNextLine); |
102 |
analyzeManifestContents(testWithSecondJarOnNextLine); |
| 101 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 102 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
103 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 103 |
assertEquals("Wrong size", 1, jars.size()); |
104 |
assertEquals("Wrong size", 1, jars.size()); |
| 104 |
assertEquals(FIRST_JAR + SECOND_JAR, jars.get(0)); |
105 |
assertEquals(FIRST_JAR + SECOND_JAR, jars.get(0)); |
|
Lines 106-113
Link Here
|
| 106 |
|
107 |
|
| 107 |
public void testWithSecondJarOnTwoLineEndedWithEOF() throws IOException { |
108 |
public void testWithSecondJarOnTwoLineEndedWithEOF() throws IOException { |
| 108 |
String testWithSecondJarOnTwoLineEndedWithEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar"; |
109 |
String testWithSecondJarOnTwoLineEndedWithEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar"; |
| 109 |
StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithEOF); |
110 |
analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithEOF); |
| 110 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 111 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
111 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 112 |
assertEquals("Wrong size", 1, jars.size()); |
112 |
assertEquals("Wrong size", 1, jars.size()); |
| 113 |
assertEquals(FIRST_JAR, jars.get(0)); |
113 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 115-122
Link Here
|
| 115 |
|
115 |
|
| 116 |
public void testWithSecondJarOnTwoLineEndedWithEOF2() throws IOException { |
116 |
public void testWithSecondJarOnTwoLineEndedWithEOF2() throws IOException { |
| 117 |
String testWithSecondJarOnTwoLineEndedWithEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar\n"; |
117 |
String testWithSecondJarOnTwoLineEndedWithEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar\n"; |
| 118 |
StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithEOF); |
118 |
analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithEOF); |
| 119 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 120 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
119 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 121 |
assertEquals("Wrong size", 2, jars.size()); |
120 |
assertEquals("Wrong size", 2, jars.size()); |
| 122 |
assertEquals(FIRST_JAR, jars.get(0)); |
121 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 125-132
Link Here
|
| 125 |
|
124 |
|
| 126 |
public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF() throws IOException { |
125 |
public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF() throws IOException { |
| 127 |
String testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar "; |
126 |
String testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar "; |
| 128 |
StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF); |
127 |
analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF); |
| 129 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 130 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
128 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 131 |
assertEquals("Wrong size", 2, jars.size()); |
129 |
assertEquals("Wrong size", 2, jars.size()); |
| 132 |
assertEquals(FIRST_JAR, jars.get(0)); |
130 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 135-142
Link Here
|
| 135 |
|
133 |
|
| 136 |
public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF() throws IOException { |
134 |
public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF() throws IOException { |
| 137 |
String testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar \n"; |
135 |
String testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar \n"; |
| 138 |
StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF); |
136 |
analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF); |
| 139 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 140 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
137 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 141 |
assertEquals("Wrong size", 2, jars.size()); |
138 |
assertEquals("Wrong size", 2, jars.size()); |
| 142 |
assertEquals(FIRST_JAR, jars.get(0)); |
139 |
assertEquals(FIRST_JAR, jars.get(0)); |
|
Lines 145-155
Link Here
|
| 145 |
|
142 |
|
| 146 |
public void testWithSecondJarOnTwoLineEndedWithNewLineEOF() throws IOException { |
143 |
public void testWithSecondJarOnTwoLineEndedWithNewLineEOF() throws IOException { |
| 147 |
String testWithSecondJarOnTwoLineEndedWithNewLineEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar\n"; |
144 |
String testWithSecondJarOnTwoLineEndedWithNewLineEOF = "Manifest-Version: 1.0\nAnt-Version: Apache Ant 1.6.5\nCreated-By: 1.5.0_14-b03 (Sun Microsystems Inc.)\nClass-Path: " + FIRST_JAR + " second\n Jar.jar\n"; |
| 148 |
StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithNewLineEOF); |
145 |
analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithNewLineEOF); |
| 149 |
this.manifestAnalyzer.analyzeManifestContents(reader); |
|
|
| 150 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
146 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 151 |
assertEquals("Wrong size", 2, jars.size()); |
147 |
assertEquals("Wrong size", 2, jars.size()); |
| 152 |
assertEquals(FIRST_JAR, jars.get(0)); |
148 |
assertEquals(FIRST_JAR, jars.get(0)); |
| 153 |
assertEquals(SECOND_JAR, jars.get(1)); |
149 |
assertEquals(SECOND_JAR, jars.get(1)); |
| 154 |
} |
150 |
} |
|
|
151 |
|
| 152 |
public void testWithOneJarUsingUTF8Name() throws IOException { |
| 153 |
InputStream inputStream = ManifestAnalyzerTest.class.getResourceAsStream("MANIFEST.MF"); |
| 154 |
this.manifestAnalyzer.analyzeManifestContents(inputStream); |
| 155 |
inputStream.close(); |
| 156 |
List jars = this.manifestAnalyzer.getCalledFileNames(); |
| 157 |
assertEquals("Wrong size", 1, jars.size()); |
| 158 |
assertEquals("called\u3042.jar", jars.get(0)); |
| 159 |
} |
| 155 |
} |
160 |
} |