Search in sources :

Example 6 with ManifestAttribute

use of org.eclipse.tycho.versions.bundle.ManifestAttribute in project tycho by eclipse.

the class ManifestAttributeTest method shouldFailOnAddLineWithNewLines.

@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);
}
Also used : ManifestAttribute(org.eclipse.tycho.versions.bundle.ManifestAttribute) Test(org.junit.Test)

Example 7 with ManifestAttribute

use of org.eclipse.tycho.versions.bundle.ManifestAttribute in project tycho by eclipse.

the class ManifestAttributeTest method shouldWriteToWithWindowsNewLine.

@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());
}
Also used : StringWriter(java.io.StringWriter) ManifestAttribute(org.eclipse.tycho.versions.bundle.ManifestAttribute) Test(org.junit.Test)

Example 8 with ManifestAttribute

use of org.eclipse.tycho.versions.bundle.ManifestAttribute in project tycho by eclipse.

the class MutableBundleManifestTest method addAttribute.

@Test
public void addAttribute() throws Exception {
    MutableBundleManifest mf = getManifest("/manifests/addheader.mf");
    mf.add(new ManifestAttribute("header", "value"));
    assertContents(mf, "/manifests/addheader.mf_expected");
}
Also used : MutableBundleManifest(org.eclipse.tycho.versions.bundle.MutableBundleManifest) ManifestAttribute(org.eclipse.tycho.versions.bundle.ManifestAttribute) MutablePomFileTest(org.eclipse.tycho.versions.pom.tests.MutablePomFileTest) Test(org.junit.Test)

Example 9 with ManifestAttribute

use of org.eclipse.tycho.versions.bundle.ManifestAttribute in project tycho by eclipse.

the class ManifestAttributeTest method shouldCreateWithWindowsLine.

@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));
}
Also used : ManifestAttribute(org.eclipse.tycho.versions.bundle.ManifestAttribute) Test(org.junit.Test)

Example 10 with ManifestAttribute

use of org.eclipse.tycho.versions.bundle.ManifestAttribute in project tycho by eclipse.

the class ManifestAttributeTest method shouldGetValue.

@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());
}
Also used : ManifestAttribute(org.eclipse.tycho.versions.bundle.ManifestAttribute) Test(org.junit.Test)

Aggregations

ManifestAttribute (org.eclipse.tycho.versions.bundle.ManifestAttribute)12 Test (org.junit.Test)12 StringWriter (java.io.StringWriter)3 MutableBundleManifest (org.eclipse.tycho.versions.bundle.MutableBundleManifest)1 MutablePomFileTest (org.eclipse.tycho.versions.pom.tests.MutablePomFileTest)1