use of org.jboss.fuse.patch.management.BundleUpdate in project fuse-karaf by jboss-fuse.
the class ProtectedTest method updateBinInstanceReferences.
@Test
public void updateBinInstanceReferences() throws IOException {
File binInstance = new File(git.getRepository().getWorkTree(), "bin/instance");
FileUtils.copyFile(new File("src/test/resources/files/bin/instance"), binInstance);
List<BundleUpdate> bundleUpdates = new LinkedList<>();
bundleUpdates.add(BundleUpdate.from("mvn:org.apache.karaf.instance/org.apache.karaf.instance.core/4.2.0.redhat-700001").to("mvn:org.apache.karaf.instance/org.apache.karaf.instance.core/4.2.0.redhat-700002"));
bundleUpdates.add(BundleUpdate.from("mvn:org.apache.karaf.shell/org.apache.karaf.shell.core/4.2.0.redhat-700001").to("mvn:org.apache.karaf.shell/org.apache.karaf.shell.core/4.2.0.redhat-700002"));
bundleUpdates.add(BundleUpdate.from("mvn:org.jline/jline/3.5.2").to("mvn:org.jline/jline/3.5.3"));
Map<String, String> updates = Utils.collectLocationUpdates(bundleUpdates);
new GitPatchManagementServiceImpl(context).updateReferences(git, "bin/instance", "system/", updates, false);
String expected = FileUtils.readFileToString(new File("src/test/resources/files/bin/instance.updated"), "UTF-8");
String changed = FileUtils.readFileToString(binInstance, "UTF-8");
assertThat(changed, equalTo(expected));
}
use of org.jboss.fuse.patch.management.BundleUpdate in project fuse-karaf by jboss-fuse.
the class ProtectedTest method updateEtcStartupReferences.
@Test
public void updateEtcStartupReferences() throws IOException {
File etcConfig = new File(git.getRepository().getWorkTree(), "etc/startup.properties");
FileUtils.copyFile(new File("src/test/resources/files/etc/startup.properties"), etcConfig);
List<BundleUpdate> bundleUpdates = new LinkedList<>();
bundleUpdates.add(BundleUpdate.from("mvn:org.fusesource.jansi/jansi/1.16").to("mvn:org.fusesource.jansi/jansi/1.17"));
bundleUpdates.add(BundleUpdate.from("mvn:org.apache.felix/org.apache.felix.configadmin/1.8.16").to("mvn:org.apache.felix/org.apache.felix.configadmin/1.8.17"));
Map<String, String> updates = Utils.collectLocationUpdates(bundleUpdates);
new GitPatchManagementServiceImpl(context).updateReferences(git, "etc/startup.properties", "", updates, false);
String expected = FileUtils.readFileToString(new File("src/test/resources/files/etc/startup.properties.updated"), "UTF-8");
String changed = FileUtils.readFileToString(etcConfig, "UTF-8");
assertThat(changed, equalTo(expected));
}
use of org.jboss.fuse.patch.management.BundleUpdate in project fuse-karaf by jboss-fuse.
the class ProtectedTest method updateEtcConfigReferences.
@Test
public void updateEtcConfigReferences() throws IOException {
File etcConfig = new File(git.getRepository().getWorkTree(), "etc/config.properties");
FileUtils.copyFile(new File("src/test/resources/files/etc/config.properties"), etcConfig);
List<BundleUpdate> bundleUpdates = new LinkedList<>();
bundleUpdates.add(BundleUpdate.from("mvn:org.eclipse.platform/org.eclipse.osgi/3.12.50").to("mvn:org.eclipse.platform/org.eclipse.osgi/3.12.51"));
bundleUpdates.add(BundleUpdate.from("mvn:org.apache.felix/org.apache.felix.framework/5.6.10").to("mvn:org.apache.felix/org.apache.felix.framework/5.6.11"));
Map<String, String> updates = Utils.collectLocationUpdates(bundleUpdates);
new GitPatchManagementServiceImpl(context).updateReferences(git, "etc/config.properties", "", updates, false);
String expected = FileUtils.readFileToString(new File("src/test/resources/files/etc/config.properties.updated"), "UTF-8");
String changed = FileUtils.readFileToString(etcConfig, "UTF-8");
assertThat(changed, equalTo(expected));
}
use of org.jboss.fuse.patch.management.BundleUpdate in project fuse-karaf by jboss-fuse.
the class ProtectedTest method updateBinInstanceBatReferences.
@Test
public void updateBinInstanceBatReferences() throws IOException {
File binInstance = new File(git.getRepository().getWorkTree(), "bin/instance.bat");
FileUtils.copyFile(new File("src/test/resources/files/bin/instance.bat"), binInstance);
List<BundleUpdate> bundleUpdates = new LinkedList<>();
bundleUpdates.add(BundleUpdate.from("mvn:org.apache.karaf.instance/org.apache.karaf.instance.core/4.2.0.redhat-700001").to("mvn:org.apache.karaf.instance/org.apache.karaf.instance.core/4.2.0.redhat-700002"));
bundleUpdates.add(BundleUpdate.from("mvn:org.apache.karaf.shell/org.apache.karaf.shell.core/4.2.0.redhat-700001").to("mvn:org.apache.karaf.shell/org.apache.karaf.shell.core/4.2.0.redhat-700002"));
bundleUpdates.add(BundleUpdate.from("mvn:org.jline/jline/3.5.2").to("mvn:org.jline/jline/3.5.3"));
Map<String, String> updates = Utils.collectLocationUpdates(bundleUpdates);
new GitPatchManagementServiceImpl(context).updateReferences(git, "bin/instance.bat", "system/", updates, true);
String expected = FileUtils.readFileToString(new File("src/test/resources/files/bin/instance.bat.updated"), "UTF-8");
expected = expected.replaceAll("\\r\\n", "\n");
String changed = FileUtils.readFileToString(binInstance, "UTF-8");
changed = changed.replaceAll("\\r\\n", "\n");
assertThat(changed, equalTo(expected));
}
use of org.jboss.fuse.patch.management.BundleUpdate in project fuse-karaf by jboss-fuse.
the class Presentation method displayBundleUpdates.
/**
* Displays a table with installed (<code>install == true</code>) or rolledback bundles
* @param updatesForBundleKeys
* @param install is this displayed during patch install (<code>true</code>) or rollback (<code>false</code>)
*/
public static void displayBundleUpdates(Collection<BundleUpdate> updatesForBundleKeys, boolean install) {
int l1 = "[symbolic name]".length();
int l2 = "[version]".length();
int l3 = install ? "[new location]".length() : "[previous location]".length();
// updates
int tu = 0;
// updates as part of features
int tuf = 0;
// reinstalls
int tk = 0;
// reinstalls as part of features
int tkf = 0;
Map<String, BundleUpdate> map = new TreeMap<>();
for (BundleUpdate be : updatesForBundleKeys) {
String sn = be.getSymbolicName() == null ? "" : stripSymbolicName(be.getSymbolicName());
if (sn.length() > l1) {
l1 = sn.length();
}
if (install) {
String version = be.getPreviousVersion() == null ? "<update>" : be.getPreviousVersion();
if (version.length() > l2) {
l2 = version.length();
}
} else {
String version = be.getNewVersion() == null ? be.getPreviousVersion() : be.getNewVersion();
if (version.length() > l2) {
l2 = version.length();
}
}
if (install) {
String newLocation = be.getNewLocation() == null ? "<reinstall>" : be.getNewLocation();
if (newLocation.length() > l3) {
l3 = newLocation.length();
}
} else {
String previousLocation = be.getPreviousLocation();
if (previousLocation.length() > l3) {
l3 = previousLocation.length();
}
}
if (be.getNewLocation() != null) {
if (be.isIndependent()) {
tu++;
} else {
tuf++;
}
} else {
if (be.isIndependent()) {
tk++;
} else {
tkf++;
}
}
map.put(be.getSymbolicName(), be);
}
if (tu > 0) {
System.out.printf("========== Bundles to %s (%d):%n", install ? "update" : "downgrade", tu);
System.out.printf("%-" + l1 + "s %-" + l2 + "s %-" + l3 + "s%n", "[symbolic name]", "[version]", install ? "[new location]" : "[previous location]");
for (Map.Entry<String, BundleUpdate> e : map.entrySet()) {
BundleUpdate be = e.getValue();
if (be.isIndependent() && be.getNewLocation() != null) {
System.out.printf("%-" + l1 + "s %-" + l2 + "s %-" + l3 + "s%n", be.getSymbolicName() == null ? "" : stripSymbolicName(be.getSymbolicName()), install ? (be.getPreviousVersion() == null ? "<update>" : be.getPreviousVersion()) : be.getNewVersion(), install ? be.getNewLocation() : be.getPreviousLocation());
}
}
}
if (tuf > 0) {
System.out.printf("========== Bundles to %s as part of features or core bundles (%d):%n", install ? "update" : "downgrade", tuf);
System.out.printf("%-" + l1 + "s %-" + l2 + "s %-" + l3 + "s%n", "[symbolic name]", "[version]", install ? "[new location]" : "[previous location]");
for (Map.Entry<String, BundleUpdate> e : map.entrySet()) {
BundleUpdate be = e.getValue();
if (!be.isIndependent() && be.getNewLocation() != null) {
System.out.printf("%-" + l1 + "s %-" + l2 + "s %-" + l3 + "s%n", be.getSymbolicName() == null ? "" : stripSymbolicName(be.getSymbolicName()), install ? be.getPreviousVersion() : be.getNewVersion(), install ? be.getNewLocation() : be.getPreviousLocation());
}
}
}
if (tk > 0) {
System.out.printf("========== Bundles to reinstall (%d):%n", tk);
System.out.printf("%-" + l1 + "s %-" + l2 + "s %-" + l3 + "s%n", "[symbolic name]", "[version]", "[location]");
for (Map.Entry<String, BundleUpdate> e : map.entrySet()) {
BundleUpdate be = e.getValue();
if (be.isIndependent() && be.getNewLocation() == null) {
System.out.printf("%-" + l1 + "s %-" + l2 + "s %-" + l3 + "s%n", be.getSymbolicName() == null ? "" : stripSymbolicName(be.getSymbolicName()), be.getPreviousVersion(), be.getPreviousLocation());
}
}
}
if (tkf > 0) {
System.out.printf("========== Bundles to reinstall as part of features or core bundles (%d):%n", tkf);
System.out.printf("%-" + l1 + "s %-" + l2 + "s %-" + l3 + "s%n", "[symbolic name]", "[version]", "[location]");
for (Map.Entry<String, BundleUpdate> e : map.entrySet()) {
BundleUpdate be = e.getValue();
if (!be.isIndependent() && be.getNewLocation() == null) {
System.out.printf("%-" + l1 + "s %-" + l2 + "s %-" + l3 + "s%n", be.getSymbolicName() == null ? "" : stripSymbolicName(be.getSymbolicName()), be.getPreviousVersion(), be.getPreviousLocation());
}
}
}
System.out.flush();
}
Aggregations