Search in sources :

Example 11 with MavenResolver

use of org.ops4j.pax.url.mvn.MavenResolver in project karaf by apache.

the class MavenTest method awaitMavenResolver.

/**
 * Invoke config admin task and await reregistration of {@link MavenResolver} service
 */
private void awaitMavenResolver(Runnable task) throws Exception {
    final CountDownLatch latch = new CountDownLatch(2);
    ServiceListener listener = event -> {
        if (event.getType() == ServiceEvent.UNREGISTERING || event.getType() == ServiceEvent.REGISTERED) {
            latch.countDown();
        }
    };
    bundleContext.addServiceListener(listener, "(objectClass=org.ops4j.pax.url.mvn.MavenResolver)");
    try {
        task.run();
        assertTrue(latch.await(5, TimeUnit.SECONDS));
    } finally {
        bundleContext.removeServiceListener(listener);
    }
}
Also used : Request(org.eclipse.jetty.server.Request) Configuration(org.ops4j.pax.exam.Configuration) PaxExam(org.ops4j.pax.exam.junit.PaxExam) CoreOptions(org.ops4j.pax.exam.CoreOptions) Arrays(java.util.Arrays) BeforeClass(org.junit.BeforeClass) Constants(org.osgi.framework.Constants) ServletException(javax.servlet.ServletException) AbstractHandler(org.eclipse.jetty.server.handler.AbstractHandler) CoreMatchers.equalTo(org.hamcrest.CoreMatchers.equalTo) RunWith(org.junit.runner.RunWith) LoggerFactory(org.slf4j.LoggerFactory) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ServiceEvent(org.osgi.framework.ServiceEvent) Inject(javax.inject.Inject) HttpServletRequest(javax.servlet.http.HttpServletRequest) MavenArtifactUrlReference(org.ops4j.pax.exam.options.MavenArtifactUrlReference) Charset(java.nio.charset.Charset) KarafTestSupport(org.apache.karaf.itests.KarafTestSupport) PerClass(org.ops4j.pax.exam.spi.reactors.PerClass) LinkedList(java.util.LinkedList) Server(org.eclipse.jetty.server.Server) ExecutorService(java.util.concurrent.ExecutorService) ProbeBuilder(org.ops4j.pax.exam.ProbeBuilder) MavenResolver(org.ops4j.pax.url.mvn.MavenResolver) AfterClass(org.junit.AfterClass) Logger(org.slf4j.Logger) NetworkConnector(org.eclipse.jetty.server.NetworkConnector) KarafDistributionOption(org.ops4j.pax.exam.karaf.options.KarafDistributionOption) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Test(org.junit.Test) TestProbeBuilder(org.ops4j.pax.exam.TestProbeBuilder) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) BundleContext(org.osgi.framework.BundleContext) ServiceListener(org.osgi.framework.ServiceListener) TimeUnit(java.util.concurrent.TimeUnit) ExamReactorStrategy(org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy) CountDownLatch(java.util.concurrent.CountDownLatch) List(java.util.List) Option(org.ops4j.pax.exam.Option) LogLevelOption(org.ops4j.pax.exam.karaf.options.LogLevelOption) ConfigurationAdmin(org.osgi.service.cm.ConfigurationAdmin) Assert(org.junit.Assert) Dictionary(java.util.Dictionary) ServiceListener(org.osgi.framework.ServiceListener) CountDownLatch(java.util.concurrent.CountDownLatch)

Aggregations

MavenResolver (org.ops4j.pax.url.mvn.MavenResolver)11 File (java.io.File)7 IOException (java.io.IOException)5 Test (org.junit.Test)4 FileOutputStream (java.io.FileOutputStream)3 ConfigurationAdmin (org.osgi.service.cm.ConfigurationAdmin)3 InputStream (java.io.InputStream)2 URI (java.net.URI)2 URL (java.net.URL)2 Path (java.nio.file.Path)2 ArrayList (java.util.ArrayList)2 Dictionary (java.util.Dictionary)2 HashSet (java.util.HashSet)2 LinkedHashSet (java.util.LinkedHashSet)2 List (java.util.List)2 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)2 ZipEntry (java.util.zip.ZipEntry)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Lists (com.google.common.collect.Lists)1