use of org.apache.servicecomb.core.provider.producer.ProducerProviderManager 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.provider.producer.ProducerProviderManager 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.provider.producer.ProducerProviderManager 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.provider.producer.ProducerProviderManager 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));
}
use of org.apache.servicecomb.core.provider.producer.ProducerProviderManager 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());
}
Aggregations