use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class TestSensitiveWordsRecognitionServiceImpl method testRecognize.
@Test
public void testRecognize() {
String text = "我的敏感词包二奶仓井空";
try {
RecognitionResult result = this.sensitiveWordsRecognitionService.recognize(text);
Assert.assertTrue(result.isContainSensitiveWord());
} catch (CloudSDKException e) {
Assert.fail(e.getMessage());
}
}
use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class TestTencentOCRServiceImpl method getTempCredential.
@Test
public void getTempCredential() {
try {
TempCredential tempCredential = ocrService.getTempCredential(30);
Assert.assertNotNull(tempCredential);
} catch (CloudSDKException e) {
Assert.fail(e.getMessage());
}
}
use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class TestCOSObjectStorageServiceImpl method testgenPresignedUploadUrl.
@Test
public void testgenPresignedUploadUrl() {
String objectName = "/pre/testd/test.txt";
URL url = null;
try {
String filePath = TestCOSObjectStorageServiceImpl.class.getClassLoader().getResource("test.txt").getPath();
File localFile = new File(filePath);
String contentMd5 = FileDigestUtils.md5AsBase64(localFile);
long signExpired = 60 * 1000;
url = objectStoreageService.genPresignedUploadUrl(BUCKETNAME, objectName, signExpired, contentMd5);
System.out.println(url.toString());
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.setRequestMethod("PUT");
connection.setRequestProperty("content-md5", contentMd5);
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
FileInputStream fStream = new FileInputStream(localFile);
int bufferSize = 1024;
byte[] buffer = new byte[bufferSize];
int length = -1;
while ((length = fStream.read(buffer)) != -1) {
out.write(buffer, 0, length);
}
fStream.close();
out.close();
int responseCode = connection.getResponseCode();
System.out.println("Service returned response code " + responseCode);
} catch (CloudSDKException e) {
Assert.fail(e.getMessage());
} catch (ProtocolException e) {
Assert.fail(e.getMessage());
} catch (IOException e) {
Assert.fail(e.getMessage());
}
}
use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class TestCOSObjectStorageServiceImpl method testgetObjectMetadata.
@Test
public void testgetObjectMetadata() {
try {
ObjectMetadata objectMetadata = objectStoreageService.getObjectMetadata(BUCKETNAME, OBJECTNAME);
System.out.println(objectMetadata.getContentLength());
} catch (CloudSDKException e) {
Assert.fail(e.getMessage());
}
}
use of com.mizhousoft.cloudsdk.CloudSDKException in project cloud-sdk by mizhousoft.
the class TestQCloudVODServiceImpl method getVideoMeta.
@Test
public void getVideoMeta() {
try {
MediaMeta mediaMeta = vodService.getVideoMeta("5285890786997530566");
Assert.assertNotNull(mediaMeta);
} catch (CloudSDKException e) {
Assert.fail(e.getMessage());
}
}
Aggregations