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();
}
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();
}
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();
}
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;
}
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));
}
Aggregations