Search in sources :

Example 1 with YAMLBackendServicesReader

use of com.hotels.styx.proxy.backends.file.FileBackedBackendServicesRegistry.YAMLBackendServicesReader in project styx by ExpediaGroup.

the class FileBackedBackendServicesRegistryTest method yamlBackendReaderPropagatesExceptionWhenFailsToReadFromByteStream.

@Test
public void yamlBackendReaderPropagatesExceptionWhenFailsToReadFromByteStream() {
    Resource resource = newResource("classpath:/backends/origins-with-invalid-path.yml");
    assertThrows(RuntimeException.class, () -> new YAMLBackendServicesReader().read(bytes(resource.inputStream(), true)));
}
Also used : YAMLBackendServicesReader(com.hotels.styx.proxy.backends.file.FileBackedBackendServicesRegistry.YAMLBackendServicesReader) ResourceFactory.newResource(com.hotels.styx.common.io.ResourceFactory.newResource) Resource(com.hotels.styx.api.Resource) Test(org.junit.jupiter.api.Test)

Example 2 with YAMLBackendServicesReader

use of com.hotels.styx.proxy.backends.file.FileBackedBackendServicesRegistry.YAMLBackendServicesReader in project styx by ExpediaGroup.

the class FileBackedBackendServicesRegistryTest method yamlBackendReaderReadsBackendServicesFromByteStream.

@Test
public void yamlBackendReaderReadsBackendServicesFromByteStream() throws IOException {
    Resource resource = newResource("classpath:/backends/origins.yml");
    Iterable<BackendService> backendServices = new YAMLBackendServicesReader().read(bytes(resource.inputStream(), true));
    assertThat(iterableToList(backendServices).size(), is(3));
}
Also used : BackendService(com.hotels.styx.api.extension.service.BackendService) YAMLBackendServicesReader(com.hotels.styx.proxy.backends.file.FileBackedBackendServicesRegistry.YAMLBackendServicesReader) ResourceFactory.newResource(com.hotels.styx.common.io.ResourceFactory.newResource) Resource(com.hotels.styx.api.Resource) Test(org.junit.jupiter.api.Test)

Aggregations

Resource (com.hotels.styx.api.Resource)2 ResourceFactory.newResource (com.hotels.styx.common.io.ResourceFactory.newResource)2 YAMLBackendServicesReader (com.hotels.styx.proxy.backends.file.FileBackedBackendServicesRegistry.YAMLBackendServicesReader)2 Test (org.junit.jupiter.api.Test)2 BackendService (com.hotels.styx.api.extension.service.BackendService)1