use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.
the class TestInspectorBootListener method disabled.
@Test
public void disabled() {
SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
scbEngine.setProducerMicroserviceMeta(new MicroserviceMeta(scbEngine, "ms", false));
InspectorConfig inspectorConfig = new InspectorConfig().setEnabled(false);
new InspectorBootListener(inspectorConfig, null).onAfterTransport(new BootEvent(scbEngine, EventType.AFTER_TRANSPORT));
Assert.assertNull(scbEngine.getProducerMicroserviceMeta().findSchemaMeta("inspector"));
}
use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.
the class TestInspectorBootListener method enabled.
@Test
public void enabled() {
Holder<Object> holder = new Holder<>();
SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
scbEngine.setProducerMicroserviceMeta(new MicroserviceMeta(scbEngine, "ms", false));
scbEngine.setProducerProviderManager(new ProducerProviderManager(scbEngine) {
@Override
public SchemaMeta registerSchema(String schemaId, Object instance) {
if ("inspector".equals(schemaId)) {
holder.value = instance;
}
return null;
}
});
InspectorConfig inspectorConfig = new InspectorConfig().setEnabled(true);
new InspectorBootListener(inspectorConfig, null).onAfterTransport(new BootEvent(scbEngine, EventType.AFTER_TRANSPORT));
Assert.assertNotNull(holder.value);
}
use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.
the class TestMetricsBootListener method onBeforeProducerProvider_metrics_endpoint_disabled.
@Test
public void onBeforeProducerProvider_metrics_endpoint_disabled() {
ArchaiusUtils.setProperty("servicecomb.metrics.endpoint.enabled", false);
final MetricsBootListener listener = new MetricsBootListener();
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());
}
use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.
the class TestMetricsBootListener method onBeforeProducerProvider_metrics_endpoint_enabled_by_default.
@Test
public void onBeforeProducerProvider_metrics_endpoint_enabled_by_default() {
final MetricsBootListener listener = new MetricsBootListener();
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("metricsEndpoint"));
Assert.assertThat(producerMeta.getInstance(), Matchers.instanceOf(MetricsRestPublisher.class));
}
use of org.apache.servicecomb.core.SCBEngine in project java-chassis by ServiceComb.
the class PojoReferenceMetaTest method testHasConsumerInterface.
@Test
public void testHasConsumerInterface() {
SCBEngine scbEngine = SCBBootstrap.createSCBEngineForTest();
PojoReferenceMeta pojoReferenceMeta = new PojoReferenceMeta();
pojoReferenceMeta.setMicroserviceName("test");
pojoReferenceMeta.setSchemaId("schemaId");
pojoReferenceMeta.setConsumerIntf(IPerson.class);
pojoReferenceMeta.afterPropertiesSet();
Assert.assertEquals(IPerson.class, pojoReferenceMeta.getObjectType());
assertThat(pojoReferenceMeta.getProxy(), instanceOf(IPerson.class));
Assert.assertEquals(true, pojoReferenceMeta.isSingleton());
scbEngine.destroy();
}
Aggregations