### Eclipse Workspace Patch 1.0 #P org.eclipse.jdt.core Index: model/org/eclipse/jdt/internal/core/ClasspathEntry.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/model/org/eclipse/jdt/internal/core/ClasspathEntry.java,v retrieving revision 1.115 diff -u -r1.115 ClasspathEntry.java --- model/org/eclipse/jdt/internal/core/ClasspathEntry.java 7 Mar 2009 00:58:57 -0000 1.115 +++ model/org/eclipse/jdt/internal/core/ClasspathEntry.java 17 Apr 2009 20:05:50 -0000 @@ -10,11 +10,10 @@ *******************************************************************************/ package org.eclipse.jdt.internal.core; -import java.io.BufferedReader; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; -import java.io.InputStreamReader; +import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.util.ArrayList; @@ -49,8 +48,8 @@ import org.eclipse.jdt.core.compiler.CharOperation; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.internal.compiler.env.AccessRestriction; -import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; import org.eclipse.jdt.internal.compiler.env.AccessRule; +import org.eclipse.jdt.internal.compiler.env.AccessRuleSet; import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer; import org.eclipse.jdt.internal.core.util.Messages; @@ -904,7 +903,7 @@ return null; JavaModelManager manager = JavaModelManager.getJavaModelManager(); ZipFile zip = null; - BufferedReader reader = null; + InputStream inputStream = null; List calledFileNames = null; try { zip = manager.getZipFile(jarPath); @@ -912,9 +911,9 @@ if (manifest == null) return null; // non-null implies regular file - reader = new BufferedReader(new InputStreamReader(zip.getInputStream(manifest))); ManifestAnalyzer analyzer = new ManifestAnalyzer(); - boolean success = analyzer.analyzeManifestContents(reader); + inputStream = zip.getInputStream(manifest); + boolean success = analyzer.analyzeManifestContents(inputStream); calledFileNames = analyzer.getCalledFileNames(); if (!success || analyzer.getClasspathSectionsCount() == 1 && calledFileNames == null) { if (JavaModelManager.CP_RESOLVE_VERBOSE_FAILURE) { @@ -941,9 +940,9 @@ } } finally { manager.closeZipFile(zip); - if (reader != null) { + if (inputStream != null) { try { - reader.close(); + inputStream.close(); } catch (IOException e) { // best effort } @@ -1462,7 +1461,7 @@ *
true
if the analysis is successful, false
otherwise.
+ * @throws IOException if an exception occurs while analyzing the file
+ */
+ public boolean analyzeManifestContents(InputStream inputStream) throws IOException {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName(Util.UTF_8)));
+ try {
+ int state = START, substate = 0;
+ StringBuffer currentJarToken = new StringBuffer();
+ int currentChar;
+ this.classpathSectionsCount = 0;
+ this.calledFilesNames = null;
+ for (;;) {
currentChar = reader.read();
- switch (state) {
- case START:
- if (currentChar == -1) {
- return true;
- } else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) {
- state = IN_CLASSPATH_HEADER;
- substate = 1;
- } else {
- state = SKIP_LINE;
- }
- break;
- case IN_CLASSPATH_HEADER:
- if (currentChar == -1) {
- return true;
- } else if (currentChar == '\n') {
- state = START;
- } else if (currentChar != CLASSPATH_HEADER_TOKEN[substate++]) {
- state = SKIP_LINE;
- } else if (substate == CLASSPATH_HEADER_TOKEN.length) {
- state = PAST_CLASSPATH_HEADER;
- }
- break;
- case PAST_CLASSPATH_HEADER:
- if (currentChar == ' ') {
- state = SKIPPING_WHITESPACE;
- this.classpathSectionsCount++;
- } else {
- return false;
- }
- break;
- case SKIPPING_WHITESPACE:
- if (currentChar == -1) {
- // >>>>>>>>>>>>>>>>>> Add the latest jar read
- addCurrentTokenJarWhenNecessary(currentJarToken);
- return true;
- } else if (currentChar == '\n') {
- state = CONTINUING;
- } else if (currentChar != ' ') {
- currentJarToken.append((char) currentChar);
- state = READING_JAR;
- } else {
- // >>>>>>>>>>>>>>>>>> Add the latest jar read
- addCurrentTokenJarWhenNecessary(currentJarToken);
- }
- break;
- case CONTINUING:
- if (currentChar == -1) {
- // >>>>>>>>>>>>>>>>>> Add the latest jar read
- addCurrentTokenJarWhenNecessary(currentJarToken);
- return true;
- } else if (currentChar == '\n') {
- addCurrentTokenJarWhenNecessary(currentJarToken);
- state = START;
- } else if (currentChar == ' ') {
- state = SKIPPING_WHITESPACE;
- } else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) {
- addCurrentTokenJarWhenNecessary(currentJarToken);
- state = IN_CLASSPATH_HEADER;
- substate = 1;
- } else if (this.calledFilesNames == null) {
- // >>>>>>>>>>>>>>>>>> Add the latest jar read
- addCurrentTokenJarWhenNecessary(currentJarToken);
- state = START;
- } else {
- // >>>>>>>>>>>>>>>>>> Add the latest jar read
- addCurrentTokenJarWhenNecessary(currentJarToken);
- state = SKIP_LINE;
- }
- break;
- case SKIP_LINE:
- if (currentChar == -1) {
- if (this.classpathSectionsCount != 0) {
- if (this.calledFilesNames == null) {
- return false;
+ if (currentChar == '\r') // skip \r, will consider \n later (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079 )
+ currentChar = reader.read();
+ switch (state) {
+ case START:
+ if (currentChar == -1) {
+ return true;
+ } else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) {
+ state = IN_CLASSPATH_HEADER;
+ substate = 1;
+ } else {
+ state = SKIP_LINE;
+ }
+ break;
+ case IN_CLASSPATH_HEADER:
+ if (currentChar == -1) {
+ return true;
+ } else if (currentChar == '\n') {
+ state = START;
+ } else if (currentChar != CLASSPATH_HEADER_TOKEN[substate++]) {
+ state = SKIP_LINE;
+ } else if (substate == CLASSPATH_HEADER_TOKEN.length) {
+ state = PAST_CLASSPATH_HEADER;
+ }
+ break;
+ case PAST_CLASSPATH_HEADER:
+ if (currentChar == ' ') {
+ state = SKIPPING_WHITESPACE;
+ this.classpathSectionsCount++;
+ } else {
+ return false;
+ }
+ break;
+ case SKIPPING_WHITESPACE:
+ if (currentChar == -1) {
+ // >>>>>>>>>>>>>>>>>> Add the latest jar read
+ addCurrentTokenJarWhenNecessary(currentJarToken);
+ return true;
+ } else if (currentChar == '\n') {
+ state = CONTINUING;
+ } else if (currentChar != ' ') {
+ currentJarToken.append((char) currentChar);
+ state = READING_JAR;
+ } else {
+ // >>>>>>>>>>>>>>>>>> Add the latest jar read
+ addCurrentTokenJarWhenNecessary(currentJarToken);
+ }
+ break;
+ case CONTINUING:
+ if (currentChar == -1) {
+ // >>>>>>>>>>>>>>>>>> Add the latest jar read
+ addCurrentTokenJarWhenNecessary(currentJarToken);
+ return true;
+ } else if (currentChar == '\n') {
+ addCurrentTokenJarWhenNecessary(currentJarToken);
+ state = START;
+ } else if (currentChar == ' ') {
+ state = SKIPPING_WHITESPACE;
+ } else if (currentChar == CLASSPATH_HEADER_TOKEN[0]) {
+ addCurrentTokenJarWhenNecessary(currentJarToken);
+ state = IN_CLASSPATH_HEADER;
+ substate = 1;
+ } else if (this.calledFilesNames == null) {
+ // >>>>>>>>>>>>>>>>>> Add the latest jar read
+ addCurrentTokenJarWhenNecessary(currentJarToken);
+ state = START;
+ } else {
+ // >>>>>>>>>>>>>>>>>> Add the latest jar read
+ addCurrentTokenJarWhenNecessary(currentJarToken);
+ state = SKIP_LINE;
+ }
+ break;
+ case SKIP_LINE:
+ if (currentChar == -1) {
+ if (this.classpathSectionsCount != 0) {
+ if (this.calledFilesNames == null) {
+ return false;
+ }
}
+ return true;
+ } else if (currentChar == '\n') {
+ state = START;
+ }
+ break;
+ case READING_JAR:
+ if (currentChar == -1) {
+ // >>>>>>>>>>>>>>>>>> Add the latest jar read
+ return false;
+ } else if (currentChar == '\n') {
+ // appends token below
+ state = CONTINUING;
+ // >>>>>>>>>>> Add a break to not add the jar yet as it can continue on the next line
+ break;
+ } else if (currentChar == ' ') {
+ // appends token below
+ state = SKIPPING_WHITESPACE;
+ } else {
+ currentJarToken.append((char) currentChar);
+ break;
}
- return true;
- } else if (currentChar == '\n') {
- state = START;
- }
- break;
- case READING_JAR:
- if (currentChar == -1) {
- // >>>>>>>>>>>>>>>>>> Add the latest jar read
- return false;
- } else if (currentChar == '\n') {
- // appends token below
- state = CONTINUING;
- // >>>>>>>>>>> Add a break to not add the jar yet as it can continue on the next line
- break;
- } else if (currentChar == ' ') {
- // appends token below
- state = SKIPPING_WHITESPACE;
- } else {
- currentJarToken.append((char) currentChar);
- break;
- }
- addCurrentTokenJarWhenNecessary(currentJarToken);
- break;
+ addCurrentTokenJarWhenNecessary(currentJarToken);
+ break;
+ }
}
+ } finally {
+ reader.close();
}
}
#P org.eclipse.jdt.core.tests.compiler
Index: src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java,v
retrieving revision 1.1
diff -u -r1.1 ManifestAnalyzerTest.java
--- src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java 4 Mar 2009 16:13:47 -0000 1.1
+++ src/org/eclipse/jdt/core/tests/compiler/regression/ManifestAnalyzerTest.java 17 Apr 2009 20:05:51 -0000
@@ -10,8 +10,9 @@
* IBM Corporation - code review and integration
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;
+import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.io.StringReader;
+import java.io.InputStream;
import java.util.List;
import org.eclipse.jdt.internal.compiler.util.ManifestAnalyzer;
@@ -29,17 +30,23 @@
}
public void testWithOneJar() throws IOException {
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";
- StringReader reader = new StringReader(testWithOneJar);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithOneJar);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 1, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
}
+ private void analyzeManifestContents(String contents) throws IOException {
+ InputStream stream = new ByteArrayInputStream(contents.getBytes());
+ try {
+ this.manifestAnalyzer.analyzeManifestContents(stream);
+ } catch(IOException e) {
+ stream.close();
+ }
+ }
public void testWithOneJarWithWiteSpace() throws IOException {
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";
- StringReader reader = new StringReader(testWithOneJarWithWiteSpace);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithOneJarWithWiteSpace);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 1, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -47,8 +54,7 @@
public void testWithSecondJarOnNextLine() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnNextLine);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnNextLine);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 2, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -57,8 +63,7 @@
public void testWithSecondJarOnTwoLine() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnTwoLine);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnTwoLine);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 2, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -67,8 +72,7 @@
public void testWithSecondJarOnTwoLine2() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnTwoLine);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnTwoLine);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 3, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -78,8 +82,7 @@
public void testWithSecondJarOnTwoLine3() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnTwoLine);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnTwoLine);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 2, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -88,8 +91,7 @@
public void testWithSecondJarOnTwoLine4() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnTwoLine);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnTwoLine);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 1, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -97,8 +99,7 @@
public void testWithSecondJarOnNextLine5() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnNextLine);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnNextLine);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 1, jars.size());
assertEquals(FIRST_JAR + SECOND_JAR, jars.get(0));
@@ -106,8 +107,7 @@
public void testWithSecondJarOnTwoLineEndedWithEOF() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithEOF);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithEOF);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 1, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -115,8 +115,7 @@
public void testWithSecondJarOnTwoLineEndedWithEOF2() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithEOF);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithEOF);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 2, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -125,8 +124,7 @@
public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF() throws IOException {
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 ";
- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithWhiteSpaceEOF);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 2, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -135,8 +133,7 @@
public void testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithWhiteSpaceNewLineEOF);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 2, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
@@ -145,11 +142,19 @@
public void testWithSecondJarOnTwoLineEndedWithNewLineEOF() throws IOException {
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";
- StringReader reader = new StringReader(testWithSecondJarOnTwoLineEndedWithNewLineEOF);
- this.manifestAnalyzer.analyzeManifestContents(reader);
+ analyzeManifestContents(testWithSecondJarOnTwoLineEndedWithNewLineEOF);
List jars = this.manifestAnalyzer.getCalledFileNames();
assertEquals("Wrong size", 2, jars.size());
assertEquals(FIRST_JAR, jars.get(0));
assertEquals(SECOND_JAR, jars.get(1));
}
+
+ public void testWithOneJarUsingUTF8Name() throws IOException {
+ InputStream inputStream = ManifestAnalyzerTest.class.getResourceAsStream("MANIFEST.MF");
+ this.manifestAnalyzer.analyzeManifestContents(inputStream);
+ inputStream.close();
+ List jars = this.manifestAnalyzer.getCalledFileNames();
+ assertEquals("Wrong size", 1, jars.size());
+ assertEquals("called\u3042.jar", jars.get(0));
+ }
}
Index: src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java
===================================================================
RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java,v
retrieving revision 1.185
diff -u -r1.185 BatchCompilerTest.java
--- src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 10 Dec 2008 17:42:07 -0000 1.185
+++ src/org/eclipse/jdt/core/tests/compiler/regression/BatchCompilerTest.java 17 Apr 2009 20:05:51 -0000
@@ -12,10 +12,12 @@
package org.eclipse.jdt.core.tests.compiler.regression;
import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringReader;
import java.text.MessageFormat;
@@ -10518,13 +10520,13 @@
public void test268_jar_ref_in_jar(){
try {
ManifestAnalyzer analyzer = new ManifestAnalyzer();
- assertTrue(analyzer.analyzeManifestContents(
- new StringReader(
- "Manifest-Version: 1.0\n" +
- "Created-By: Eclipse JDT Test Harness\n" +
- "Class-Path: lib1.jar\n" +
- "\n" +
- "Class-Path: lib3.jar\n")));
+ assertTrue(analyzeManifestContents(
+ analyzer,
+ "Manifest-Version: 1.0\n" +
+ "Created-By: Eclipse JDT Test Harness\n" +
+ "Class-Path: lib1.jar\n" +
+ "\n" +
+ "Class-Path: lib3.jar\n"));
assertEquals(2, analyzer.getClasspathSectionsCount());
assertEquals(2, analyzer.getCalledFileNames().size());
} catch (IOException e) {
@@ -10539,13 +10541,13 @@
public void test269_jar_ref_in_jar(){
try {
ManifestAnalyzer analyzer = new ManifestAnalyzer();
- assertTrue(analyzer.analyzeManifestContents(
- new StringReader(
- "Manifest-Version: 1.0\n" +
- "Created-By: Eclipse JDT Test Harness\n" +
- "Class-Path: lib1.jar\n" +
- "Dummy:\n" +
- "Class-Path: lib3.jar\n")));
+ assertTrue(analyzeManifestContents(
+ analyzer,
+ "Manifest-Version: 1.0\n" +
+ "Created-By: Eclipse JDT Test Harness\n" +
+ "Class-Path: lib1.jar\n" +
+ "Dummy:\n" +
+ "Class-Path: lib3.jar\n"));
assertEquals(2, analyzer.getClasspathSectionsCount());
assertEquals(2, analyzer.getCalledFileNames().size());
} catch (IOException e) {
@@ -10559,11 +10561,11 @@
public void test270_jar_ref_in_jar(){
try {
ManifestAnalyzer analyzer = new ManifestAnalyzer();
- assertTrue(analyzer.analyzeManifestContents(
- new StringReader(
- "Manifest-Version: 1.0\n" +
- "Created-By: Eclipse JDT Test Harness\n" +
- "Class-Path: lib1.jar\tlib2.jar\n")));
+ assertTrue(analyzeManifestContents(
+ analyzer,
+ "Manifest-Version: 1.0\n" +
+ "Created-By: Eclipse JDT Test Harness\n" +
+ "Class-Path: lib1.jar\tlib2.jar\n"));
assertEquals(1, analyzer.getClasspathSectionsCount());
assertEquals(1, analyzer.getCalledFileNames().size());
} catch (IOException e) {
@@ -10600,13 +10602,13 @@
public void test272_jar_ref_in_jar(){
try {
ManifestAnalyzer analyzer = new ManifestAnalyzer();
- assertTrue(analyzer.analyzeManifestContents(
- new StringReader(
- "Manifest-Version: 1.0\n" +
- "Created-By: Eclipse JDT Test Harness\n" +
- "Class-Path: \n" +
- " lib1.jar \n" +
- "\n")));
+ assertTrue(analyzeManifestContents(
+ analyzer,
+ "Manifest-Version: 1.0\n" +
+ "Created-By: Eclipse JDT Test Harness\n" +
+ "Class-Path: \n" +
+ " lib1.jar \n" +
+ "\n"));
assertEquals(1, analyzer.getClasspathSectionsCount());
assertEquals(1, analyzer.getCalledFileNames().size());
} catch (IOException e) {
@@ -10619,16 +10621,16 @@
public void test273_jar_ref_in_jar(){
try {
ManifestAnalyzer analyzer = new ManifestAnalyzer();
- assertTrue(analyzer.analyzeManifestContents(
- new StringReader(
- "Manifest-Version: 1.0\n" +
- "Created-By: Eclipse JDT Test Harness\n" +
- "Class-Path: \n" +
- " \n" +
- " lib1.jar \n" +
- " \n" +
- " lib1.jar \n" +
- "\n")));
+ assertTrue(analyzeManifestContents(
+ analyzer,
+ "Manifest-Version: 1.0\n" +
+ "Created-By: Eclipse JDT Test Harness\n" +
+ "Class-Path: \n" +
+ " \n" +
+ " lib1.jar \n" +
+ " \n" +
+ " lib1.jar \n" +
+ "\n"));
assertEquals(1, analyzer.getClasspathSectionsCount());
assertEquals(2, analyzer.getCalledFileNames().size());
} catch (IOException e) {
@@ -10641,12 +10643,12 @@
public void test274_jar_ref_in_jar(){
try {
ManifestAnalyzer analyzer = new ManifestAnalyzer();
- assertFalse(analyzer.analyzeManifestContents(
- new StringReader(
- "Manifest-Version: 1.0\n" +
- "Created-By: Eclipse JDT Test Harness\n" +
- "Class-Path: \n" +
- " lib1.jar")));
+ assertFalse(analyzeManifestContents(
+ analyzer,
+ "Manifest-Version: 1.0\n" +
+ "Created-By: Eclipse JDT Test Harness\n" +
+ "Class-Path: \n" +
+ " lib1.jar"));
} catch (IOException e) {
e.printStackTrace();
fail();
@@ -10656,28 +10658,37 @@
// white-box test: variants on continuations
public void test275_jar_ref_in_jar(){
try {
- assertFalse(new ManifestAnalyzer().analyzeManifestContents(
- new StringReader(
- "Manifest-Version: 1.0\n" +
- "Created-By: Eclipse JDT Test Harness\n" +
- "Class-Path: \n" +
- " \n" +
- " lib1.jar")));
+ assertFalse(analyzeManifestContents(
+ new ManifestAnalyzer(),
+ "Manifest-Version: 1.0\n" +
+ "Created-By: Eclipse JDT Test Harness\n" +
+ "Class-Path: \n" +
+ " \n" +
+ " lib1.jar"));
} catch (IOException e) {
e.printStackTrace();
fail();
}
}
+private boolean analyzeManifestContents(ManifestAnalyzer manifestAnalyzer,
+ String string) throws IOException {
+ InputStream stream = new ByteArrayInputStream(string.getBytes());
+ try {
+ return manifestAnalyzer.analyzeManifestContents(stream);
+ } finally {
+ stream.close();
+ }
+}
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=97332 - jars pointed by jars
// white-box test: variants on continuations
public void test276_jar_ref_in_jar(){
try {
- assertFalse(new ManifestAnalyzer().analyzeManifestContents(
- new StringReader(
- "Manifest-Version: 1.0\n" +
- "Created-By: Eclipse JDT Test Harness\n" +
- "Class-Path: \n" +
- "lib1.jar")));
+ assertFalse(analyzeManifestContents(
+ new ManifestAnalyzer(),
+ "Manifest-Version: 1.0\n" +
+ "Created-By: Eclipse JDT Test Harness\n" +
+ "Class-Path: \n" +
+ "lib1.jar"));
} catch (IOException e) {
e.printStackTrace();
fail();
@@ -11031,13 +11042,13 @@
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=251079
public void test291_jar_ref_in_jar() throws Exception {
ManifestAnalyzer analyzer = new ManifestAnalyzer();
- assertTrue(analyzer.analyzeManifestContents(
- new StringReader(
- "Manifest-Version: 1.0\r\n" +
- "Created-By: Eclipse JDT Test Harness\r\n" +
- "Class-Path: \r\n" +
- "\r\n"
- )));
+ assertTrue(analyzeManifestContents(
+ analyzer,
+ "Manifest-Version: 1.0\r\n" +
+ "Created-By: Eclipse JDT Test Harness\r\n" +
+ "Class-Path: \r\n" +
+ "\r\n"
+ ));
List calledFileNames = analyzer.getCalledFileNames();
String actual = calledFileNames == null ? "