use of aQute.bnd.version.Version in project bnd by bndtools.
the class RemoteTest method testUpdate.
public void testUpdate() throws Exception {
LauncherSupervisor supervisor = new LauncherSupervisor();
supervisor.connect("localhost", Agent.DEFAULT_PORT);
File t1 = create("bsn-1", new Version(1, 0, 0));
File t2 = create("bsn-2", new Version(1, 0, 0));
assertTrue(t1.isFile());
assertTrue(t2.isFile());
String sha1 = supervisor.addFile(t1);
String sha2 = supervisor.addFile(t2);
Map<String, String> update = new HashMap<String, String>();
update.put(t1.getAbsolutePath(), sha1);
String errors = supervisor.getAgent().update(update);
assertNull(errors);
//
// Verify that t1 is installed and t2 not
//
Bundle b1 = context.getBundle(t1.getAbsolutePath());
assertNotNull(b1);
Bundle b2 = context.getBundle(t2.getAbsolutePath());
assertNull(b2);
//
// Now add a new one
//
update = new HashMap<String, String>();
update.put(t1.getAbsolutePath(), sha1);
update.put(t2.getAbsolutePath(), sha2);
errors = supervisor.getAgent().update(update);
assertNull(errors);
assertNotNull(context.getBundle(t1.getAbsolutePath()));
assertNotNull(context.getBundle(t2.getAbsolutePath()));
//
// Now change a bundle
//
t1 = create("bsn-1", new Version(2, 0, 0));
sha1 = supervisor.addFile(t1);
update = new HashMap<String, String>();
update.put(t1.getAbsolutePath(), sha1);
update.put(t2.getAbsolutePath(), sha2);
errors = supervisor.getAgent().update(update);
assertNull(errors);
b1 = context.getBundle(t1.getAbsolutePath());
assertNotNull(b1);
b2 = context.getBundle(t2.getAbsolutePath());
assertNotNull(b2);
assertEquals(new Version(2, 0, 0).toString(), b1.getVersion().toString());
assertEquals(Bundle.ACTIVE, b1.getState());
assertEquals(Bundle.ACTIVE, b2.getState());
//
// Now delete t1
//
update = new HashMap<String, String>();
update.put(t2.getAbsolutePath(), sha2);
errors = supervisor.getAgent().update(update);
assertNull(errors);
assertNull(context.getBundle(t1.getAbsolutePath()));
assertNotNull(context.getBundle(t2.getAbsolutePath()));
//
// Delete all
//
supervisor.getAgent().update(null);
assertNull(context.getBundle(t1.getAbsolutePath()));
assertNull(context.getBundle(t2.getAbsolutePath()));
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class NexusOBR method putArtifact.
protected URL putArtifact(File tmpFile) throws Exception {
assert (tmpFile != null);
assert (tmpFile.isFile());
init();
Version version;
String bsn;
try (Jar jar = new Jar(tmpFile)) {
bsn = jar.getBsn();
if (bsn == null || !Verifier.isBsn(bsn))
throw new IllegalArgumentException("Jar does not have a " + Constants.BUNDLE_SYMBOLICNAME + " manifest header");
String versionString = jar.getVersion();
if (versionString == null)
versionString = "0";
else if (!Verifier.isVersion(versionString))
throw new IllegalArgumentException("Invalid version " + versionString + " in file " + tmpFile);
version = Version.parseVersion(versionString);
}
URL url = put(tmpFile, bsn, version);
reset();
return url;
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class AgentTest method setUp.
@Override
protected void setUp() throws Exception {
tmp = IO.getFile("generated/tmp");
tmp.mkdirs();
t1 = create("bsn-1", new Version(1, 0, 0));
t2 = create("bsn-2", new Version(2, 0, 0));
t3 = create("bsn-3", new Version(3, 0, 0));
ServiceLoader<FrameworkFactory> sl = ServiceLoader.load(FrameworkFactory.class, this.getClass().getClassLoader());
FrameworkFactory ff = sl.iterator().next();
Map<String, String> configuration = new HashMap<String, String>();
configuration.put(Constants.FRAMEWORK_STORAGE_CLEAN, Constants.FRAMEWORK_STORAGE_CLEAN_ONFIRSTINIT);
configuration.put(Constants.FRAMEWORK_STORAGE, new File(tmp, "fwstorage").getAbsolutePath());
framework = ff.newFramework(configuration);
framework.init();
framework.start();
context = framework.getBundleContext();
String location = "reference:" + t1.toURI().toString();
context.installBundle(location);
location = "reference:" + t2.toURI().toString();
context.installBundle(location);
location = "reference:" + IO.getFile("generated/biz.aQute.remote.agent.jar").toURI().toString();
agent = context.installBundle(location);
agent.start();
supervisor = new TestSupervisor();
supervisor.connect("localhost", Agent.DEFAULT_PORT);
super.setUp();
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class AgentTest method testAgentUpdateBundle.
public void testAgentUpdateBundle() throws Exception {
BundleDTO t2Bundle = supervisor.getAgent().getBundles(2).get(0);
assertEquals("bsn-2", t2Bundle.symbolicName);
assertEquals("2.0.0", t2Bundle.version);
long previousModified = t2Bundle.lastModified;
File t2prime = create("bsn-2", new Version(2, 0, 1));
String sha = supervisor.addFile(t2prime);
assertNull(supervisor.getAgent().update(2, sha));
t2Bundle = supervisor.getAgent().getBundles(2).get(0);
assertTrue(previousModified != t2Bundle.lastModified);
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class AetherRepsitoryTests method testStrategyExactVersion.
public void testStrategyExactVersion() throws Exception {
RepositoryPlugin repo = createRepo();
Map<String, String> attrs = new HashMap<String, String>();
attrs.put("version", "2.5");
attrs.put("strategy", "exact");
File file = repo.get("javax.servlet:servlet-api", new Version(2, 5, 0), attrs, listener);
assertNotNull(file);
assertEquals("servlet-api-2.5.jar", file.getName());
}
Aggregations