|
15 | 15 |
|
16 | 16 | import static org.junit.Assert.assertEquals; |
17 | 17 | import static org.junit.Assert.assertFalse; |
| 18 | +import static org.junit.Assert.assertNotEquals; |
18 | 19 | import static org.junit.Assert.assertNotNull; |
19 | 20 | import static org.junit.Assert.assertTrue; |
20 | 21 |
|
@@ -633,6 +634,44 @@ public void testSerialization3() throws Exception { |
633 | 634 | deserializationTest(location); |
634 | 635 | } |
635 | 636 |
|
| 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 | + |
636 | 675 | @Test |
637 | 676 | public void testSerializationVersionRange() throws Exception { |
638 | 677 | URI uri = getURI("/tests/sites/site.a.b"); |
|
0 commit comments