Skip to content

Commit 9863695

Browse files
tivervaclaeubi
authored andcommitted
Add testcase to correctly update location attributes in Target Editor
1 parent ff15efc commit 9863695

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

ui/org.eclipse.pde.ui.tests/src/org/eclipse/pde/ui/tests/target/IUBundleContainerTests.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import static org.junit.Assert.assertEquals;
1717
import static org.junit.Assert.assertFalse;
18+
import static org.junit.Assert.assertNotEquals;
1819
import static org.junit.Assert.assertNotNull;
1920
import static org.junit.Assert.assertTrue;
2021

@@ -633,6 +634,44 @@ public void testSerialization3() throws Exception {
633634
deserializationTest(location);
634635
}
635636

637+
@Test
638+
public void testSerializationOnlyLocationAttributeChanged() throws Exception {
639+
URI uri = getURI("/tests/sites/site.a.b");
640+
String[] unitIds = new String[] { "feature.b.feature.group" };
641+
IInstallableUnit[] units = getUnits(unitIds, uri);
642+
643+
IUBundleContainer location1 = createContainer(units, new URI[] { uri },
644+
IUBundleContainer.INCLUDE_ALL_ENVIRONMENTS | IUBundleContainer.INCLUDE_SOURCE);
645+
String xml1 = location1.serialize();
646+
assertIncludeAllPlatform(xml1, true);
647+
assertIncludeMode(xml1, "slicer");
648+
assertIncludeSource(xml1, true);
649+
650+
IUBundleContainer location2 = createContainer(units, new URI[] { uri },
651+
IUBundleContainer.INCLUDE_ALL_ENVIRONMENTS); // no source
652+
String xml2 = location2.serialize();
653+
assertIncludeAllPlatform(xml2, true);
654+
assertIncludeMode(xml2, "slicer");
655+
assertIncludeSource(xml2, false); // no source
656+
657+
ITargetDefinition td = getTargetService().newTarget();
658+
td.setTargetLocations(new ITargetLocation[] { location1 });
659+
ByteArrayOutputStream out1 = new ByteArrayOutputStream();
660+
TargetDefinitionPersistenceHelper.persistXML(td, out1);
661+
String resultXmlOld = new String(out1.toByteArray());
662+
663+
td.setTargetLocations(new ITargetLocation[] { location2 });
664+
ByteArrayOutputStream out2 = new ByteArrayOutputStream();
665+
TargetDefinitionPersistenceHelper.persistXML(td, out2);
666+
String resultXmlNew = new String(out2.toByteArray());
667+
668+
String normalizedOld = resultXmlOld.replaceAll("\r?\n[ \t]*", "");
669+
String normalizedNew = resultXmlNew.replaceAll("\r?\n[ \t]*", "");
670+
671+
assertNotEquals(normalizedOld, normalizedNew);
672+
assertEquals(normalizedOld, normalizedNew.replace("includeSource=\"false\"", "includeSource=\"true\""));
673+
}
674+
636675
@Test
637676
public void testSerializationVersionRange() throws Exception {
638677
URI uri = getURI("/tests/sites/site.a.b");

0 commit comments

Comments
 (0)