use of org.apache.servicecomb.core.BootListener.BootEvent 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.BootListener.BootEvent 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.BootListener.BootEvent in project incubator-servicecomb-java-chassis by apache.
the class CseApplicationListener method triggerEvent.
protected void triggerEvent(EventType eventType) {
BootEvent event = new BootEvent();
event.setEventType(eventType);
for (BootListener listener : bootListenerList) {
listener.onBootEvent(event);
}
}
use of org.apache.servicecomb.core.BootListener.BootEvent in project incubator-servicecomb-java-chassis by apache.
the class TestAuthHandlerBoot method testGenerateRSAKey.
@Test
public void testGenerateRSAKey() {
MicroserviceInstance microserviceInstance = new MicroserviceInstance();
Microservice microservice = new Microservice();
microservice.setInstance(microserviceInstance);
new Expectations(RegistryUtils.class) {
{
RegistryUtils.getMicroserviceInstance();
result = microserviceInstance;
}
};
AuthHandlerBoot authHandlerBoot = new AuthHandlerBoot();
BootEvent bootEvent = new BootEvent();
bootEvent.setEventType(BootListener.EventType.BEFORE_REGISTRY);
authHandlerBoot.onBootEvent(bootEvent);
Assert.assertNotNull(RSAKeypair4Auth.INSTANCE.getPrivateKey());
Assert.assertNotNull(RSAKeypair4Auth.INSTANCE.getPublicKey());
}
use of org.apache.servicecomb.core.BootListener.BootEvent in project java-chassis by ServiceComb.
the class TestProducerBootListener method onBootEvent_notClose.
@Test
public void onBootEvent_notClose() {
BootEvent event = new BootEvent();
event.setEventType(EventType.BEFORE_CLOSE);
// should not throw exception
producerBootListener.onBootEvent(event);
}
Aggregations