use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class TestFixedIndexedRepo method testIndex2Compressed.
public void testIndex2Compressed() throws Exception {
Processor reporter = new Processor();
FixedIndexedRepo repo = new FixedIndexedRepo();
Map<String, String> props = new HashMap<String, String>();
props.put("name", "index2");
props.put("locations", IO.getFile("testdata/index2.xml.gz").toURI().toString());
props.put(FixedIndexedRepo.PROP_CACHE, tmp.getAbsolutePath());
repo.setProperties(props);
repo.setReporter(reporter);
assertEquals(56, countBundles(repo));
assertEquals(0, reporter.getErrors().size());
assertEquals(0, reporter.getWarnings().size());
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class TestFixedIndexedRepo method testExternalEntitiesNotFetched.
public void testExternalEntitiesNotFetched() throws Exception {
final AtomicInteger accessCount = new AtomicInteger(0);
FixedIndexedRepo repo;
Map<String, String> config;
Processor reporter = new Processor();
repo = new FixedIndexedRepo() {
// A bit of a hack, this makes sure that only OBR can be selected
protected synchronized void loadAllContentProviders() {
super.loadAllContentProviders();
allContentProviders.remove("R5");
}
};
config = new HashMap<String, String>();
config.put("locations", IO.getFile("testdata/xmlWithDtdRef.xml").getAbsoluteFile().toURI().toString());
config.put(FixedIndexedRepo.PROP_CACHE, tmp.getAbsolutePath());
repo.setProperties(config);
repo.setReporter(reporter);
repo.list(null);
repo = new FixedIndexedRepo() {
protected synchronized void loadAllContentProviders() {
super.loadAllContentProviders();
allContentProviders.remove("OBR");
}
};
config = new HashMap<String, String>();
config.put("locations", IO.getFile("testdata/xmlWithDtdRef.xml").getAbsoluteFile().toURI().toString());
config.put(FixedIndexedRepo.PROP_CACHE, tmp.getAbsolutePath());
repo.setProperties(config);
repo.setReporter(reporter);
repo.list(null);
assertEquals("Should not make any HTTP connection.", 0, accessCount.get());
assertTrue("Should be some ambiguity warnings", reporter.getWarnings().size() > 0);
assertTrue(reporter.check("Content provider 'OBR' was unable to determine", "No content provider matches the specified index unambiguously. Selected 'OBR' arbitrarily.", "Content provider 'R5' was unable to determine compatibility with index at URL ", "No content provider matches the specified index unambiguously. Selected 'R5' arbitrarily"));
assertEquals("Should not be any errors", 0, reporter.getErrors().size());
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class TestCompressedObrRepo method setUp.
@Override
protected void setUp() throws Exception {
httpd = new NanoHTTPD(0, IO.getFile("testdata/http"));
httpdPort = httpd.getPort();
Sed.file2GzFile(obrSrc, "__httpdPort__", Integer.toString(httpdPort), obrDst);
reporter = new Processor();
obr = new FixedIndexedRepo();
Map<String, String> config = new HashMap<String, String>();
config.put("name", "obr");
config.put("locations", new File(obrDst).toURI().toString());
config.put("type", "OBR");
obr.setProperties(config);
obr.setReporter(reporter);
File tmpFile = File.createTempFile("cache", ".tmp");
tmpFile.deleteOnExit();
obr.setCacheDirectory(new File(tmpFile.getAbsolutePath() + ".dir"));
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class SettingsParserTest method testMavenEncryptedPassword.
public void testMavenEncryptedPassword() throws Exception {
System.setProperty(ConnectionSettings.M2_SETTINGS_SECURITY_PROPERTY, "testresources/settings-security.xml");
Processor proc = new Processor();
proc.setProperty("-connection-settings", "testresources/server-maven-encrypted-selection.xml");
try (ConnectionSettings cs = new ConnectionSettings(proc, new HttpClient())) {
cs.readSettings();
List<ServerDTO> serverDTOs = cs.getServerDTOs();
assertEquals(1, serverDTOs.size());
ServerDTO s = serverDTOs.get(0);
assertEquals("encrypted-password", s.id);
assertEquals("FOOBAR", s.password);
}
}
use of aQute.bnd.osgi.Processor in project bnd by bndtools.
the class HttpClientTest method testCancel.
public void testCancel() throws Exception {
final long deadline = System.currentTimeMillis() + 1000L;
try (HttpClient hc = new HttpClient()) {
Processor p = new Processor();
p.addBasicPlugin(new ProgressPlugin() {
@Override
public Task startTask(String name, int size) {
return new Task() {
@Override
public void worked(int units) {
System.out.println("Worked " + units);
}
@Override
public void done(String message, Throwable e) {
System.out.println("Done " + message + " " + e);
}
@Override
public boolean isCanceled() {
System.out.println("Cancel check ");
return System.currentTimeMillis() > deadline;
}
};
}
});
hc.setRegistry(p);
TaggedData tag = hc.build().asTag().go(httpServer.getBaseURI("timeout/50"));
assertNotNull(tag);
assertEquals(200, tag.getResponseCode());
try {
String s = IO.collect(tag.getInputStream());
fail();
} catch (Exception e) {
e.printStackTrace();
}
}
}
Aggregations