use of com.alipay.sofa.runtime.ext.spring.ExtensionFactoryBean in project sofa-boot by alipay.
the class IsleCheckStartupReporterTest method testStartupReporter.
@Test
public void testStartupReporter() {
Assert.assertNotNull(startupReporter);
StartupReporter.StartupStaticsModel startupStaticsModel = startupReporter.report();
Assert.assertNotNull(startupStaticsModel);
Assert.assertEquals(7, startupStaticsModel.getStageStats().size());
BaseStat isleModelCreatingStage = startupReporter.getStageNyName(BootStageConstants.ISLE_MODEL_CREATING_STAGE);
Assert.assertNotNull(isleModelCreatingStage);
Assert.assertTrue(isleModelCreatingStage.getCost() > 0);
BaseStat isleSpringContextInstallStage = startupReporter.getStageNyName(BootStageConstants.ISLE_SPRING_CONTEXT_INSTALL_STAGE);
Assert.assertNotNull(isleSpringContextInstallStage);
Assert.assertTrue(isleSpringContextInstallStage.getCost() > 0);
Assert.assertTrue(isleSpringContextInstallStage instanceof ChildrenStat);
Assert.assertEquals(1, ((ChildrenStat<?>) isleSpringContextInstallStage).getChildren().size());
ModuleStat moduleStat = (ModuleStat) ((ChildrenStat<?>) isleSpringContextInstallStage).getChildren().get(0);
Assert.assertNotNull(moduleStat);
Assert.assertEquals("testModule", moduleStat.getName());
Assert.assertTrue(moduleStat.getEndTime() > moduleStat.getStartTime());
Assert.assertEquals(moduleStat.getCost(), moduleStat.getEndTime() - moduleStat.getStartTime());
List<BeanStat> beanStats = moduleStat.getChildren();
Assert.assertNotNull(beanStats);
Assert.assertTrue(beanStats.size() >= 4);
// test parent bean
BeanStat parentBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("(parent)")).findFirst().orElse(null);
Assert.assertNotNull(parentBeanStat);
Assert.assertEquals(CHILD_INIT_TIME + PARENT_INIT_TIM, parentBeanStat.getRefreshElapsedTime(), 20);
Assert.assertEquals(PARENT_INIT_TIM, parentBeanStat.getRealRefreshElapsedTime(), 20);
Assert.assertEquals(PARENT_INIT_TIM, parentBeanStat.getAfterPropertiesSetTime(), 20);
Assert.assertEquals(1, parentBeanStat.getChildren().size());
Assert.assertEquals(ParentBean.class.getName() + " (parent)", parentBeanStat.getBeanClassName());
// test child bean
BeanStat childBeanStat = parentBeanStat.getChildren().get(0);
Assert.assertNotNull(childBeanStat);
Assert.assertEquals(CHILD_INIT_TIME, childBeanStat.getRealRefreshElapsedTime(), 15);
Assert.assertEquals(CHILD_INIT_TIME, childBeanStat.getInitTime(), 10);
Assert.assertEquals(0, childBeanStat.getChildren().size());
Assert.assertEquals(ChildBean.class.getName() + " (child)", childBeanStat.getBeanClassName());
// test sofa service
BeanStat serviceBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("ServiceFactoryBean")).findFirst().orElse(null);
Assert.assertNotNull(serviceBeanStat);
Assert.assertTrue(serviceBeanStat.getRefreshElapsedTime() > 0);
Assert.assertEquals(ServiceFactoryBean.class.getName() + " (sample)", serviceBeanStat.getBeanClassName());
Assert.assertEquals("com.alipay.sofa.startup.test.beans.facade.SampleService", serviceBeanStat.getInterfaceType());
// test sofa reference
BeanStat referenceBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("ReferenceFactoryBean")).findFirst().orElse(null);
Assert.assertNotNull(referenceBeanStat);
Assert.assertTrue(referenceBeanStat.getRefreshElapsedTime() > 0);
Assert.assertEquals(ReferenceFactoryBean.class.getName() + " (reference)", referenceBeanStat.getBeanClassName());
Assert.assertEquals("com.alipay.sofa.startup.test.beans.facade.TestService", referenceBeanStat.getInterfaceType());
// test extension bean
BeanStat extensionBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("ExtensionFactoryBean")).findFirst().orElse(null);
Assert.assertNotNull(extensionBeanStat);
Assert.assertTrue(extensionBeanStat.getRefreshElapsedTime() > 0);
Assert.assertEquals(ExtensionFactoryBean.class.getName(), extensionBeanStat.getBeanClassName());
Assert.assertEquals("ExtensionPointTarget: extension", extensionBeanStat.getExtensionProperty());
// test extension point bean
BeanStat extensionPointBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("ExtensionPointFactoryBean")).findFirst().orElse(null);
Assert.assertNotNull(extensionPointBeanStat);
Assert.assertTrue(extensionPointBeanStat.getRefreshElapsedTime() > 0);
Assert.assertEquals(ExtensionPointFactoryBean.class.getName(), extensionPointBeanStat.getBeanClassName());
Assert.assertEquals("ExtensionPointTarget: extension", extensionPointBeanStat.getExtensionProperty());
}
use of com.alipay.sofa.runtime.ext.spring.ExtensionFactoryBean in project sofa-boot by sofastack.
the class IsleCheckStartupReporterTest method testStartupReporter.
@Test
public void testStartupReporter() {
Assert.assertNotNull(startupReporter);
StartupReporter.StartupStaticsModel startupStaticsModel = startupReporter.report();
Assert.assertNotNull(startupStaticsModel);
Assert.assertEquals(7, startupStaticsModel.getStageStats().size());
BaseStat isleModelCreatingStage = startupReporter.getStageNyName(BootStageConstants.ISLE_MODEL_CREATING_STAGE);
Assert.assertNotNull(isleModelCreatingStage);
Assert.assertTrue(isleModelCreatingStage.getCost() > 0);
BaseStat isleSpringContextInstallStage = startupReporter.getStageNyName(BootStageConstants.ISLE_SPRING_CONTEXT_INSTALL_STAGE);
Assert.assertNotNull(isleSpringContextInstallStage);
Assert.assertTrue(isleSpringContextInstallStage.getCost() > 0);
Assert.assertTrue(isleSpringContextInstallStage instanceof ChildrenStat);
Assert.assertEquals(1, ((ChildrenStat<?>) isleSpringContextInstallStage).getChildren().size());
ModuleStat moduleStat = (ModuleStat) ((ChildrenStat<?>) isleSpringContextInstallStage).getChildren().get(0);
Assert.assertNotNull(moduleStat);
Assert.assertEquals("testModule", moduleStat.getName());
Assert.assertTrue(moduleStat.getEndTime() > moduleStat.getStartTime());
Assert.assertEquals(moduleStat.getCost(), moduleStat.getEndTime() - moduleStat.getStartTime());
List<BeanStat> beanStats = moduleStat.getChildren();
Assert.assertNotNull(beanStats);
Assert.assertTrue(beanStats.size() >= 4);
// test parent bean
BeanStat parentBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("(parent)")).findFirst().orElse(null);
Assert.assertNotNull(parentBeanStat);
Assert.assertEquals(CHILD_INIT_TIME + PARENT_INIT_TIM, parentBeanStat.getRefreshElapsedTime(), 20);
Assert.assertEquals(PARENT_INIT_TIM, parentBeanStat.getRealRefreshElapsedTime(), 20);
Assert.assertEquals(PARENT_INIT_TIM, parentBeanStat.getAfterPropertiesSetTime(), 20);
Assert.assertEquals(1, parentBeanStat.getChildren().size());
Assert.assertEquals(ParentBean.class.getName() + " (parent)", parentBeanStat.getBeanClassName());
// test child bean
BeanStat childBeanStat = parentBeanStat.getChildren().get(0);
Assert.assertNotNull(childBeanStat);
Assert.assertEquals(CHILD_INIT_TIME, childBeanStat.getRealRefreshElapsedTime(), 15);
Assert.assertEquals(CHILD_INIT_TIME, childBeanStat.getInitTime(), 10);
Assert.assertEquals(0, childBeanStat.getChildren().size());
Assert.assertEquals(ChildBean.class.getName() + " (child)", childBeanStat.getBeanClassName());
// test sofa service
BeanStat serviceBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("ServiceFactoryBean")).findFirst().orElse(null);
Assert.assertNotNull(serviceBeanStat);
Assert.assertTrue(serviceBeanStat.getRefreshElapsedTime() > 0);
Assert.assertEquals(ServiceFactoryBean.class.getName() + " (sample)", serviceBeanStat.getBeanClassName());
Assert.assertEquals("com.alipay.sofa.startup.test.beans.facade.SampleService", serviceBeanStat.getInterfaceType());
// test sofa reference
BeanStat referenceBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("ReferenceFactoryBean")).findFirst().orElse(null);
Assert.assertNotNull(referenceBeanStat);
Assert.assertTrue(referenceBeanStat.getRefreshElapsedTime() > 0);
Assert.assertEquals(ReferenceFactoryBean.class.getName() + " (reference)", referenceBeanStat.getBeanClassName());
Assert.assertEquals("com.alipay.sofa.startup.test.beans.facade.TestService", referenceBeanStat.getInterfaceType());
// test extension bean
BeanStat extensionBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("ExtensionFactoryBean")).findFirst().orElse(null);
Assert.assertNotNull(extensionBeanStat);
Assert.assertTrue(extensionBeanStat.getRefreshElapsedTime() > 0);
Assert.assertEquals(ExtensionFactoryBean.class.getName(), extensionBeanStat.getBeanClassName());
Assert.assertEquals("ExtensionPointTarget: extension", extensionBeanStat.getExtensionProperty());
// test extension point bean
BeanStat extensionPointBeanStat = beanStats.stream().filter(beanStat -> beanStat.getBeanClassName().contains("ExtensionPointFactoryBean")).findFirst().orElse(null);
Assert.assertNotNull(extensionPointBeanStat);
Assert.assertTrue(extensionPointBeanStat.getRefreshElapsedTime() > 0);
Assert.assertEquals(ExtensionPointFactoryBean.class.getName(), extensionPointBeanStat.getBeanClassName());
Assert.assertEquals("ExtensionPointTarget: extension", extensionPointBeanStat.getExtensionProperty());
}
Aggregations