Search in sources :

Example 11 with Resource

use of com.hotels.styx.api.Resource in project styx by ExpediaGroup.

the class ResourceFactoryTest method canAcquireFileResources.

@Test
public void canAcquireFileResources() {
    String filePath = ResourceFactoryTest.class.getResource("/com/hotels/styx/common/io/resource.txt").getPath();
    Resource resource = ResourceFactory.newResource(filePath);
    assertThat(resource, contains("This is an example resource.\nIt has content to use in automated tests."));
}
Also used : Resource(com.hotels.styx.api.Resource) Test(org.junit.jupiter.api.Test)

Example 12 with Resource

use of com.hotels.styx.api.Resource in project styx by ExpediaGroup.

the class ResourceFactoryTest method canAcquireClasspathResources.

@Test
public void canAcquireClasspathResources() {
    Resource resource = ResourceFactory.newResource("classpath:com/hotels/styx/common/io/resource.txt");
    assertThat(resource, contains("This is an example resource.\nIt has content to use in automated tests."));
}
Also used : Resource(com.hotels.styx.api.Resource) Test(org.junit.jupiter.api.Test)

Example 13 with Resource

use of com.hotels.styx.api.Resource in project styx by ExpediaGroup.

the class FileResourceIndexTest method listsResourcesFromFileSystemFile.

@Test
public void listsResourcesFromFileSystemFile() {
    File file = new File(PLUGINS_FIXTURE_PATH.toFile(), "groovy/UrlRewrite.groovy");
    Iterable<Resource> files = resourceIndex.list(file.getPath(), ".anything");
    assertThat(files, contains(resourceWithPath(PLUGINS_FIXTURE_PATH.resolve("groovy/UrlRewrite.groovy").toString())));
}
Also used : Resource(com.hotels.styx.api.Resource) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

Resource (com.hotels.styx.api.Resource)13 Test (org.junit.jupiter.api.Test)12 BackendService (com.hotels.styx.api.extension.service.BackendService)6 ReloadResult (com.hotels.styx.api.extension.service.spi.Registry.ReloadResult)6 Registry (com.hotels.styx.api.extension.service.spi.Registry)5 ReloadResult.reloaded (com.hotels.styx.api.extension.service.spi.Registry.ReloadResult.reloaded)5 ReloadResult.unchanged (com.hotels.styx.api.extension.service.spi.Registry.ReloadResult.unchanged)5 StyxFutures.await (com.hotels.styx.common.StyxFutures.await)5 JustATestException (com.hotels.styx.support.JustATestException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IOException (java.io.IOException)5 UTF_8 (java.nio.charset.StandardCharsets.UTF_8)5 List (java.util.List)5 MatcherAssert.assertThat (org.hamcrest.MatcherAssert.assertThat)5 Matchers.instanceOf (org.hamcrest.Matchers.instanceOf)5 Matchers.is (org.hamcrest.Matchers.is)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 Matchers.eq (org.mockito.Matchers.eq)5 Mockito.mock (org.mockito.Mockito.mock)5 Mockito.verify (org.mockito.Mockito.verify)5