Search in sources :

Example 1 with ServiceLoader

use of java.util.ServiceLoader in project knox by apache.

the class ServicePathFunctionProcessorTest method testServiceLoader.

@Test
public void testServiceLoader() throws Exception {
    ServiceLoader loader = ServiceLoader.load(UrlRewriteFunctionProcessor.class);
    Iterator iterator = loader.iterator();
    assertThat("Service iterator empty.", iterator.hasNext());
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object instanceof ServicePathFunctionProcessor) {
            return;
        }
    }
    fail("Failed to find " + ServicePathFunctionProcessor.class.getName() + " via service loader.");
}
Also used : ServiceLoader(java.util.ServiceLoader) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 2 with ServiceLoader

use of java.util.ServiceLoader in project knox by apache.

the class ServicePortFunctionProcessorTest method testServiceLoader.

@Test
public void testServiceLoader() throws Exception {
    ServiceLoader loader = ServiceLoader.load(UrlRewriteFunctionProcessor.class);
    Iterator iterator = loader.iterator();
    assertThat("Service iterator empty.", iterator.hasNext());
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object instanceof ServicePortFunctionProcessor) {
            return;
        }
    }
    fail("Failed to find " + ServicePortFunctionProcessor.class.getName() + " via service loader.");
}
Also used : ServiceLoader(java.util.ServiceLoader) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 3 with ServiceLoader

use of java.util.ServiceLoader in project knox by apache.

the class ServiceSchemeFunctionProcessorTest method testServiceLoader.

@Test
public void testServiceLoader() throws Exception {
    ServiceLoader loader = ServiceLoader.load(UrlRewriteFunctionProcessor.class);
    Iterator iterator = loader.iterator();
    assertThat("Service iterator empty.", iterator.hasNext());
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object instanceof ServiceSchemeFunctionProcessor) {
            return;
        }
    }
    fail("Failed to find " + ServiceSchemeFunctionProcessor.class.getName() + " via service loader.");
}
Also used : ServiceLoader(java.util.ServiceLoader) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 4 with ServiceLoader

use of java.util.ServiceLoader in project knox by apache.

the class ServiceUrlFunctionProcessorTest method testServiceLoader.

@Test
public void testServiceLoader() throws Exception {
    ServiceLoader loader = ServiceLoader.load(UrlRewriteFunctionProcessor.class);
    Iterator iterator = loader.iterator();
    assertThat("Service iterator empty.", iterator.hasNext());
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object instanceof ServiceUrlFunctionProcessor) {
            return;
        }
    }
    fail("Failed to find " + ServiceUrlFunctionProcessor.class.getName() + " via service loader.");
}
Also used : ServiceLoader(java.util.ServiceLoader) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 5 with ServiceLoader

use of java.util.ServiceLoader in project knox by apache.

the class ServicePathFunctionDescriptorTest method testServiceLoader.

@Test
public void testServiceLoader() throws Exception {
    ServiceLoader loader = ServiceLoader.load(UrlRewriteFunctionDescriptor.class);
    Iterator iterator = loader.iterator();
    assertThat("Service iterator empty.", iterator.hasNext());
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object instanceof ServicePathFunctionDescriptor) {
            return;
        }
    }
    fail("Failed to find " + ServicePathFunctionDescriptor.class.getName() + " via service loader.");
}
Also used : ServiceLoader(java.util.ServiceLoader) Iterator(java.util.Iterator) Test(org.junit.Test)

Aggregations

ServiceLoader (java.util.ServiceLoader)61 Iterator (java.util.Iterator)42 Test (org.junit.Test)40 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 List (java.util.List)4 NoSuchElementException (java.util.NoSuchElementException)3 Optional (java.util.Optional)3 ServiceConfigurationError (java.util.ServiceConfigurationError)3 ServletContext (javax.servlet.ServletContext)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 CharsetProvider (java.nio.charset.spi.CharsetProvider)2 Map (java.util.Map)2 Entry (java.util.Map.Entry)2 Set (java.util.Set)2 Collectors (java.util.stream.Collectors)2