Search in sources :

Example 16 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class ModuleRegistryTest method setup.

@Before
public void setup() {
    moduleRegistry = new ModuleRegistry();
    moduleRegistry.getHttpRequestContextProvider().setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
    resourceRegistry = new ResourceRegistryImpl(new DefaultResourceRegistryPart(), moduleRegistry);
    testModule = new TestModule();
    moduleRegistry.addModule(testModule);
    moduleRegistry.addModule(new CoreModule());
    moduleRegistry.addModule(new JacksonModule(new ObjectMapper(), false, ImmutableList.of(new OffsetLimitPagingBehavior())));
    moduleRegistry.setServiceDiscovery(serviceDiscovery);
    moduleRegistry.init(new ObjectMapper());
    Assert.assertEquals(resourceRegistry, moduleRegistry.getResourceRegistry());
}
Also used : OffsetLimitPagingBehavior(io.crnk.core.queryspec.pagingspec.OffsetLimitPagingBehavior) ResourceRegistryImpl(io.crnk.core.engine.internal.registry.ResourceRegistryImpl) DefaultResourceRegistryPart(io.crnk.core.engine.registry.DefaultResourceRegistryPart) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) CoreModule(io.crnk.core.engine.internal.CoreModule) JacksonModule(io.crnk.core.engine.internal.jackson.JacksonModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 17 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class DefaultQuerySpecSerializerTest method testHttpsSchema.

@Test
public void testHttpsSchema() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("https://127.0.0.1"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(String.format("%s,io.crnk.core.queryspec.pagingspec", MockConstants.TEST_MODELS_PACKAGE)));
    boot.boot();
    urlBuilder = new JsonApiUrlBuilder(boot.getResourceRegistry());
    check("https://127.0.0.1/tasks", null, new QuerySpec(Task.class));
}
Also used : Task(io.crnk.core.mock.models.Task) CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) JsonApiUrlBuilder(io.crnk.core.engine.internal.utils.JsonApiUrlBuilder) Test(org.junit.Test)

Example 18 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class DefaultQuerySpecSerializerTest method testPort.

@Test
public void testPort() {
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("https://127.0.0.1:1234"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(String.format("%s,io.crnk.core.queryspec.pagingspec", MockConstants.TEST_MODELS_PACKAGE)));
    boot.boot();
    urlBuilder = new JsonApiUrlBuilder(boot.getResourceRegistry());
    check("https://127.0.0.1:1234/tasks", null, new QuerySpec(Task.class));
}
Also used : Task(io.crnk.core.mock.models.Task) CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) JsonApiUrlBuilder(io.crnk.core.engine.internal.utils.JsonApiUrlBuilder) Test(org.junit.Test)

Example 19 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class CrnkBoot method setupServiceUrlProvider.

private void setupServiceUrlProvider() {
    String resourceDefaultDomain = propertiesProvider.getProperty(CrnkProperties.RESOURCE_DEFAULT_DOMAIN);
    String webPathPrefix = getWebPathPrefix();
    if (resourceDefaultDomain != null) {
        String serviceUrl = buildServiceUrl(resourceDefaultDomain, webPathPrefix);
        moduleRegistry.getHttpRequestContextProvider().setServiceUrlProvider(new ConstantServiceUrlProvider(serviceUrl));
    }
}
Also used : ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider)

Example 20 with ConstantServiceUrlProvider

use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.

the class AbstractDocumentMapperTest method setup.

@Before
public void setup() {
    MockRepositoryUtil.clear();
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(String.format("%s,io.crnk.core.queryspec.pagingspec", MockConstants.TEST_MODELS_PACKAGE)));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
    boot.setPropertiesProvider(getPropertiesProvider());
    boot.boot();
    objectMapper = boot.getObjectMapper();
    moduleRegistry = boot.getModuleRegistry();
    mapper = boot.getDocumentMapper();
    resourceRegistry = boot.getResourceRegistry();
    resourceFilterDirectory = boot.getModuleRegistry().getContext().getResourceFilterDirectory();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) Before(org.junit.Before)

Aggregations

ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)40 CrnkBoot (io.crnk.core.boot.CrnkBoot)34 Before (org.junit.Before)27 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)24 Test (org.junit.Test)8 JsonApiUrlBuilder (io.crnk.core.engine.internal.utils.JsonApiUrlBuilder)6 TestModule (io.crnk.test.mock.TestModule)6 Task (io.crnk.core.mock.models.Task)5 ResourceMetaProvider (io.crnk.meta.provider.resource.ResourceMetaProvider)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 ResourceRegistryImpl (io.crnk.core.engine.internal.registry.ResourceRegistryImpl)4 DefaultResourceRegistryPart (io.crnk.core.engine.registry.DefaultResourceRegistryPart)4 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)4 SimpleModule (io.crnk.core.module.SimpleModule)4 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)3 RelationIdTestResource (io.crnk.core.mock.models.RelationIdTestResource)3 ModuleRegistry (io.crnk.core.module.ModuleRegistry)3 CoreModule (io.crnk.core.engine.internal.CoreModule)2 PathBuilder (io.crnk.core.engine.internal.dispatcher.path.PathBuilder)2 DefaultInformationBuilder (io.crnk.core.engine.internal.information.DefaultInformationBuilder)2