Search in sources :

Example 21 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class NoneDelegateTestClassLoader method createTestBiz.

private Biz createTestBiz(String bizIdentity) {
    String[] bizNameAndVersion = bizIdentity.split(":");
    if (bizNameAndVersion.length != 2) {
        throw new ArkRuntimeException("error bizIdentity format.");
    }
    BizManagerService bizManagerService = ArkServiceContainerHolder.getContainer().getService(BizManagerService.class);
    Biz testBiz = new BizModel().setBizName(bizNameAndVersion[0]).setBizVersion(bizNameAndVersion[1]).setClassLoader(this).setDenyImportPackages("").setDenyImportClasses("").setDenyImportResources("").setBizState(BizState.RESOLVED);
    bizManagerService.registerBiz(testBiz);
    return testBiz;
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BizModel(com.alipay.sofa.ark.container.model.BizModel) BizManagerService(com.alipay.sofa.ark.spi.service.biz.BizManagerService) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 22 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class BaseTest method registerMockBiz.

protected void registerMockBiz() {
    if (arkContainer == null) {
        String[] args = new String[] { "-Ajar=" + jarURL.toExternalForm() };
        arkContainer = (ArkContainer) ArkContainer.main(args);
    }
    BizManagerService bizManagerService = ArkServiceContainerHolder.getContainer().getService(BizManagerService.class);
    Biz biz = new BizModel().setBizName("mock").setBizVersion("1.0").setClassLoader(this.getClass().getClassLoader()).setDenyImportPackages("").setDenyImportClasses("").setDenyImportResources("").setBizState(BizState.RESOLVED);
    bizManagerService.registerBiz(biz);
    ((BizModel) biz).setBizState(BizState.ACTIVATED);
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BizModel(com.alipay.sofa.ark.container.model.BizModel) BizManagerService(com.alipay.sofa.ark.spi.service.biz.BizManagerService)

Example 23 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class TestClassLoader method createTestBiz.

private Biz createTestBiz(String bizIdentity) {
    String[] bizNameAndVersion = bizIdentity.split(":");
    if (bizNameAndVersion.length != 2) {
        throw new ArkRuntimeException("error bizIdentity format.");
    }
    BizManagerService bizManagerService = ArkServiceContainerHolder.getContainer().getService(BizManagerService.class);
    Biz testBiz = new BizModel().setBizName(bizNameAndVersion[0]).setBizVersion(bizNameAndVersion[1]).setClassLoader(this).setDenyImportPackages("").setDenyImportClasses("").setDenyImportResources("").setBizState(BizState.RESOLVED);
    bizManagerService.registerBiz(testBiz);
    return testBiz;
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BizModel(com.alipay.sofa.ark.container.model.BizModel) BizManagerService(com.alipay.sofa.ark.spi.service.biz.BizManagerService) ArkRuntimeException(com.alipay.sofa.ark.exception.ArkRuntimeException)

Example 24 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class BizCommandProviderTest method testSwitchBiz.

@Test
public void testSwitchBiz() {
    Biz bizA1 = ((MockBiz) bizManagerService.getBizByIdentity("A1:V1")).setBizState(BizState.ACTIVATED);
    Biz bizA2 = ((MockBiz) bizManagerService.getBizByIdentity("A1:V2")).setBizState(BizState.DEACTIVATED);
    Biz bizB1 = ((MockBiz) bizManagerService.getBizByIdentity("B1:V1")).setBizState(BizState.ACTIVATED);
    bizCommandProvider.handleCommand("biz -o A1:V2");
    sleep(200);
    Assert.assertTrue(bizA1.getBizState().equals(BizState.DEACTIVATED));
    Assert.assertTrue(bizA2.getBizState().equals(BizState.ACTIVATED));
    Assert.assertTrue(bizB1.getBizState().equals(BizState.ACTIVATED));
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BaseTest(com.alipay.sofa.ark.container.BaseTest) Test(org.junit.Test)

Example 25 with Biz

use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.

the class BizCommandProviderTest method testUninstallBiz.

@Test
public void testUninstallBiz() {
    Biz bizA1 = ((MockBiz) bizManagerService.getBizByIdentity("A1:V1")).setBizState(BizState.ACTIVATED);
    Biz bizA2 = ((MockBiz) bizManagerService.getBizByIdentity("A1:V2")).setBizState(BizState.DEACTIVATED);
    Biz bizB1 = ((MockBiz) bizManagerService.getBizByIdentity("B1:V1")).setBizState(BizState.ACTIVATED);
    bizCommandProvider.handleCommand("biz -u B1:V1");
    sleep(200);
    Assert.assertTrue(bizA1.getBizState().equals(BizState.ACTIVATED));
    Assert.assertTrue(bizA2.getBizState().equals(BizState.DEACTIVATED));
    Assert.assertNull(bizManagerService.getBizByIdentity("B1:V1"));
}
Also used : Biz(com.alipay.sofa.ark.spi.model.Biz) BaseTest(com.alipay.sofa.ark.container.BaseTest) Test(org.junit.Test)

Aggregations

Biz (com.alipay.sofa.ark.spi.model.Biz)38 Test (org.junit.Test)14 BaseTest (com.alipay.sofa.ark.container.BaseTest)13 BizModel (com.alipay.sofa.ark.container.model.BizModel)12 ArkRuntimeException (com.alipay.sofa.ark.exception.ArkRuntimeException)6 BizManagerService (com.alipay.sofa.ark.spi.service.biz.BizManagerService)6 Plugin (com.alipay.sofa.ark.spi.model.Plugin)5 AfterBizStartupEvent (com.alipay.sofa.ark.spi.event.biz.AfterBizStartupEvent)3 PluginModel (com.alipay.sofa.ark.container.model.PluginModel)2 ExecutableArchive (com.alipay.sofa.ark.spi.archive.ExecutableArchive)2 PluginArchive (com.alipay.sofa.ark.spi.archive.PluginArchive)2 AfterBizSwitchEvent (com.alipay.sofa.ark.spi.event.biz.AfterBizSwitchEvent)2 BeforeBizStartupEvent (com.alipay.sofa.ark.spi.event.biz.BeforeBizStartupEvent)2 BeforeBizSwitchEvent (com.alipay.sofa.ark.spi.event.biz.BeforeBizSwitchEvent)2 BeforePluginStartupEvent (com.alipay.sofa.ark.spi.event.plugin.BeforePluginStartupEvent)2 EventAdminService (com.alipay.sofa.ark.spi.service.event.EventAdminService)2 URL (java.net.URL)2 HashSet (java.util.HashSet)2 MainMethodRunner (com.alipay.sofa.ark.bootstrap.MainMethodRunner)1 OrderComparator (com.alipay.sofa.ark.common.util.OrderComparator)1