use of com.alipay.sofa.ark.container.model.BizModel 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.container.model.BizModel in project sofa-ark by alipay.
the class HandleArchiveTest method testIncludeBiz.
@Test
public void testIncludeBiz() {
try {
HandleArchiveStage handleArchiveStage = new HandleArchiveStage();
System.setProperty(BIZ_ACTIVE_INCLUDE, "bizA:1.0.0");
BizModel bizModel = new BizModel();
bizModel.setBizName("bizA").setBizVersion("1.0.0");
Assert.assertFalse(handleArchiveStage.isBizExcluded(bizModel));
bizModel.setBizName("pluginB");
Assert.assertTrue(handleArchiveStage.isBizExcluded(bizModel));
bizModel.setBizName("pluginC");
Assert.assertTrue(handleArchiveStage.isBizExcluded(bizModel));
} finally {
System.clearProperty(BIZ_ACTIVE_INCLUDE);
}
}
use of com.alipay.sofa.ark.container.model.BizModel in project sofa-ark by alipay.
the class HandleArchiveTest method testExcludeBiz.
@Test
public void testExcludeBiz() {
try {
HandleArchiveStage handleArchiveStage = new HandleArchiveStage();
System.setProperty(BIZ_ACTIVE_EXCLUDE, "bizA:1.0.0,bizB:1.0.0");
BizModel bizModel = new BizModel();
bizModel.setBizName("bizA").setBizVersion("1.0.0");
Assert.assertTrue(handleArchiveStage.isBizExcluded(bizModel));
bizModel.setBizName("bizB");
Assert.assertTrue(handleArchiveStage.isBizExcluded(bizModel));
bizModel.setBizName("bizC");
Assert.assertFalse(handleArchiveStage.isBizExcluded(bizModel));
} finally {
System.clearProperty(BIZ_ACTIVE_EXCLUDE);
}
}
use of com.alipay.sofa.ark.container.model.BizModel in project sofa-ark by alipay.
the class HandleArchiveTest method testNoIncludeExcludePlugin.
@Test
public void testNoIncludeExcludePlugin() {
HandleArchiveStage handleArchiveStage = new HandleArchiveStage();
BizModel bizModel = new BizModel();
bizModel.setBizName("bizA").setBizVersion("1.0.0");
Assert.assertFalse(handleArchiveStage.isBizExcluded(bizModel));
bizModel.setBizName("bizB");
Assert.assertFalse(handleArchiveStage.isBizExcluded(bizModel));
}
use of com.alipay.sofa.ark.container.model.BizModel in project sofa-ark by alipay.
the class BizFactoryServiceImpl method createBiz.
@Override
public Biz createBiz(File file) throws IOException {
BizArchive bizArchive;
if (ArkConfigs.isEmbedEnable()) {
File unpackFile = new File(file.getAbsolutePath() + "-unpack");
if (!unpackFile.exists()) {
unpackFile = FileUtils.unzip(file, file.getAbsolutePath() + "-unpack");
}
if (file.exists()) {
file.delete();
}
file = unpackFile;
bizArchive = new ExplodedBizArchive(unpackFile);
} else {
JarFile bizFile = new JarFile(file);
JarFileArchive jarFileArchive = new JarFileArchive(bizFile);
bizArchive = new JarBizArchive(jarFileArchive);
}
BizModel biz = (BizModel) createBiz(bizArchive);
biz.setBizTempWorkDir(file);
return biz;
}
Aggregations