Search in sources :

Example 6 with SCBEngine

use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.

the class TestRpcReferenceProcessor method testReference.

@Test
public void testReference(@Injectable ApplicationContext applicationContext) {
    SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
    PersonReference bean = new PersonReference();
    Assert.assertNull(bean.person);
    consumers.setEmbeddedValueResolver((strVal) -> strVal);
    Assert.assertSame(bean, consumers.postProcessBeforeInitialization(bean, "id"));
    Assert.assertNotNull(bean.person);
    scbEngine.destroy();
}
Also used : SCBEngine(org.apache.servicecomb.core.SCBEngine) PersonReference(org.apache.servicecomb.provider.pojo.PersonReference) Test(org.junit.Test)

Example 7 with SCBEngine

use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.

the class TestServicePathManager method testBuildProducerPathsNoPrefix.

@Test
public void testBuildProducerPathsNoPrefix() {
    SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest().addProducerMeta("sid1", new TestPathSchema()).run();
    ServicePathManager spm = ServicePathManager.getServicePathManager(scbEngine.getProducerMicroserviceMeta());
    Assert.assertSame(spm.producerPaths, spm.swaggerPaths);
    scbEngine.destroy();
}
Also used : SCBEngine(org.apache.servicecomb.core.SCBEngine) Test(org.junit.Test)

Example 8 with SCBEngine

use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.

the class TestServicePathManager method testBuildProducerPathsHasPrefix.

@Test
public void testBuildProducerPathsHasPrefix() {
    ClassLoaderScopeContext.setClassLoaderScopeProperty(DefinitionConst.URL_PREFIX, "/root/rest");
    SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest().addProducerMeta("sid1", new TestPathSchema()).run();
    ServicePathManager spm = ServicePathManager.getServicePathManager(scbEngine.getProducerMicroserviceMeta());
    // all locate should be success
    spm.producerLocateOperation("/root/rest/static/", "GET");
    spm.producerLocateOperation("/root/rest/static/", "POST");
    spm.producerLocateOperation("/root/rest/dynamic/1/", "GET");
    spm.producerLocateOperation("/root/rest/dynamicEx/1/", "GET");
    scbEngine.destroy();
}
Also used : SCBEngine(org.apache.servicecomb.core.SCBEngine) Test(org.junit.Test)

Example 9 with SCBEngine

use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.

the class TestInspectorImpl method initInspector.

private static InspectorImpl initInspector(String urlPrefix) {
    SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
    scbEngine.getTransportManager().clearTransportBeforeInit();
    if (StringUtils.isNotEmpty(urlPrefix)) {
        Map<String, Transport> transportMap = Deencapsulation.getField(scbEngine.getTransportManager(), "transportMap");
        transportMap.put(RESTFUL, new ServletRestTransport());
        ClassLoaderScopeContext.setClassLoaderScopeProperty(DefinitionConst.URL_PREFIX, urlPrefix);
    }
    scbEngine.run();
    InspectorImpl inspector = new InspectorImpl().setInspectorConfig(scbEngine.getPriorityPropertyManager().createConfigObject(InspectorConfig.class)).setSchemas(schemas);
    inspector.correctBasePathForOnlineTest(scbEngine);
    return inspector;
}
Also used : SCBEngine(org.apache.servicecomb.core.SCBEngine) ServletRestTransport(org.apache.servicecomb.transport.rest.servlet.ServletRestTransport) Transport(org.apache.servicecomb.core.Transport) ServletRestTransport(org.apache.servicecomb.transport.rest.servlet.ServletRestTransport)

Example 10 with SCBEngine

use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.

the class TestHealthBootListener method onBeforeProducerProvider_health_endpoint_enabled_by_default.

@Test
public void onBeforeProducerProvider_health_endpoint_enabled_by_default() {
    final HealthBootListener listener = new HealthBootListener();
    final List<ProducerMeta> producerMetas = new ArrayList<>();
    final BootEvent event = new BootEvent();
    final ProducerMeta producerMeta = new ProducerMeta();
    final SCBEngine scbEngine = new SCBEngine() {

        public final ProducerProviderManager producerProviderManager = new ProducerProviderManager(this) {

            @Override
            public void addProducerMeta(String schemaId, Object instance) {
                producerMeta.setSchemaId(schemaId);
                producerMeta.setInstance(instance);
                producerMetas.add(producerMeta);
            }
        };

        @Override
        public ProducerProviderManager getProducerProviderManager() {
            return producerProviderManager;
        }
    };
    event.setScbEngine(scbEngine);
    listener.onBeforeProducerProvider(event);
    Assert.assertThat(producerMetas, Matchers.contains(producerMeta));
    Assert.assertThat(producerMeta.getSchemaId(), Matchers.equalTo("healthEndpoint"));
    Assert.assertThat(producerMeta.getInstance(), Matchers.instanceOf(HealthCheckerRestPublisher.class));
}
Also used : ProducerMeta(org.apache.servicecomb.core.provider.producer.ProducerMeta) SCBEngine(org.apache.servicecomb.core.SCBEngine) ArrayList(java.util.ArrayList) BootEvent(org.apache.servicecomb.core.BootListener.BootEvent) HealthCheckerRestPublisher(org.apache.servicecomb.metrics.core.publish.HealthCheckerRestPublisher) ProducerProviderManager(org.apache.servicecomb.core.provider.producer.ProducerProviderManager) Test(org.junit.Test)

Aggregations

SCBEngine (org.apache.servicecomb.core.SCBEngine)12 Test (org.junit.Test)11 BootEvent (org.apache.servicecomb.core.BootListener.BootEvent)6 ProducerProviderManager (org.apache.servicecomb.core.provider.producer.ProducerProviderManager)5 ArrayList (java.util.ArrayList)4 ProducerMeta (org.apache.servicecomb.core.provider.producer.ProducerMeta)4 MicroserviceMeta (org.apache.servicecomb.core.definition.MicroserviceMeta)2 JavaType (com.fasterxml.jackson.databind.JavaType)1 Method (java.lang.reflect.Method)1 Transport (org.apache.servicecomb.core.Transport)1 SchemaMeta (org.apache.servicecomb.core.definition.SchemaMeta)1 Holder (org.apache.servicecomb.foundation.common.Holder)1 HealthCheckerRestPublisher (org.apache.servicecomb.metrics.core.publish.HealthCheckerRestPublisher)1 MetricsRestPublisher (org.apache.servicecomb.metrics.core.publish.MetricsRestPublisher)1 IPerson (org.apache.servicecomb.provider.pojo.IPerson)1 PersonReference (org.apache.servicecomb.provider.pojo.PersonReference)1 ServletRestTransport (org.apache.servicecomb.transport.rest.servlet.ServletRestTransport)1