use of com.alipay.sofa.ark.api.ClientResponse in project sofa-ark by alipay.
the class ArkClientTest method testCheckBiz.
@Test
public void testCheckBiz() throws Throwable {
testInstallBiz();
// test check all biz
ClientResponse response = ArkClient.checkBiz();
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
Assert.assertEquals(3, response.getBizInfos().size());
// test check specified bizName
response = ArkClient.checkBiz("biz-demo");
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
Assert.assertEquals(3, response.getBizInfos().size());
// test check specified bizName and version
response = ArkClient.checkBiz("biz-demo", "2.0.0");
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
Assert.assertEquals(1, response.getBizInfos().size());
response = ArkClient.checkBiz("biz-demo", "3.0.0");
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
Assert.assertEquals(1, response.getBizInfos().size());
response = ArkClient.checkBiz("biz-demo", "4.0.0");
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
Assert.assertEquals(0, response.getBizInfos().size());
}
use of com.alipay.sofa.ark.api.ClientResponse in project sofa-ark by alipay.
the class ArkClientTest method testInstallBiz.
@Test
public void testInstallBiz() throws Throwable {
ClientResponse response = ArkClient.checkBiz();
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
Assert.assertEquals(0, response.getBizInfos().size());
// test install
File bizFile = ArkClient.createBizSaveFile("biz-demo", "1.0.0");
FileUtils.copyInputStreamToFile(bizUrl1.openStream(), bizFile);
response = ArkClient.installBiz(bizFile);
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
BizInfo bizInfo = response.getBizInfos().iterator().next();
Assert.assertEquals(BizState.ACTIVATED, bizInfo.getBizState());
// test install biz with same bizName and bizVersion
// test install
File bizFile1 = ArkClient.createBizSaveFile("biz-demo", "1.0.0");
FileUtils.copyInputStreamToFile(bizUrl1.openStream(), bizFile1);
response = ArkClient.installBiz(bizFile1);
Assert.assertEquals(ResponseCode.REPEAT_BIZ, response.getCode());
// test install biz with same bizName and different bizVersion
// response = ArkClient.installBiz(new File(bizUrl2.getFile()));
File bizFile2 = ArkClient.createBizSaveFile("biz-demo", "2.0.0");
FileUtils.copyInputStreamToFile(bizUrl2.openStream(), bizFile2);
response = ArkClient.installBiz(bizFile2);
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
bizInfo = response.getBizInfos().iterator().next();
Assert.assertEquals(BizState.DEACTIVATED, bizInfo.getBizState());
// test install biz with same bizName and different bizVersion and active latest
System.setProperty(Constants.ACTIVATE_NEW_MODULE, "true");
System.setProperty(Constants.EMBED_ENABLE, "true");
File bizFile3 = ArkClient.createBizSaveFile("biz-demo", "3.0.0");
FileUtils.copyInputStreamToFile(bizUrl3.openStream(), bizFile3);
response = ArkClient.installBiz(bizFile3);
System.setProperty(Constants.ACTIVATE_NEW_MODULE, "");
System.setProperty(Constants.EMBED_ENABLE, "");
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
bizInfo = response.getBizInfos().iterator().next();
Assert.assertEquals(BizState.ACTIVATED, bizInfo.getBizState());
}
use of com.alipay.sofa.ark.api.ClientResponse in project sofa-ark by alipay.
the class ArkClientTest method testUninstallBiz.
@Test
public void testUninstallBiz() throws Throwable {
testCheckBiz();
// test uninstall biz
ClientResponse response = ArkClient.uninstallBiz("biz-demo", "1.0.0");
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
// test check all biz
response = ArkClient.checkBiz();
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
Assert.assertEquals(2, response.getBizInfos().size());
}
use of com.alipay.sofa.ark.api.ClientResponse in project sofa-ark by alipay.
the class ArkClientTest method testSwitchBiz.
public void testSwitchBiz() throws Throwable {
testUninstallBiz();
// test switch biz
ClientResponse response = ArkClient.installBiz(new File(bizUrl1.getFile()));
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
BizInfo bizInfo = response.getBizInfos().iterator().next();
Assert.assertEquals(BizState.ACTIVATED, bizInfo.getBizState());
response = ArkClient.checkBiz("biz-demo", "2.0.0");
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
Assert.assertEquals(1, response.getBizInfos().size());
bizInfo = response.getBizInfos().iterator().next();
Assert.assertEquals(BizState.DEACTIVATED, bizInfo.getBizState());
response = ArkClient.switchBiz("biz-demo", "2.0.0");
Assert.assertEquals(ResponseCode.SUCCESS, response.getCode());
response = ArkClient.switchBiz("biz-demo", "3.0.0");
Assert.assertEquals(ResponseCode.NOT_FOUND_BIZ, response.getCode());
response = ArkClient.checkBiz("biz-demo", "2.0.0");
bizInfo = response.getBizInfos().iterator().next();
Assert.assertEquals(BizState.ACTIVATED, bizInfo.getBizState());
response = ArkClient.checkBiz("biz-demo", "1.0.0");
bizInfo = response.getBizInfos().iterator().next();
Assert.assertEquals(BizState.DEACTIVATED, bizInfo.getBizState());
// Uninstall biz
ArkClient.uninstallBiz("biz-demo", "1.0.0");
ArkClient.uninstallBiz("biz-demo", "2.0.0");
}
Aggregations