use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.
the class BizManagerServiceTest method testRemovingAndAddBiz.
@Test
public void testRemovingAndAddBiz() {
Biz adding = new BizModel().setBizName("test-biz-adding").setBizVersion("1.0.0").setBizState(BizState.ACTIVATED);
Biz removing = new BizModel().setBizName("test-biz-removing").setBizVersion("1.0.0").setBizState(BizState.RESOLVED);
bizManagerService.registerBiz(removing);
((BizModel) removing).setBizState(BizState.ACTIVATED);
bizManagerService.removeAndAddBiz(adding, removing);
List<Biz> biz = bizManagerService.getBiz("test-biz-adding");
Assert.assertTrue(biz.size() == 1);
biz = bizManagerService.getBiz("test-biz-removing");
Assert.assertTrue(biz.size() == 0);
bizManagerService.unRegisterBiz(adding.getBizName(), adding.getBizVersion());
}
use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.
the class BizManagerServiceTest method before.
@Before
public void before() {
super.before();
Biz biz = new BizModel().setBizName("test-biz").setBizVersion("1.0.0").setBizState(BizState.RESOLVED);
bizManagerService.registerBiz(biz);
}
use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.
the class BizManagerServiceTest method testUnRegister.
@Test
public void testUnRegister() {
Biz biz = bizManagerService.unRegisterBiz("test-biz", "1.0.1");
Assert.assertNull(biz);
Assert.assertTrue(bizManagerService.getBiz("test-biz").size() == 1);
biz = bizManagerService.unRegisterBizStrictly("test-biz", "1.0.0");
Assert.assertNotNull(biz);
Assert.assertTrue(bizManagerService.getBiz("test-biz").size() == 0);
bizManagerService.registerBiz(biz);
Assert.assertTrue(bizManagerService.getBiz("test-biz").size() == 1);
}
use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.
the class ClassLoaderServiceTest method testIsDeniedImportClass.
@Test
public void testIsDeniedImportClass() {
Biz biz = new BizModel().setBizName("mockBiz").setBizVersion("1.0.0").setDenyImportPackages("a.c, a.b.c.*, a.b.c").setDenyImportClasses("").setBizState(BizState.RESOLVED);
bizManagerService.registerBiz(biz);
AssertUtils.isFalse(classloaderService.isDeniedImportClass(biz.getIdentity(), "a.c"), "Exception error");
AssertUtils.isTrue(classloaderService.isDeniedImportClass(biz.getIdentity(), "a.c.E"), "Exception error");
AssertUtils.isFalse(classloaderService.isDeniedImportClass(biz.getIdentity(), "a.c.e.G"), "Exception error");
AssertUtils.isTrue(classloaderService.isDeniedImportClass(biz.getIdentity(), "a.b.c.E"), "Exception error");
AssertUtils.isTrue(classloaderService.isDeniedImportClass(biz.getIdentity(), "a.b.c.e.G"), "Exception error");
AssertUtils.isFalse(classloaderService.isDeniedImportClass(biz.getIdentity(), "a.b.c"), "Exception error");
}
use of com.alipay.sofa.ark.spi.model.Biz in project sofa-ark by alipay.
the class ArkClient method uninstallBiz.
/**
* Uninstall biz.
*
* @param bizName
* @param bizVersion
* @return
* @throws Throwable
*/
public static ClientResponse uninstallBiz(String bizName, String bizVersion) throws Throwable {
AssertUtils.assertNotNull(bizFactoryService, "bizFactoryService must not be null!");
AssertUtils.assertNotNull(bizManagerService, "bizFactoryService must not be null!");
AssertUtils.assertNotNull(bizName, "bizName must not be null!");
AssertUtils.assertNotNull(bizVersion, "bizVersion must not be null!");
// ignore when uninstall master biz
if (bizName.equals(ArkConfigs.getStringValue(Constants.MASTER_BIZ))) {
return new ClientResponse().setCode(ResponseCode.FAILED).setMessage("Master biz must not be uninstalled.");
}
Biz biz = bizManagerService.getBiz(bizName, bizVersion);
ClientResponse response = new ClientResponse().setCode(ResponseCode.NOT_FOUND_BIZ).setMessage(String.format("Uninstall biz: %s not found.", BizIdentityUtils.generateBizIdentity(bizName, bizVersion)));
if (biz != null) {
try {
biz.stop();
} catch (Throwable throwable) {
LOGGER.error(String.format("UnInstall Biz: %s fail.", biz.getIdentity()), throwable);
throw throwable;
} finally {
bizManagerService.unRegisterBizStrictly(biz.getBizName(), biz.getBizVersion());
}
response.setCode(ResponseCode.SUCCESS).setMessage(String.format("Uninstall biz: %s success.", biz.getIdentity()));
}
LOGGER.info(response.getMessage());
return response;
}
Aggregations