use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class OsgiLogServiceIntegrationTest method requireThatAllSupportedLogFrameworksAreConfigured.
@Test
@SuppressWarnings("unchecked")
public void requireThatAllSupportedLogFrameworksAreConfigured() throws Exception {
// need to explicitly set log level of root logger since integration suite now provides a logger config file,
// which disables that setLevel() call of the OsgiLogManager.
Logger.getLogger("").setLevel(Level.INFO);
long now = System.currentTimeMillis();
TestDriver driver = TestDriver.newApplicationBundleInstance("app-h-log.jar", false);
BundleContext ctx = driver.osgiFramework().bundleContext();
ServiceReference<?> ref = ctx.getServiceReference(LogReaderService.class.getName());
LogReaderService reader = (LogReaderService) ctx.getService(ref);
ArrayList<LogEntry> logEntries = Collections.list(reader.getLog());
assertTrue(logEntries.size() >= 4);
assertLogContainsEntry("[jdk14] hello world", logEntries, now);
assertLogContainsEntry("[slf4j] hello world", logEntries, now);
assertLogContainsEntry("[log4j] hello world", logEntries, now);
assertLogContainsEntry("[jcl] hello world", logEntries, now);
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ContainerNotReadyTestCase method requireThatExceptionIsThrown.
@Test
public void requireThatExceptionIsThrown() throws BindingSetNotFoundException {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
try {
driver.newReference(URI.create("http://host"));
fail();
} catch (ContainerNotReadyException e) {
}
driver.close();
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class NoBindingSetSelectedTestCase method requireThatNoBindingSetSelectedIsThrown.
@Test
public void requireThatNoBindingSetSelectedIsThrown() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() {
@Override
protected void configure() {
bind(BindingSetSelector.class).toInstance(new MySelector());
}
});
driver.activateContainer(driver.newContainerBuilder());
URI uri = URI.create("http://host");
try {
driver.newReference(uri);
fail();
} catch (NoBindingSetSelectedException e) {
assertEquals(uri, e.uri());
}
driver.close();
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class AbstractApplicationTestCase method requireThatBundleInstallerCanBeAccessed.
@Test
public void requireThatBundleInstallerCanBeAccessed() throws BundleException {
TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.class);
MyApplication app = (MyApplication) driver.application();
List<Bundle> lst = app.installAndStartBundle("cert-a.jar");
assertEquals(1, lst.size());
assertEquals("com.yahoo.vespa.jdisc_core.cert-a", lst.get(0).getSymbolicName());
app.stopAndUninstallBundle(lst.get(0));
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class BundleInstallerIntegrationTest method requireThatUninstallWorks.
@Test
public void requireThatUninstallWorks() throws Exception {
TestDriver driver = TestDriver.newSimpleApplicationInstance();
List<Bundle> prev = new LinkedList<>(driver.osgiFramework().bundles());
BundleInstaller installer = new BundleInstaller(driver.osgiFramework());
Bundle bundle = installer.installAndStart("cert-a.jar").get(0);
assertNotNull(bundle);
installer.stopAndUninstall(bundle);
for (Bundle entry : driver.osgiFramework().bundles()) {
assertTrue(prev.remove(entry));
}
assertTrue(prev.isEmpty());
driver.close();
}
Aggregations