use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class OSGiRepositoryTest method testPolling.
public void testPolling() throws Exception {
Processor p = new Processor();
testPolling(Workspace.createStandaloneWorkspace(p, ws.toURI()));
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class P2RepositoryTest method testSimple.
public void testSimple() throws Exception {
try (P2Repository p2r = new P2Repository()) {
Workspace w = Workspace.createStandaloneWorkspace(new Processor(), tmp.toURI());
w.setBase(tmp);
p2r.setRegistry(w);
Map<String, String> config = new HashMap<>();
config.put("url", "https://dl.bintray.com/bndtools/bndtools/latest/");
config.put("name", "test");
p2r.setProperties(config);
List<String> list = p2r.list(null);
assertNotNull(list);
assertTrue(list.size() > 1);
}
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class OSGiRepositoryTest method testPolling.
public void testPolling(Workspace workspace) throws Exception {
try (OSGiRepository r = new OSGiRepository()) {
Map<String, String> map = new HashMap<>();
map.put("locations", fnx.getBaseURI("/repo/minir5.xml").toString());
map.put("cache", cache.getPath());
map.put("max.stale", "10000");
map.put("name", "test");
map.put("poll.time", "1");
r.setProperties(map);
Processor p = new Processor();
HttpClient httpClient = new HttpClient();
httpClient.setCache(cache);
httpClient.setRegistry(p);
p.addBasicPlugin(httpClient);
p.setBase(ws);
p.addBasicPlugin(workspace);
r.setRegistry(p);
final AtomicReference<RepositoryPlugin> refreshed = new AtomicReference<>();
p.addBasicPlugin(new RepositoryListenerPlugin() {
@Override
public void repositoryRefreshed(RepositoryPlugin repository) {
refreshed.set(repository);
}
@Override
public void repositoriesRefreshed() {
// TODO Auto-generated method stub
}
@Override
public void bundleRemoved(RepositoryPlugin repository, Jar jar, File file) {
// TODO Auto-generated method stub
}
@Override
public void bundleAdded(RepositoryPlugin repository, Jar jar, File file) {
// TODO Auto-generated method stub
}
});
File file = r.get("dummybundle", new Version("0"), null);
assertNotNull(file);
// not stale, default name
assertNull(r.title(new Object[0]));
System.out.println("1");
Thread.sleep(3000);
System.out.println("2");
assertEquals(null, refreshed.get());
System.out.println("3");
// update the index file
File index = IO.getFile(remote, "minir5.xml");
long time = index.lastModified();
String s = IO.collect(index);
// change the sha
s += " ";
IO.store(s, index);
System.out.println("5 " + index + " " + (index.lastModified() - time));
// give the poller a chance
Thread.sleep(3000);
System.out.println("6");
assertEquals(r, refreshed.get());
assertEquals("test [stale]", r.title(new Object[0]));
System.out.println(r.tooltip(new Object[0]));
}
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class MavenBndRepoTest method config.
void config(Map<String, String> override) throws Exception {
Map<String, String> config = new HashMap<>();
config.put("local", tmpName + "/local");
config.put("index", tmpName + "/index");
config.put("releaseUrl", fnx.getBaseURI() + "/repo/");
if (override != null)
config.putAll(override);
reporter = new Processor();
reporter.addBasicPlugin(new ProgressPlugin() {
@Override
public Task startTask(final String name, int size) {
System.out.println("Starting " + name);
return new Task() {
@Override
public void worked(int units) {
System.out.println("Worked " + name + " " + units);
}
@Override
public void done(String message, Throwable e) {
System.out.println("Done " + name + " " + message + " " + e);
}
@Override
public boolean isCanceled() {
return false;
}
};
}
});
HttpClient client = new HttpClient();
client.setRegistry(reporter);
Executor executor = Executors.newCachedThreadPool();
reporter.addBasicPlugin(client);
reporter.setTrace(true);
repo = new MavenBndRepository();
repo.setReporter(reporter);
repo.setRegistry(reporter);
repo.setProperties(config);
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class DistroCommandTest method testResolveAgainstDistro.
public void testResolveAgainstDistro() throws Exception {
bnd bnd = new bnd();
CommandLine cmdline = new CommandLine(null);
List<String> remoteArgs = new ArrayList<>();
RemoteOptions remoteOptions = cmdline.getOptions(RemoteOptions.class, remoteArgs);
File distro = new File("generated/tmp/test.distro.jar");
List<String> distroArgs = new ArrayList<>();
distroArgs.add("-o");
distroArgs.add(distro.getPath());
distroArgs.add("test.distro");
distroArgs.add("1.0.0");
DistroOptions distroOptions = cmdline.getOptions(DistroOptions.class, distroArgs);
new RemoteCommand(bnd, remoteOptions)._distro(distroOptions);
assertTrue(distro.exists());
ResolveProcess process = new ResolveProcess();
ResolverLogger logger = new ResolverLogger();
MockRegistry registry = new MockRegistry();
Processor model = new Processor();
model.setProperty("-distro", distro.getAbsolutePath() + ";version=file");
model.setProperty("-runfw", "org.eclipse.osgi");
model.setProperty("-runrequires", "osgi.wiring.package;filter:='(osgi.wiring.package=com.liferay.dynamic.data.mapping.taglib.servlet.taglib)'");
Map<Resource, List<Wire>> requiredResources = process.resolveRequired(model, null, registry, new BndResolver(logger), Collections.<ResolutionCallback>emptyList(), logger);
assertEquals(1, requiredResources.size());
}
Aggregations