Search in sources :

Example 16 with HaDescriptor

use of org.apache.knox.gateway.ha.provider.HaDescriptor in project knox by apache.

the class HaDescriptorManagerTest method testDescriptorDefaults.

@Test
public void testDescriptorDefaults() throws IOException {
    String xml = "<ha><service name='foo'/></ha>";
    ByteArrayInputStream inputStream = new ByteArrayInputStream(xml.getBytes());
    HaDescriptor descriptor = HaDescriptorManager.load(inputStream);
    assertNotNull(descriptor);
    assertEquals(1, descriptor.getEnabledServiceNames().size());
    HaServiceConfig config = descriptor.getServiceConfig("foo");
    assertNotNull(config);
    assertEquals("foo", config.getServiceName());
    assertEquals(HaServiceConfigConstants.DEFAULT_MAX_FAILOVER_ATTEMPTS, config.getMaxFailoverAttempts());
    assertEquals(HaServiceConfigConstants.DEFAULT_FAILOVER_SLEEP, config.getFailoverSleep());
    assertEquals(HaServiceConfigConstants.DEFAULT_MAX_RETRY_ATTEMPTS, config.getMaxRetryAttempts());
    assertEquals(HaServiceConfigConstants.DEFAULT_RETRY_SLEEP, config.getRetrySleep());
    assertEquals(HaServiceConfigConstants.DEFAULT_ENABLED, config.isEnabled());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) HaDescriptor(org.apache.knox.gateway.ha.provider.HaDescriptor) HaServiceConfig(org.apache.knox.gateway.ha.provider.HaServiceConfig) Test(org.junit.Test)

Aggregations

HaDescriptor (org.apache.knox.gateway.ha.provider.HaDescriptor)16 Test (org.junit.Test)14 HaProvider (org.apache.knox.gateway.ha.provider.HaProvider)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Service (org.apache.knox.gateway.topology.Service)5 Topology (org.apache.knox.gateway.topology.Topology)5 URI (java.net.URI)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 FilterConfig (javax.servlet.FilterConfig)4 ServletContext (javax.servlet.ServletContext)4 HttpServletRequest (javax.servlet.http.HttpServletRequest)4 HttpServletResponse (javax.servlet.http.HttpServletResponse)4 HttpUriRequest (org.apache.http.client.methods.HttpUriRequest)4 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)4 HttpClientBuilder (org.apache.http.impl.client.HttpClientBuilder)4 BasicHttpParams (org.apache.http.params.BasicHttpParams)4 DeploymentContext (org.apache.knox.gateway.deploy.DeploymentContext)4