summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorBeat Strasser2011-05-05 17:14:14 (EDT)
committer jsievers2011-09-23 05:20:41 (EDT)
commit23a65315559c084428e65d27c85af73f53ce8711 (patch)
tree3c10ce2272074177efd9a5c64c449f8bf66c8332
parenteb2e53fdb199a6850d566bfc1e304c1a58ab24b7 (diff)
downloadorg.eclipse.tycho-23a65315559c084428e65d27c85af73f53ce8711.zip
org.eclipse.tycho-23a65315559c084428e65d27c85af73f53ce8711.tar.gz
org.eclipse.tycho-23a65315559c084428e65d27c85af73f53ce8711.tar.bz2
344210 tycho-versions-plugin: preserve line ending style in MANIFEST.MF
-rw-r--r--tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/ManifestAttribute.java58
-rw-r--r--tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java86
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/ManifestAttributeTest.java226
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java88
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/manifests/addheader.mf8
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/manifests/addheader.mf_expected9
-rw-r--r--tycho-release/tycho-versions-plugin/src/test/resources/manifests/setVersion.mf_expected726
7 files changed, 420 insertions, 61 deletions
diff --git a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/ManifestAttribute.java b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/ManifestAttribute.java
index 281a2f4..c216f0e 100644
--- a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/ManifestAttribute.java
+++ b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/ManifestAttribute.java
@@ -19,7 +19,7 @@ public class ManifestAttribute {
private List<String> lines = new ArrayList<String>();
public ManifestAttribute(String str) {
- lines.add(str);
+ lines.add(chopNewLine(str));
}
public ManifestAttribute(String name, String value) {
@@ -27,29 +27,49 @@ public class ManifestAttribute {
}
public void add(String str) {
- lines.add(str);
+ String choppedLine = chopNewLine(str);
+
+ if (!choppedLine.substring(0, 1).startsWith(" ")) {
+ throw new IllegalArgumentException("Additional attribute lines must start with a space.");
+ }
+ if (choppedLine.contains("\n") || choppedLine.contains("\r")) {
+ throw new IllegalArgumentException("Additional attribute line must not consist of multiple lines");
+ }
+
+ lines.add(choppedLine);
}
- public void writeTo(Writer w) throws IOException {
- for (int i = 0; i < lines.size(); i++) {
- if (i > 0) {
- w.write("\r\n ");
+ private String chopNewLine(String str) {
+ if (str.length() > 0) {
+ char lastChar = str.charAt(str.length() - 1);
+ if (lastChar == '\n' || lastChar == '\r' || lastChar == '\u2028' || lastChar == '\u2029'
+ || lastChar == '\u0085') // see Scanner#LINE_SEPARATOR_PATTERN
+ {
+ return str.substring(0, str.length() - (str.endsWith("\r\n") ? 2 : 1));
}
- w.write(lines.get(i));
}
+ return str;
}
- public boolean hasName(String name) {
- if (lines.size() > 0) {
- return lines.get(0).startsWith(name + ": ");
+ /**
+ * Writes the lines to {@code w} using the given line termination chars. There will be a
+ * trailing newline!
+ */
+ public void writeTo(Writer w, String lineTermination) throws IOException {
+ for (String line : lines) {
+ w.write(line);
+ w.write(lineTermination);
}
- return false;
+ }
+
+ public boolean hasName(String name) {
+ return lines.get(0).startsWith(name + ": ");
}
public String getValue() {
- StringBuilder sb = new StringBuilder();
- for (String line : lines) {
- sb.append(line);
+ StringBuilder sb = new StringBuilder(lines.get(0));
+ for (int i = 1; i < lines.size(); i++) {
+ sb.append(lines.get(i).substring(1));
}
int idx = sb.indexOf(": ");
@@ -61,12 +81,14 @@ public class ManifestAttribute {
}
public void set(String name, String value) {
+ String attribute = (name != null ? name.trim() : "") + ": " + (value != null ? value.trim() : "");
+
lines.clear();
- StringBuilder sb = new StringBuilder(name + ": " + value);
- for (int i = 71; i < sb.length(); i += 73) {
- sb.insert(i, "\r\n ");
+ while (attribute.length() > 71) {
+ lines.add(attribute.substring(0, 70));
+ attribute = " " + attribute.substring(70);
}
- lines.add(sb.toString());
+ lines.add(attribute);
}
}
diff --git a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java
index 1c68287..cb25843 100644
--- a/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java
+++ b/tycho-release/tycho-versions-plugin/src/main/java/org/eclipse/tycho/versions/bundle/MutableBundleManifest.java
@@ -21,6 +21,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.io.PushbackReader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
@@ -32,12 +33,13 @@ import org.osgi.framework.Constants;
public class MutableBundleManifest {
- private List<ManifestAttribute> lines = new ArrayList<ManifestAttribute>();
+ private final List<ManifestAttribute> attributes = new ArrayList<ManifestAttribute>();
+ private String lineEnding = "";
private String unparsed;
- public void add(ManifestAttribute line) {
- lines.add(line);
+ public void add(ManifestAttribute attribute) {
+ attributes.add(attribute);
}
public static MutableBundleManifest read(File file) throws IOException {
@@ -50,24 +52,20 @@ public class MutableBundleManifest {
}
public static MutableBundleManifest read(InputStream is) throws IOException {
- BufferedReader br = new BufferedReader(new InputStreamReader(is, "UTF8"));
+ PushbackReader br = new PushbackReader(new BufferedReader(new InputStreamReader(is, "UTF8")), 1);
MutableBundleManifest mf = new MutableBundleManifest();
ManifestAttribute curr = null;
String str;
- while ((str = br.readLine()) != null) {
- if (str.length() == 0) {
- break;
- }
-
- if (str.length() == 0) {
+ while ((str = readLineWithLineEnding(br, mf)) != null) {
+ if (str.trim().length() == 0) {
break;
} else if (str.charAt(0) == ' ') {
if (curr == null) {
throw new IOException("");
}
- curr.add(str.substring(1));
+ curr.add(str);
} else {
curr = new ManifestAttribute(str);
mf.add(curr);
@@ -75,7 +73,7 @@ public class MutableBundleManifest {
}
if (str != null) {
- StringBuilder sb = new StringBuilder("\r\n");
+ StringBuilder sb = new StringBuilder(str);
int ch;
while ((ch = br.read()) != -1) {
sb.append((char) ch);
@@ -86,6 +84,44 @@ public class MutableBundleManifest {
return mf;
}
+ private static String readLineWithLineEnding(PushbackReader reader, MutableBundleManifest mf) throws IOException {
+ StringBuilder result = new StringBuilder();
+ int ch, lastch = -1;
+
+ while ((ch = reader.read()) != -1) {
+ if (lastch == '\r') {
+ if (ch == '\n') {
+ result.append((char) ch);
+ mf.setLineEndingWhenFirstLine("\r\n");
+ } else {
+ reader.unread(ch);
+ mf.setLineEndingWhenFirstLine("\r");
+ }
+ break;
+ }
+
+ result.append((char) ch);
+
+ if (ch == '\n' || ch == '\u2028' || ch == '\u2029' || ch == '\u0085') { // see Scanner#LINE_SEPARATOR_PATTERN
+ mf.setLineEndingWhenFirstLine(new String(new char[] { (char) ch }));
+ break;
+ }
+
+ lastch = ch;
+ }
+
+ if (result.length() > 0) {
+ return result.toString();
+ }
+ return null;
+ }
+
+ private void setLineEndingWhenFirstLine(String lineEnding) {
+ if (this.lineEnding.length() == 0 && lineEnding != null) {
+ this.lineEnding = lineEnding;
+ }
+ }
+
private void setUnparsed(String unparsed) {
this.unparsed = unparsed;
}
@@ -102,13 +138,9 @@ public class MutableBundleManifest {
public static void write(MutableBundleManifest mf, OutputStream os) throws IOException {
Writer w = new OutputStreamWriter(os, "UTF8");
- for (int i = 0; i < mf.lines.size(); i++) {
- if (i > 0) {
- w.write("\r\n");
- }
- mf.lines.get(i).writeTo(w);
+ for (ManifestAttribute attribute : mf.attributes) {
+ attribute.writeTo(w, mf.lineEnding);
}
- w.write("\r\n");
if (mf.unparsed != null) {
w.write(mf.unparsed);
@@ -119,12 +151,18 @@ public class MutableBundleManifest {
public String getSymbolicName() {
ManifestElement[] id = parseHeader(Constants.BUNDLE_SYMBOLICNAME);
- return id[0].getValue();
+ if (id != null && id.length > 0) {
+ return id[0].getValue();
+ }
+ return null;
}
public String getVersion() {
ManifestElement[] version = parseHeader(Constants.BUNDLE_VERSION);
- return version[0].getValue();
+ if (version != null && version.length > 0) {
+ return version[0].getValue();
+ }
+ return null;
}
private ManifestElement[] parseHeader(String name) {
@@ -140,9 +178,9 @@ public class MutableBundleManifest {
}
private ManifestAttribute getAttribute(String name) {
- for (ManifestAttribute line : lines) {
- if (line.hasName(name)) {
- return line;
+ for (ManifestAttribute attribute : attributes) {
+ if (attribute.hasName(name)) {
+ return attribute;
}
}
return null;
@@ -153,7 +191,7 @@ public class MutableBundleManifest {
if (attr != null) {
attr.set(Constants.BUNDLE_VERSION, version);
} else {
- lines.add(new ManifestAttribute(Constants.BUNDLE_VERSION, version));
+ attributes.add(new ManifestAttribute(Constants.BUNDLE_VERSION, version));
}
}
diff --git a/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/ManifestAttributeTest.java b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/ManifestAttributeTest.java
new file mode 100644
index 0000000..ea6b093
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/ManifestAttributeTest.java
@@ -0,0 +1,226 @@
+/*******************************************************************************
+ * Copyright (c) 2008, 2011 Sonatype Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *******************************************************************************/
+package org.eclipse.tycho.versions.bundle.tests;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertFalse;
+import static junit.framework.Assert.assertTrue;
+
+import java.io.StringWriter;
+
+import org.eclipse.tycho.versions.bundle.ManifestAttribute;
+import org.junit.Test;
+
+public class ManifestAttributeTest {
+
+ @Test
+ public void shouldCreateWithParameters() {
+ // given
+ String key = "headername";
+ String value = "headervalue";
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(key, value);
+
+ // then
+ assertEquals(value, attribute.getValue());
+ assertTrue(attribute.hasName(key));
+ assertFalse(attribute.hasName("headernames"));
+ assertFalse(attribute.hasName("header"));
+ }
+
+ @Test
+ public void shouldCreateWithUnixLine() {
+ // given
+ String key = "headername";
+ String value = "headervalue";
+ String line = key + ": " + value + "\n";
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(line);
+
+ // then
+ assertEquals(value, attribute.getValue());
+ assertTrue(attribute.hasName(key));
+ }
+
+ @Test
+ public void shouldCreateWithOldMacLine() {
+ // given
+ String key = "headername";
+ String value = "headervalue";
+ String line = key + ": " + value + "\r";
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(line);
+
+ // then
+ assertEquals(value, attribute.getValue());
+ assertTrue(attribute.hasName(key));
+ }
+
+ @Test
+ public void shouldCreateWithWindowsLine() {
+ // given
+ String key = "headername";
+ String value = "headervalue";
+ String line = key + ": " + value + "\r\n";
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(line);
+
+ // then
+ assertEquals(value, attribute.getValue());
+ assertTrue(attribute.hasName(key));
+ }
+
+ @Test
+ public void shouldCreateWithChoppedLine() {
+ // given
+ String key = "headername";
+ String value = "headervalue";
+ String line = key + ": " + value;
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(line);
+
+ // then
+ assertEquals(value, attribute.getValue());
+ assertTrue(attribute.hasName(key));
+ }
+
+ @Test
+ public void shouldAddLine() {
+ // given
+ String line1 = "headername: headervalue1\n";
+ String line2 = " headervalue2\n";
+ String line3 = " headervalue3";
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(line1);
+ attribute.add(line2);
+ attribute.add(line3);
+
+ // then
+ assertEquals("headervalue1headervalue2headervalue3", attribute.getValue());
+ assertTrue(attribute.hasName("headername"));
+ assertFalse(attribute.hasName("headernames"));
+ assertFalse(attribute.hasName("header"));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void shouldFailOnAddLineWithNewLines() {
+ // given
+ String line1 = "headername: headervalue1";
+ String line2 = " header\n value2\n";
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(line1);
+ attribute.add(line2);
+ }
+
+ @Test
+ public void shouldWriteToWithUnixNewLine() throws Exception {
+ // given
+ StringWriter writer = new StringWriter();
+ String name = "headername";
+ String value = "headervalue";
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(name, value);
+ attribute.writeTo(writer, "\n");
+
+ // then
+ assertEquals(name + ": " + value + "\n", writer.toString());
+ }
+
+ @Test
+ public void shouldWriteToWithWindowsNewLine() throws Exception {
+ // given
+ StringWriter writer = new StringWriter();
+ String name = "headername";
+ String value = "headervalue";
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(name, value);
+ attribute.writeTo(writer, "\r\n");
+
+ // then
+ assertEquals(name + ": " + value + "\r\n", writer.toString());
+ }
+
+ @Test
+ public void shouldGetValue() throws Exception {
+ // given
+ String name = "headername";
+ String value = "headervalue";
+ String valuelong = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
+
+ // when
+ ManifestAttribute attribute0 = new ManifestAttribute(name, value);
+ ManifestAttribute attribute1 = new ManifestAttribute(name, valuelong);
+ ManifestAttribute attribute2 = new ManifestAttribute(name + ": " + valuelong);
+ ManifestAttribute attribute3 = new ManifestAttribute(name + ": abcdefghijklmnopq");
+ attribute3.add(" rstuvwxyzABCDEFGHIJKLMN");
+ attribute3.add(" OPQRSTUVWXYZ0123456789");
+ attribute3.add(" abcdefghijklmnop");
+ attribute3.add(" qrstuvwxyzABCDE");
+ attribute3.add(" FGHIJKLMNOPQRSTUVWXYZ0123");
+ attribute3.add(" 456789");
+
+ // then
+ assertEquals(value, attribute0.getValue());
+ assertEquals(valuelong, attribute1.getValue());
+ assertEquals(valuelong, attribute2.getValue());
+ assertEquals(valuelong, attribute3.getValue());
+ }
+
+ @Test
+ public void shouldNotWrapOriginalLines() throws Exception {
+ // given
+ StringWriter writer = new StringWriter();
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute("headername: abcdefghijklmnopq");
+ attribute
+ .add(" rstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
+ attribute.add(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
+ attribute.add(" abcdefghijklmnop");
+ attribute.add(" qrstuvwxyzABCDE");
+ attribute.add(" FGHIJKLMNOPQRSTUVWXYZ0123");
+ attribute.add(" 456789");
+ attribute.writeTo(writer, "\n");
+
+ // then
+ assertEquals(
+ "headername: abcdefghijklmnopq\n"
+ + " rstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n"
+ + " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\n" + " abcdefghijklmnop\n"
+ + " qrstuvwxyzABCDE\n" + " FGHIJKLMNOPQRSTUVWXYZ0123\n" + " 456789\n", writer.toString());
+ }
+
+ @Test
+ public void shouldWrapNewValue() throws Exception {
+ // given
+ StringWriter writer = new StringWriter();
+ String headername = "headername";
+ String longValue = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abc";
+
+ // when
+ ManifestAttribute attribute = new ManifestAttribute(headername, longValue);
+ attribute.writeTo(writer, "\n");
+
+ // then
+ assertEquals(longValue, attribute.getValue());
+ assertEquals(headername + ": " + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345\n"
+ + " 6789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abc\n", writer.toString());
+ }
+
+}
diff --git a/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java
index c54d50a..dd27ee2 100644
--- a/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java
+++ b/tycho-release/tycho-versions-plugin/src/test/java/org/eclipse/tycho/versions/bundle/tests/MutableBundleManifestTest.java
@@ -10,15 +10,14 @@
*******************************************************************************/
package org.eclipse.tycho.versions.bundle.tests;
-import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import org.codehaus.plexus.util.IOUtil;
+import org.eclipse.tycho.versions.bundle.ManifestAttribute;
import org.eclipse.tycho.versions.bundle.MutableBundleManifest;
import org.eclipse.tycho.versions.pom.tests.MutablePomFileTest;
import org.junit.Assert;
@@ -51,6 +50,76 @@ public class MutableBundleManifestTest {
assertContents(mf, "/manifests/setVersion.mf_expected72");
}
+ @Test
+ public void addAttribute() throws Exception {
+ MutableBundleManifest mf = getManifest("/manifests/addheader.mf");
+ mf.add(new ManifestAttribute("header", "value"));
+ assertContents(mf, "/manifests/addheader.mf_expected");
+ }
+
+ @Test
+ public void shouldRoundtripWithoutLineEnding() throws Exception {
+ // given
+ String manifestStr = "Bundle-SymbolicName: name";
+
+ // when
+ InputStream manifestIs = new ByteArrayInputStream(manifestStr.getBytes("ascii"));
+ MutableBundleManifest manifest = MutableBundleManifest.read(manifestIs);
+ String written = toAsciiString(manifest);
+
+ // then
+ Assert.assertEquals(manifestStr, written);
+ Assert.assertEquals("name", manifest.getSymbolicName());
+ }
+
+ @Test
+ public void shouldPreserveWindowsLineEndings() throws Exception {
+ // given
+ String manifestStr = "Bundle-SymbolicName: name\r\nBundle-Version: version\r\n\r\nUnparsed1\r\nUnparsed2\r\n";
+
+ // when
+ InputStream manifestIs = new ByteArrayInputStream(manifestStr.getBytes("ascii"));
+ MutableBundleManifest manifest = MutableBundleManifest.read(manifestIs);
+ String written = toAsciiString(manifest);
+
+ // then
+ Assert.assertEquals(manifestStr, written);
+ Assert.assertEquals("name", manifest.getSymbolicName());
+ Assert.assertEquals("version", manifest.getVersion());
+ }
+
+ @Test
+ public void shouldPreserveUnixLineEndings() throws Exception {
+ // given
+ String manifestStr = "Bundle-SymbolicName: name\nBundle-Version: version\n\nUnparsed1\nUnparsed2\n";
+
+ // when
+ InputStream manifestIs = new ByteArrayInputStream(manifestStr.getBytes("ascii"));
+ MutableBundleManifest manifest = MutableBundleManifest.read(manifestIs);
+ String written = toAsciiString(manifest);
+
+ // then
+ Assert.assertEquals(manifestStr, written);
+ Assert.assertEquals("name", manifest.getSymbolicName());
+ Assert.assertEquals("version", manifest.getVersion());
+ }
+
+ @Test
+ public void shouldPreserveOldMacLineEndings() throws Exception {
+ // given
+ String manifestStr = "Bundle-SymbolicName: name\rBundle-Version: version\r\rUnparsed1\rUnparsed2\r";
+
+ // when
+ InputStream manifestIs = new ByteArrayInputStream(manifestStr.getBytes("ascii"));
+ MutableBundleManifest manifest = MutableBundleManifest.read(manifestIs);
+ String written = toAsciiString(manifest);
+
+ // then
+ Assert.assertEquals(manifestStr, written);
+ Assert.assertEquals("name", manifest.getSymbolicName());
+ Assert.assertEquals("version", manifest.getVersion());
+ }
+
private void assertRoundtrip(String path) throws IOException {
MutableBundleManifest mf = getManifest(path);
@@ -85,20 +154,7 @@ public class MutableBundleManifestTest {
}
private static String toAsciiString(byte[] bytes) throws UnsupportedEncodingException {
- BufferedReader r = new BufferedReader(new InputStreamReader(new ByteArrayInputStream(bytes), "ascii"));
- try {
- StringBuilder sb = new StringBuilder();
- String str;
- while ((str = r.readLine()) != null) {
- sb.append(str).append('\n');
- }
-
- return sb.toString();
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- IOUtil.close(r);
- }
+ return new String(bytes, "ascii");
}
}
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/manifests/addheader.mf b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/addheader.mf
new file mode 100644
index 0000000..79cd546
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/addheader.mf
@@ -0,0 +1,8 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundle01
+Bundle-SymbolicName: TYCHO0214versionChange.bundle01
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+
+unparsed stuff
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/manifests/addheader.mf_expected b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/addheader.mf_expected
new file mode 100644
index 0000000..8033be9
--- /dev/null
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/addheader.mf_expected
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundle01
+Bundle-SymbolicName: TYCHO0214versionChange.bundle01
+Bundle-Version: 1.0.0.qualifier
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+header: value
+
+unparsed stuff
diff --git a/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setVersion.mf_expected72 b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setVersion.mf_expected72
index 5031512..9f7ff4c 100644
--- a/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setVersion.mf_expected72
+++ b/tycho-release/tycho-versions-plugin/src/test/resources/manifests/setVersion.mf_expected72
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Bundle01
Bundle-SymbolicName: TYCHO0214
versionChange.bundle01
-Bundle-Version: 1.0.1.qualifierrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
- rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
- rrrrrrrrrrrrrrrrrrr
+Bundle-Version: 1.0.1.qualifierrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
+ rrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
+ rrrrrrrrrrrrrrrrrrrrr
Bundle-RequiredExecutionEnvironment: J2SE-1.5