Search in sources :

Example 11 with SCBEngine

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

the class TestHealthBootListener method onBeforeProducerProvider_health_endpoint_disabled.

@Test
public void onBeforeProducerProvider_health_endpoint_disabled() {
    ArchaiusUtils.setProperty("servicecomb.health.endpoint.enabled", false);
    final HealthBootListener listener = new HealthBootListener();
    final List<ProducerMeta> producerMetas = new ArrayList<>();
    final BootEvent event = new BootEvent();
    final SCBEngine scbEngine = new SCBEngine() {

        public final ProducerProviderManager producerProviderManager = new ProducerProviderManager(this) {

            @Override
            public void addProducerMeta(String schemaId, Object instance) {
                producerMetas.add(new ProducerMeta(schemaId, instance));
            }
        };

        @Override
        public ProducerProviderManager getProducerProviderManager() {
            return producerProviderManager;
        }
    };
    event.setScbEngine(scbEngine);
    listener.onBeforeProducerProvider(event);
    Assert.assertThat(producerMetas, Matchers.empty());
}
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) ProducerProviderManager(org.apache.servicecomb.core.provider.producer.ProducerProviderManager) Test(org.junit.Test)

Example 12 with SCBEngine

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

the class TestInvoker method should_generate_response_meta_for_download.

@Test
public void should_generate_response_meta_for_download() throws NoSuchMethodException {
    SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest().addProducerMeta("download", new DownloadSchema()).run();
    PojoConsumerMetaRefresher refresher = new PojoConsumerMetaRefresher(scbEngine.getProducerMicroserviceMeta().getMicroserviceName(), "download", DownloadIntf.class);
    Method method = DownloadIntf.class.getMethod("download");
    JavaType javaType = refresher.getLatestMeta().ensureFindOperationMeta(method).getResponsesType();
    Assert.assertSame(Part.class, javaType.getRawClass());
    scbEngine.destroy();
}
Also used : SCBEngine(org.apache.servicecomb.core.SCBEngine) JavaType(com.fasterxml.jackson.databind.JavaType) Method(java.lang.reflect.Method) 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