Search in sources :

Example 11 with ServiceLoader

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

the class EncryptDecryptUriProcessorTest method testServiceLoader.

@SuppressWarnings("rawtypes")
@Test
public void testServiceLoader() throws Exception {
    ServiceLoader loader = ServiceLoader.load(UrlRewriteStepProcessor.class);
    Iterator iterator = loader.iterator();
    assertThat("Service iterator empty.", iterator.hasNext());
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object instanceof EncryptUriProcessor) {
            return;
        }
    }
    fail("Failed to find " + EncryptUriProcessor.class.getName() + " via service loader.");
    loader = ServiceLoader.load(UrlRewriteStepProcessor.class);
    iterator = loader.iterator();
    assertThat("Service iterator empty.", iterator.hasNext());
    while (iterator.hasNext()) {
        Object object = iterator.next();
        if (object instanceof DecryptUriProcessor) {
            return;
        }
    }
    fail("Failed to find " + DecryptUriProcessor.class.getName() + " via service loader.");
}
Also used : ServiceLoader(java.util.ServiceLoader) UrlRewriteStepProcessor(org.apache.knox.gateway.filter.rewrite.spi.UrlRewriteStepProcessor) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 12 with ServiceLoader

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

the class FrontendFunctionProcessorTest method testServiceLoader.

@SuppressWarnings("rawtypes")
@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 FrontendFunctionProcessor) {
            return;
        }
    }
    fail("Failed to find " + FrontendFunctionProcessor.class.getName() + " via service loader.");
}
Also used : ServiceLoader(java.util.ServiceLoader) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 13 with ServiceLoader

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

the class HtmlImportFunctionProcessorTest method testServiceLoader.

@SuppressWarnings("rawtypes")
@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 HtmlImportFunctionProcessor) {
            return;
        }
    }
    fail("Failed to find " + HtmlImportFunctionProcessor.class.getName() + " via service loader.");
}
Also used : ServiceLoader(java.util.ServiceLoader) Iterator(java.util.Iterator) Test(org.junit.Test)

Example 14 with ServiceLoader

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

the class HaProviderDeploymentContributorTest method testServiceLoader.

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

Example 15 with ServiceLoader

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

the class HostmapDeploymentContributorTest method testServiceLoader.

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

Aggregations

ServiceLoader (java.util.ServiceLoader)59 Iterator (java.util.Iterator)42 Test (org.junit.Test)40 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 NoSuchElementException (java.util.NoSuchElementException)3 ServiceConfigurationError (java.util.ServiceConfigurationError)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 CharsetProvider (java.nio.charset.spi.CharsetProvider)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Optional (java.util.Optional)2 ResourceBundle (java.util.ResourceBundle)2 BundleReference (org.osgi.framework.BundleReference)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Person (com.dockerx.traffic.providespro.entity.Person)1 Analysis (com.dockerx.traffic.providespro.service.Analysis)1 Joiner.on (com.google.common.base.Joiner.on)1 ImmutableMap (com.google.common.collect.ImmutableMap)1