use of org.osgi.service.indexer.impl.RepoIndex in project bnd by bndtools.
the class TestStandaloneLibrary method testBasicServiceInvocation.
public void testBasicServiceInvocation() throws Exception {
ResourceIndexer indexer = new RepoIndex();
StringWriter writer = new StringWriter();
File tempDir = createTempDir();
File tempFile = copyToTempFile(tempDir, "testdata/01-bsn+version.jar");
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
indexer.indexFragment(Collections.singleton(tempFile), writer, config);
assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/fragment-basic.txt")), writer.toString().trim());
deleteWithException(tempDir);
}
use of org.osgi.service.indexer.impl.RepoIndex in project bnd by bndtools.
the class TestStandaloneLibrary method testKnownBundleRecognition.
public void testKnownBundleRecognition() throws Exception {
RepoIndex indexer = new RepoIndex();
indexer.addAnalyzer(new KnownBundleAnalyzer(), FrameworkUtil.createFilter("(name=*)"));
StringWriter writer = new StringWriter();
File tempDir = createTempDir();
File tempFile = copyToTempFile(tempDir, "testdata/org.eclipse.equinox.ds-1.4.0.jar");
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
indexer.indexFragment(Collections.singleton(tempFile), writer, config);
assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/org.eclipse.equinox.ds-1.4.0.fragment.txt")), writer.toString().trim());
deleteWithException(tempDir);
}
use of org.osgi.service.indexer.impl.RepoIndex in project bnd by bndtools.
the class TestStandaloneLibrary method assertIndexPath.
private void assertIndexPath(String root, String file, String dest) throws Exception {
File tempDir = IO.getFile(root);
tempDir.mkdirs();
final List<String> errors = new ArrayList<>();
final List<String> warnings = new ArrayList<>();
File target = IO.getFile(tempDir, dest);
target.getParentFile().mkdirs();
try {
IO.copy(IO.getFile("src/testdata/01-bsn+version.jar"), target);
ResourceIndexer indexer = new RepoIndex(new LogService() {
@Override
public void log(ServiceReference sr, int level, String message, Throwable exception) {
log(level, message + " " + exception);
}
@Override
public void log(ServiceReference sr, int level, String message) {
log(level, message);
}
@Override
public void log(int level, String message, Throwable exception) {
log(level, message + " " + exception);
}
@Override
public void log(int level, String message) {
switch(level) {
case LogService.LOG_ERROR:
errors.add(message);
break;
case LogService.LOG_WARNING:
warnings.add(message);
break;
default:
break;
}
}
});
StringWriter writer = new StringWriter();
String osRootPath = root.replace('/', File.separatorChar);
String rootURI = new File(osRootPath).toURI().toString();
File osFile = new File(file.replace('/', File.separatorChar));
assertTrue(osFile + " does not exist", osFile.isFile());
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.ROOT_URL, rootURI);
indexer.indexFragment(Collections.singleton(osFile), writer, config);
assertEquals(0, errors.size());
assertEquals(0, warnings.size());
} finally {
deleteWithException(tempDir);
}
}
use of org.osgi.service.indexer.impl.RepoIndex in project bnd by bndtools.
the class TestStandaloneLibrary method testPlainJar.
public void testPlainJar() throws Exception {
RepoIndex indexer = new RepoIndex();
StringWriter writer = new StringWriter();
File tempDir = createTempDir();
File tempFile = copyToTempFile(tempDir, "testdata/jcip-annotations.jar");
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
indexer.indexFragment(Collections.singleton(tempFile), writer, config);
assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/plainjar.fragment.txt")), writer.toString().trim());
deleteWithException(tempDir);
}
Aggregations