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