diff --git a/LICENSE.txt b/LICENSE old mode 100755 new mode 100644 similarity index 100% rename from LICENSE.txt rename to LICENSE diff --git a/pom.xml b/pom.xml index fb45daa7..92aa3ed1 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidubce bce-java-sdk - 0.10.15 + 0.10.16 bce-sdk-java The BCE SDK for Java provides Java APIs for all of BCE services. http://bce.baidu.com/sdk/index.html diff --git a/src/main/assembly/package.xml b/src/main/assembly/package.xml old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/AbstractBceClient.java b/src/main/java/com/baidubce/AbstractBceClient.java old mode 100755 new mode 100644 index 896f38ab..c8065049 --- a/src/main/java/com/baidubce/AbstractBceClient.java +++ b/src/main/java/com/baidubce/AbstractBceClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/BceClientConfiguration.java b/src/main/java/com/baidubce/BceClientConfiguration.java old mode 100755 new mode 100644 index 9ee5c0da..e100b41e --- a/src/main/java/com/baidubce/BceClientConfiguration.java +++ b/src/main/java/com/baidubce/BceClientConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/BceClientException.java b/src/main/java/com/baidubce/BceClientException.java old mode 100755 new mode 100644 index 9b1633c0..376180a3 --- a/src/main/java/com/baidubce/BceClientException.java +++ b/src/main/java/com/baidubce/BceClientException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/BceConstants.java b/src/main/java/com/baidubce/BceConstants.java old mode 100755 new mode 100644 index 54d4c160..e3a20f08 --- a/src/main/java/com/baidubce/BceConstants.java +++ b/src/main/java/com/baidubce/BceConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -16,5 +16,5 @@ * Common constants used by the whole SDK. */ public class BceConstants { - public static final String VERSION = "0.10.15"; + public static final String VERSION = "0.10.16"; } diff --git a/src/main/java/com/baidubce/BceErrorResponse.java b/src/main/java/com/baidubce/BceErrorResponse.java old mode 100755 new mode 100644 index 3576e42a..ef59af8c --- a/src/main/java/com/baidubce/BceErrorResponse.java +++ b/src/main/java/com/baidubce/BceErrorResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/BceResponseMetadata.java b/src/main/java/com/baidubce/BceResponseMetadata.java old mode 100755 new mode 100644 index f2b14dba..c9ae84b6 --- a/src/main/java/com/baidubce/BceResponseMetadata.java +++ b/src/main/java/com/baidubce/BceResponseMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/BceServiceException.java b/src/main/java/com/baidubce/BceServiceException.java old mode 100755 new mode 100644 index 8e6f6d7b..14ca1158 --- a/src/main/java/com/baidubce/BceServiceException.java +++ b/src/main/java/com/baidubce/BceServiceException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/ErrorCode.java b/src/main/java/com/baidubce/ErrorCode.java old mode 100755 new mode 100644 index 58a39bba..b5b5a2d2 --- a/src/main/java/com/baidubce/ErrorCode.java +++ b/src/main/java/com/baidubce/ErrorCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/Protocol.java b/src/main/java/com/baidubce/Protocol.java old mode 100755 new mode 100644 index dbdda219..198d5748 --- a/src/main/java/com/baidubce/Protocol.java +++ b/src/main/java/com/baidubce/Protocol.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/Region.java b/src/main/java/com/baidubce/Region.java old mode 100755 new mode 100644 index fcc2d344..431df0a4 --- a/src/main/java/com/baidubce/Region.java +++ b/src/main/java/com/baidubce/Region.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/auth/BceCredentials.java b/src/main/java/com/baidubce/auth/BceCredentials.java old mode 100755 new mode 100644 index 9bc48af8..ee3a08bd --- a/src/main/java/com/baidubce/auth/BceCredentials.java +++ b/src/main/java/com/baidubce/auth/BceCredentials.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/auth/BceSessionCredentials.java b/src/main/java/com/baidubce/auth/BceSessionCredentials.java old mode 100755 new mode 100644 index a401ee4e..a8300070 --- a/src/main/java/com/baidubce/auth/BceSessionCredentials.java +++ b/src/main/java/com/baidubce/auth/BceSessionCredentials.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/auth/BceV1Signer.java b/src/main/java/com/baidubce/auth/BceV1Signer.java old mode 100755 new mode 100644 index 4bb4d6d0..55919331 --- a/src/main/java/com/baidubce/auth/BceV1Signer.java +++ b/src/main/java/com/baidubce/auth/BceV1Signer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/auth/DefaultBceCredentials.java b/src/main/java/com/baidubce/auth/DefaultBceCredentials.java old mode 100755 new mode 100644 index 5eae98bf..06911c0b --- a/src/main/java/com/baidubce/auth/DefaultBceCredentials.java +++ b/src/main/java/com/baidubce/auth/DefaultBceCredentials.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/auth/DefaultBceSessionCredentials.java b/src/main/java/com/baidubce/auth/DefaultBceSessionCredentials.java old mode 100755 new mode 100644 index 1f530567..4c9eceb1 --- a/src/main/java/com/baidubce/auth/DefaultBceSessionCredentials.java +++ b/src/main/java/com/baidubce/auth/DefaultBceSessionCredentials.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/auth/SignOptions.java b/src/main/java/com/baidubce/auth/SignOptions.java old mode 100755 new mode 100644 index 5c6db8e8..aa722819 --- a/src/main/java/com/baidubce/auth/SignOptions.java +++ b/src/main/java/com/baidubce/auth/SignOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/auth/Signer.java b/src/main/java/com/baidubce/auth/Signer.java old mode 100755 new mode 100644 index 75491ebb..4fcb01fc --- a/src/main/java/com/baidubce/auth/Signer.java +++ b/src/main/java/com/baidubce/auth/Signer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/BceCloseableHttpResponse.java b/src/main/java/com/baidubce/http/BceCloseableHttpResponse.java old mode 100755 new mode 100644 index 3faa63fa..957efe13 --- a/src/main/java/com/baidubce/http/BceCloseableHttpResponse.java +++ b/src/main/java/com/baidubce/http/BceCloseableHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/BceHttpClient.java b/src/main/java/com/baidubce/http/BceHttpClient.java old mode 100755 new mode 100644 index 531ba03a..fe304962 --- a/src/main/java/com/baidubce/http/BceHttpClient.java +++ b/src/main/java/com/baidubce/http/BceHttpClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/BceHttpResponse.java b/src/main/java/com/baidubce/http/BceHttpResponse.java old mode 100755 new mode 100644 index 437e8a1d..22f825f2 --- a/src/main/java/com/baidubce/http/BceHttpResponse.java +++ b/src/main/java/com/baidubce/http/BceHttpResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/DefaultRetryPolicy.java b/src/main/java/com/baidubce/http/DefaultRetryPolicy.java old mode 100755 new mode 100644 index e13edff8..15a94986 --- a/src/main/java/com/baidubce/http/DefaultRetryPolicy.java +++ b/src/main/java/com/baidubce/http/DefaultRetryPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -138,13 +138,17 @@ protected boolean shouldRetry(BceClientException exception, int retriesAttempted BceServiceException e = (BceServiceException) exception; /* - * For 500 internal server errors and 503 service unavailable errors, we want to retry, but we need to use + * For 500 internal server errors and 503 service unavailable errors and 502 service bad gateway, we want to retry, but we need to use * an exponential back-off strategy so that we don't overload a server with a flood of retries. */ if (e.getStatusCode() == HttpStatus.SC_INTERNAL_SERVER_ERROR) { logger.debug("Retry for internal server error."); return true; } + if (e.getStatusCode() == HttpStatus.SC_BAD_GATEWAY) { + logger.debug("Retry for bad gateway."); + return true; + } if (e.getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE) { logger.debug("Retry for service unavailable."); return true; diff --git a/src/main/java/com/baidubce/http/Headers.java b/src/main/java/com/baidubce/http/Headers.java old mode 100755 new mode 100644 index dbd3a269..43ff887a --- a/src/main/java/com/baidubce/http/Headers.java +++ b/src/main/java/com/baidubce/http/Headers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -47,6 +47,8 @@ public interface Headers { public static final String LAST_MODIFIED = "Last-Modified"; + public static final String LOCATION = "Location"; + public static final String RANGE = "Range"; public static final String SERVER = "Server"; @@ -54,7 +56,7 @@ public interface Headers { public static final String TRANSFER_ENCODING = "Transfer-Encoding"; public static final String USER_AGENT = "User-Agent"; - + /* * BCE Common HTTP Headers @@ -66,22 +68,36 @@ public interface Headers { public static final String BCE_COPY_METADATA_DIRECTIVE = "x-bce-metadata-directive"; - public static final String BCE_COPY_SOURCE = "x-bce-copy-source"; - public static final String BCE_COPY_SOURCE_IF_MATCH = "x-bce-copy-source-if-match"; public static final String BCE_DATE = "x-bce-date"; - public static final String BCE_DEBUG_ID = "x-bce-debug-id"; - public static final String BCE_PREFIX = "x-bce-"; public static final String BCE_REQUEST_ID = "x-bce-request-id"; public static final String BCE_SECURITY_TOKEN = "x-bce-security-token"; - public static final String BCE_STORAGE_CLASS = "x-bce-storage-class"; - public static final String BCE_USER_METADATA_PREFIX = "x-bce-meta-"; + /* + * BOS HTTP Headers + */ + + public static final String BCE_COPY_SOURCE = "x-bce-copy-source"; + + public static final String BCE_COPY_SOURCE_IF_MODIFIED_SINCE = "x-bce-copy-source-if-modified-since"; + + public static final String BCE_COPY_SOURCE_IF_NONE_MATCH = "x-bce-copy-source-if-none-match"; + + public static final String BCE_COPY_SOURCE_IF_UNMODIFIED_SINCE = "x-bce-copy-source-if-unmodified-since"; + + public static final String BCE_DEBUG_ID = "x-bce-debug-id"; + + public static final String BCE_NEXT_APPEND_OFFSET = "x-bce-next-append-offset"; + + public static final String BCE_OBJECT_TYPE = "x-bce-object-type"; + + public static final String BCE_STORAGE_CLASS = "x-bce-storage-class"; + } diff --git a/src/main/java/com/baidubce/http/HttpMethodName.java b/src/main/java/com/baidubce/http/HttpMethodName.java old mode 100755 new mode 100644 index db4b3bb1..f71fb398 --- a/src/main/java/com/baidubce/http/HttpMethodName.java +++ b/src/main/java/com/baidubce/http/HttpMethodName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/IdleConnectionReaper.java b/src/main/java/com/baidubce/http/IdleConnectionReaper.java old mode 100755 new mode 100644 index c25b9949..e1c12234 --- a/src/main/java/com/baidubce/http/IdleConnectionReaper.java +++ b/src/main/java/com/baidubce/http/IdleConnectionReaper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/RetryPolicy.java b/src/main/java/com/baidubce/http/RetryPolicy.java old mode 100755 new mode 100644 index 29c3f704..96359d32 --- a/src/main/java/com/baidubce/http/RetryPolicy.java +++ b/src/main/java/com/baidubce/http/RetryPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/StatusCodes.java b/src/main/java/com/baidubce/http/StatusCodes.java old mode 100755 new mode 100644 index 7adeb9b3..5a5a8641 --- a/src/main/java/com/baidubce/http/StatusCodes.java +++ b/src/main/java/com/baidubce/http/StatusCodes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/handler/BceErrorResponseHandler.java b/src/main/java/com/baidubce/http/handler/BceErrorResponseHandler.java old mode 100755 new mode 100644 index 6974ce96..83b2fef4 --- a/src/main/java/com/baidubce/http/handler/BceErrorResponseHandler.java +++ b/src/main/java/com/baidubce/http/handler/BceErrorResponseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/handler/BceJsonResponseHandler.java b/src/main/java/com/baidubce/http/handler/BceJsonResponseHandler.java old mode 100755 new mode 100644 index 22f7247b..3d1c5242 --- a/src/main/java/com/baidubce/http/handler/BceJsonResponseHandler.java +++ b/src/main/java/com/baidubce/http/handler/BceJsonResponseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/handler/BceMetadataResponseHandler.java b/src/main/java/com/baidubce/http/handler/BceMetadataResponseHandler.java old mode 100755 new mode 100644 index 2e12d31f..fca8b38a --- a/src/main/java/com/baidubce/http/handler/BceMetadataResponseHandler.java +++ b/src/main/java/com/baidubce/http/handler/BceMetadataResponseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/http/handler/HttpResponseHandler.java b/src/main/java/com/baidubce/http/handler/HttpResponseHandler.java old mode 100755 new mode 100644 index 41d72971..888780db --- a/src/main/java/com/baidubce/http/handler/HttpResponseHandler.java +++ b/src/main/java/com/baidubce/http/handler/HttpResponseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/internal/InternalRequest.java b/src/main/java/com/baidubce/internal/InternalRequest.java old mode 100755 new mode 100644 index bcb12643..17ecaab3 --- a/src/main/java/com/baidubce/internal/InternalRequest.java +++ b/src/main/java/com/baidubce/internal/InternalRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/internal/RestartableFileInputStream.java b/src/main/java/com/baidubce/internal/RestartableFileInputStream.java old mode 100755 new mode 100644 index 2ed9fa2d..e2b6c848 --- a/src/main/java/com/baidubce/internal/RestartableFileInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableFileInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/internal/RestartableInputStream.java b/src/main/java/com/baidubce/internal/RestartableInputStream.java old mode 100755 new mode 100644 index 6c6c3ba9..abb1da62 --- a/src/main/java/com/baidubce/internal/RestartableInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/internal/RestartableMultiByteArrayInputStream.java b/src/main/java/com/baidubce/internal/RestartableMultiByteArrayInputStream.java old mode 100755 new mode 100644 index 3a12c497..0b40d8ab --- a/src/main/java/com/baidubce/internal/RestartableMultiByteArrayInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableMultiByteArrayInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/internal/RestartableNonResettableInputStream.java b/src/main/java/com/baidubce/internal/RestartableNonResettableInputStream.java old mode 100755 new mode 100644 index a60b2f03..569df535 --- a/src/main/java/com/baidubce/internal/RestartableNonResettableInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableNonResettableInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/internal/RestartableResettableInputStream.java b/src/main/java/com/baidubce/internal/RestartableResettableInputStream.java old mode 100755 new mode 100644 index aa2d62af..764ecd65 --- a/src/main/java/com/baidubce/internal/RestartableResettableInputStream.java +++ b/src/main/java/com/baidubce/internal/RestartableResettableInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/model/AbstractBceRequest.java b/src/main/java/com/baidubce/model/AbstractBceRequest.java old mode 100755 new mode 100644 index bee87945..ca0121b7 --- a/src/main/java/com/baidubce/model/AbstractBceRequest.java +++ b/src/main/java/com/baidubce/model/AbstractBceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/model/AbstractBceResponse.java b/src/main/java/com/baidubce/model/AbstractBceResponse.java old mode 100755 new mode 100644 index c2de99b1..5825c532 --- a/src/main/java/com/baidubce/model/AbstractBceResponse.java +++ b/src/main/java/com/baidubce/model/AbstractBceResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/model/GenericAccountRequest.java b/src/main/java/com/baidubce/model/GenericAccountRequest.java old mode 100755 new mode 100644 index 7169d6c6..fed1401a --- a/src/main/java/com/baidubce/model/GenericAccountRequest.java +++ b/src/main/java/com/baidubce/model/GenericAccountRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/model/User.java b/src/main/java/com/baidubce/model/User.java old mode 100755 new mode 100644 index 5e105c99..bfdf07f1 --- a/src/main/java/com/baidubce/model/User.java +++ b/src/main/java/com/baidubce/model/User.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/batch/BatchClient.java b/src/main/java/com/baidubce/services/batch/BatchClient.java new file mode 100644 index 00000000..c4ec5cf9 --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/BatchClient.java @@ -0,0 +1,275 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.auth.SignOptions; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.batch.model.CancelJobRequest; +import com.baidubce.services.batch.model.CreateJobRequest; +import com.baidubce.services.batch.model.CreateJobResponse; +import com.baidubce.services.batch.model.GetJobRequest; +import com.baidubce.services.batch.model.GetJobResponse; +import com.baidubce.services.batch.model.ListJobsRequest; +import com.baidubce.services.batch.model.ListJobsResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.fasterxml.jackson.core.JsonGenerator; + +import java.io.IOException; +import java.io.StringWriter; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; + +import static com.baidubce.util.Validate.checkIsTrue; +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Baidu Batch-Compute service. + */ +public class BatchClient extends AbstractBceClient { + private static final String VERSION = "v1"; + private static final String JOB = "job"; + private static final String[] HEADERS_TO_SIGN = {"host", "x-bce-date"}; + + /** + * Responsible for handling HttpResponse from all Batch-Compute service calls. + */ + private static final HttpResponseHandler[] BATCH_HANDLERS = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on Batch-Compute. + */ + public BatchClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new client using the client configuration to access Batch-Compute. + * + * @param clientConfiguration The BCE client configuration options. + */ + public BatchClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, BATCH_HANDLERS); + } + + /** + * List Batch-Compute jobs owned by the authenticated user. + *

+ *

+ * Users must authenticate with a valid BCE Access Key ID, and the response + * contains all the Batch-Compute jobs owned by the user. + * + * @param request The request containing valid query parameters. + * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the request. + */ + public ListJobsResponse listJobs(ListJobsRequest request) { + checkNotNull(request, "request should not be null."); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, JOB); + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() >= 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + + return this.invokeHttpClient(internalRequest, ListJobsResponse.class); + } + + /** + * List Batch-Compute jobs owned by the authenticated user. + * + * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the request. + */ + public ListJobsResponse listJobs() { + return listJobs(new ListJobsRequest()); + } + + /** + * List Batch-Compute jobs owned by the authenticated user. + * + * @param maxKeys The maximum number of jobs returned. + * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the request. + * And the size of list is limited below maxKeys. + */ + public ListJobsResponse listJobs(int maxKeys) { + return listJobs(new ListJobsRequest().withMaxKeys(maxKeys)); + } + + /** + * List Batch-Compute jobs owned by the authenticated user. + * + * @param marker The start record of jobs. + * @param maxKeys The maximum number of jobs returned. + * @return The response containing a list of the Batch-Compute jobs owned by the authenticated sender of the request. + * The jobs' records start from the marker and the size of list is limited below maxKeys. + */ + public ListJobsResponse listJobs(String marker, int maxKeys) { + return listJobs(new ListJobsRequest().withMaxKeys(maxKeys).withMarker(marker)); + } + + /** + * Describe the detail information of the target job. + * + * @param request The request object containing the ID of the target job. + * @return response containing the detail information of the target job. + */ + public GetJobResponse getJob(GetJobRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getJobId(), "The parameter jobId should not be null or empty string."); + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, JOB, request.getJobId()); + + return this.invokeHttpClient(internalRequest, GetJobResponse.class); + } + + /** + * Describe the detail information of the target job. + * + * @param jobId The ID of the target job. + * @return The response containing the detail information of the target job. + */ + public GetJobResponse getJob(String jobId) { + return getJob(new GetJobRequest().withJobId(jobId)); + } + + /** + * Create a Batch-Compute job with the specified options. + * + * @param request The request containing all options for creating a Batch-Compute job. + * @return The response containing the ID of the newly created job. + */ + public CreateJobResponse createJob(CreateJobRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getName(), "The name should not be null or empty string."); + checkStringNotEmpty(request.getVmType(), "The vmType should not be null or empty string."); + checkStringNotEmpty(request.getJobDagJson(), "The jobDagJson should not be null or empty string."); + checkIsTrue(request.getVmCount() > 0, "The vmCount should greater than 0"); + + StringWriter writer = new StringWriter(); + try { + JsonGenerator jsonGenerator = JsonUtils.jsonGeneratorOf(writer); + jsonGenerator.writeStartObject(); + jsonGenerator.writeStringField("name", request.getName()); + jsonGenerator.writeStringField("vmType", request.getVmType()); + jsonGenerator.writeNumberField("vmCount", request.getVmCount()); + jsonGenerator.writeStringField("jobDagJson", request.getJobDagJson()); + if (request.getJobTimeoutInSeconds() != null) { + jsonGenerator.writeNumberField("jobTimeoutInSeconds", request.getJobTimeoutInSeconds()); + } + if (request.getMemo() != null) { + jsonGenerator.writeStringField("memo", request.getMemo()); + } + jsonGenerator.writeEndObject(); + jsonGenerator.close(); + } catch (IOException e) { + throw new BceClientException("Fail to generate json", e); + } + + byte[] json = null; + try { + json = writer.toString().getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get UTF-8 bytes", e); + } + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, JOB); + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(json.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, "application/json"); + internalRequest.setContent(RestartableInputStream.wrap(json)); + + internalRequest.addParameter("run", "immediate"); + if (request.getClientToken() != null) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + + return this.invokeHttpClient(internalRequest, CreateJobResponse.class); + } + + /** + * Cancel a Batch-Compute job. + * + * @param request The request containing the ID of the job to be cancelled. + */ + public void cancelJob(CancelJobRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getJobId(), "The parameter jobId should not be null or empty string."); + + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, JOB, request.getJobId()); + internalRequest.addParameter("cancel", null); + + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Cancel a Batch-Compute job. + * + * @param jobId The ID of the job to be cancelled. + */ + public void cancelJob(String jobId) { + cancelJob(new CancelJobRequest().withJobId(jobId)); + } + + /** + * Creates and initializes a new request object for the specified resource. + * + * @param bceRequest The original BCE request created by the user. + * @param httpMethod The HTTP method to use when sending the request. + * @param pathVariables The optional variables used in the URI path. + * @return A new request object populated with endpoint, resource path and specific + * parameters to send. + */ + private InternalRequest createRequest( + AbstractBceRequest bceRequest, HttpMethodName httpMethod, String... pathVariables) { + List path = new ArrayList(); + path.add(VERSION); + + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + path.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(this.getEndpoint(), path.toArray(new String[path.size()])); + InternalRequest request = new InternalRequest(httpMethod, uri); + SignOptions signOptions = new SignOptions(); + signOptions.setHeadersToSign(new HashSet(Arrays.asList(HEADERS_TO_SIGN))); + request.setSignOptions(signOptions); + request.setCredentials(bceRequest.getRequestCredentials()); + + return request; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/batch/model/CancelJobRequest.java b/src/main/java/com/baidubce/services/batch/model/CancelJobRequest.java new file mode 100644 index 00000000..863d3219 --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/model/CancelJobRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Provides options for canceling Batch-Compute job. + */ +public class CancelJobRequest extends AbstractBceRequest { + private String jobId; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + /** + * Configure the job ID for the request. + * + * @param jobId The ID of job that to be cancelled. + * @return CancelJobRequest + */ + public CancelJobRequest withJobId(String jobId) { + this.setJobId(jobId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CancelJobRequest + */ + public CancelJobRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/batch/model/CreateJobRequest.java b/src/main/java/com/baidubce/services/batch/model/CreateJobRequest.java new file mode 100644 index 00000000..9ba234cd --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/model/CreateJobRequest.java @@ -0,0 +1,137 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Provides options for creating a Batch-Compute job. + */ +public class CreateJobRequest extends AbstractBceRequest { + private String clientToken; + private String name; + private String vmType; + private int vmCount; + private String jobDagJson; + private Integer jobTimeoutInSeconds; + private String memo; + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVmType() { + return vmType; + } + + public void setVmType(String vmType) { + this.vmType = vmType; + } + + public int getVmCount() { + return vmCount; + } + + public void setVmCount(int vmCount) { + this.vmCount = vmCount; + } + + public String getJobDagJson() { + return jobDagJson; + } + + public void setJobDagJson(String jobDagJson) { + this.jobDagJson = jobDagJson; + } + + public Integer getJobTimeoutInSeconds() { + return jobTimeoutInSeconds; + } + + public void setJobTimeoutInSeconds(Integer jobTimeoutInSeconds) { + this.jobTimeoutInSeconds = jobTimeoutInSeconds; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } + + /** + * Configure optional client token for the request. The request will be idempotent if client token is provided. + * + * @param clientToken An ASCII string whose length is less than 64. + * @return CreateJobRequest + */ + public CreateJobRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + public CreateJobRequest withName(String name) { + this.setName(name); + return this; + } + + public CreateJobRequest withVmType(String vmType) { + this.setVmType(vmType); + return this; + } + + public CreateJobRequest withVmCount(int vmCount) { + this.setVmCount(vmCount); + return this; + } + + public CreateJobRequest withJobDagJson(String jobDagJson) { + this.setJobDagJson(jobDagJson); + return this; + } + + public CreateJobRequest withJobTimeoutInSeconds(Integer jobTimeoutInSeconds) { + this.setJobTimeoutInSeconds(jobTimeoutInSeconds); + return this; + } + + public CreateJobRequest withMemo(String memo) { + this.setMemo(memo); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateJobRequest + */ + public CreateJobRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/batch/model/CreateJobResponse.java b/src/main/java/com/baidubce/services/batch/model/CreateJobResponse.java new file mode 100644 index 00000000..9b72ee69 --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/model/CreateJobResponse.java @@ -0,0 +1,35 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the response for the CreateJobRequest. + *

+ * The response contains the ID of the newly created job. + */ +public class CreateJobResponse extends AbstractBceResponse { + /** + * The ID of newly created job. + */ + private String jobId; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } +} diff --git a/src/main/java/com/baidubce/services/batch/model/GetJobRequest.java b/src/main/java/com/baidubce/services/batch/model/GetJobRequest.java new file mode 100644 index 00000000..8acc33a1 --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/model/GetJobRequest.java @@ -0,0 +1,53 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Provides option for describing a Batch-Compute Job. The essential option is job ID. + */ +public class GetJobRequest extends AbstractBceRequest { + private String jobId; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + /** + * Configure the job ID for the request. + * + * @param jobId The ID of Batch-Compute job. + * @return GetJobRequest + */ + public GetJobRequest withJobId(String jobId) { + this.setJobId(jobId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetJobRequest + */ + public GetJobRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/batch/model/GetJobResponse.java b/src/main/java/com/baidubce/services/batch/model/GetJobResponse.java new file mode 100644 index 00000000..b6cb0fb0 --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/model/GetJobResponse.java @@ -0,0 +1,31 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the response of GetJobRequest. + */ +public class GetJobResponse extends AbstractBceResponse { + + Job job; + + public Job getJob() { + return job; + } + + public void setJob(Job job) { + this.job = job; + } +} diff --git a/src/main/java/com/baidubce/services/batch/model/Job.java b/src/main/java/com/baidubce/services/batch/model/Job.java new file mode 100644 index 00000000..18467bd9 --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/model/Job.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch.model; + +import java.util.Date; + +/** + * Represent a Batch-Compute Job. + */ +public class Job { + private String jobId; + private String jobState; + private JobDescription jobDescription; + private Date jobStartTime; + private Date jobEndTime; + + public String getJobId() { + return jobId; + } + + public void setJobId(String jobId) { + this.jobId = jobId; + } + + public String getJobState() { + return jobState; + } + + public void setJobState(String jobState) { + this.jobState = jobState; + } + + public JobDescription getJobDescription() { + return jobDescription; + } + + public void setJobDescription(JobDescription jobDescription) { + this.jobDescription = jobDescription; + } + + public Date getJobStartTime() { + return jobStartTime; + } + + public void setJobStartTime(Date jobStartTime) { + this.jobStartTime = jobStartTime; + } + + public Date getJobEndTime() { + return jobEndTime; + } + + public void setJobEndTime(Date jobEndTime) { + this.jobEndTime = jobEndTime; + } +} diff --git a/src/main/java/com/baidubce/services/batch/model/JobDescription.java b/src/main/java/com/baidubce/services/batch/model/JobDescription.java new file mode 100644 index 00000000..d77c8195 --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/model/JobDescription.java @@ -0,0 +1,73 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch.model; + +/** + * Represent a Batch-Compute JobDescription. + */ +public class JobDescription { + private String name; + private String vmType; + private int vmCount; + private String jobDagJson; + private Long jobTimeoutInSeconds; + private String memo; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getVmType() { + return vmType; + } + + public void setVmType(String vmType) { + this.vmType = vmType; + } + + public int getVmCount() { + return vmCount; + } + + public void setVmCount(int vmCount) { + this.vmCount = vmCount; + } + + public String getJobDagJson() { + return jobDagJson; + } + + public void setJobDagJson(String jobDagJson) { + this.jobDagJson = jobDagJson; + } + + public Long getJobTimeoutInSeconds() { + return jobTimeoutInSeconds; + } + + public void setJobTimeoutInSeconds(Long jobTimeoutInSeconds) { + this.jobTimeoutInSeconds = jobTimeoutInSeconds; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } +} diff --git a/src/main/java/com/baidubce/services/batch/model/ListJobsRequest.java b/src/main/java/com/baidubce/services/batch/model/ListJobsRequest.java new file mode 100644 index 00000000..14e6eaa3 --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/model/ListJobsRequest.java @@ -0,0 +1,78 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Provides options for listing jobs. + *

+ * The optional query parameters are marker and max keys. + */ +public class ListJobsRequest extends AbstractBceRequest { + private String marker; + private int maxKeys = -1; + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public int getMaxKeys() { + return maxKeys; + } + + public void setMaxKeys(int maxKeys) { + this.maxKeys = maxKeys; + } + + /** + * Configure the marker for the query request. + * The marker marks the starting point for the query. + * + * @param marker + * @return ListJobsRequest + */ + public ListJobsRequest withMarker(String marker) { + this.setMarker(marker); + return this; + } + + /** + * Configure the max count for each response page. + * The max keys can not more than 1000, any number exceeding 1000 will be + * reset to 1000. + * + * @param maxKeys The max count for each response page. + * @return ListJobsRequest + */ + public ListJobsRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListJobsRequest + */ + public ListJobsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/batch/model/ListJobsResponse.java b/src/main/java/com/baidubce/services/batch/model/ListJobsResponse.java new file mode 100644 index 00000000..36664257 --- /dev/null +++ b/src/main/java/com/baidubce/services/batch/model/ListJobsResponse.java @@ -0,0 +1,72 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.batch.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +/** + * Represent the response of ListJobsResponse. + *

+ * The response contains a array of Batch Job objects. + */ +public class ListJobsResponse extends AbstractBceResponse { + private String marker; + private String nextMarker; + private int maxKeys; + private boolean isTruncated; + private List jobs; + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public int getMaxKeys() { + return maxKeys; + } + + public void setMaxKeys(int maxKeys) { + this.maxKeys = maxKeys; + } + + public String getNextMarker() { + return nextMarker; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public boolean isTruncated() { + return this.isTruncated; + } + + @JsonProperty("isTruncated") + public void setTruncated(boolean isTruncated) { + this.isTruncated = isTruncated; + } + + public List getJobs() { + return jobs; + } + + public void setJobs(List jobs) { + this.jobs = jobs; + } +} diff --git a/src/main/java/com/baidubce/services/bmr/BmrClient.java b/src/main/java/com/baidubce/services/bmr/BmrClient.java old mode 100755 new mode 100644 index ba087235..a9a537fd --- a/src/main/java/com/baidubce/services/bmr/BmrClient.java +++ b/src/main/java/com/baidubce/services/bmr/BmrClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/AddStepsRequest.java b/src/main/java/com/baidubce/services/bmr/model/AddStepsRequest.java old mode 100755 new mode 100644 index 321b32d7..60905f94 --- a/src/main/java/com/baidubce/services/bmr/model/AddStepsRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/AddStepsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/AddStepsResponse.java b/src/main/java/com/baidubce/services/bmr/model/AddStepsResponse.java old mode 100755 new mode 100644 index 8218aa30..3f86a469 --- a/src/main/java/com/baidubce/services/bmr/model/AddStepsResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/AddStepsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/Application.java b/src/main/java/com/baidubce/services/bmr/model/Application.java old mode 100755 new mode 100644 index d7a2eed5..ab1aae8a --- a/src/main/java/com/baidubce/services/bmr/model/Application.java +++ b/src/main/java/com/baidubce/services/bmr/model/Application.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/ApplicationConfig.java old mode 100755 new mode 100644 index 0d3ed47a..ab3eab64 --- a/src/main/java/com/baidubce/services/bmr/model/ApplicationConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/ApplicationConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/Cluster.java b/src/main/java/com/baidubce/services/bmr/model/Cluster.java old mode 100755 new mode 100644 index 73d23a2f..c09bb445 --- a/src/main/java/com/baidubce/services/bmr/model/Cluster.java +++ b/src/main/java/com/baidubce/services/bmr/model/Cluster.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ClusterStatus.java b/src/main/java/com/baidubce/services/bmr/model/ClusterStatus.java old mode 100755 new mode 100644 index 4c42f703..812117fd --- a/src/main/java/com/baidubce/services/bmr/model/ClusterStatus.java +++ b/src/main/java/com/baidubce/services/bmr/model/ClusterStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java b/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java old mode 100755 new mode 100644 index a705fd81..71b042fa --- a/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/CreateClusterResponse.java b/src/main/java/com/baidubce/services/bmr/model/CreateClusterResponse.java old mode 100755 new mode 100644 index f5ed868c..40a68503 --- a/src/main/java/com/baidubce/services/bmr/model/CreateClusterResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/CreateClusterResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/GetClusterRequest.java b/src/main/java/com/baidubce/services/bmr/model/GetClusterRequest.java old mode 100755 new mode 100644 index d3d7bf58..82b2e2e4 --- a/src/main/java/com/baidubce/services/bmr/model/GetClusterRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/GetClusterRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/GetClusterResponse.java b/src/main/java/com/baidubce/services/bmr/model/GetClusterResponse.java old mode 100755 new mode 100644 index c3cf544b..6fac6fde --- a/src/main/java/com/baidubce/services/bmr/model/GetClusterResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/GetClusterResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/GetStepRequest.java b/src/main/java/com/baidubce/services/bmr/model/GetStepRequest.java old mode 100755 new mode 100644 index 6c72f82e..2d423772 --- a/src/main/java/com/baidubce/services/bmr/model/GetStepRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/GetStepRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java b/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java old mode 100755 new mode 100644 index ed11650f..c2d53eb7 --- a/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/HBaseApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/HBaseApplicationConfig.java old mode 100755 new mode 100644 index cd0addea..60120dbb --- a/src/main/java/com/baidubce/services/bmr/model/HBaseApplicationConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/HBaseApplicationConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/HiveApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/HiveApplicationConfig.java old mode 100755 new mode 100644 index 0b27ab18..b5a8f380 --- a/src/main/java/com/baidubce/services/bmr/model/HiveApplicationConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/HiveApplicationConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/HiveStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/HiveStepConfig.java old mode 100755 new mode 100644 index 2ecd688d..b595f994 --- a/src/main/java/com/baidubce/services/bmr/model/HiveStepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/HiveStepConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/HueApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/HueApplicationConfig.java old mode 100755 new mode 100644 index e5d026de..b60baf25 --- a/src/main/java/com/baidubce/services/bmr/model/HueApplicationConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/HueApplicationConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/Instance.java b/src/main/java/com/baidubce/services/bmr/model/Instance.java old mode 100755 new mode 100644 index 0fbfe377..163133e2 --- a/src/main/java/com/baidubce/services/bmr/model/Instance.java +++ b/src/main/java/com/baidubce/services/bmr/model/Instance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/InstanceGroup.java b/src/main/java/com/baidubce/services/bmr/model/InstanceGroup.java old mode 100755 new mode 100644 index 81a56804..9118b6cb --- a/src/main/java/com/baidubce/services/bmr/model/InstanceGroup.java +++ b/src/main/java/com/baidubce/services/bmr/model/InstanceGroup.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/InstanceGroupConfig.java b/src/main/java/com/baidubce/services/bmr/model/InstanceGroupConfig.java old mode 100755 new mode 100644 index 00054471..0c764127 --- a/src/main/java/com/baidubce/services/bmr/model/InstanceGroupConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/InstanceGroupConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/JavaStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/JavaStepConfig.java old mode 100755 new mode 100644 index 64672bdc..ce29dc78 --- a/src/main/java/com/baidubce/services/bmr/model/JavaStepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/JavaStepConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java old mode 100755 new mode 100644 index c8d9e731..600e5440 --- a/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ListClustersResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListClustersResponse.java old mode 100755 new mode 100644 index 506c042b..02be361c --- a/src/main/java/com/baidubce/services/bmr/model/ListClustersResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListClustersResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsRequest.java old mode 100755 new mode 100644 index f1a2880e..1e4b5082 --- a/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsResponse.java old mode 100755 new mode 100644 index a8d40576..deb0c791 --- a/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListInstanceGroupsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ListInstancesRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListInstancesRequest.java old mode 100755 new mode 100644 index c347cb2d..7606828a --- a/src/main/java/com/baidubce/services/bmr/model/ListInstancesRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListInstancesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ListInstancesResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListInstancesResponse.java old mode 100755 new mode 100644 index 03314bf9..a6f656a5 --- a/src/main/java/com/baidubce/services/bmr/model/ListInstancesResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListInstancesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java old mode 100755 new mode 100644 index bee604a1..ded14eab --- a/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/ListStepsResponse.java b/src/main/java/com/baidubce/services/bmr/model/ListStepsResponse.java old mode 100755 new mode 100644 index 572bfec0..35d0b2a6 --- a/src/main/java/com/baidubce/services/bmr/model/ListStepsResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListStepsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/PigApplicationConfig.java b/src/main/java/com/baidubce/services/bmr/model/PigApplicationConfig.java old mode 100755 new mode 100644 index a0fe1f3d..b3a56600 --- a/src/main/java/com/baidubce/services/bmr/model/PigApplicationConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/PigApplicationConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/PigStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/PigStepConfig.java old mode 100755 new mode 100644 index a522703c..bfc9ebd0 --- a/src/main/java/com/baidubce/services/bmr/model/PigStepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/PigStepConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/Step.java b/src/main/java/com/baidubce/services/bmr/model/Step.java old mode 100755 new mode 100644 index d61c73bf..f8a54a88 --- a/src/main/java/com/baidubce/services/bmr/model/Step.java +++ b/src/main/java/com/baidubce/services/bmr/model/Step.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/StepConfig.java b/src/main/java/com/baidubce/services/bmr/model/StepConfig.java old mode 100755 new mode 100644 index 97de8a76..5a89739f --- a/src/main/java/com/baidubce/services/bmr/model/StepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/StepConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/StepStatus.java b/src/main/java/com/baidubce/services/bmr/model/StepStatus.java old mode 100755 new mode 100644 index fa11018c..01a29f18 --- a/src/main/java/com/baidubce/services/bmr/model/StepStatus.java +++ b/src/main/java/com/baidubce/services/bmr/model/StepStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/StreamingStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/StreamingStepConfig.java old mode 100755 new mode 100644 index 09e61139..d3b764d2 --- a/src/main/java/com/baidubce/services/bmr/model/StreamingStepConfig.java +++ b/src/main/java/com/baidubce/services/bmr/model/StreamingStepConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bmr/model/TerminateClusterRequest.java b/src/main/java/com/baidubce/services/bmr/model/TerminateClusterRequest.java old mode 100755 new mode 100644 index af853812..abcb8fd2 --- a/src/main/java/com/baidubce/services/bmr/model/TerminateClusterRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/TerminateClusterRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/BosClient.java b/src/main/java/com/baidubce/services/bos/BosClient.java old mode 100755 new mode 100644 index e8825cc1..417fc942 --- a/src/main/java/com/baidubce/services/bos/BosClient.java +++ b/src/main/java/com/baidubce/services/bos/BosClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -898,83 +898,9 @@ public PutObjectResponse putObject(PutObjectRequest request) { checkNotNull(request, "request should not be null."); assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); - ObjectMetadata metadata = request.getObjectMetadata(); - InputStream input = request.getInputStream(); - InternalRequest internalRequest = this.createRequest(request, HttpMethodName.PUT); - // If a file is specified for upload, we need to pull some additional information from it to auto-configure a - // few options - if (request.getFile() != null) { - File file = request.getFile(); - - if (file.length() > 5 * 1024 * 1024 * 1024L) { - BceServiceException bse = new BceServiceException("Your proposed upload exceeds the maximum allowed " - + "object size."); - bse.setStatusCode(400); - bse.setErrorCode("EntityTooLarge"); - bse.setErrorType(BceServiceException.ErrorType.Client); - throw bse; - } - - // Always set the content length, even if it's already set - metadata.setContentLength(file.length()); - - if (metadata.getContentType() == null) { - metadata.setContentType(Mimetypes.getInstance().getMimetype(file)); - } - - FileInputStream fileInputStream = null; - try { - fileInputStream = new FileInputStream(file); - metadata.setBceContentSha256(new String(Hex.encodeHex(HashUtils.computeSha256Hash(fileInputStream)))); - } catch (Exception e) { - throw new BceClientException("Unable to calculate SHA-256 hash", e); - } finally { - try { - if (fileInputStream != null) { - fileInputStream.close(); - } - } catch (Exception e) { - // ignore - } - } - - try { - internalRequest.setContent(new RestartableFileInputStream(file)); - } catch (FileNotFoundException e) { - throw new BceClientException("Unable to find file to upload", e); - } - } else { - checkNotNull(input, "Either file or inputStream should be set for PutObjectRequest."); - if (metadata.getContentLength() < 0) { - logger.warn("No content length specified for stream data. Trying to read them all into memory."); - List data = this.readAll(input, metadata); - internalRequest.setContent(new RestartableMultiByteArrayInputStream(data, metadata.getContentLength())); - } else if (input instanceof RestartableInputStream) { - internalRequest.setContent((RestartableInputStream) input); - } else { - internalRequest.setContent(this.wrapRestartableInputStream(input)); - } - } - if (request.getStorageClass() != null) { - metadata.setStorageClass(request.getStorageClass()); - } - internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(metadata.getContentLength())); - - populateRequestMetadata(internalRequest, metadata); - - BosResponse response; - try { - response = this.invokeHttpClient(internalRequest, BosResponse.class); - } finally { - try { - internalRequest.getContent().close(); - } catch (Exception e) { - logger.warn("Fail to close input stream", e); - } - } - + BosResponse response = uploadObject(request, internalRequest); PutObjectResponse result = new PutObjectResponse(); result.setETag(response.getMetadata().getETag()); @@ -1013,7 +939,20 @@ public CopyObjectResponse copyObject(CopyObjectRequest request) { copySourceHeader = HttpUtils.normalizePath(copySourceHeader); internalRequest.addHeader(Headers.BCE_COPY_SOURCE, copySourceHeader); if (request.getETag() != null) { - internalRequest.addHeader(Headers.BCE_COPY_SOURCE_IF_MATCH, "\"" + request.getETag() + "\""); + internalRequest.addHeader(Headers.BCE_COPY_SOURCE_IF_MATCH, + "\"" + request.getETag() + "\""); + } + if (request.getNoneMatchETagConstraint() != null) { + internalRequest.addHeader( + Headers.BCE_COPY_SOURCE_IF_NONE_MATCH, "\"" + request.getNoneMatchETagConstraint() + "\""); + } + if (request.getUnmodifiedSinceConstraint() != null) { + internalRequest.addHeader( + Headers.BCE_COPY_SOURCE_IF_UNMODIFIED_SINCE, request.getUnmodifiedSinceConstraint()); + } + if (request.getModifiedSinceConstraint() != null) { + internalRequest.addHeader( + Headers.BCE_COPY_SOURCE_IF_MODIFIED_SINCE, request.getModifiedSinceConstraint()); } if (request.getStorageClass() != null) { internalRequest.addHeader(Headers.BCE_STORAGE_CLASS, request.getStorageClass()); @@ -1407,6 +1346,9 @@ private static void populateRequestMetadata(InternalRequest request, ObjectMetad if (metadata.getETag() != null) { request.addHeader(Headers.ETAG, metadata.getETag()); } + if (metadata.getExpires() != null) { + request.addHeader(Headers.EXPIRES, metadata.getExpires()); + } if (metadata.getCacheControl() != null) { request.addHeader(Headers.CACHE_CONTROL, metadata.getCacheControl()); } @@ -1660,4 +1602,240 @@ private URL convertRequestToUrl(InternalRequest request) { throw new BceClientException("Unable to convert request to well formed URL: " + e.getMessage(), e); } } + + /** + * Uploads the specified appendable file to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param file The appendable file containing the data to be uploaded to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, File file) { + return this.appendObject(new AppendObjectRequest(bucketName, key, file)); + } + + /** + * Uploads the specified appendable file to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param file The file containing the data to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, File file, ObjectMetadata metadata) { + return this.appendObject(new AppendObjectRequest(bucketName, key, file, metadata)); + } + + /** + * Uploads the specified string to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The string containing the value to be uploaded to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, String value) { + try { + return this.appendObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), new ObjectMetadata()); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get bytes.", e); + } + } + + /** + * Uploads the specified string and object metadata to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The string containing the value to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, String value, ObjectMetadata metadata) { + try { + return this.appendObject(bucketName, key, value.getBytes(DEFAULT_ENCODING), metadata); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Fail to get bytes.", e); + } + } + + /** + * Uploads the specified bytes to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The bytes containing the value to be uploaded to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, byte[] value) { + return this.appendObject(bucketName, key, value, new ObjectMetadata()); + } + + /** + * Uploads the appendable bytes and object metadata to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param value The bytes containing the value to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject( + String bucketName, String key, byte[] value, ObjectMetadata metadata) { + checkNotNull(metadata, "metadata should not be null."); + if (metadata.getContentLength() == -1) { + metadata.setContentLength(value.length); + } + return this.appendObject( + new AppendObjectRequest(bucketName, key, RestartableInputStream.wrap(value), metadata)); + } + + /** + * Uploads the appendable input stream to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param input The input stream containing the value to be uploaded to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(String bucketName, String key, InputStream input) { + return this.appendObject(new AppendObjectRequest(bucketName, key, input)); + } + + /** + * Uploads the appendable input stream and object metadata to Bos under the specified bucket and key name. + * + * @param bucketName The name of an existing bucket, to which you have Write permission. + * @param key The key under which to store the specified file. + * @param input The input stream containing the value to be uploaded to Bos. + * @param metadata Additional metadata instructing Bos how to handle the uploaded data + * (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject( + String bucketName, String key, InputStream input, ObjectMetadata metadata) { + return this.appendObject(new AppendObjectRequest(bucketName, key, input, metadata)); + } + + /** + * Uploads a new object to the specified Bos bucket. The AppendObjectRequest contains all the + * details of the request, including the bucket to upload to, the key the object will be uploaded under, + * and the file or input stream containing the data to upload. + * + * @param request The request object containing all the parameters to upload a new appendable object to Bos. + * @return An AppendObjectResponse object containing the information returned by Bos for the newly created object. + */ + public AppendObjectResponse appendObject(AppendObjectRequest request) { + checkNotNull(request, "request should not be null."); + assertStringNotNullOrEmpty(request.getKey(), "object key should not be null or empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST); + internalRequest.addParameter("append", null); + if (request.getOffset() != null) { + internalRequest.addParameter("offset", request.getOffset().toString()); + } + BosResponse response = uploadObject(request, internalRequest); + AppendObjectResponse result = new AppendObjectResponse(); + result.setNextAppendOffset(response.getMetadata().getNextAppendOffset()); + result.setContentMd5(response.getMetadata().getContentMd5()); + result.setETag(response.getMetadata().getETag()); + return result; + } + + /** + * Uploads a object to Bos bucket. The PutObjcetRequest contains all the details of the request.The internalRequest + * represents a request being send to a BCE Service. + * + * @param request The request object containing all the parameters to upload a new appendable object to Bos. + * @param internalRequest Represents a request being sent to a BCE Service, including the parameters being + * sent as part of the request, the endpoint to which the request should be sent, etc. + * @return A BosResponse object containing the bos-metadata information returned by Bos for the newly created + * object + */ + private BosResponse uploadObject(PutObjectRequest request, InternalRequest internalRequest) { + ObjectMetadata metadata = request.getObjectMetadata(); + InputStream input = request.getInputStream(); + if (request.getFile() != null) { + File file = request.getFile(); + + if (file.length() > 5 * 1024 * 1024 * 1024L) { + BceServiceException bse = new BceServiceException("Your proposed upload exceeds the maximum allowed " + + "object size."); + bse.setStatusCode(400); + bse.setErrorCode("EntityTooLarge"); + bse.setErrorType(BceServiceException.ErrorType.Client); + throw bse; + } + + // Always set the content length, even if it's already set + if (metadata.getContentLength() < 0) { + metadata.setContentLength(file.length()); + } + + if (metadata.getContentType() == null) { + metadata.setContentType(Mimetypes.getInstance().getMimetype(file)); + } + + if (metadata.getContentLength() == file.length()) { + FileInputStream fileInputStream = null; + try { + fileInputStream = new FileInputStream(file); + metadata.setBceContentSha256( + new String(Hex.encodeHex(HashUtils.computeSha256Hash(fileInputStream)))); + } catch (Exception e) { + throw new BceClientException("Unable to calculate SHA-256 hash", e); + } finally { + try { + if (fileInputStream != null) { + fileInputStream.close(); + } + } catch (Exception e) { + logger.warn("The inputStream accured error"); + } + } + } + try { + internalRequest.setContent(new RestartableFileInputStream(file)); + } catch (FileNotFoundException e) { + throw new BceClientException("Unable to find file to upload", e); + } + } else { + checkNotNull(input, "Either file or inputStream should be set."); + if (metadata.getContentLength() < 0) { + logger.warn("No content length specified for stream data. Trying to read them all into memory."); + List data = this.readAll(input, metadata); + internalRequest.setContent(new RestartableMultiByteArrayInputStream(data, metadata.getContentLength())); + } else if (input instanceof RestartableInputStream) { + internalRequest.setContent((RestartableInputStream) input); + } else { + internalRequest.setContent(this.wrapRestartableInputStream(input)); + } + if (metadata.getContentType() == null) { + metadata.setContentType(Mimetypes.getInstance().getMimetype(request.getKey())); + } + } + if (request.getStorageClass() != null) { + metadata.setStorageClass(request.getStorageClass()); + } + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(metadata.getContentLength())); + + populateRequestMetadata(internalRequest, metadata); + + BosResponse response; + try { + response = this.invokeHttpClient(internalRequest, BosResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + logger.warn("Fail to close input stream", e); + } + } + return response; + } } diff --git a/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java b/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java old mode 100755 new mode 100644 index fd0cb793..675f26b5 --- a/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java +++ b/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/BosMetadataResponseHandler.java b/src/main/java/com/baidubce/services/bos/BosMetadataResponseHandler.java old mode 100755 new mode 100644 index 410dee99..03a4b11a --- a/src/main/java/com/baidubce/services/bos/BosMetadataResponseHandler.java +++ b/src/main/java/com/baidubce/services/bos/BosMetadataResponseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -12,7 +12,6 @@ */ package com.baidubce.services.bos; -import com.baidubce.BceResponseMetadata; import com.baidubce.http.BceHttpResponse; import com.baidubce.http.Headers; import com.baidubce.http.handler.HttpResponseHandler; @@ -23,9 +22,17 @@ public class BosMetadataResponseHandler implements HttpResponseHandler { @Override public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response) throws Exception { - BceResponseMetadata metadata = response.getMetadata(); - if (metadata instanceof BosResponseMetadata) { - ((BosResponseMetadata) metadata).setBosDebugId(httpResponse.getHeader(Headers.BCE_DEBUG_ID)); + if (response.getMetadata() instanceof BosResponseMetadata) { + BosResponseMetadata metadata = (BosResponseMetadata) response.getMetadata(); + metadata.setBosDebugId(httpResponse.getHeader(Headers.BCE_DEBUG_ID)); + if (httpResponse.getHeader(Headers.BCE_NEXT_APPEND_OFFSET) != null) { + metadata.setNextAppendOffset( + Long.parseLong(httpResponse.getHeader(Headers.BCE_NEXT_APPEND_OFFSET))); + } + if (httpResponse.getHeader(Headers.LOCATION) != null) { + metadata.setLocation(httpResponse.getHeader(Headers.LOCATION)); + } + } return false; } diff --git a/src/main/java/com/baidubce/services/bos/BosObjectInputStream.java b/src/main/java/com/baidubce/services/bos/BosObjectInputStream.java old mode 100755 new mode 100644 index 71fac824..3e52cbef --- a/src/main/java/com/baidubce/services/bos/BosObjectInputStream.java +++ b/src/main/java/com/baidubce/services/bos/BosObjectInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/BosObjectResponseHandler.java b/src/main/java/com/baidubce/services/bos/BosObjectResponseHandler.java old mode 100755 new mode 100644 index bad9ace8..264bc3c4 --- a/src/main/java/com/baidubce/services/bos/BosObjectResponseHandler.java +++ b/src/main/java/com/baidubce/services/bos/BosObjectResponseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -45,6 +45,9 @@ public boolean handle(BceHttpResponse httpResponse, AbstractBceResponse response objectMetadata.setContentType(httpResponse.getHeader(Headers.CONTENT_TYPE)); objectMetadata.setContentEncoding(httpResponse.getHeader(Headers.CONTENT_ENCODING)); objectMetadata.setContentMd5(httpResponse.getHeader(Headers.CONTENT_MD5)); + objectMetadata.setExpires(httpResponse.getHeader(Headers.EXPIRES)); + objectMetadata.setObjectType(httpResponse.getHeader(Headers.BCE_OBJECT_TYPE)); + objectMetadata.setAppendOffset(httpResponse.getHeader(Headers.BCE_NEXT_APPEND_OFFSET)); objectMetadata.setContentDisposition(httpResponse.getHeader(Headers.CONTENT_DISPOSITION)); objectMetadata.setCacheControl(httpResponse.getHeader(Headers.CACHE_CONTROL)); // set whatever the BOS server returns if not null diff --git a/src/main/java/com/baidubce/services/bos/model/AbortMultipartUploadRequest.java b/src/main/java/com/baidubce/services/bos/model/AbortMultipartUploadRequest.java old mode 100755 new mode 100644 index 0591d48b..8b9cad20 --- a/src/main/java/com/baidubce/services/bos/model/AbortMultipartUploadRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/AbortMultipartUploadRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/AppendObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/AppendObjectRequest.java new file mode 100644 index 00000000..082c060a --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/AppendObjectRequest.java @@ -0,0 +1,239 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +import static com.google.common.base.Preconditions.checkNotNull; + +import java.io.File; +import java.io.InputStream; + +import com.baidubce.auth.BceCredentials; + +/** + * Uploads a new object to the specified Baidu Bos bucket. The AppendObjectRequest optionally uploads object metadata + * and applies a canned access control policy to the new object. + * + *

+ * Baidu Bos never stores partial objects; if during this call an exception wasn't thrown, the entire object was stored. + */ +public class AppendObjectRequest extends PutObjectRequest { + + /** + * The offset indicates the size of data has been uploaded to Baidu bos. If the value of the offset is null, + * this means that users create a new appendable object on Baidu bos, otherwise it means that appending + * a object which had already exist. + */ + private Long offset; + + /** + * Constructs a new AppendObjectRequest object to upload a file to the + * specified bucket and key. After constructing the request, + * users may optionally specify object metadata or a canned ACL as well. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. + * @param file The path of the file to upload to Baidu Bos. + */ + public AppendObjectRequest(String bucketName, String key, File file) { + this(bucketName, key, file, null, new ObjectMetadata()); + checkNotNull(file, "file should not be null."); + } + + /** + * Constructs a new AppendObjectRequest object to upload an appendable file + * to the specified bucket and key. After constructing the request, + * users may optionally specify object metadata or a canned ACL as well. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. + * @param file The path of the file to upload to Baidu Bos. + * @param metadata The object metadata. At minimum this specifies the + * content length for the stream of data being uploaded. + */ + public AppendObjectRequest(String bucketName, String key, File file, ObjectMetadata metadata) { + this(bucketName, key, file, null, metadata); + checkNotNull(file, "file should not be null."); + checkNotNull(metadata, "metadata should not be null."); + } + + /** + * Constructs a new AppendObjectRequest object to upload a stream of data to + * the specified bucket and key. After constructing the request, + * users may optionally specify object metadata or a canned ACL as well. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. + * @param inputStream The stream of data to upload to Baidu Bos. + */ + public AppendObjectRequest(String bucketName, String key, InputStream inputStream) { + this(bucketName, key, null, inputStream, new ObjectMetadata()); + checkNotNull(inputStream, "inputStream should not be null."); + } + + /** + * Constructs a new AppendObjectRequest object to upload a stream of data to + * the specified bucket and key. After constructing the request, + * users may optionally specify object metadata or a canned ACL as well. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. + * @param inputStream The stream of data to upload to Baidu Bos. + * @param metadata The object metadata. At minimum this specifies the + * content length for the stream of data being uploaded. + */ + public AppendObjectRequest(String bucketName, String key, InputStream inputStream, ObjectMetadata metadata) { + this(bucketName, key, null, inputStream, metadata); + checkNotNull(inputStream, "inputStream should not be null."); + checkNotNull(metadata, "metadata should not be null."); + } + + /** + * Constructs a new AppendObjectRequest object to upload a file and a stream of data to + * the specified bucket and key. After constructing the request, + * users may optionally specify object metadata or a canned ACL as well. + * + * @param bucketName The name of an existing bucket to which the new object will be uploaded. + * @param key The key under which to store the new object. + * @param file The path of the file to upload to Baidu Bos. + * @param inputStream The stream of data to upload to Baidu Bos. + * @param objectMetadata The object metadata. At minimum this specifies the + * content length for the stream of data being uploaded. + */ + private AppendObjectRequest( + String bucketName, String key, File file, InputStream inputStream, ObjectMetadata objectMetadata) { + super(bucketName, key, file, inputStream, objectMetadata); + } + + /** + * Gets the offset of the file, which shows the resume position of appendable file. + * @return The offset that indicates the size of data has been uploaded to Baidu bos. + */ + public Long getOffset() { + return offset; + } + + /** + * Sets the offset of the file, which shows the resume position of appendable file. + * @param offset The offset indicates the size of data has been uploaded to Baidu bos. + */ + public void setOffset(Long offset) { + this.offset = offset; + } + + /** + * Sets the offset of the file, which shows the resume position of appendable file. + * @param offset The offset indicates the size of data has been uploaded to Baidu bos. + * @return This AppendObjectRequest, so that additional method calls to be chained together. + */ + public AppendObjectRequest withOffset(Long offset) { + this.setOffset(offset); + return this; + } + + /** + * Sets the optional metadata instructing Baidu Bos how to handle the + * uploaded data (e.g. custom user metadata, hooks for specifying content + * type, etc.). Returns this AppendObjectRequest, enabling additional method + * calls to be chained together. + * + *

+ * If uploading from an input stream, + * always specify metadata with the content size set. Otherwise the + * contents of the input stream have to be buffered in memory before + * being sent to Baidu Bos. This can cause very negative performance + * impacts. + * + * @param objectMetadata The optional metadata instructing Baidu Bos how to handle the + * uploaded data (e.g. custom user metadata, hooks for specifying content type, etc.). + * @return This AppendObjectRequest, so that additional method calls to be chained together. + */ + @Override + public AppendObjectRequest withObjectMetadata(ObjectMetadata objectMetadata) { + this.setObjectMetadata(objectMetadata); + return this; + } + + /** + * Sets the file containing the data to be uploaded to Baidu Bos. + * Returns this AppendObjectRequest, enabling additional method calls to be chained together. + * + *

+ * Either specify a file or an input stream containing the data to + * be uploaded to Baidu Bos; both cannot be specified. + * + * @param file The file containing the data to be uploaded to Baidu Bos. + * @return This AppendObjectRequest, enabling additional method calls to be chained together. + */ + @Override + public AppendObjectRequest withFile(File file) { + this.setFile(file); + return this; + } + + /** + * Sets the input stream containing the data to be uploaded to Baidu Bos. + * Returns this AppendObjectRequest, enabling additional method calls to be chained together. + * + *

+ * Either specify a file or an input stream containing the data to be + * uploaded to Baidu Bos; both cannot be specified. + * + * @param inputStream The InputStream containing the data to be uploaded to Baidu Bos. + * @return This AppendObjectRequest, so that additional method calls can be chained together. + */ + @Override + public AppendObjectRequest withInputStream(InputStream inputStream) { + this.setInputStream(inputStream); + return this; + } + + /** + * Sets the optional credentials to use for this request, overriding the default credentials set at the client + * level. + * + * @param credentials The optional BOS security credentials to use for this request. + * @return This AppendObjectRequest, so that additional method calls can be chained together. + */ + @Override + public AppendObjectRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + /** + * Sets the name of the bucket where this request will upload a new + * object to. Returns this object, enabling additional method calls to be + * chained together. + * + * @param bucketName The name of an existing bucket where this request will upload a new object to. + * @return This AppendObjectRequest, enabling additional method calls to be chained together. + */ + @Override + public AppendObjectRequest withBucketName(String bucketName) { + this.setBucketName(bucketName); + return this; + } + + /** + * Sets the key under which to store the new object. Returns this object, + * enabling additional method calls to be chained together. + * + * @param key The key under which to store the new object. + * @return This AppendObjectRequest, so that additional method calls to be chained together. + */ + @Override + public AppendObjectRequest withKey(String key) { + this.setKey(key); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/bos/model/AppendObjectResponse.java b/src/main/java/com/baidubce/services/bos/model/AppendObjectResponse.java new file mode 100644 index 00000000..53b3869c --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/AppendObjectResponse.java @@ -0,0 +1,48 @@ +/* + * Copyright 2014 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.bos.model; + +/** + * Contains the data returned by Baidu Bos from the putObject operation. + * Use this request to access information about the new object created from the + * putObject request, such as its ETag and optional version ID. + */ +public class AppendObjectResponse extends PutObjectResponse { + + /** + * The contentMd5 is the md5 of the object that has been uploaded to bos. + */ + private String contentMd5; + + /** + * The nextOffset indicates that which position to append to the object. + */ + private Long nextAppendOffset; + + public String getContentMd5() { + return contentMd5; + } + + public void setContentMd5(String contentMd5) { + this.contentMd5 = contentMd5; + } + + public Long getNextAppendOffset() { + return nextAppendOffset; + } + + public void setNextAppendOffset(Long nextAppendOffset) { + this.nextAppendOffset = nextAppendOffset; + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/bos/model/BosObject.java b/src/main/java/com/baidubce/services/bos/model/BosObject.java old mode 100755 new mode 100644 index 7cea3ccf..788f3dbf --- a/src/main/java/com/baidubce/services/bos/model/BosObject.java +++ b/src/main/java/com/baidubce/services/bos/model/BosObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/BosObjectSummary.java b/src/main/java/com/baidubce/services/bos/model/BosObjectSummary.java old mode 100755 new mode 100644 index 97905f86..c4613fdb --- a/src/main/java/com/baidubce/services/bos/model/BosObjectSummary.java +++ b/src/main/java/com/baidubce/services/bos/model/BosObjectSummary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/BosResponse.java b/src/main/java/com/baidubce/services/bos/model/BosResponse.java old mode 100755 new mode 100644 index 826f9f45..94af7587 --- a/src/main/java/com/baidubce/services/bos/model/BosResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/BosResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/BosResponseMetadata.java b/src/main/java/com/baidubce/services/bos/model/BosResponseMetadata.java old mode 100755 new mode 100644 index a20cf829..4bf3da72 --- a/src/main/java/com/baidubce/services/bos/model/BosResponseMetadata.java +++ b/src/main/java/com/baidubce/services/bos/model/BosResponseMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -18,6 +18,8 @@ public class BosResponseMetadata extends BceResponseMetadata { private String debugId; + private Long nextAppendOffset; + public String getBosDebugId() { return this.debugId; } @@ -26,4 +28,13 @@ public void setBosDebugId(String debugId) { this.debugId = debugId; } + public Long getNextAppendOffset() { + return nextAppendOffset; + } + + public void setNextAppendOffset(Long nextAppendOffset) { + this.nextAppendOffset = nextAppendOffset; + } + + } diff --git a/src/main/java/com/baidubce/services/bos/model/BucketSummary.java b/src/main/java/com/baidubce/services/bos/model/BucketSummary.java old mode 100755 new mode 100644 index c5a22c3e..9d98266d --- a/src/main/java/com/baidubce/services/bos/model/BucketSummary.java +++ b/src/main/java/com/baidubce/services/bos/model/BucketSummary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/CannedAccessControlList.java b/src/main/java/com/baidubce/services/bos/model/CannedAccessControlList.java old mode 100755 new mode 100644 index 79787406..b09d7515 --- a/src/main/java/com/baidubce/services/bos/model/CannedAccessControlList.java +++ b/src/main/java/com/baidubce/services/bos/model/CannedAccessControlList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/CommonPrefixesDeserializer.java b/src/main/java/com/baidubce/services/bos/model/CommonPrefixesDeserializer.java old mode 100755 new mode 100644 index a29859de..15cc607e --- a/src/main/java/com/baidubce/services/bos/model/CommonPrefixesDeserializer.java +++ b/src/main/java/com/baidubce/services/bos/model/CommonPrefixesDeserializer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadRequest.java b/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadRequest.java old mode 100755 new mode 100644 index 39bf2261..e3f01e86 --- a/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java b/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java old mode 100755 new mode 100644 index 601e98bd..f22be91f --- a/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/CopyObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/CopyObjectRequest.java old mode 100755 new mode 100644 index cc9b0314..8b1bb22f --- a/src/main/java/com/baidubce/services/bos/model/CopyObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/CopyObjectRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -40,11 +40,29 @@ public class CopyObjectRequest extends GenericObjectRequest { private ObjectMetadata newObjectMetadata = null; /** - * Optional ETag value that constrain the copy request to only be executed - * if the source object's ETag matches the specified ETag values. + * Optional ETag value that constrain the copy request to only be executed if the source + * object's ETag matches the specified ETag value. */ private String eTag; + /** + * Optional ETag value that constrain the copy request to only be executed if the source + * object's ETag does not match the specified ETag value. + */ + private String noneMatchETagConstraint; + + /** + * If the value of the unmodifiedSinceConstraint is equal to or later than the actual file + * modification time, then take the normal file transfer process. + */ + private String unmodifiedSinceConstraint; + + /** + * If the value of the modifiedSinceConstraint is less than the actual file modification + * time, then take the normal file transfer process. + */ + private String modifiedSinceConstraint; + /** * The storage class is an identification that distinguish between infrequent access bos * and standard bos. @@ -258,7 +276,7 @@ public void setStorageClass(String storageClass) { /** * Sets the storageClass of the input file which is to be copyed to Baidu Bos. - * + * * @param storageClass The StorageClass is an identification that distinguish between infrequent access bos * and standard bos. * @return This CopyObjectRequest, so that additional method calls can be chained together. @@ -267,4 +285,96 @@ public CopyObjectRequest withStorageClass(String storageClass) { this.setStorageClass(storageClass); return this; } + + /** + * Gets the the value of the unmodifiedSinceConstraint,if the value is equal to or later than the actual + * file modification time, then take the normal file transfer process. + * + * @return unmodifiedSinceConstraint + */ + public String getUnmodifiedSinceConstraint() { + return unmodifiedSinceConstraint; + } + + /** + * Sets the the value of the unmodifiedSinceConstraint,if the value is equal to or later than the actual + * file modification time, then take the normal file transfer process. + * + * @param unmodifiedSinceConstraint + */ + public void setUnmodifiedSinceConstraint(String unmodifiedSinceConstraint) { + this.unmodifiedSinceConstraint = unmodifiedSinceConstraint; + } + + /** + * Sets the the value of the unmodifiedSinceConstraint,if the value is equal to or later than the actual + * file modification time, then take the normal file transfer process. + * + * @param unmodifiedSinceConstraint + * @return This CopyObjectRequest, enabling additional method calls to be chained together. + */ + public CopyObjectRequest withUnmodifiedSinceConstraint(String unmodifiedSinceConstraint) { + this.setUnmodifiedSinceConstraint(unmodifiedSinceConstraint); + return this; + } + + /** + * Gets the the value of the modifiedSinceConstraint,if the value is less than the actual file modification + * time, then take the normal file transfer process. + * @return modifiedSinceConstraint + */ + public String getModifiedSinceConstraint() { + return modifiedSinceConstraint; + } + + /** + * Sets the the value of the modifiedSinceConstraint,if the value is less than the actual file modification + * time, then take the normal file transfer process. + * @param modifiedSinceConstraint + */ + public void setModifiedSinceConstraint(String modifiedSinceConstraint) { + this.modifiedSinceConstraint = modifiedSinceConstraint; + } + + /** + * Sets the the value of the modifiedSinceConstraint,if the value is less than the actual file modification + * time, then take the normal file transfer process. + * + * @param modifiedSinceConstraint + * @return This CopyObjectRequest, enabling additional method calls to be chained together. + */ + public CopyObjectRequest withModifiedSinceConstraint(String modifiedSinceConstraint) { + this.setModifiedSinceConstraint(modifiedSinceConstraint); + return this; + } + + /** + * Gets the optional ETag that, when present, must be not a match for the source object's current + * ETag in order for the copy object request to be executed. + * @return noneMatchETagConstraint + */ + public String getNoneMatchETagConstraint() { + return noneMatchETagConstraint; + } + + /** + * Sets the optional ETag that, when present, must be not a match for the source object's current + * ETag in order for the copy object request to be executed. + * @param noneMatchETagConstraint + */ + public void setNoneMatchETagConstraint(String noneMatchETagConstraint) { + this.noneMatchETagConstraint = noneMatchETagConstraint; + } + + /** + * Sets the optional ETag that, when present, must be not a match for the source object's current + * ETag in order for the copy object request to be executed. + * + * @param noneMatchETagConstraint + * @return This CopyObjectRequest, enabling additional method calls to be chained together. + */ + public CopyObjectRequest withNoMatchingETagConstraint(String noneMatchETagConstraint) { + this.setNoneMatchETagConstraint(noneMatchETagConstraint); + return this; + } } diff --git a/src/main/java/com/baidubce/services/bos/model/CopyObjectResponse.java b/src/main/java/com/baidubce/services/bos/model/CopyObjectResponse.java old mode 100755 new mode 100644 index f1978778..ba2ae846 --- a/src/main/java/com/baidubce/services/bos/model/CopyObjectResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/CopyObjectResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java b/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java old mode 100755 new mode 100644 index d72c5119..4f5fbce6 --- a/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java +++ b/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/CreateBucketRequest.java b/src/main/java/com/baidubce/services/bos/model/CreateBucketRequest.java old mode 100755 new mode 100644 index 797a1202..a7e2acae --- a/src/main/java/com/baidubce/services/bos/model/CreateBucketRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/CreateBucketRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/CreateBucketResponse.java b/src/main/java/com/baidubce/services/bos/model/CreateBucketResponse.java old mode 100755 new mode 100644 index 3e3bb689..33e8a6cf --- a/src/main/java/com/baidubce/services/bos/model/CreateBucketResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/CreateBucketResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteBucketRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteBucketRequest.java old mode 100755 new mode 100644 index bf3911f6..d0c8c7e3 --- a/src/main/java/com/baidubce/services/bos/model/DeleteBucketRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/DeleteBucketRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/DeleteObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/DeleteObjectRequest.java old mode 100755 new mode 100644 index 81d183c6..1098ddc0 --- a/src/main/java/com/baidubce/services/bos/model/DeleteObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/DeleteObjectRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/DoesBucketExistRequest.java b/src/main/java/com/baidubce/services/bos/model/DoesBucketExistRequest.java old mode 100755 new mode 100644 index e10d715e..a6294467 --- a/src/main/java/com/baidubce/services/bos/model/DoesBucketExistRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/DoesBucketExistRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GeneratePresignedUrlRequest.java b/src/main/java/com/baidubce/services/bos/model/GeneratePresignedUrlRequest.java old mode 100755 new mode 100644 index a28f71ab..242bc256 --- a/src/main/java/com/baidubce/services/bos/model/GeneratePresignedUrlRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GeneratePresignedUrlRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GenericBucketRequest.java b/src/main/java/com/baidubce/services/bos/model/GenericBucketRequest.java old mode 100755 new mode 100644 index 29bcbd84..abad02f5 --- a/src/main/java/com/baidubce/services/bos/model/GenericBucketRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GenericBucketRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GenericObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/GenericObjectRequest.java old mode 100755 new mode 100644 index 0f292ac6..d0240bea --- a/src/main/java/com/baidubce/services/bos/model/GenericObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GenericObjectRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GenericUploadRequest.java b/src/main/java/com/baidubce/services/bos/model/GenericUploadRequest.java old mode 100755 new mode 100644 index cd2882ce..d5ce5730 --- a/src/main/java/com/baidubce/services/bos/model/GenericUploadRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GenericUploadRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GetBosAccountOwnerRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBosAccountOwnerRequest.java old mode 100755 new mode 100644 index ef54257e..b7bff2d1 --- a/src/main/java/com/baidubce/services/bos/model/GetBosAccountOwnerRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GetBosAccountOwnerRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketAclRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketAclRequest.java old mode 100755 new mode 100644 index 1cce6055..67af16f2 --- a/src/main/java/com/baidubce/services/bos/model/GetBucketAclRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketAclRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketAclResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketAclResponse.java old mode 100755 new mode 100644 index c836176f..f10ba262 --- a/src/main/java/com/baidubce/services/bos/model/GetBucketAclResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/GetBucketAclResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketLocationRequest.java b/src/main/java/com/baidubce/services/bos/model/GetBucketLocationRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/bos/model/GetBucketLocationResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketLocationResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectMetadataRequest.java b/src/main/java/com/baidubce/services/bos/model/GetObjectMetadataRequest.java old mode 100755 new mode 100644 index 5a0129cf..5965e194 --- a/src/main/java/com/baidubce/services/bos/model/GetObjectMetadataRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GetObjectMetadataRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectMetadataResponse.java b/src/main/java/com/baidubce/services/bos/model/GetObjectMetadataResponse.java old mode 100755 new mode 100644 index bdf1389c..5408e396 --- a/src/main/java/com/baidubce/services/bos/model/GetObjectMetadataResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/GetObjectMetadataResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java old mode 100755 new mode 100644 index cfa80978..2bb66b6d --- a/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectResponse.java b/src/main/java/com/baidubce/services/bos/model/GetObjectResponse.java old mode 100755 new mode 100644 index 7f4fa632..9fc31a40 --- a/src/main/java/com/baidubce/services/bos/model/GetObjectResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/GetObjectResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/Grant.java b/src/main/java/com/baidubce/services/bos/model/Grant.java old mode 100755 new mode 100644 index 7daa4bc0..a5065a6b --- a/src/main/java/com/baidubce/services/bos/model/Grant.java +++ b/src/main/java/com/baidubce/services/bos/model/Grant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/Grantee.java b/src/main/java/com/baidubce/services/bos/model/Grantee.java old mode 100755 new mode 100644 index 23943be6..83b92feb --- a/src/main/java/com/baidubce/services/bos/model/Grantee.java +++ b/src/main/java/com/baidubce/services/bos/model/Grantee.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/InitiateMultipartUploadRequest.java b/src/main/java/com/baidubce/services/bos/model/InitiateMultipartUploadRequest.java old mode 100755 new mode 100644 index 089824a3..d5a202f9 --- a/src/main/java/com/baidubce/services/bos/model/InitiateMultipartUploadRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/InitiateMultipartUploadRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/InitiateMultipartUploadResponse.java b/src/main/java/com/baidubce/services/bos/model/InitiateMultipartUploadResponse.java old mode 100755 new mode 100644 index d5522898..4a636cb7 --- a/src/main/java/com/baidubce/services/bos/model/InitiateMultipartUploadResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/InitiateMultipartUploadResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ListBucketsRequest.java b/src/main/java/com/baidubce/services/bos/model/ListBucketsRequest.java old mode 100755 new mode 100644 index 109f85a4..f0938972 --- a/src/main/java/com/baidubce/services/bos/model/ListBucketsRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/ListBucketsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ListBucketsResponse.java b/src/main/java/com/baidubce/services/bos/model/ListBucketsResponse.java old mode 100755 new mode 100644 index 62f62034..f93d4aed --- a/src/main/java/com/baidubce/services/bos/model/ListBucketsResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/ListBucketsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ListMultipartUploadsRequest.java b/src/main/java/com/baidubce/services/bos/model/ListMultipartUploadsRequest.java old mode 100755 new mode 100644 index 69eb01d3..1baf3fc0 --- a/src/main/java/com/baidubce/services/bos/model/ListMultipartUploadsRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/ListMultipartUploadsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ListMultipartUploadsResponse.java b/src/main/java/com/baidubce/services/bos/model/ListMultipartUploadsResponse.java old mode 100755 new mode 100644 index 2a95adc5..203c6768 --- a/src/main/java/com/baidubce/services/bos/model/ListMultipartUploadsResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/ListMultipartUploadsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ListObjectsRequest.java b/src/main/java/com/baidubce/services/bos/model/ListObjectsRequest.java old mode 100755 new mode 100644 index 18209a11..f7b50d95 --- a/src/main/java/com/baidubce/services/bos/model/ListObjectsRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/ListObjectsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java b/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java old mode 100755 new mode 100644 index e5a2d3be..9495a901 --- a/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ListPartsRequest.java b/src/main/java/com/baidubce/services/bos/model/ListPartsRequest.java old mode 100755 new mode 100644 index 53ab5746..9a166d3b --- a/src/main/java/com/baidubce/services/bos/model/ListPartsRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/ListPartsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ListPartsResponse.java b/src/main/java/com/baidubce/services/bos/model/ListPartsResponse.java old mode 100755 new mode 100644 index 66815215..6eaf25f7 --- a/src/main/java/com/baidubce/services/bos/model/ListPartsResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/ListPartsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/MultipartUploadSummary.java b/src/main/java/com/baidubce/services/bos/model/MultipartUploadSummary.java old mode 100755 new mode 100644 index 7d65b120..92161ea5 --- a/src/main/java/com/baidubce/services/bos/model/MultipartUploadSummary.java +++ b/src/main/java/com/baidubce/services/bos/model/MultipartUploadSummary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java b/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java old mode 100755 new mode 100644 index be7d6958..da21a8a7 --- a/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java +++ b/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -34,26 +34,69 @@ public class ObjectMetadata { private String bceContentSha256; + /** + * It provide a default file name when customers download file from bos. + */ private String contentDisposition; + /** + * The contentEnding entity header is used compress the media-type. + */ private String contentEncoding; + /** + * The length of the request body. + */ private long contentLength = -1; + /** + * A Base64-encoded binary MD5 sum of the content of the request body. + */ private String contentMd5; + /** + * The MIME type of the body of the request. + */ private String contentType; + /** + * The entity tag of the URL. + */ private String eTag; private long instanceLength = -1; + /** + * The lastModified time of the object. + */ private Date lastModified; + /** + * Where in a full body message this partial message belongs. + */ private String contentRange; + /** + * The cacheControl is used for controlling HTTP caching. + */ private String cacheControl; + /** + * The expiration of optional object. + */ + private String expires; + + /** + * The offset of the append object. + */ + private String appendOffset; + + /** + * The objectType identifies whether the object is an appendable object + * or a normal object. + */ + private String objectType; + private String storageClass; public ObjectMetadata() { @@ -72,6 +115,9 @@ public ObjectMetadata(ObjectMetadata other) { this.setETag(other.getETag()); this.setInstanceLength(other.getInstanceLength()); this.setLastModified(other.getLastModified()); + this.setExpires(other.getExpires()); + this.setAppendOffset(other.getAppendOffset()); + this.setObjectType(other.getObjectType()); this.setCacheControl(other.getCacheControl()); this.setStorageClass(other.getStorageClass()); } @@ -391,6 +437,30 @@ public String toString() { return builder.toString(); } + public String getExpires() { + return expires; + } + + public void setExpires(String expires) { + this.expires = expires; + } + + public String getAppendOffset() { + return appendOffset; + } + + public void setAppendOffset(String appendOffset) { + this.appendOffset = appendOffset; + } + + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + public String getCacheControl() { return cacheControl; } diff --git a/src/main/java/com/baidubce/services/bos/model/PartETag.java b/src/main/java/com/baidubce/services/bos/model/PartETag.java old mode 100755 new mode 100644 index fbcb65b2..f40ad815 --- a/src/main/java/com/baidubce/services/bos/model/PartETag.java +++ b/src/main/java/com/baidubce/services/bos/model/PartETag.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/PartSummary.java b/src/main/java/com/baidubce/services/bos/model/PartSummary.java old mode 100755 new mode 100644 index fe0ffb7d..5cb58064 --- a/src/main/java/com/baidubce/services/bos/model/PartSummary.java +++ b/src/main/java/com/baidubce/services/bos/model/PartSummary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/Permission.java b/src/main/java/com/baidubce/services/bos/model/Permission.java old mode 100755 new mode 100644 index ff4aaae2..4c768aca --- a/src/main/java/com/baidubce/services/bos/model/Permission.java +++ b/src/main/java/com/baidubce/services/bos/model/Permission.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/PutObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/PutObjectRequest.java old mode 100755 new mode 100644 index 53f6fcb3..840c9d8b --- a/src/main/java/com/baidubce/services/bos/model/PutObjectRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/PutObjectRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -132,7 +132,7 @@ public PutObjectRequest(String bucketName, String key, InputStream inputStream, * @param objectMetadata The object metadata. At minimum this specifies the * content length for the stream of data being uploaded. */ - private PutObjectRequest(String bucketName, String key, File file, InputStream inputStream, + protected PutObjectRequest(String bucketName, String key, File file, InputStream inputStream, ObjectMetadata objectMetadata) { super(bucketName, key); this.file = file; diff --git a/src/main/java/com/baidubce/services/bos/model/PutObjectResponse.java b/src/main/java/com/baidubce/services/bos/model/PutObjectResponse.java old mode 100755 new mode 100644 index 363f475f..4cddf0fd --- a/src/main/java/com/baidubce/services/bos/model/PutObjectResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/PutObjectResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java b/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java old mode 100755 new mode 100644 index 45818fb9..a010a56c --- a/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java +++ b/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/SetBucketAclRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketAclRequest.java old mode 100755 new mode 100644 index aaaaf14b..957564f9 --- a/src/main/java/com/baidubce/services/bos/model/SetBucketAclRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/SetBucketAclRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/UploadPartRequest.java b/src/main/java/com/baidubce/services/bos/model/UploadPartRequest.java old mode 100755 new mode 100644 index d5a197f6..6ee5ade4 --- a/src/main/java/com/baidubce/services/bos/model/UploadPartRequest.java +++ b/src/main/java/com/baidubce/services/bos/model/UploadPartRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/bos/model/UploadPartResponse.java b/src/main/java/com/baidubce/services/bos/model/UploadPartResponse.java old mode 100755 new mode 100644 index e2099e35..af47681e --- a/src/main/java/com/baidubce/services/bos/model/UploadPartResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/UploadPartResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/DocClient.java b/src/main/java/com/baidubce/services/doc/DocClient.java old mode 100755 new mode 100644 index 3b68bfa7..ae805306 --- a/src/main/java/com/baidubce/services/doc/DocClient.java +++ b/src/main/java/com/baidubce/services/doc/DocClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -209,6 +209,30 @@ public CreateDocumentResponse createDocument(File file, String title, String for return this.createDocument(request); } + /** + * Create a Document. + * + * @param file The document . + * @param title The document title. + * @param format The document format. + * @param notification The document notification name. + * @param access The document access privilege(PUBLIC/PRIVATE). + * @param targetType The document converts type(h5/image). + * + * @return A CreateDocumentResponse object containing the information returned by Document. + */ + public CreateDocumentResponse createDocument(File file, String title, String format, + String notification, String access, String targetType) { + CreateDocumentRequest request = new CreateDocumentRequest(); + request.setFile(file); + request.setTitle(title); + request.setFormat(format); + request.setNotification(notification); + request.setAccess(access); + request.setTargetType(targetType); + return this.createDocument(request); + } + /** * Create a Document. * @@ -292,6 +316,33 @@ public CreateDocumentFromBosResponse createDocumentFromBos(String bucket, String return this.createDocumentFromBos(request); } + /** + * Create a Document. + * + * @param bucket The document bucket. + * @param object The document object. + * @param title The document title. + * @param format The document format. + * @param notification The document notification name. + * @param access The document access privilege(PUBLIC/PRIVATE). + * @param targetType The document converts type(h5/image). + * + * @return A CreateDocumentFromBosResponse object containing the information returned by Document. + */ + public CreateDocumentFromBosResponse createDocumentFromBos(String bucket, String object, + String title, String format, + String notification, String access, String targetType) { + CreateDocumentFromBosRequest request = new CreateDocumentFromBosRequest(); + request.setBucket(bucket); + request.setObject(object); + request.setTitle(title); + request.setFormat(format); + request.setNotification(notification); + request.setAccess(access); + request.setTargetType(targetType); + return this.createDocumentFromBos(request); + } + /** * Create a Document. * @@ -500,6 +551,38 @@ public ListDocumentsResponse listDocuments(String status) { return response; } + /** + * list all Document by status, marker. + *@param status document status + *@param marker the marker, can be "" + *@param maxSize the maxSize, should be (0, 200] + * + * @return A ListDocumentsResponse object containing the information returned by Document. + */ + public ListDocumentsResponse listDocuments(String status, String marker, int maxSize) { + ListDocumentsRequest request = new ListDocumentsRequest(); + InternalRequest internalRequest = this.createRequest(HttpMethodName.GET, request, DOC); + internalRequest.addParameter("status", status); + if (marker != null) { + internalRequest.addParameter("marker", marker); + } + internalRequest.addParameter("maxSize", String.valueOf(maxSize)); + + ListDocumentsResponse response; + try { + response = this.invokeHttpClient(internalRequest, ListDocumentsResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + // ignore exception + } + } + + return response; + } + + /** * delete a Document. * @@ -843,7 +926,4 @@ private InternalRequest createRequest( return internalRequest; } - - - } diff --git a/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosRequest.java b/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosRequest.java old mode 100755 new mode 100644 index 3c4f4ba6..b3dcdc91 --- a/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosRequest.java +++ b/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosRequest.java @@ -1,11 +1,22 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + package com.baidubce.services.doc.model; import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; -/** - * Created by baidu on 15/12/30. - */ + public class CreateDocumentFromBosRequest extends AbstractBceRequest { private String bucket = null; private String object = null; @@ -13,6 +24,7 @@ public class CreateDocumentFromBosRequest extends AbstractBceRequest { private String format = null; private String notification = null; private String access = null; + private String targetType = null; public CreateDocumentFromBosRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); @@ -56,4 +68,12 @@ public String getAccess() { public void setAccess(String access) { this.access = access; } + + public String getTargetType() { + return targetType; + } + + public void setTargetType(String targetType) { + this.targetType = targetType; + } } diff --git a/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosResponse.java b/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/CreateDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/CreateDocumentRequest.java old mode 100755 new mode 100644 index 250719a9..337288d0 --- a/src/main/java/com/baidubce/services/doc/model/CreateDocumentRequest.java +++ b/src/main/java/com/baidubce/services/doc/model/CreateDocumentRequest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + package com.baidubce.services.doc.model; import com.baidubce.auth.BceCredentials; @@ -5,15 +18,13 @@ import java.io.File; -/** - * Created by baidu on 15/12/30. - */ public class CreateDocumentRequest extends AbstractBceRequest { private File file = null; private String title = null; private String format = null; private String notification = null; private String access = null; + private String targetType = null; public CreateDocumentRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); @@ -51,4 +62,12 @@ public String getAccess() { public void setAccess(String access) { this.access = access; } + + public String getTargetType() { + return targetType; + } + + public void setTargetType(String targetType) { + this.targetType = targetType; + } } diff --git a/src/main/java/com/baidubce/services/doc/model/CreateDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/CreateDocumentResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/CreateNotificationRequest.java b/src/main/java/com/baidubce/services/doc/model/CreateNotificationRequest.java old mode 100755 new mode 100644 index da084902..03b2cde3 --- a/src/main/java/com/baidubce/services/doc/model/CreateNotificationRequest.java +++ b/src/main/java/com/baidubce/services/doc/model/CreateNotificationRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/CreateNotificationResponse.java b/src/main/java/com/baidubce/services/doc/model/CreateNotificationResponse.java old mode 100755 new mode 100644 index a259b3ac..0c25290a --- a/src/main/java/com/baidubce/services/doc/model/CreateNotificationResponse.java +++ b/src/main/java/com/baidubce/services/doc/model/CreateNotificationResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/DeleteDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/DeleteDocumentRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/DeleteDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/DeleteDocumentResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/DeleteNotificationRequest.java b/src/main/java/com/baidubce/services/doc/model/DeleteNotificationRequest.java old mode 100755 new mode 100644 index 0632e886..86a9f091 --- a/src/main/java/com/baidubce/services/doc/model/DeleteNotificationRequest.java +++ b/src/main/java/com/baidubce/services/doc/model/DeleteNotificationRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/DeleteNotificationResponse.java b/src/main/java/com/baidubce/services/doc/model/DeleteNotificationResponse.java old mode 100755 new mode 100644 index 50933447..e3af71ad --- a/src/main/java/com/baidubce/services/doc/model/DeleteNotificationResponse.java +++ b/src/main/java/com/baidubce/services/doc/model/DeleteNotificationResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/DisableReadTokenRequest.java b/src/main/java/com/baidubce/services/doc/model/DisableReadTokenRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/DisableReadTokenResponse.java b/src/main/java/com/baidubce/services/doc/model/DisableReadTokenResponse.java old mode 100755 new mode 100644 index 6f0f26e5..01d2d300 --- a/src/main/java/com/baidubce/services/doc/model/DisableReadTokenResponse.java +++ b/src/main/java/com/baidubce/services/doc/model/DisableReadTokenResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/Document.java b/src/main/java/com/baidubce/services/doc/model/Document.java old mode 100755 new mode 100644 index 7a0b8f07..4acab5dc --- a/src/main/java/com/baidubce/services/doc/model/Document.java +++ b/src/main/java/com/baidubce/services/doc/model/Document.java @@ -1,10 +1,20 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + package com.baidubce.services.doc.model; import java.util.Date; -/** - * Created by baidu on 16/1/4. - */ public class Document { private String documentId = null; private String status = null; @@ -12,6 +22,7 @@ public class Document { private String format = null; private String notification = null; private String access = null; + private String targetType = null; private DocumentError error = null; private Date createTime = null; @@ -63,6 +74,14 @@ public void setAccess(String access) { this.access = access; } + public String getTargetType() { + return targetType; + } + + public void setTargetType(String targetType) { + this.targetType = targetType; + } + public DocumentError getError() { return error; } @@ -89,6 +108,7 @@ public String toString() { sb.append(" format: ").append(format).append("\n"); sb.append(" notification: ").append(notification).append("\n"); sb.append(" access: ").append(access).append("\n"); + sb.append(" targetType: ").append(targetType).append("\n"); sb.append(" createTime: ").append(createTime).append("\n"); if (error != null) { sb.append(" error: ").append(error.toString()).append("\n"); diff --git a/src/main/java/com/baidubce/services/doc/model/DocumentError.java b/src/main/java/com/baidubce/services/doc/model/DocumentError.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/DocumentMeta.java b/src/main/java/com/baidubce/services/doc/model/DocumentMeta.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/DocumentPublishInfo.java b/src/main/java/com/baidubce/services/doc/model/DocumentPublishInfo.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/DocumentUploadInfo.java b/src/main/java/com/baidubce/services/doc/model/DocumentUploadInfo.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadRequest.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadResponse.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentResponse.java old mode 100755 new mode 100644 index 3ebaa16f..71ed533e --- a/src/main/java/com/baidubce/services/doc/model/GetDocumentResponse.java +++ b/src/main/java/com/baidubce/services/doc/model/GetDocumentResponse.java @@ -1,12 +1,22 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + package com.baidubce.services.doc.model; import com.baidubce.model.AbstractBceResponse; import java.util.Date; -/** - * Created by baidu on 15/12/31. - */ public class GetDocumentResponse extends AbstractBceResponse { private String documentId = null; private String status = null; @@ -14,6 +24,7 @@ public class GetDocumentResponse extends AbstractBceResponse { private String format = null; private String notification = null; private String access = null; + private String targetType = null; private Date createTime = null; private DocumentUploadInfo uploadInfo = null; private DocumentPublishInfo publishInfo = null; @@ -67,6 +78,14 @@ public void setAccess(String access) { this.access = access; } + public String getTargetType() { + return targetType; + } + + public void setTargetType(String targetType) { + this.targetType = targetType; + } + public Date getCreateTime() { return createTime; } @@ -110,6 +129,7 @@ public String toString() { sb.append(" format: ").append(format).append("\n"); sb.append(" notification: ").append(notification).append("\n"); sb.append(" access: ").append(access).append("\n"); + sb.append(" targetType: ").append(targetType).append("\n"); sb.append(" createTime: ").append(createTime).append("\n"); if (this.status.equals("PUBLISHED")) { sb.append(" publishInfo:").append(publishInfo.toString()).append("\n"); diff --git a/src/main/java/com/baidubce/services/doc/model/GetNotificationRequest.java b/src/main/java/com/baidubce/services/doc/model/GetNotificationRequest.java old mode 100755 new mode 100644 index e6fd11a7..3b62325c --- a/src/main/java/com/baidubce/services/doc/model/GetNotificationRequest.java +++ b/src/main/java/com/baidubce/services/doc/model/GetNotificationRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/GetNotificationResponse.java b/src/main/java/com/baidubce/services/doc/model/GetNotificationResponse.java old mode 100755 new mode 100644 index 6707ba6f..a7dc0037 --- a/src/main/java/com/baidubce/services/doc/model/GetNotificationResponse.java +++ b/src/main/java/com/baidubce/services/doc/model/GetNotificationResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/ListDocumentsRequest.java b/src/main/java/com/baidubce/services/doc/model/ListDocumentsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/ListDocumentsResponse.java b/src/main/java/com/baidubce/services/doc/model/ListDocumentsResponse.java old mode 100755 new mode 100644 index f57d59ff..b12b314d --- a/src/main/java/com/baidubce/services/doc/model/ListDocumentsResponse.java +++ b/src/main/java/com/baidubce/services/doc/model/ListDocumentsResponse.java @@ -1,25 +1,68 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + package com.baidubce.services.doc.model; import com.baidubce.model.AbstractBceResponse; import java.util.ArrayList; import java.util.List; -/** - * Created by baidu on 15/12/31. - */ public class ListDocumentsResponse extends AbstractBceResponse { private List documents = new ArrayList(); + private String marker; + + private boolean isTruncated; + + private String nextMarker; + public void setDocuments(List documents) { this.documents = documents; } public List getDocuments() { return this.documents; } + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public boolean getIsTruncated() { + return this.isTruncated; + } + + public void setIsTruncated(boolean truncated) { + this.isTruncated = truncated; + } + + public String getNextMarker() { + return nextMarker; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("class ListDocumentsResponse {\n"); + sb.append("marker:").append(this.marker).append("\n"); + sb.append("nextMarker:").append(this.nextMarker).append("\n"); + sb.append("isTruncated").append(this.isTruncated).append("\n"); sb.append(" documents: ").append(documents).append("\n"); sb.append("}\n"); return sb.toString(); diff --git a/src/main/java/com/baidubce/services/doc/model/ListNotificationsRequest.java b/src/main/java/com/baidubce/services/doc/model/ListNotificationsRequest.java old mode 100755 new mode 100644 index 3db5154a..baa3ec4c --- a/src/main/java/com/baidubce/services/doc/model/ListNotificationsRequest.java +++ b/src/main/java/com/baidubce/services/doc/model/ListNotificationsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/ListNotificationsResponse.java b/src/main/java/com/baidubce/services/doc/model/ListNotificationsResponse.java old mode 100755 new mode 100644 index 89861824..2651dee8 --- a/src/main/java/com/baidubce/services/doc/model/ListNotificationsResponse.java +++ b/src/main/java/com/baidubce/services/doc/model/ListNotificationsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/Notification.java b/src/main/java/com/baidubce/services/doc/model/Notification.java old mode 100755 new mode 100644 index de82cc66..1728ed5e --- a/src/main/java/com/baidubce/services/doc/model/Notification.java +++ b/src/main/java/com/baidubce/services/doc/model/Notification.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/doc/model/PublishDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/PublishDocumentRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/PublishDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/PublishDocumentResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/ReadDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/ReadDocumentRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/ReadDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/ReadDocumentResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/RegisterDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/RegisterDocumentRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/doc/model/RegisterDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/RegisterDocumentResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/iotdm/IotDmClient.java b/src/main/java/com/baidubce/services/iotdm/IotDmClient.java old mode 100755 new mode 100644 index 67273ef8..47d851f4 --- a/src/main/java/com/baidubce/services/iotdm/IotDmClient.java +++ b/src/main/java/com/baidubce/services/iotdm/IotDmClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java b/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java old mode 100755 new mode 100644 index e8bb98a3..42aad74a --- a/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java +++ b/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/CreateDevicesRequest.java b/src/main/java/com/baidubce/services/iotdm/model/CreateDevicesRequest.java old mode 100755 new mode 100644 index 215b6bee..f3f51e0e --- a/src/main/java/com/baidubce/services/iotdm/model/CreateDevicesRequest.java +++ b/src/main/java/com/baidubce/services/iotdm/model/CreateDevicesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/CreateDevicesResponse.java b/src/main/java/com/baidubce/services/iotdm/model/CreateDevicesResponse.java old mode 100755 new mode 100644 index 900a54f8..ef602cd4 --- a/src/main/java/com/baidubce/services/iotdm/model/CreateDevicesResponse.java +++ b/src/main/java/com/baidubce/services/iotdm/model/CreateDevicesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/CreateGroupRequest.java b/src/main/java/com/baidubce/services/iotdm/model/CreateGroupRequest.java old mode 100755 new mode 100644 index 3615bea9..10311ddd --- a/src/main/java/com/baidubce/services/iotdm/model/CreateGroupRequest.java +++ b/src/main/java/com/baidubce/services/iotdm/model/CreateGroupRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceAccessDetail.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceAccessDetail.java old mode 100755 new mode 100644 index a4ff9962..9731a426 --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceAccessDetail.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceAccessDetail.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceAttributes.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceAttributes.java old mode 100755 new mode 100644 index cdbf526c..a994ac43 --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceAttributes.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceGroup.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceGroup.java old mode 100755 new mode 100644 index 5393db51..e3ccd8cd --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceGroup.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceGroup.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceOperation.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceOperation.java old mode 100755 new mode 100644 index 8ff5de26..f9d0118c --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceOperation.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceOperation.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceOperationRequest.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceOperationRequest.java old mode 100755 new mode 100644 index a2f29698..59bff92e --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceOperationRequest.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceOperationRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceProfile.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceProfile.java old mode 100755 new mode 100644 index cf2b9ff7..52b02f44 --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceProfile.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceProfile.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceProfileResponse.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceProfileResponse.java old mode 100755 new mode 100644 index d252b02c..678997ac --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceProfileResponse.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceProfileResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceQueryRequest.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceQueryRequest.java old mode 100755 new mode 100644 index 2bbb2591..58be7a73 --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceQueryRequest.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceQueryRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/DeviceQueryResponse.java b/src/main/java/com/baidubce/services/iotdm/model/DeviceQueryResponse.java old mode 100755 new mode 100644 index 35999f61..a6019895 --- a/src/main/java/com/baidubce/services/iotdm/model/DeviceQueryResponse.java +++ b/src/main/java/com/baidubce/services/iotdm/model/DeviceQueryResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/GroupInfoResponse.java b/src/main/java/com/baidubce/services/iotdm/model/GroupInfoResponse.java old mode 100755 new mode 100644 index 8fa31585..873f5273 --- a/src/main/java/com/baidubce/services/iotdm/model/GroupInfoResponse.java +++ b/src/main/java/com/baidubce/services/iotdm/model/GroupInfoResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/GroupListResponse.java b/src/main/java/com/baidubce/services/iotdm/model/GroupListResponse.java old mode 100755 new mode 100644 index 2605e5fd..6967e776 --- a/src/main/java/com/baidubce/services/iotdm/model/GroupListResponse.java +++ b/src/main/java/com/baidubce/services/iotdm/model/GroupListResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/Page.java b/src/main/java/com/baidubce/services/iotdm/model/Page.java old mode 100755 new mode 100644 index bd06c4d9..4253d7a7 --- a/src/main/java/com/baidubce/services/iotdm/model/Page.java +++ b/src/main/java/com/baidubce/services/iotdm/model/Page.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/RemoveDevicesRequest.java b/src/main/java/com/baidubce/services/iotdm/model/RemoveDevicesRequest.java old mode 100755 new mode 100644 index 11889117..1f7b94d4 --- a/src/main/java/com/baidubce/services/iotdm/model/RemoveDevicesRequest.java +++ b/src/main/java/com/baidubce/services/iotdm/model/RemoveDevicesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/ThingDetail.java b/src/main/java/com/baidubce/services/iotdm/model/ThingDetail.java old mode 100755 new mode 100644 index 94ae25e0..e6716122 --- a/src/main/java/com/baidubce/services/iotdm/model/ThingDetail.java +++ b/src/main/java/com/baidubce/services/iotdm/model/ThingDetail.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/UpdateDeviceProfileRequest.java b/src/main/java/com/baidubce/services/iotdm/model/UpdateDeviceProfileRequest.java old mode 100755 new mode 100644 index b376352b..2f064aeb --- a/src/main/java/com/baidubce/services/iotdm/model/UpdateDeviceProfileRequest.java +++ b/src/main/java/com/baidubce/services/iotdm/model/UpdateDeviceProfileRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/UpdateDeviceRegistryRequest.java b/src/main/java/com/baidubce/services/iotdm/model/UpdateDeviceRegistryRequest.java old mode 100755 new mode 100644 index 7d0398e0..cdbad9df --- a/src/main/java/com/baidubce/services/iotdm/model/UpdateDeviceRegistryRequest.java +++ b/src/main/java/com/baidubce/services/iotdm/model/UpdateDeviceRegistryRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iotdm/model/UpdateGroupRequest.java b/src/main/java/com/baidubce/services/iotdm/model/UpdateGroupRequest.java old mode 100755 new mode 100644 index 70d03870..c37394b6 --- a/src/main/java/com/baidubce/services/iotdm/model/UpdateGroupRequest.java +++ b/src/main/java/com/baidubce/services/iotdm/model/UpdateGroupRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/IotHubClient.java b/src/main/java/com/baidubce/services/iothub/IotHubClient.java old mode 100755 new mode 100644 index b64baed1..3779e6b7 --- a/src/main/java/com/baidubce/services/iothub/IotHubClient.java +++ b/src/main/java/com/baidubce/services/iothub/IotHubClient.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/AttachPrincipalToPolicyRequest.java b/src/main/java/com/baidubce/services/iothub/model/AttachPrincipalToPolicyRequest.java old mode 100755 new mode 100644 index 554fb5fc..fad788c1 --- a/src/main/java/com/baidubce/services/iothub/model/AttachPrincipalToPolicyRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/AttachPrincipalToPolicyRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/AttachThingToPrincipalRequest.java b/src/main/java/com/baidubce/services/iothub/model/AttachThingToPrincipalRequest.java old mode 100755 new mode 100644 index 242a6003..dd3f40c3 --- a/src/main/java/com/baidubce/services/iothub/model/AttachThingToPrincipalRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/AttachThingToPrincipalRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/BaseRequest.java b/src/main/java/com/baidubce/services/iothub/model/BaseRequest.java old mode 100755 new mode 100644 index 7b5cbe45..684f714c --- a/src/main/java/com/baidubce/services/iothub/model/BaseRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/BaseRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/BaseResponse.java b/src/main/java/com/baidubce/services/iothub/model/BaseResponse.java old mode 100755 new mode 100644 index c2352abc..3c305b75 --- a/src/main/java/com/baidubce/services/iothub/model/BaseResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/BaseResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/CreatePermissionRequest.java b/src/main/java/com/baidubce/services/iothub/model/CreatePermissionRequest.java old mode 100755 new mode 100644 index beae691f..5ae37731 --- a/src/main/java/com/baidubce/services/iothub/model/CreatePermissionRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/CreatePermissionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/CreatePrincipalResponse.java b/src/main/java/com/baidubce/services/iothub/model/CreatePrincipalResponse.java old mode 100755 new mode 100644 index 8699c5b3..6fcc6f63 --- a/src/main/java/com/baidubce/services/iothub/model/CreatePrincipalResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/CreatePrincipalResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/DeleteThingRequest.java b/src/main/java/com/baidubce/services/iothub/model/DeleteThingRequest.java old mode 100755 new mode 100644 index b6eb4390..91bd7cbe --- a/src/main/java/com/baidubce/services/iothub/model/DeleteThingRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/DeleteThingRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/ListEndpointsRequest.java b/src/main/java/com/baidubce/services/iothub/model/ListEndpointsRequest.java old mode 100755 new mode 100644 index fa3cf1bc..1462204e --- a/src/main/java/com/baidubce/services/iothub/model/ListEndpointsRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/ListEndpointsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/ListPermissionResponse.java b/src/main/java/com/baidubce/services/iothub/model/ListPermissionResponse.java old mode 100755 new mode 100644 index e0eed999..1b872252 --- a/src/main/java/com/baidubce/services/iothub/model/ListPermissionResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/ListPermissionResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/ListPolicyRequest.java b/src/main/java/com/baidubce/services/iothub/model/ListPolicyRequest.java old mode 100755 new mode 100644 index beb5b7c8..7a050a41 --- a/src/main/java/com/baidubce/services/iothub/model/ListPolicyRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/ListPolicyRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/ListPrincipalsRequest.java b/src/main/java/com/baidubce/services/iothub/model/ListPrincipalsRequest.java old mode 100755 new mode 100644 index 548b7430..beeb833d --- a/src/main/java/com/baidubce/services/iothub/model/ListPrincipalsRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/ListPrincipalsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/ListResponse.java b/src/main/java/com/baidubce/services/iothub/model/ListResponse.java old mode 100755 new mode 100644 index 3c6fc013..ae4f3e9d --- a/src/main/java/com/baidubce/services/iothub/model/ListResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/ListResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/ListThingsRequest.java b/src/main/java/com/baidubce/services/iothub/model/ListThingsRequest.java old mode 100755 new mode 100644 index a1b9db84..4dc347ab --- a/src/main/java/com/baidubce/services/iothub/model/ListThingsRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/ListThingsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/Operation.java b/src/main/java/com/baidubce/services/iothub/model/Operation.java old mode 100755 new mode 100644 index c346af27..020b093f --- a/src/main/java/com/baidubce/services/iothub/model/Operation.java +++ b/src/main/java/com/baidubce/services/iothub/model/Operation.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/Permission.java b/src/main/java/com/baidubce/services/iothub/model/Permission.java old mode 100755 new mode 100644 index 5d0f949b..1d142194 --- a/src/main/java/com/baidubce/services/iothub/model/Permission.java +++ b/src/main/java/com/baidubce/services/iothub/model/Permission.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryEndpointRequest.java b/src/main/java/com/baidubce/services/iothub/model/QueryEndpointRequest.java old mode 100755 new mode 100644 index 262e12be..e28cd6f7 --- a/src/main/java/com/baidubce/services/iothub/model/QueryEndpointRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryEndpointRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryEndpointResponse.java b/src/main/java/com/baidubce/services/iothub/model/QueryEndpointResponse.java old mode 100755 new mode 100644 index bd176217..20e999e4 --- a/src/main/java/com/baidubce/services/iothub/model/QueryEndpointResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryEndpointResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryPermissionRequest.java b/src/main/java/com/baidubce/services/iothub/model/QueryPermissionRequest.java old mode 100755 new mode 100644 index 5d6c3dbc..b93b9738 --- a/src/main/java/com/baidubce/services/iothub/model/QueryPermissionRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryPermissionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryPermissionResponse.java b/src/main/java/com/baidubce/services/iothub/model/QueryPermissionResponse.java old mode 100755 new mode 100644 index 14cffe12..416f1469 --- a/src/main/java/com/baidubce/services/iothub/model/QueryPermissionResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryPermissionResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryPolicyRequest.java b/src/main/java/com/baidubce/services/iothub/model/QueryPolicyRequest.java old mode 100755 new mode 100644 index 19a6d47c..c9e52c98 --- a/src/main/java/com/baidubce/services/iothub/model/QueryPolicyRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryPolicyRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryPolicyResponse.java b/src/main/java/com/baidubce/services/iothub/model/QueryPolicyResponse.java old mode 100755 new mode 100644 index da441ccf..463b42d1 --- a/src/main/java/com/baidubce/services/iothub/model/QueryPolicyResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryPolicyResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalRequest.java b/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalRequest.java old mode 100755 new mode 100644 index cfcbe2e5..56bbebaa --- a/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalResponse.java b/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalResponse.java old mode 100755 new mode 100644 index 85fcd226..6d97409b --- a/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryPrincipalResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryResponse.java b/src/main/java/com/baidubce/services/iothub/model/QueryResponse.java old mode 100755 new mode 100644 index ceea135a..18bf314b --- a/src/main/java/com/baidubce/services/iothub/model/QueryResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryThingRequest.java b/src/main/java/com/baidubce/services/iothub/model/QueryThingRequest.java old mode 100755 new mode 100644 index 46699c6c..a11b6b95 --- a/src/main/java/com/baidubce/services/iothub/model/QueryThingRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryThingRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/QueryThingResponse.java b/src/main/java/com/baidubce/services/iothub/model/QueryThingResponse.java old mode 100755 new mode 100644 index 27e9fcf0..8f3f4670 --- a/src/main/java/com/baidubce/services/iothub/model/QueryThingResponse.java +++ b/src/main/java/com/baidubce/services/iothub/model/QueryThingResponse.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/RegenerateCertRequest.java b/src/main/java/com/baidubce/services/iothub/model/RegenerateCertRequest.java old mode 100755 new mode 100644 index be408b30..f88537ef --- a/src/main/java/com/baidubce/services/iothub/model/RegenerateCertRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/RegenerateCertRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/iothub/model/UpdatePermissionRequest.java b/src/main/java/com/baidubce/services/iothub/model/UpdatePermissionRequest.java old mode 100755 new mode 100644 index a3c51d08..0daddd96 --- a/src/main/java/com/baidubce/services/iothub/model/UpdatePermissionRequest.java +++ b/src/main/java/com/baidubce/services/iothub/model/UpdatePermissionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016 Baidu, Inc. All Rights Reserved. + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/LssClient.java b/src/main/java/com/baidubce/services/lss/LssClient.java old mode 100755 new mode 100644 index b8d08f31..401e76cb --- a/src/main/java/com/baidubce/services/lss/LssClient.java +++ b/src/main/java/com/baidubce/services/lss/LssClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/LssUtils.java b/src/main/java/com/baidubce/services/lss/LssUtils.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/AntiLeech.java b/src/main/java/com/baidubce/services/lss/model/AntiLeech.java old mode 100755 new mode 100644 index 324be276..f631a0a9 --- a/src/main/java/com/baidubce/services/lss/model/AntiLeech.java +++ b/src/main/java/com/baidubce/services/lss/model/AntiLeech.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Audio.java b/src/main/java/com/baidubce/services/lss/model/Audio.java old mode 100755 new mode 100644 index 0e1dc776..22457913 --- a/src/main/java/com/baidubce/services/lss/model/Audio.java +++ b/src/main/java/com/baidubce/services/lss/model/Audio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Auth.java b/src/main/java/com/baidubce/services/lss/model/Auth.java old mode 100755 new mode 100644 index 5d9edc53..d3db94be --- a/src/main/java/com/baidubce/services/lss/model/Auth.java +++ b/src/main/java/com/baidubce/services/lss/model/Auth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/AuthInfo.java b/src/main/java/com/baidubce/services/lss/model/AuthInfo.java old mode 100755 new mode 100644 index 94b413fd..683d5a19 --- a/src/main/java/com/baidubce/services/lss/model/AuthInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/AuthInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Bos.java b/src/main/java/com/baidubce/services/lss/model/Bos.java old mode 100755 new mode 100644 index 317ef3d2..f6032c4b --- a/src/main/java/com/baidubce/services/lss/model/Bos.java +++ b/src/main/java/com/baidubce/services/lss/model/Bos.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Capture.java b/src/main/java/com/baidubce/services/lss/model/Capture.java old mode 100755 new mode 100644 index af91c536..009f1d52 --- a/src/main/java/com/baidubce/services/lss/model/Capture.java +++ b/src/main/java/com/baidubce/services/lss/model/Capture.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/CodecOptions.java b/src/main/java/com/baidubce/services/lss/model/CodecOptions.java old mode 100755 new mode 100644 index d49ad695..7de98260 --- a/src/main/java/com/baidubce/services/lss/model/CodecOptions.java +++ b/src/main/java/com/baidubce/services/lss/model/CodecOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/CreateNotificationRequest.java b/src/main/java/com/baidubce/services/lss/model/CreateNotificationRequest.java old mode 100755 new mode 100644 index b7779b65..41a6fc13 --- a/src/main/java/com/baidubce/services/lss/model/CreateNotificationRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/CreateNotificationRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/CreateNotificationResponse.java b/src/main/java/com/baidubce/services/lss/model/CreateNotificationResponse.java old mode 100755 new mode 100644 index 32c16c1e..a64ee453 --- a/src/main/java/com/baidubce/services/lss/model/CreateNotificationResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/CreateNotificationResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/CreatePresetRequest.java b/src/main/java/com/baidubce/services/lss/model/CreatePresetRequest.java old mode 100755 new mode 100644 index 8f74a590..6cbe3b31 --- a/src/main/java/com/baidubce/services/lss/model/CreatePresetRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/CreatePresetRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/CreatePresetResponse.java b/src/main/java/com/baidubce/services/lss/model/CreatePresetResponse.java old mode 100755 new mode 100644 index e2516438..2749cebd --- a/src/main/java/com/baidubce/services/lss/model/CreatePresetResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/CreatePresetResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/CreateSessionRequest.java b/src/main/java/com/baidubce/services/lss/model/CreateSessionRequest.java old mode 100755 new mode 100644 index 19317009..e584637e --- a/src/main/java/com/baidubce/services/lss/model/CreateSessionRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/CreateSessionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/CreateSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/CreateSessionResponse.java old mode 100755 new mode 100644 index feb03993..141fcf34 --- a/src/main/java/com/baidubce/services/lss/model/CreateSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/CreateSessionResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/CreateStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/CreateStreamRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/CreateStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/CreateStreamResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/DeleteNotificationRequest.java b/src/main/java/com/baidubce/services/lss/model/DeleteNotificationRequest.java old mode 100755 new mode 100644 index 53302486..fee3e0ca --- a/src/main/java/com/baidubce/services/lss/model/DeleteNotificationRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/DeleteNotificationRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/DeleteNotificationResponse.java b/src/main/java/com/baidubce/services/lss/model/DeleteNotificationResponse.java old mode 100755 new mode 100644 index b80a349f..9312ea87 --- a/src/main/java/com/baidubce/services/lss/model/DeleteNotificationResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/DeleteNotificationResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/DeletePresetRequest.java b/src/main/java/com/baidubce/services/lss/model/DeletePresetRequest.java old mode 100755 new mode 100644 index 6e7918ad..9905b650 --- a/src/main/java/com/baidubce/services/lss/model/DeletePresetRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/DeletePresetRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/DeletePresetResponse.java b/src/main/java/com/baidubce/services/lss/model/DeletePresetResponse.java old mode 100755 new mode 100644 index 6c220f89..ad52f819 --- a/src/main/java/com/baidubce/services/lss/model/DeletePresetResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/DeletePresetResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/DeleteSessionRequest.java b/src/main/java/com/baidubce/services/lss/model/DeleteSessionRequest.java old mode 100755 new mode 100644 index 709b0165..2c3016ef --- a/src/main/java/com/baidubce/services/lss/model/DeleteSessionRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/DeleteSessionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/DeleteSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/DeleteSessionResponse.java old mode 100755 new mode 100644 index d29e9d83..81475919 --- a/src/main/java/com/baidubce/services/lss/model/DeleteSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/DeleteSessionResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Encryption.java b/src/main/java/com/baidubce/services/lss/model/Encryption.java old mode 100755 new mode 100644 index 015ac4d2..144588dc --- a/src/main/java/com/baidubce/services/lss/model/Encryption.java +++ b/src/main/java/com/baidubce/services/lss/model/Encryption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsBandwidthResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsBandwidthResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsPlayCountResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsPlayCountResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsStatisticsRequest.java b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsStatisticsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetAllDomainsTrafficResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAllDomainsTrafficResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetAppRequest.java b/src/main/java/com/baidubce/services/lss/model/GetAppRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetAppResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAppResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetAppStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/GetAppStreamRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetAppStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAppStreamResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetDomainStatisticsRequest.java b/src/main/java/com/baidubce/services/lss/model/GetDomainStatisticsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetDomainStatisticsResponse.java b/src/main/java/com/baidubce/services/lss/model/GetDomainStatisticsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetDomainSummaryStatisticsRequest.java b/src/main/java/com/baidubce/services/lss/model/GetDomainSummaryStatisticsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetDomainSummaryStatisticsResponse.java b/src/main/java/com/baidubce/services/lss/model/GetDomainSummaryStatisticsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetNotificationRequest.java b/src/main/java/com/baidubce/services/lss/model/GetNotificationRequest.java old mode 100755 new mode 100644 index 7a0f6c0c..b1ac9c54 --- a/src/main/java/com/baidubce/services/lss/model/GetNotificationRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/GetNotificationRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetNotificationResponse.java b/src/main/java/com/baidubce/services/lss/model/GetNotificationResponse.java old mode 100755 new mode 100644 index 42a62f37..01947b82 --- a/src/main/java/com/baidubce/services/lss/model/GetNotificationResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetNotificationResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetOneDomainBandwidthResponse.java b/src/main/java/com/baidubce/services/lss/model/GetOneDomainBandwidthResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetOneDomainPlayCountResponse.java b/src/main/java/com/baidubce/services/lss/model/GetOneDomainPlayCountResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetOneDomainStatisticsRequest.java b/src/main/java/com/baidubce/services/lss/model/GetOneDomainStatisticsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetOneDomainTrafficResponse.java b/src/main/java/com/baidubce/services/lss/model/GetOneDomainTrafficResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetPresetRequest.java b/src/main/java/com/baidubce/services/lss/model/GetPresetRequest.java old mode 100755 new mode 100644 index 0ec8f5b8..ea2d7d82 --- a/src/main/java/com/baidubce/services/lss/model/GetPresetRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/GetPresetRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetPresetResponse.java b/src/main/java/com/baidubce/services/lss/model/GetPresetResponse.java old mode 100755 new mode 100644 index b3c02ad0..1676c611 --- a/src/main/java/com/baidubce/services/lss/model/GetPresetResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetPresetResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetRecordingRequest.java b/src/main/java/com/baidubce/services/lss/model/GetRecordingRequest.java old mode 100755 new mode 100644 index 10346afa..3b9323cf --- a/src/main/java/com/baidubce/services/lss/model/GetRecordingRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/GetRecordingRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetRecordingResponse.java b/src/main/java/com/baidubce/services/lss/model/GetRecordingResponse.java old mode 100755 new mode 100644 index a193c583..ec183214 --- a/src/main/java/com/baidubce/services/lss/model/GetRecordingResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetRecordingResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetSecurityPolicyRequest.java b/src/main/java/com/baidubce/services/lss/model/GetSecurityPolicyRequest.java old mode 100755 new mode 100644 index 88bdafd6..d79a9db5 --- a/src/main/java/com/baidubce/services/lss/model/GetSecurityPolicyRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/GetSecurityPolicyRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetSecurityPolicyResponse.java b/src/main/java/com/baidubce/services/lss/model/GetSecurityPolicyResponse.java old mode 100755 new mode 100644 index fdf286a2..c0568326 --- a/src/main/java/com/baidubce/services/lss/model/GetSecurityPolicyResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetSecurityPolicyResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetSessionRequest.java b/src/main/java/com/baidubce/services/lss/model/GetSessionRequest.java old mode 100755 new mode 100644 index 3f7dbea1..efe82eb8 --- a/src/main/java/com/baidubce/services/lss/model/GetSessionRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/GetSessionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/GetSessionResponse.java old mode 100755 new mode 100644 index 830b9bce..fbce93aa --- a/src/main/java/com/baidubce/services/lss/model/GetSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetSessionResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetSessionSourceInfoRequest.java b/src/main/java/com/baidubce/services/lss/model/GetSessionSourceInfoRequest.java old mode 100755 new mode 100644 index dd3be176..69586831 --- a/src/main/java/com/baidubce/services/lss/model/GetSessionSourceInfoRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/GetSessionSourceInfoRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetSessionSourceInfoResponse.java b/src/main/java/com/baidubce/services/lss/model/GetSessionSourceInfoResponse.java old mode 100755 new mode 100644 index 5b1a7335..eb866aeb --- a/src/main/java/com/baidubce/services/lss/model/GetSessionSourceInfoResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetSessionSourceInfoResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/GetSessionStatisticsRequest.java b/src/main/java/com/baidubce/services/lss/model/GetSessionStatisticsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetSessionStatisticsResponse.java b/src/main/java/com/baidubce/services/lss/model/GetSessionStatisticsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/GetStreamRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/GetStreamResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetStreamStatisticsRequest.java b/src/main/java/com/baidubce/services/lss/model/GetStreamStatisticsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/GetStreamStatisticsResponse.java b/src/main/java/com/baidubce/services/lss/model/GetStreamStatisticsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/Hls.java b/src/main/java/com/baidubce/services/lss/model/Hls.java old mode 100755 new mode 100644 index 863eef7d..b965e59d --- a/src/main/java/com/baidubce/services/lss/model/Hls.java +++ b/src/main/java/com/baidubce/services/lss/model/Hls.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/HlsEncryption.java b/src/main/java/com/baidubce/services/lss/model/HlsEncryption.java old mode 100755 new mode 100644 index 9b34235f..284b6a08 --- a/src/main/java/com/baidubce/services/lss/model/HlsEncryption.java +++ b/src/main/java/com/baidubce/services/lss/model/HlsEncryption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/IP.java b/src/main/java/com/baidubce/services/lss/model/IP.java old mode 100755 new mode 100644 index ff6440a4..164b1f54 --- a/src/main/java/com/baidubce/services/lss/model/IP.java +++ b/src/main/java/com/baidubce/services/lss/model/IP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/InnerSessionStatistics.java b/src/main/java/com/baidubce/services/lss/model/InnerSessionStatistics.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/InsertCuePointInnerRequest.java b/src/main/java/com/baidubce/services/lss/model/InsertCuePointInnerRequest.java old mode 100755 new mode 100644 index 4d3f58dc..68743011 --- a/src/main/java/com/baidubce/services/lss/model/InsertCuePointInnerRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/InsertCuePointInnerRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/InsertCuePointRequest.java b/src/main/java/com/baidubce/services/lss/model/InsertCuePointRequest.java old mode 100755 new mode 100644 index 771782b8..484ddcef --- a/src/main/java/com/baidubce/services/lss/model/InsertCuePointRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/InsertCuePointRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/InsertCuePointResponse.java b/src/main/java/com/baidubce/services/lss/model/InsertCuePointResponse.java old mode 100755 new mode 100644 index 7f47fc83..4a723013 --- a/src/main/java/com/baidubce/services/lss/model/InsertCuePointResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/InsertCuePointResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListAppRequest.java b/src/main/java/com/baidubce/services/lss/model/ListAppRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListAppResponse.java b/src/main/java/com/baidubce/services/lss/model/ListAppResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListAppStreamsRequest.java b/src/main/java/com/baidubce/services/lss/model/ListAppStreamsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListAppStreamsResponse.java b/src/main/java/com/baidubce/services/lss/model/ListAppStreamsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListDomainAppRequest.java b/src/main/java/com/baidubce/services/lss/model/ListDomainAppRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListDomainAppResponse.java b/src/main/java/com/baidubce/services/lss/model/ListDomainAppResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListDomainStatisticsRequest.java b/src/main/java/com/baidubce/services/lss/model/ListDomainStatisticsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListDomainStatisticsResponse.java b/src/main/java/com/baidubce/services/lss/model/ListDomainStatisticsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListNotificationsRequest.java b/src/main/java/com/baidubce/services/lss/model/ListNotificationsRequest.java old mode 100755 new mode 100644 index 5ea21a40..5a9ed4f8 --- a/src/main/java/com/baidubce/services/lss/model/ListNotificationsRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/ListNotificationsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListNotificationsResponse.java b/src/main/java/com/baidubce/services/lss/model/ListNotificationsResponse.java old mode 100755 new mode 100644 index 0e4aa1f1..bfdab954 --- a/src/main/java/com/baidubce/services/lss/model/ListNotificationsResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/ListNotificationsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListPresetsRequest.java b/src/main/java/com/baidubce/services/lss/model/ListPresetsRequest.java old mode 100755 new mode 100644 index d0a207df..3f0c9be4 --- a/src/main/java/com/baidubce/services/lss/model/ListPresetsRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/ListPresetsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListPresetsResponse.java b/src/main/java/com/baidubce/services/lss/model/ListPresetsResponse.java old mode 100755 new mode 100644 index b3c89ec5..106f7c9e --- a/src/main/java/com/baidubce/services/lss/model/ListPresetsResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/ListPresetsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListRecordingsRequest.java b/src/main/java/com/baidubce/services/lss/model/ListRecordingsRequest.java old mode 100755 new mode 100644 index f3effdf7..c03cdbc1 --- a/src/main/java/com/baidubce/services/lss/model/ListRecordingsRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/ListRecordingsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListRecordingsResponse.java b/src/main/java/com/baidubce/services/lss/model/ListRecordingsResponse.java old mode 100755 new mode 100644 index 6b2d2d58..333a2090 --- a/src/main/java/com/baidubce/services/lss/model/ListRecordingsResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/ListRecordingsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListSecurityPoliciesRequest.java b/src/main/java/com/baidubce/services/lss/model/ListSecurityPoliciesRequest.java old mode 100755 new mode 100644 index d40385a3..3e8e91a1 --- a/src/main/java/com/baidubce/services/lss/model/ListSecurityPoliciesRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/ListSecurityPoliciesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListSecurityPoliciesResponse.java b/src/main/java/com/baidubce/services/lss/model/ListSecurityPoliciesResponse.java old mode 100755 new mode 100644 index 9816f233..2f362c31 --- a/src/main/java/com/baidubce/services/lss/model/ListSecurityPoliciesResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/ListSecurityPoliciesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListSessionsRequest.java b/src/main/java/com/baidubce/services/lss/model/ListSessionsRequest.java old mode 100755 new mode 100644 index 40502b06..61d00d21 --- a/src/main/java/com/baidubce/services/lss/model/ListSessionsRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/ListSessionsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListSessionsResponse.java b/src/main/java/com/baidubce/services/lss/model/ListSessionsResponse.java old mode 100755 new mode 100644 index db94d359..7ba8fc09 --- a/src/main/java/com/baidubce/services/lss/model/ListSessionsResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/ListSessionsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ListStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/ListStreamRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/ListStreamResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListStreamStatisticsRequest.java b/src/main/java/com/baidubce/services/lss/model/ListStreamStatisticsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ListStreamStatisticsResponse.java b/src/main/java/com/baidubce/services/lss/model/ListStreamStatisticsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/LiveAuth.java b/src/main/java/com/baidubce/services/lss/model/LiveAuth.java old mode 100755 new mode 100644 index f9720be7..50a5cca4 --- a/src/main/java/com/baidubce/services/lss/model/LiveAuth.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveAuth.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LiveDomainStatistics.java b/src/main/java/com/baidubce/services/lss/model/LiveDomainStatistics.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/LiveInfo.java b/src/main/java/com/baidubce/services/lss/model/LiveInfo.java old mode 100755 new mode 100644 index 24838a52..ad4c8ed0 --- a/src/main/java/com/baidubce/services/lss/model/LiveInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LivePlay.java b/src/main/java/com/baidubce/services/lss/model/LivePlay.java old mode 100755 new mode 100644 index 7b455811..ac58c1a2 --- a/src/main/java/com/baidubce/services/lss/model/LivePlay.java +++ b/src/main/java/com/baidubce/services/lss/model/LivePlay.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LivePreset.java b/src/main/java/com/baidubce/services/lss/model/LivePreset.java old mode 100755 new mode 100644 index 26008a40..ad393c76 --- a/src/main/java/com/baidubce/services/lss/model/LivePreset.java +++ b/src/main/java/com/baidubce/services/lss/model/LivePreset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LivePublish.java b/src/main/java/com/baidubce/services/lss/model/LivePublish.java old mode 100755 new mode 100644 index 0aeb40f6..f19d4b6c --- a/src/main/java/com/baidubce/services/lss/model/LivePublish.java +++ b/src/main/java/com/baidubce/services/lss/model/LivePublish.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LivePublishInfo.java b/src/main/java/com/baidubce/services/lss/model/LivePublishInfo.java old mode 100755 new mode 100644 index 86e1f8b0..8f5109df --- a/src/main/java/com/baidubce/services/lss/model/LivePublishInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/LivePublishInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LiveRecordPrefix.java b/src/main/java/com/baidubce/services/lss/model/LiveRecordPrefix.java old mode 100755 new mode 100644 index 5c532678..b2d62ad0 --- a/src/main/java/com/baidubce/services/lss/model/LiveRecordPrefix.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveRecordPrefix.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LiveSession.java b/src/main/java/com/baidubce/services/lss/model/LiveSession.java old mode 100755 new mode 100644 index 791c355f..185294c4 --- a/src/main/java/com/baidubce/services/lss/model/LiveSession.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStatistics.java b/src/main/java/com/baidubce/services/lss/model/LiveStatistics.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStatisticsSummary.java b/src/main/java/com/baidubce/services/lss/model/LiveStatisticsSummary.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStatisticsWithDate.java b/src/main/java/com/baidubce/services/lss/model/LiveStatisticsWithDate.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStream.java b/src/main/java/com/baidubce/services/lss/model/LiveStream.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/LiveStreamStatistics.java b/src/main/java/com/baidubce/services/lss/model/LiveStreamStatistics.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/LiveTarget.java b/src/main/java/com/baidubce/services/lss/model/LiveTarget.java old mode 100755 new mode 100644 index bda59038..c6f0976e --- a/src/main/java/com/baidubce/services/lss/model/LiveTarget.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveTarget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LiveThumbnail.java b/src/main/java/com/baidubce/services/lss/model/LiveThumbnail.java old mode 100755 new mode 100644 index 3f3c049a..c88f8280 --- a/src/main/java/com/baidubce/services/lss/model/LiveThumbnail.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveThumbnail.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LiveThumbnailPrefix.java b/src/main/java/com/baidubce/services/lss/model/LiveThumbnailPrefix.java old mode 100755 new mode 100644 index 3d769bfc..a731c998 --- a/src/main/java/com/baidubce/services/lss/model/LiveThumbnailPrefix.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveThumbnailPrefix.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/LiveToken.java b/src/main/java/com/baidubce/services/lss/model/LiveToken.java old mode 100755 new mode 100644 index ac803d73..fa125d76 --- a/src/main/java/com/baidubce/services/lss/model/LiveToken.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveToken.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Notification.java b/src/main/java/com/baidubce/services/lss/model/Notification.java old mode 100755 new mode 100644 index 89270127..27d45d1c --- a/src/main/java/com/baidubce/services/lss/model/Notification.java +++ b/src/main/java/com/baidubce/services/lss/model/Notification.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/PauseAppStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/PauseAppStreamRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/PauseAppStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/PauseAppStreamResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/PauseDomainStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/PauseDomainStreamRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/PauseDomainStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/PauseDomainStreamResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/PauseSessionRequest.java b/src/main/java/com/baidubce/services/lss/model/PauseSessionRequest.java old mode 100755 new mode 100644 index 84315390..17eae662 --- a/src/main/java/com/baidubce/services/lss/model/PauseSessionRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/PauseSessionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/PauseSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/PauseSessionResponse.java old mode 100755 new mode 100644 index 27d09176..6ef26711 --- a/src/main/java/com/baidubce/services/lss/model/PauseSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/PauseSessionResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/PlayPrefix.java b/src/main/java/com/baidubce/services/lss/model/PlayPrefix.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/PublishPrefix.java b/src/main/java/com/baidubce/services/lss/model/PublishPrefix.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/RealTimeSessionStatistics.java b/src/main/java/com/baidubce/services/lss/model/RealTimeSessionStatistics.java old mode 100755 new mode 100644 index 0abbeb26..36dff105 --- a/src/main/java/com/baidubce/services/lss/model/RealTimeSessionStatistics.java +++ b/src/main/java/com/baidubce/services/lss/model/RealTimeSessionStatistics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Recording.java b/src/main/java/com/baidubce/services/lss/model/Recording.java old mode 100755 new mode 100644 index b9760c67..a5e2a13f --- a/src/main/java/com/baidubce/services/lss/model/Recording.java +++ b/src/main/java/com/baidubce/services/lss/model/Recording.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/RecordingInfo.java b/src/main/java/com/baidubce/services/lss/model/RecordingInfo.java old mode 100755 new mode 100644 index cb5ca2b3..edbc256e --- a/src/main/java/com/baidubce/services/lss/model/RecordingInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/RecordingInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Refer.java b/src/main/java/com/baidubce/services/lss/model/Refer.java old mode 100755 new mode 100644 index 6b5a7a81..ed275b68 --- a/src/main/java/com/baidubce/services/lss/model/Refer.java +++ b/src/main/java/com/baidubce/services/lss/model/Refer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/RefreshSessionRequest.java b/src/main/java/com/baidubce/services/lss/model/RefreshSessionRequest.java old mode 100755 new mode 100644 index f4c4ddda..5174e1e8 --- a/src/main/java/com/baidubce/services/lss/model/RefreshSessionRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/RefreshSessionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/RefreshSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/RefreshSessionResponse.java old mode 100755 new mode 100644 index 8ed583f1..4650dfc7 --- a/src/main/java/com/baidubce/services/lss/model/RefreshSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/RefreshSessionResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ResumeDomainStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/ResumeDomainStreamRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ResumeDomainStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/ResumeDomainStreamResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/ResumeSessionRequest.java b/src/main/java/com/baidubce/services/lss/model/ResumeSessionRequest.java old mode 100755 new mode 100644 index a28e2892..88f4d685 --- a/src/main/java/com/baidubce/services/lss/model/ResumeSessionRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/ResumeSessionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/ResumeSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/ResumeSessionResponse.java old mode 100755 new mode 100644 index 0b746d6b..4f807360 --- a/src/main/java/com/baidubce/services/lss/model/ResumeSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/ResumeSessionResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Rtmp.java b/src/main/java/com/baidubce/services/lss/model/Rtmp.java old mode 100755 new mode 100644 index 51252bf9..3d85e0fa --- a/src/main/java/com/baidubce/services/lss/model/Rtmp.java +++ b/src/main/java/com/baidubce/services/lss/model/Rtmp.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/SafeCode.java b/src/main/java/com/baidubce/services/lss/model/SafeCode.java old mode 100755 new mode 100644 index 14bcf679..ad5177ce --- a/src/main/java/com/baidubce/services/lss/model/SafeCode.java +++ b/src/main/java/com/baidubce/services/lss/model/SafeCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/SecurityPolicy.java b/src/main/java/com/baidubce/services/lss/model/SecurityPolicy.java old mode 100755 new mode 100644 index 2aee85ca..b765fab4 --- a/src/main/java/com/baidubce/services/lss/model/SecurityPolicy.java +++ b/src/main/java/com/baidubce/services/lss/model/SecurityPolicy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/SecurityPolicyInfo.java b/src/main/java/com/baidubce/services/lss/model/SecurityPolicyInfo.java old mode 100755 new mode 100644 index cda72af3..32d0000b --- a/src/main/java/com/baidubce/services/lss/model/SecurityPolicyInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/SecurityPolicyInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/SessionAggregate.java b/src/main/java/com/baidubce/services/lss/model/SessionAggregate.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/SessionErrorInfo.java b/src/main/java/com/baidubce/services/lss/model/SessionErrorInfo.java old mode 100755 new mode 100644 index 21fb206c..3ea944b1 --- a/src/main/java/com/baidubce/services/lss/model/SessionErrorInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/SessionErrorInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/StartPullSessionRequest.java b/src/main/java/com/baidubce/services/lss/model/StartPullSessionRequest.java old mode 100755 new mode 100644 index ca463226..7bf3be62 --- a/src/main/java/com/baidubce/services/lss/model/StartPullSessionRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/StartPullSessionRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/StartPullSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/StartPullSessionResponse.java old mode 100755 new mode 100644 index 4bb3c54a..e2329888 --- a/src/main/java/com/baidubce/services/lss/model/StartPullSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/StartPullSessionResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/StartRecordingRequest.java b/src/main/java/com/baidubce/services/lss/model/StartRecordingRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/StartRecordingResponse.java b/src/main/java/com/baidubce/services/lss/model/StartRecordingResponse.java old mode 100755 new mode 100644 index 6b376c11..6c2c17ff --- a/src/main/java/com/baidubce/services/lss/model/StartRecordingResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/StartRecordingResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/StopRecordingRequest.java b/src/main/java/com/baidubce/services/lss/model/StopRecordingRequest.java old mode 100755 new mode 100644 index b8cba6ea..b67ad534 --- a/src/main/java/com/baidubce/services/lss/model/StopRecordingRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/StopRecordingRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/StopRecordingResponse.java b/src/main/java/com/baidubce/services/lss/model/StopRecordingResponse.java old mode 100755 new mode 100644 index 4fb36f32..8490a8f0 --- a/src/main/java/com/baidubce/services/lss/model/StopRecordingResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/StopRecordingResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Target.java b/src/main/java/com/baidubce/services/lss/model/Target.java old mode 100755 new mode 100644 index 6b4f5475..5bc3c51f --- a/src/main/java/com/baidubce/services/lss/model/Target.java +++ b/src/main/java/com/baidubce/services/lss/model/Target.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyInnerRequest.java b/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyInnerRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyRequest.java b/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyRequest.java old mode 100755 new mode 100644 index 7fa66c21..a13a9761 --- a/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyResponse.java b/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyResponse.java old mode 100755 new mode 100644 index 30806ea0..cbbb2bdc --- a/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/UpdateSecurityPolicyResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Video.java b/src/main/java/com/baidubce/services/lss/model/Video.java old mode 100755 new mode 100644 index a91fb219..6a2a2c04 --- a/src/main/java/com/baidubce/services/lss/model/Video.java +++ b/src/main/java/com/baidubce/services/lss/model/Video.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/lss/model/Watermarks.java b/src/main/java/com/baidubce/services/lss/model/Watermarks.java old mode 100755 new mode 100644 index 07969571..829293d1 --- a/src/main/java/com/baidubce/services/lss/model/Watermarks.java +++ b/src/main/java/com/baidubce/services/lss/model/Watermarks.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/MediaClient.java b/src/main/java/com/baidubce/services/media/MediaClient.java old mode 100755 new mode 100644 index 67c6ef83..1f26d101 --- a/src/main/java/com/baidubce/services/media/MediaClient.java +++ b/src/main/java/com/baidubce/services/media/MediaClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/Audio.java b/src/main/java/com/baidubce/services/media/model/Audio.java old mode 100755 new mode 100644 index 68e8dce2..02c26735 --- a/src/main/java/com/baidubce/services/media/model/Audio.java +++ b/src/main/java/com/baidubce/services/media/model/Audio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/AudioInfo.java b/src/main/java/com/baidubce/services/media/model/AudioInfo.java old mode 100755 new mode 100644 index ca735d1a..fdf865a5 --- a/src/main/java/com/baidubce/services/media/model/AudioInfo.java +++ b/src/main/java/com/baidubce/services/media/model/AudioInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/Clip.java b/src/main/java/com/baidubce/services/media/model/Clip.java old mode 100755 new mode 100644 index 2ea04b40..1fdecf2d --- a/src/main/java/com/baidubce/services/media/model/Clip.java +++ b/src/main/java/com/baidubce/services/media/model/Clip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CodecOptions.java b/src/main/java/com/baidubce/services/media/model/CodecOptions.java old mode 100755 new mode 100644 index 855ba9c0..ea6f5e63 --- a/src/main/java/com/baidubce/services/media/model/CodecOptions.java +++ b/src/main/java/com/baidubce/services/media/model/CodecOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreateJobRequest.java b/src/main/java/com/baidubce/services/media/model/CreateJobRequest.java old mode 100755 new mode 100644 index 93e21e5c..61983564 --- a/src/main/java/com/baidubce/services/media/model/CreateJobRequest.java +++ b/src/main/java/com/baidubce/services/media/model/CreateJobRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreateJobResponse.java b/src/main/java/com/baidubce/services/media/model/CreateJobResponse.java old mode 100755 new mode 100644 index caad54b5..d51ea15f --- a/src/main/java/com/baidubce/services/media/model/CreateJobResponse.java +++ b/src/main/java/com/baidubce/services/media/model/CreateJobResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreatePipelineRequest.java b/src/main/java/com/baidubce/services/media/model/CreatePipelineRequest.java old mode 100755 new mode 100644 index 4283ac51..249f0127 --- a/src/main/java/com/baidubce/services/media/model/CreatePipelineRequest.java +++ b/src/main/java/com/baidubce/services/media/model/CreatePipelineRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreatePipelineResponse.java b/src/main/java/com/baidubce/services/media/model/CreatePipelineResponse.java old mode 100755 new mode 100644 index 1f38afd5..982a7be7 --- a/src/main/java/com/baidubce/services/media/model/CreatePipelineResponse.java +++ b/src/main/java/com/baidubce/services/media/model/CreatePipelineResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreatePresetRequest.java b/src/main/java/com/baidubce/services/media/model/CreatePresetRequest.java old mode 100755 new mode 100644 index 22cc72c6..a830404f --- a/src/main/java/com/baidubce/services/media/model/CreatePresetRequest.java +++ b/src/main/java/com/baidubce/services/media/model/CreatePresetRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreatePresetResponse.java b/src/main/java/com/baidubce/services/media/model/CreatePresetResponse.java old mode 100755 new mode 100644 index dbb11663..6f0df1ad --- a/src/main/java/com/baidubce/services/media/model/CreatePresetResponse.java +++ b/src/main/java/com/baidubce/services/media/model/CreatePresetResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobRequest.java b/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobRequest.java old mode 100755 new mode 100644 index 5fef9447..3c38696f --- a/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobRequest.java +++ b/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobResponse.java b/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobResponse.java old mode 100755 new mode 100644 index c79115e4..20cd6f2e --- a/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobResponse.java +++ b/src/main/java/com/baidubce/services/media/model/CreateThumbnailJobResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreateTranscodingJobRequest.java b/src/main/java/com/baidubce/services/media/model/CreateTranscodingJobRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/media/model/CreateTranscodingJobResponse.java b/src/main/java/com/baidubce/services/media/model/CreateTranscodingJobResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/media/model/CreateWaterMarkRequest.java b/src/main/java/com/baidubce/services/media/model/CreateWaterMarkRequest.java old mode 100755 new mode 100644 index 5d5291e4..78dab18a --- a/src/main/java/com/baidubce/services/media/model/CreateWaterMarkRequest.java +++ b/src/main/java/com/baidubce/services/media/model/CreateWaterMarkRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/CreateWaterMarkResponse.java b/src/main/java/com/baidubce/services/media/model/CreateWaterMarkResponse.java old mode 100755 new mode 100644 index 877b28b5..023c9106 --- a/src/main/java/com/baidubce/services/media/model/CreateWaterMarkResponse.java +++ b/src/main/java/com/baidubce/services/media/model/CreateWaterMarkResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/DeletePipelineRequest.java b/src/main/java/com/baidubce/services/media/model/DeletePipelineRequest.java old mode 100755 new mode 100644 index f7f69560..310db8c0 --- a/src/main/java/com/baidubce/services/media/model/DeletePipelineRequest.java +++ b/src/main/java/com/baidubce/services/media/model/DeletePipelineRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/DeletePipelineResponse.java b/src/main/java/com/baidubce/services/media/model/DeletePipelineResponse.java old mode 100755 new mode 100644 index db017565..665a82a3 --- a/src/main/java/com/baidubce/services/media/model/DeletePipelineResponse.java +++ b/src/main/java/com/baidubce/services/media/model/DeletePipelineResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/DeletePresetRequest.java b/src/main/java/com/baidubce/services/media/model/DeletePresetRequest.java old mode 100755 new mode 100644 index 63fedd1d..38a87ef5 --- a/src/main/java/com/baidubce/services/media/model/DeletePresetRequest.java +++ b/src/main/java/com/baidubce/services/media/model/DeletePresetRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/DeletePresetResponse.java b/src/main/java/com/baidubce/services/media/model/DeletePresetResponse.java old mode 100755 new mode 100644 index 7a511471..6c1bf848 --- a/src/main/java/com/baidubce/services/media/model/DeletePresetResponse.java +++ b/src/main/java/com/baidubce/services/media/model/DeletePresetResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/DeleteWaterMarkRequest.java b/src/main/java/com/baidubce/services/media/model/DeleteWaterMarkRequest.java old mode 100755 new mode 100644 index 2aa28665..74432c2d --- a/src/main/java/com/baidubce/services/media/model/DeleteWaterMarkRequest.java +++ b/src/main/java/com/baidubce/services/media/model/DeleteWaterMarkRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/DeleteWaterMarkResponse.java b/src/main/java/com/baidubce/services/media/model/DeleteWaterMarkResponse.java old mode 100755 new mode 100644 index e2043ede..388cce7f --- a/src/main/java/com/baidubce/services/media/model/DeleteWaterMarkResponse.java +++ b/src/main/java/com/baidubce/services/media/model/DeleteWaterMarkResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/Encryption.java b/src/main/java/com/baidubce/services/media/model/Encryption.java old mode 100755 new mode 100644 index f5627e15..549aa4a8 --- a/src/main/java/com/baidubce/services/media/model/Encryption.java +++ b/src/main/java/com/baidubce/services/media/model/Encryption.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ErrorResponse.java b/src/main/java/com/baidubce/services/media/model/ErrorResponse.java old mode 100755 new mode 100644 index f1d3ff99..87b23e5d --- a/src/main/java/com/baidubce/services/media/model/ErrorResponse.java +++ b/src/main/java/com/baidubce/services/media/model/ErrorResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetJobRequest.java b/src/main/java/com/baidubce/services/media/model/GetJobRequest.java old mode 100755 new mode 100644 index 0add1d2e..a6918816 --- a/src/main/java/com/baidubce/services/media/model/GetJobRequest.java +++ b/src/main/java/com/baidubce/services/media/model/GetJobRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetJobResponse.java b/src/main/java/com/baidubce/services/media/model/GetJobResponse.java old mode 100755 new mode 100644 index b54f9670..d25c0f26 --- a/src/main/java/com/baidubce/services/media/model/GetJobResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetJobResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileRequest.java b/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileRequest.java old mode 100755 new mode 100644 index ccbfe025..159fd7c5 --- a/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileRequest.java +++ b/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileResponse.java b/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileResponse.java old mode 100755 new mode 100644 index b6372e4c..62614535 --- a/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetMediaInfoOfFileResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetPipelineRequest.java b/src/main/java/com/baidubce/services/media/model/GetPipelineRequest.java old mode 100755 new mode 100644 index 03ffa4d0..9e72aa77 --- a/src/main/java/com/baidubce/services/media/model/GetPipelineRequest.java +++ b/src/main/java/com/baidubce/services/media/model/GetPipelineRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetPipelineResponse.java b/src/main/java/com/baidubce/services/media/model/GetPipelineResponse.java old mode 100755 new mode 100644 index 9b9e5413..9d225c53 --- a/src/main/java/com/baidubce/services/media/model/GetPipelineResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetPipelineResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetPresetRequest.java b/src/main/java/com/baidubce/services/media/model/GetPresetRequest.java old mode 100755 new mode 100644 index e70ccafb..7c353884 --- a/src/main/java/com/baidubce/services/media/model/GetPresetRequest.java +++ b/src/main/java/com/baidubce/services/media/model/GetPresetRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetPresetResponse.java b/src/main/java/com/baidubce/services/media/model/GetPresetResponse.java old mode 100755 new mode 100644 index 677acc9c..d2c60ef4 --- a/src/main/java/com/baidubce/services/media/model/GetPresetResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetPresetResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetThumbnailJobRequest.java b/src/main/java/com/baidubce/services/media/model/GetThumbnailJobRequest.java old mode 100755 new mode 100644 index 76e8e80a..9ba4f145 --- a/src/main/java/com/baidubce/services/media/model/GetThumbnailJobRequest.java +++ b/src/main/java/com/baidubce/services/media/model/GetThumbnailJobRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetThumbnailJobResponse.java b/src/main/java/com/baidubce/services/media/model/GetThumbnailJobResponse.java old mode 100755 new mode 100644 index 7c3376b5..63075376 --- a/src/main/java/com/baidubce/services/media/model/GetThumbnailJobResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetThumbnailJobResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -27,7 +27,8 @@ public class GetThumbnailJobResponse extends AbstractBceResponse { private ThumbnailTargetStatus target = null; private ThumbnailCapture capture = null; - + + private MediaError error = null; public String getJobId() { return jobId; @@ -76,7 +77,15 @@ public ThumbnailCapture getCapture() { public void setCapture(ThumbnailCapture capture) { this.capture = capture; } - + + public MediaError getError() { + return error; + } + + public void setError(MediaError error) { + this.error = error; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -87,6 +96,9 @@ public String toString() { sb.append(" source: ").append(source).append("\n"); sb.append(" target: ").append(target).append("\n"); sb.append(" capture: ").append(capture).append("\n"); + if (error != null) { + sb.append(error).append("\n"); + } sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/GetTranscodingJobRequest.java b/src/main/java/com/baidubce/services/media/model/GetTranscodingJobRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/media/model/GetTranscodingJobResponse.java b/src/main/java/com/baidubce/services/media/model/GetTranscodingJobResponse.java old mode 100755 new mode 100644 index d64ab732..7a10567e --- a/src/main/java/com/baidubce/services/media/model/GetTranscodingJobResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetTranscodingJobResponse.java @@ -12,6 +12,7 @@ public class GetTranscodingJobResponse extends AbstractBceResponse { private String jobStatus = null; private Date startTime = null; private Date endTime = null; + private MediaError error = null; /** * 任务的唯一标识 @@ -91,6 +92,14 @@ public void setEndTime(Date endTime) { this.endTime = endTime; } + public MediaError getError() { + return error; + } + + public void setError(MediaError error) { + this.error = error; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -103,6 +112,9 @@ public String toString() { sb.append(" jobStatus: ").append(jobStatus).append("\n"); sb.append(" startTime: ").append(startTime).append("\n"); sb.append(" endTime: ").append(endTime).append("\n"); + if (error != null) { + sb.append(error).append("\n"); + } sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/GetWaterMarkRequest.java b/src/main/java/com/baidubce/services/media/model/GetWaterMarkRequest.java old mode 100755 new mode 100644 index 6a17854b..95dd7400 --- a/src/main/java/com/baidubce/services/media/model/GetWaterMarkRequest.java +++ b/src/main/java/com/baidubce/services/media/model/GetWaterMarkRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/GetWaterMarkResponse.java b/src/main/java/com/baidubce/services/media/model/GetWaterMarkResponse.java old mode 100755 new mode 100644 index bdcb6546..dbbd44b9 --- a/src/main/java/com/baidubce/services/media/model/GetWaterMarkResponse.java +++ b/src/main/java/com/baidubce/services/media/model/GetWaterMarkResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/Job.java b/src/main/java/com/baidubce/services/media/model/Job.java old mode 100755 new mode 100644 index bfec0390..44b12a8d --- a/src/main/java/com/baidubce/services/media/model/Job.java +++ b/src/main/java/com/baidubce/services/media/model/Job.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -23,6 +23,7 @@ public class Job { private String jobStatus = null; private Date startTime = null; private Date endTime = null; + private MediaError error = null; /** * 任务的唯一标识 @@ -102,6 +103,14 @@ public void setEndTime(Date endTime) { this.endTime = endTime; } + public MediaError getError() { + return error; + } + + public void setError(MediaError error) { + this.error = error; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -114,6 +123,9 @@ public String toString() { sb.append(" jobStatus: ").append(jobStatus).append("\n"); sb.append(" startTime: ").append(startTime).append("\n"); sb.append(" endTime: ").append(endTime).append("\n"); + if (error != null) { + sb.append(error).append("\n"); + } sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/JobStatus.java b/src/main/java/com/baidubce/services/media/model/JobStatus.java old mode 100755 new mode 100644 index b31b5c97..d60da037 --- a/src/main/java/com/baidubce/services/media/model/JobStatus.java +++ b/src/main/java/com/baidubce/services/media/model/JobStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListJobsRequest.java b/src/main/java/com/baidubce/services/media/model/ListJobsRequest.java old mode 100755 new mode 100644 index bd61092b..7a1aab2c --- a/src/main/java/com/baidubce/services/media/model/ListJobsRequest.java +++ b/src/main/java/com/baidubce/services/media/model/ListJobsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListJobsResponse.java b/src/main/java/com/baidubce/services/media/model/ListJobsResponse.java old mode 100755 new mode 100644 index 1f542875..b276d0d9 --- a/src/main/java/com/baidubce/services/media/model/ListJobsResponse.java +++ b/src/main/java/com/baidubce/services/media/model/ListJobsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListPipelinesRequest.java b/src/main/java/com/baidubce/services/media/model/ListPipelinesRequest.java old mode 100755 new mode 100644 index 4c17b653..cbd2ea7e --- a/src/main/java/com/baidubce/services/media/model/ListPipelinesRequest.java +++ b/src/main/java/com/baidubce/services/media/model/ListPipelinesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListPipelinesResponse.java b/src/main/java/com/baidubce/services/media/model/ListPipelinesResponse.java old mode 100755 new mode 100644 index 1f2128e0..db9c9bec --- a/src/main/java/com/baidubce/services/media/model/ListPipelinesResponse.java +++ b/src/main/java/com/baidubce/services/media/model/ListPipelinesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListPresetsRequest.java b/src/main/java/com/baidubce/services/media/model/ListPresetsRequest.java old mode 100755 new mode 100644 index 384adfe9..09cef6ad --- a/src/main/java/com/baidubce/services/media/model/ListPresetsRequest.java +++ b/src/main/java/com/baidubce/services/media/model/ListPresetsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListPresetsResponse.java b/src/main/java/com/baidubce/services/media/model/ListPresetsResponse.java old mode 100755 new mode 100644 index d5788526..60eb2f0a --- a/src/main/java/com/baidubce/services/media/model/ListPresetsResponse.java +++ b/src/main/java/com/baidubce/services/media/model/ListPresetsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListThumbnailJobsRequest.java b/src/main/java/com/baidubce/services/media/model/ListThumbnailJobsRequest.java old mode 100755 new mode 100644 index 5c7e37f1..095a4ba6 --- a/src/main/java/com/baidubce/services/media/model/ListThumbnailJobsRequest.java +++ b/src/main/java/com/baidubce/services/media/model/ListThumbnailJobsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListThumbnailJobsResponse.java b/src/main/java/com/baidubce/services/media/model/ListThumbnailJobsResponse.java old mode 100755 new mode 100644 index b941df64..8e1f0bd2 --- a/src/main/java/com/baidubce/services/media/model/ListThumbnailJobsResponse.java +++ b/src/main/java/com/baidubce/services/media/model/ListThumbnailJobsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListTranscodingJobsRequest.java b/src/main/java/com/baidubce/services/media/model/ListTranscodingJobsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/media/model/ListTranscodingJobsResponse.java b/src/main/java/com/baidubce/services/media/model/ListTranscodingJobsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/media/model/ListWaterMarkRequest.java b/src/main/java/com/baidubce/services/media/model/ListWaterMarkRequest.java old mode 100755 new mode 100644 index f3dc4fb0..5069cda3 --- a/src/main/java/com/baidubce/services/media/model/ListWaterMarkRequest.java +++ b/src/main/java/com/baidubce/services/media/model/ListWaterMarkRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ListWaterMarkResponse.java b/src/main/java/com/baidubce/services/media/model/ListWaterMarkResponse.java old mode 100755 new mode 100644 index 4073e961..c95e2c02 --- a/src/main/java/com/baidubce/services/media/model/ListWaterMarkResponse.java +++ b/src/main/java/com/baidubce/services/media/model/ListWaterMarkResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/MediaError.java b/src/main/java/com/baidubce/services/media/model/MediaError.java new file mode 100644 index 00000000..9d45f6eb --- /dev/null +++ b/src/main/java/com/baidubce/services/media/model/MediaError.java @@ -0,0 +1,45 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.media.model; + +public class MediaError { + private String code = null; + private String message = null; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + sb.append(" code: ").append(code).append("\n"); + sb.append(" message: ").append(message).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/media/model/PipelineConfig.java b/src/main/java/com/baidubce/services/media/model/PipelineConfig.java old mode 100755 new mode 100644 index d962795e..46332ca3 --- a/src/main/java/com/baidubce/services/media/model/PipelineConfig.java +++ b/src/main/java/com/baidubce/services/media/model/PipelineConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/PipelineStatus.java b/src/main/java/com/baidubce/services/media/model/PipelineStatus.java old mode 100755 new mode 100644 index c9ba6147..9bda85b4 --- a/src/main/java/com/baidubce/services/media/model/PipelineStatus.java +++ b/src/main/java/com/baidubce/services/media/model/PipelineStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/Source.java b/src/main/java/com/baidubce/services/media/model/Source.java old mode 100755 new mode 100644 index 3509005b..ea902ea5 --- a/src/main/java/com/baidubce/services/media/model/Source.java +++ b/src/main/java/com/baidubce/services/media/model/Source.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/Target.java b/src/main/java/com/baidubce/services/media/model/Target.java old mode 100755 new mode 100644 index aebd1c37..a6f04998 --- a/src/main/java/com/baidubce/services/media/model/Target.java +++ b/src/main/java/com/baidubce/services/media/model/Target.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailCapture.java b/src/main/java/com/baidubce/services/media/model/ThumbnailCapture.java old mode 100755 new mode 100644 index 7dc9f668..229bce73 --- a/src/main/java/com/baidubce/services/media/model/ThumbnailCapture.java +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailCapture.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailJobStatus.java b/src/main/java/com/baidubce/services/media/model/ThumbnailJobStatus.java old mode 100755 new mode 100644 index 34291fe6..fd98820f --- a/src/main/java/com/baidubce/services/media/model/ThumbnailJobStatus.java +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailJobStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -26,7 +26,8 @@ public class ThumbnailJobStatus { private ThumbnailTargetStatus target = null; private ThumbnailCapture capture = null; - + + private MediaError error = null; public String getJobId() { return jobId; @@ -75,7 +76,15 @@ public ThumbnailCapture getCapture() { public void setCapture(ThumbnailCapture capture) { this.capture = capture; } - + + public MediaError getError() { + return error; + } + + public void setError(MediaError error) { + this.error = error; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -86,6 +95,9 @@ public String toString() { sb.append(" source: ").append(source).append("\n"); sb.append(" target: ").append(target).append("\n"); sb.append(" capture: ").append(capture).append("\n"); + if (error != null) { + sb.append(error).append("\n"); + } sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailSource.java b/src/main/java/com/baidubce/services/media/model/ThumbnailSource.java old mode 100755 new mode 100644 index 38107362..4d82aeb2 --- a/src/main/java/com/baidubce/services/media/model/ThumbnailSource.java +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailTarget.java b/src/main/java/com/baidubce/services/media/model/ThumbnailTarget.java old mode 100755 new mode 100644 index aa24ce78..84241d94 --- a/src/main/java/com/baidubce/services/media/model/ThumbnailTarget.java +++ b/src/main/java/com/baidubce/services/media/model/ThumbnailTarget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/ThumbnailTargetStatus.java b/src/main/java/com/baidubce/services/media/model/ThumbnailTargetStatus.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/media/model/Video.java b/src/main/java/com/baidubce/services/media/model/Video.java old mode 100755 new mode 100644 index f07c16d1..a46f2c97 --- a/src/main/java/com/baidubce/services/media/model/Video.java +++ b/src/main/java/com/baidubce/services/media/model/Video.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/VideoInfo.java b/src/main/java/com/baidubce/services/media/model/VideoInfo.java old mode 100755 new mode 100644 index cf94fbb0..dacf6c8b --- a/src/main/java/com/baidubce/services/media/model/VideoInfo.java +++ b/src/main/java/com/baidubce/services/media/model/VideoInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/model/WaterMark.java b/src/main/java/com/baidubce/services/media/model/WaterMark.java old mode 100755 new mode 100644 index 24e676b6..b310ceb6 --- a/src/main/java/com/baidubce/services/media/model/WaterMark.java +++ b/src/main/java/com/baidubce/services/media/model/WaterMark.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/media/package-info.java b/src/main/java/com/baidubce/services/media/package-info.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/MolaDbClient.java b/src/main/java/com/baidubce/services/moladb/MolaDbClient.java old mode 100755 new mode 100644 index f40adda2..2e61f121 --- a/src/main/java/com/baidubce/services/moladb/MolaDbClient.java +++ b/src/main/java/com/baidubce/services/moladb/MolaDbClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/MolaDbClientConfiguration.java b/src/main/java/com/baidubce/services/moladb/MolaDbClientConfiguration.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/MolaDbConstants.java b/src/main/java/com/baidubce/services/moladb/MolaDbConstants.java old mode 100755 new mode 100644 index 8db9d636..dd30ce74 --- a/src/main/java/com/baidubce/services/moladb/MolaDbConstants.java +++ b/src/main/java/com/baidubce/services/moladb/MolaDbConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/MolaDbJsonResponseHandler.java b/src/main/java/com/baidubce/services/moladb/MolaDbJsonResponseHandler.java old mode 100755 new mode 100644 index 2c98b632..811a056b --- a/src/main/java/com/baidubce/services/moladb/MolaDbJsonResponseHandler.java +++ b/src/main/java/com/baidubce/services/moladb/MolaDbJsonResponseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/example/MolaDbExample.java b/src/main/java/com/baidubce/services/moladb/example/MolaDbExample.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/AttributeDefinition.java b/src/main/java/com/baidubce/services/moladb/model/AttributeDefinition.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/AttributeValue.java b/src/main/java/com/baidubce/services/moladb/model/AttributeValue.java old mode 100755 new mode 100644 index d748c1e2..0f9e5e20 --- a/src/main/java/com/baidubce/services/moladb/model/AttributeValue.java +++ b/src/main/java/com/baidubce/services/moladb/model/AttributeValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/AttributeValueUpdate.java b/src/main/java/com/baidubce/services/moladb/model/AttributeValueUpdate.java old mode 100755 new mode 100644 index 7ed430e9..6127834d --- a/src/main/java/com/baidubce/services/moladb/model/AttributeValueUpdate.java +++ b/src/main/java/com/baidubce/services/moladb/model/AttributeValueUpdate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/BatchGetItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/BatchGetItemRequest.java old mode 100755 new mode 100644 index 42a9d0b7..e0b387b7 --- a/src/main/java/com/baidubce/services/moladb/model/BatchGetItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/BatchGetItemRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/BatchGetItemResponse.java b/src/main/java/com/baidubce/services/moladb/model/BatchGetItemResponse.java old mode 100755 new mode 100644 index 05e07a2e..e3c51d48 --- a/src/main/java/com/baidubce/services/moladb/model/BatchGetItemResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/BatchGetItemResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/BatchWriteItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/BatchWriteItemRequest.java old mode 100755 new mode 100644 index 63a9ee24..c7b72ceb --- a/src/main/java/com/baidubce/services/moladb/model/BatchWriteItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/BatchWriteItemRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/BatchWriteItemResponse.java b/src/main/java/com/baidubce/services/moladb/model/BatchWriteItemResponse.java old mode 100755 new mode 100644 index 346b11b8..1b3326f3 --- a/src/main/java/com/baidubce/services/moladb/model/BatchWriteItemResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/BatchWriteItemResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/CreateInstanceRequest.java b/src/main/java/com/baidubce/services/moladb/model/CreateInstanceRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/CreateInstanceResponse.java b/src/main/java/com/baidubce/services/moladb/model/CreateInstanceResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/CreateTableRequest.java b/src/main/java/com/baidubce/services/moladb/model/CreateTableRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/CreateTableResponse.java b/src/main/java/com/baidubce/services/moladb/model/CreateTableResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/DeleteInstanceRequest.java b/src/main/java/com/baidubce/services/moladb/model/DeleteInstanceRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/DeleteInstanceResponse.java b/src/main/java/com/baidubce/services/moladb/model/DeleteInstanceResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/DeleteItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/DeleteItemRequest.java old mode 100755 new mode 100644 index f3505861..5950603d --- a/src/main/java/com/baidubce/services/moladb/model/DeleteItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/DeleteItemRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/DeleteItemResponse.java b/src/main/java/com/baidubce/services/moladb/model/DeleteItemResponse.java old mode 100755 new mode 100644 index f4110841..3490fcf9 --- a/src/main/java/com/baidubce/services/moladb/model/DeleteItemResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/DeleteItemResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/DeleteRequest.java b/src/main/java/com/baidubce/services/moladb/model/DeleteRequest.java old mode 100755 new mode 100644 index 0a9e3f06..6343e8a8 --- a/src/main/java/com/baidubce/services/moladb/model/DeleteRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/DeleteRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/DeleteTableRequest.java b/src/main/java/com/baidubce/services/moladb/model/DeleteTableRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/DeleteTableResponse.java b/src/main/java/com/baidubce/services/moladb/model/DeleteTableResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/GetInstanceRequest.java b/src/main/java/com/baidubce/services/moladb/model/GetInstanceRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/GetInstanceResponse.java b/src/main/java/com/baidubce/services/moladb/model/GetInstanceResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/GetItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/GetItemRequest.java old mode 100755 new mode 100644 index f6f61efe..d6c14abb --- a/src/main/java/com/baidubce/services/moladb/model/GetItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/GetItemRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/GetItemResponse.java b/src/main/java/com/baidubce/services/moladb/model/GetItemResponse.java old mode 100755 new mode 100644 index c5f35d3e..c6fe34a4 --- a/src/main/java/com/baidubce/services/moladb/model/GetItemResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/GetItemResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/GetTableRequest.java b/src/main/java/com/baidubce/services/moladb/model/GetTableRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/GetTableResponse.java b/src/main/java/com/baidubce/services/moladb/model/GetTableResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/Key.java b/src/main/java/com/baidubce/services/moladb/model/Key.java old mode 100755 new mode 100644 index 5dfd3c83..5eef9c89 --- a/src/main/java/com/baidubce/services/moladb/model/Key.java +++ b/src/main/java/com/baidubce/services/moladb/model/Key.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/KeySchemaElement.java b/src/main/java/com/baidubce/services/moladb/model/KeySchemaElement.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/KeysAndAttributes.java b/src/main/java/com/baidubce/services/moladb/model/KeysAndAttributes.java old mode 100755 new mode 100644 index 859a57d9..acdd9414 --- a/src/main/java/com/baidubce/services/moladb/model/KeysAndAttributes.java +++ b/src/main/java/com/baidubce/services/moladb/model/KeysAndAttributes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/ListInstancesRequest.java b/src/main/java/com/baidubce/services/moladb/model/ListInstancesRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/ListInstancesResponse.java b/src/main/java/com/baidubce/services/moladb/model/ListInstancesResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/ListTablesRequest.java b/src/main/java/com/baidubce/services/moladb/model/ListTablesRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/ListTablesResponse.java b/src/main/java/com/baidubce/services/moladb/model/ListTablesResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/ProvisionedThroughput.java b/src/main/java/com/baidubce/services/moladb/model/ProvisionedThroughput.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/ProvisionedThroughputDescription.java b/src/main/java/com/baidubce/services/moladb/model/ProvisionedThroughputDescription.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/PutItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/PutItemRequest.java old mode 100755 new mode 100644 index 3b688b03..f5c33fdb --- a/src/main/java/com/baidubce/services/moladb/model/PutItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/PutItemRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/PutItemResponse.java b/src/main/java/com/baidubce/services/moladb/model/PutItemResponse.java old mode 100755 new mode 100644 index efe3ab4b..fa73601a --- a/src/main/java/com/baidubce/services/moladb/model/PutItemResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/PutItemResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/PutRequest.java b/src/main/java/com/baidubce/services/moladb/model/PutRequest.java old mode 100755 new mode 100644 index 5ba7dd8a..c89d8317 --- a/src/main/java/com/baidubce/services/moladb/model/PutRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/PutRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/QueryRequest.java b/src/main/java/com/baidubce/services/moladb/model/QueryRequest.java old mode 100755 new mode 100644 index 055ec627..02941c99 --- a/src/main/java/com/baidubce/services/moladb/model/QueryRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/QueryRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/QueryResponse.java b/src/main/java/com/baidubce/services/moladb/model/QueryResponse.java old mode 100755 new mode 100644 index f49857b0..89bf8bd5 --- a/src/main/java/com/baidubce/services/moladb/model/QueryResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/QueryResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/UpdateItemRequest.java b/src/main/java/com/baidubce/services/moladb/model/UpdateItemRequest.java old mode 100755 new mode 100644 index e2052fa7..0b592ebc --- a/src/main/java/com/baidubce/services/moladb/model/UpdateItemRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/UpdateItemRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/UpdateItemResponse.java b/src/main/java/com/baidubce/services/moladb/model/UpdateItemResponse.java old mode 100755 new mode 100644 index 7b963308..514b536c --- a/src/main/java/com/baidubce/services/moladb/model/UpdateItemResponse.java +++ b/src/main/java/com/baidubce/services/moladb/model/UpdateItemResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/UpdateTableRequest.java b/src/main/java/com/baidubce/services/moladb/model/UpdateTableRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/UpdateTableResponse.java b/src/main/java/com/baidubce/services/moladb/model/UpdateTableResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/WriteRequest.java b/src/main/java/com/baidubce/services/moladb/model/WriteRequest.java old mode 100755 new mode 100644 index c6cdd9b2..1598647e --- a/src/main/java/com/baidubce/services/moladb/model/WriteRequest.java +++ b/src/main/java/com/baidubce/services/moladb/model/WriteRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/AttributeValueMapUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/AttributeValueMapUnmarshaller.java old mode 100755 new mode 100644 index 80dd5c60..5c7e05eb --- a/src/main/java/com/baidubce/services/moladb/model/transform/AttributeValueMapUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/AttributeValueMapUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/AttributeValueUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/AttributeValueUnmarshaller.java old mode 100755 new mode 100644 index b4701bd2..976b37ee --- a/src/main/java/com/baidubce/services/moladb/model/transform/AttributeValueUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/AttributeValueUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetItemResponseContentUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetItemResponseContentUnmarshaller.java old mode 100755 new mode 100644 index a031aff5..e65c4ae9 --- a/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetItemResponseContentUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetItemResponseContentUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetItemResponseUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetItemResponseUnmarshaller.java old mode 100755 new mode 100644 index 9382f57e..afac0090 --- a/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetItemResponseUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetItemResponseUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetUnprocessItemsUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetUnprocessItemsUnmarshaller.java old mode 100755 new mode 100644 index 0bcc15ae..f1f8dc50 --- a/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetUnprocessItemsUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/BatchGetUnprocessItemsUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/BatchWriteItemResponseUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/BatchWriteItemResponseUnmarshaller.java old mode 100755 new mode 100644 index f72b824e..dca3ffcb --- a/src/main/java/com/baidubce/services/moladb/model/transform/BatchWriteItemResponseUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/BatchWriteItemResponseUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/BatchWriteUnprocessItemsUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/BatchWriteUnprocessItemsUnmarshaller.java old mode 100755 new mode 100644 index 6e631f20..2d46700e --- a/src/main/java/com/baidubce/services/moladb/model/transform/BatchWriteUnprocessItemsUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/BatchWriteUnprocessItemsUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/DeleteRequestUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/DeleteRequestUnmarshaller.java old mode 100755 new mode 100644 index 3c7c4cdd..7a9be3a4 --- a/src/main/java/com/baidubce/services/moladb/model/transform/DeleteRequestUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/DeleteRequestUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/DescribeTableUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/DescribeTableUnmarshaller.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/GetInstanceResponseUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/GetInstanceResponseUnmarshaller.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/GetItemResponseUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/GetItemResponseUnmarshaller.java old mode 100755 new mode 100644 index 4726e36a..42928dc1 --- a/src/main/java/com/baidubce/services/moladb/model/transform/GetItemResponseUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/GetItemResponseUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/ItemListUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/ItemListUnmarshaller.java old mode 100755 new mode 100644 index 93e464dc..b9ebc6ff --- a/src/main/java/com/baidubce/services/moladb/model/transform/ItemListUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/ItemListUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/ItemUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/ItemUnmarshaller.java old mode 100755 new mode 100644 index 5369db15..07983a6c --- a/src/main/java/com/baidubce/services/moladb/model/transform/ItemUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/ItemUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/KeySchemaUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/KeySchemaUnmarshaller.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/KeyUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/KeyUnmarshaller.java old mode 100755 new mode 100644 index fb17656e..8ea8f8d4 --- a/src/main/java/com/baidubce/services/moladb/model/transform/KeyUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/KeyUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/KeysAndAttributesUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/KeysAndAttributesUnmarshaller.java old mode 100755 new mode 100644 index 3d5bf11a..aa668d81 --- a/src/main/java/com/baidubce/services/moladb/model/transform/KeysAndAttributesUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/KeysAndAttributesUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/ListInstancesResponseUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/ListInstancesResponseUnmarshaller.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/ListTablesResponseUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/ListTablesResponseUnmarshaller.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/ProvisionedThroughputUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/ProvisionedThroughputUnmarshaller.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/PutRequestUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/PutRequestUnmarshaller.java old mode 100755 new mode 100644 index 0c8cd40b..15149b30 --- a/src/main/java/com/baidubce/services/moladb/model/transform/PutRequestUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/PutRequestUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/QueryResponseUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/QueryResponseUnmarshaller.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/Unmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/Unmarshaller.java old mode 100755 new mode 100644 index dda3e432..bc0764e2 --- a/src/main/java/com/baidubce/services/moladb/model/transform/Unmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/Unmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/Unmarshallers.java b/src/main/java/com/baidubce/services/moladb/model/transform/Unmarshallers.java old mode 100755 new mode 100644 index f52c3cd5..c0d5bac0 --- a/src/main/java/com/baidubce/services/moladb/model/transform/Unmarshallers.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/Unmarshallers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/WriteRequestListUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/WriteRequestListUnmarshaller.java old mode 100755 new mode 100644 index 9cac9d07..99ca9540 --- a/src/main/java/com/baidubce/services/moladb/model/transform/WriteRequestListUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/WriteRequestListUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/moladb/model/transform/WriteRequestUnmarshaller.java b/src/main/java/com/baidubce/services/moladb/model/transform/WriteRequestUnmarshaller.java old mode 100755 new mode 100644 index adf9e20f..720ddebe --- a/src/main/java/com/baidubce/services/moladb/model/transform/WriteRequestUnmarshaller.java +++ b/src/main/java/com/baidubce/services/moladb/model/transform/WriteRequestUnmarshaller.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ocr/OcrClient.java b/src/main/java/com/baidubce/services/ocr/OcrClient.java new file mode 100644 index 00000000..225a9fb7 --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/OcrClient.java @@ -0,0 +1,274 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.http.Headers; +import com.baidubce.http.HttpMethodName; +import com.baidubce.http.handler.BceErrorResponseHandler; +import com.baidubce.http.handler.BceJsonResponseHandler; +import com.baidubce.http.handler.BceMetadataResponseHandler; +import com.baidubce.http.handler.HttpResponseHandler; +import com.baidubce.internal.InternalRequest; +import com.baidubce.internal.RestartableInputStream; + +import com.baidubce.services.ocr.model.BankcardRecognitionRequest; +import com.baidubce.services.ocr.model.BankcardRecognitionResponse; +import com.baidubce.services.ocr.model.FormAbstractBceRequest; +import com.baidubce.services.ocr.model.GeneralRecognitionRequest; +import com.baidubce.services.ocr.model.GeneralRecognitionResponse; +import com.baidubce.services.ocr.model.IdcardRecognitionRequest; +import com.baidubce.services.ocr.model.IdcardRecognitionResponse; + +import com.baidubce.util.HttpUtils; + +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Created by lvsiyuan on 16/11/18. + */ +public class OcrClient extends AbstractBceClient { + + private static final String VERSION = "api/v1"; + private static final String PATH_OCR = "ocr"; + + private static final String PARA_GENERAL = "general"; + private static final String PARA_BANK = "bankcard"; + private static final String PARA_ID = "idcard"; + + private static final String FORM_CONTENT_TYPE = "application/x-www-form-urlencoded"; + + /** + * Responsible for handling httpResponses from all Ocr service calls. + */ + private static final HttpResponseHandler[] responseHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client using the client configuration. + * + * @param ocrConfig The client configuration options controlling how this client connects to Ocr services + * (e.g. proxy settings, retry counts, etc). + */ + public OcrClient(BceClientConfiguration ocrConfig) { + // enable HTTP Async manner for PUT method + super(ocrConfig, responseHandlers, true); + } + + /** + * Gets the bankcard recognition properties of specific image resource. + * + *

+ * The caller must authenticate with a valid BCE Access Key / Private Key pair. + * + * @param image The image data which needs to be base64 + * @return The bankcard recognition properties of the image resource + */ + public BankcardRecognitionResponse bankcardRecognition(String image) { + BankcardRecognitionRequest request = new BankcardRecognitionRequest().withImage(image); + return bankcardRecognition(request); + } + + /** + * Gets the bankcard recognition properties of specific image resource. + * + *

+ * The caller must authenticate with a valid BCE Access Key / Private Key pair. + * + * @param request The request wrapper object containing all options. + * @return The bankcard recognition properties of the image resource + */ + public BankcardRecognitionResponse bankcardRecognition(BankcardRecognitionRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getImage(), "Image should not be null or empty!"); + + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, PARA_BANK); + + return invokeHttpClient(internalRequest, BankcardRecognitionResponse.class); + } + + /** + * Gets the idcard recognition properties of specific image resource. + * + *

+ * The caller must authenticate with a valid BCE Access Key / Private Key pair. + * + * @param image The image data which needs to be base64 + * @param side The side of idcard image. (front/back) + * @return The idcard recognition properties of the image resource + */ + public IdcardRecognitionResponse idcardRecognition(String image, String side) { + IdcardRecognitionRequest request = new IdcardRecognitionRequest().withImage(image).withSide(side); + return idcardRecognition(request); + } + + /** + * Gets the idcard recognition properties of specific image resource. + * + *

+ * The caller must authenticate with a valid BCE Access Key / Private Key pair. + * + * @param image The image data which needs to be base64 + * @param side The side of idcard image. (front/back) + * @param direction Decide if the image has been rotated (true/false) + * @return The idcard recognition properties of the image resource + */ + public IdcardRecognitionResponse idcardRecognition(String image, String side, Boolean direction) { + IdcardRecognitionRequest request = new IdcardRecognitionRequest().withImage(image) + .withSide(side).withDirection(direction); + return idcardRecognition(request); + } + + /** + * Gets the idcard recognition properties of specific image resource. + * + *

+ * The caller must authenticate with a valid BCE Access Key / Private Key pair. + * + * @param request The request wrapper object containing all options. + * @return The idcard recognition properties of the image resource + */ + public IdcardRecognitionResponse idcardRecognition(IdcardRecognitionRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getImage(), "Image should not be null or empty!"); + + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, PARA_ID); + + return invokeHttpClient(internalRequest, IdcardRecognitionResponse.class); + } + + /** + * Gets the general recognition properties of specific image resource. + * + *

+ * The caller must authenticate with a valid BCE Access Key / Private Key pair. + * + * @param image The image data which needs to be base64 + * @return The general recognition properties of the image resource + */ + public GeneralRecognitionResponse generalRecognition(String image) { + GeneralRecognitionRequest request = new GeneralRecognitionRequest().withImage(image); + return generalRecognition(request); + } + + /** + * Gets the general recognition properties of specific image resource. + * + *

+ * The caller must authenticate with a valid BCE Access Key / Private Key pair. + * + * @param image The image data which needs to be base64 + * @param granularity Decide if recognize single character (big/small) + * @param mask Represent the gray/white/black shade image area (base64 data) + * @param langType Language type, detail to be CHN_ENG (ENG/POR/FRE/GER/ITA/SPA/RUS/JAP) + * @param direction Decide if the image has been rotated (true/false) + * @return The general recognition properties of the image resource + */ + public GeneralRecognitionResponse generalRecognition(String image, String granularity, + String mask, String langType, Boolean direction) { + GeneralRecognitionRequest request = new GeneralRecognitionRequest().withImage(image) + .withGranularity(granularity).withMask(mask).withLangType(langType).withDirection(direction); + return generalRecognition(request); + } + + /** + * Gets the general recognition properties of specific image resource. + * + *

+ * The caller must authenticate with a valid BCE Access Key / Private Key pair. + * + * @param request The request wrapper object containing all options. + * @return The general recognition properties of the image resource + */ + public GeneralRecognitionResponse generalRecognition(GeneralRecognitionRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getImage(), "Image should not be null or empty!"); + + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, PARA_GENERAL); + + return invokeHttpClient(internalRequest, GeneralRecognitionResponse.class); + } + + /** + * Creates and initializes a new request object for the specified resource. This method is responsible for + * determining HTTP method, URI path, credentials and request body for POST method. + *

+ * Note: The Query parameters in URL should be specified by caller method. + *

+ * + * @param httpMethod The HTTP method to use when sending the request. + * @param request The original request, as created by the user. + * @param pathVariables The optional variables in URI path. + * @return A new request object, populated with endpoint, resource path, ready for callers to populate any + * additional headers or parameters, and execute. + */ + private InternalRequest createRequest( + HttpMethodName httpMethod, FormAbstractBceRequest request, String...pathVariables) { + + // Build URL paths + List pathComponents = new ArrayList(); + pathComponents.add(VERSION); + pathComponents.add(PATH_OCR); + + // Append resourceKeys,pathVariables, + // For example:/resourcekey1/resourcekey2/../pathVariable1/pathVariable2 + if (pathVariables != null) { + for (String pathVariable : pathVariables) { + pathComponents.add(pathVariable); + } + } + + URI uri = HttpUtils.appendUri(getEndpoint(), pathComponents.toArray(new String[pathComponents.size()])); + + // Get a InternalRequest instance and set headers + InternalRequest internalRequest = new InternalRequest(httpMethod, uri); + internalRequest.setCredentials(request.getRequestCredentials()); + + if (httpMethod == HttpMethodName.POST + || httpMethod == HttpMethodName.PUT) { + fillRequestPayload(internalRequest, request); + } + return internalRequest; + } + + private InternalRequest fillRequestPayload(InternalRequest internalRequest, FormAbstractBceRequest request) { + String strFormParameters = request.toFormString(); + byte[] requestJson = null; + try { + requestJson = strFormParameters.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, FORM_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + + return internalRequest; + } +} diff --git a/src/main/java/com/baidubce/services/ocr/model/BankCardResult.java b/src/main/java/com/baidubce/services/ocr/model/BankCardResult.java new file mode 100644 index 00000000..3e3b06fc --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/BankCardResult.java @@ -0,0 +1,33 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Created by lvsiyuan on 16/11/23. + */ +public class BankCardResult { + + @JsonProperty("bank_card_number") + private String number; + + public String getNumber() { + return number; + } + + public void setNumber(String number) { + this.number = number; + } +} diff --git a/src/main/java/com/baidubce/services/ocr/model/BankcardRecognitionRequest.java b/src/main/java/com/baidubce/services/ocr/model/BankcardRecognitionRequest.java new file mode 100644 index 00000000..521ea875 --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/BankcardRecognitionRequest.java @@ -0,0 +1,66 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.io.UnsupportedEncodingException; + +/** + * Created by lvsiyuan on 16/11/23. + */ +public class BankcardRecognitionRequest extends FormAbstractBceRequest { + + /* + * Required. The image data which needs to be base64. + */ + private String image; + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public BankcardRecognitionRequest withImage(String image) { + this.image = image; + return this; + } + + @Override + public String toFormString() { + try { + return "image=" + java.net.URLEncoder.encode(image, "UTF-8"); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "BankcardRecognitionRequest{" + + "image='" + image + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/ocr/model/BankcardRecognitionResponse.java b/src/main/java/com/baidubce/services/ocr/model/BankcardRecognitionResponse.java new file mode 100644 index 00000000..1a66d1ae --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/BankcardRecognitionResponse.java @@ -0,0 +1,52 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.math.BigInteger; + +/** + * Created by lvsiyuan on 16/11/23. + */ +public class BankcardRecognitionResponse extends AbstractBceResponse { + + /* + * The unique log id. + */ + @JsonProperty("log_id") + private BigInteger logId; + + public BigInteger getLogId() { + return logId; + } + + public void setLogId(BigInteger logId) { + this.logId = logId; + } + + /* + * The information detected. + */ + private BankCardResult result; + + public BankCardResult getResult() { + return result; + } + + public void setResult(BankCardResult result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/ocr/model/Chars.java b/src/main/java/com/baidubce/services/ocr/model/Chars.java new file mode 100644 index 00000000..96acfa1f --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/Chars.java @@ -0,0 +1,49 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Created by lvsiyuan on 16/11/22. + */ +public class Chars { + + /* + * The character location within the image resource. + */ + private Location location; + + public Location getLocation() { + return location; + } + + public void setLocation(Location location) { + this.location = location; + } + + /* + * The word detected from the image resource. + */ + @JsonProperty("char") + private String character; + + public String getCharacter() { + return character; + } + + public void setCharacter(String character) { + this.character = character; + } +} diff --git a/src/test/java/com/baidubce/services/sms/model/UpdateTemplateResponse.java b/src/main/java/com/baidubce/services/ocr/model/FormAbstractBceRequest.java old mode 100755 new mode 100644 similarity index 66% rename from src/test/java/com/baidubce/services/sms/model/UpdateTemplateResponse.java rename to src/main/java/com/baidubce/services/ocr/model/FormAbstractBceRequest.java index 9f743d13..03899b46 --- a/src/test/java/com/baidubce/services/sms/model/UpdateTemplateResponse.java +++ b/src/main/java/com/baidubce/services/ocr/model/FormAbstractBceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -10,7 +10,15 @@ * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the * specific language governing permissions and limitations under the License. */ -package com.baidubce.services.sms.model; -public class UpdateTemplateResponse extends SmsResponse { +package com.baidubce.services.ocr.model; + +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by lvsiyuan on 16/12/16. + */ +public abstract class FormAbstractBceRequest extends AbstractBceRequest { + + public abstract String toFormString(); } diff --git a/src/main/java/com/baidubce/services/ocr/model/GeneralRecognitionRequest.java b/src/main/java/com/baidubce/services/ocr/model/GeneralRecognitionRequest.java new file mode 100644 index 00000000..00355722 --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/GeneralRecognitionRequest.java @@ -0,0 +1,149 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.UnsupportedEncodingException; + +/** + * Created by lvsiyuan on 16/11/21. + */ +public class GeneralRecognitionRequest extends FormAbstractBceRequest { + + /* + * Required. The image data which needs to be base64. + */ + private String image; + + /* + * Optional. Decide if recognize single character. (big/small) + */ + @JsonProperty("recognize_granularity") + private String granularity = "big"; + + /* + * Optional. Represent the gray/white/black shade image area. (base64 data) + */ + private String mask = ""; + + /* + * Optional. Language type. (ENG/POR/FRE/GER/ITA/SPA/RUS/JAP) + */ + @JsonProperty("language_type") + private String langType = "CHN_ENG"; + + /* + * Optional. Decide if the image has been rotated. (true/false) + */ + @JsonProperty("detect_direction") + private Boolean direction = false; + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public GeneralRecognitionRequest withImage(String image) { + this.image = image; + return this; + } + + public String getGranularity() { + return granularity; + } + + public void setGranularity(String granularity) { + this.granularity = granularity; + } + + public GeneralRecognitionRequest withGranularity(String granularity) { + this.granularity = granularity; + return this; + } + + public String getMask() { + return mask; + } + + public void setMask(String mask) { + this.mask = mask; + } + + public GeneralRecognitionRequest withMask(String mask) { + this.mask = mask; + return this; + } + + public String getLangType() { + return langType; + } + + public void setLangType(String langType) { + this.langType = langType; + } + + public GeneralRecognitionRequest withLangType(String langType) { + this.langType = langType; + return this; + } + + public Boolean getDirection() { + return direction; + } + + public void setDirection(Boolean direction) { + this.direction = direction; + } + + public GeneralRecognitionRequest withDirection(Boolean direction) { + this.direction = direction; + return this; + } + + public String toFormString() { + try { + return "image=" + java.net.URLEncoder.encode(image, "UTF-8") + "&" + + "recognize_granularity=" + granularity + "&" + + "mask=" + mask + "&" + + "language_type=" + langType + "&" + + "detect_direction=" + direction; + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "GeneralRecognitionRequest{" + + "image='" + image + '\'' + + ", granularity='" + granularity + '\'' + + ", mask='" + mask + '\'' + + ", langType='" + langType + '\'' + + ", direction=" + direction + "" + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/ocr/model/GeneralRecognitionResponse.java b/src/main/java/com/baidubce/services/ocr/model/GeneralRecognitionResponse.java new file mode 100644 index 00000000..b8a79ba6 --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/GeneralRecognitionResponse.java @@ -0,0 +1,81 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.math.BigInteger; +import java.util.List; + +/** + * Created by lvsiyuan on 16/11/21. + */ +public class GeneralRecognitionResponse extends AbstractBceResponse { + + /* + * The unique log id. + */ + @JsonProperty("log_id") + private BigInteger logId; + + public BigInteger getLogId() { + return logId; + } + + public void setLogId(BigInteger logId) { + this.logId = logId; + } + + /* + * The number represents image direction. -1/0/1/2/3. + */ + private Integer direction; + + public Integer getDirection() { + return direction; + } + + public void setDirection(Integer direction) { + this.direction = direction; + } + + /* + * The number of words detected. + */ + @JsonProperty("words_result_num") + private Long resultNum; + + public Long getResultNum() { + return resultNum; + } + + public void setResultNum(Long resultNum) { + this.resultNum = resultNum; + } + + /* + * The words detected and listed as array. + */ + @JsonProperty("words_result") + private List result = null; + + public List getResult() { + return result; + } + + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/ocr/model/GeneralWordsResult.java b/src/main/java/com/baidubce/services/ocr/model/GeneralWordsResult.java new file mode 100644 index 00000000..9f01b72f --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/GeneralWordsResult.java @@ -0,0 +1,62 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +import java.util.List; + +/** + * Created by lvsiyuan on 16/11/23. + */ +public class GeneralWordsResult { + + /* + * The character location within the image resource. + */ + private Location location; + + public Location getLocation() { + return location; + } + + public void setLocation(Location location) { + this.location = location; + } + + /* + * The words detected from the image resource. + */ + private String words; + + public String getWords() { + return words; + } + + public void setWords(String words) { + this.words = words; + } + + /* + * If recognize_granularity = small, show the single character in array. + */ + private List chars = null; + + public List getChars() { + return chars; + } + + public void setChars(List chars) { + this.chars = chars; + } + +} diff --git a/src/main/java/com/baidubce/services/ocr/model/IdcardRecognitionRequest.java b/src/main/java/com/baidubce/services/ocr/model/IdcardRecognitionRequest.java new file mode 100644 index 00000000..616365eb --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/IdcardRecognitionRequest.java @@ -0,0 +1,108 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +import com.baidubce.BceClientException; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.io.UnsupportedEncodingException; + +/** + * Created by lvsiyuan on 16/11/23. + */ +public class IdcardRecognitionRequest extends FormAbstractBceRequest { + + /* + * Required. The image data which needs to be base64. + */ + private String image; + + /* + * Optional. The side of idcard image. (front/back) + */ + @JsonProperty("id_card_side") + private String side; + + /* + * Optional. Decide if the image has been rotated. (true/false) + */ + @JsonProperty("detect_direction") + private Boolean direction = false; + + public String getImage() { + return image; + } + + public void setImage(String image) { + this.image = image; + } + + public IdcardRecognitionRequest withImage(String image) { + this.image = image; + return this; + } + + public String getSide() { + return side; + } + + public void setSide(String side) { + this.side = side; + } + + public IdcardRecognitionRequest withSide(String side) { + this.side = side; + return this; + } + + public Boolean getDirection() { + return direction; + } + + public void setDirection(Boolean direction) { + this.direction = direction; + } + + public IdcardRecognitionRequest withDirection(Boolean direction) { + this.direction = direction; + return this; + } + + public String toFormString() { + try { + return "image=" + java.net.URLEncoder.encode(image, "UTF-8") + "&" + + "id_card_side=" + side + "&" + + "detect_direction=" + direction; + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + return "IdcardRecognitionRequest{" + + "image='" + image + '\'' + + ", side='" + side + '\'' + + ", direction=" + direction + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/ocr/model/IdcardRecognitionResponse.java b/src/main/java/com/baidubce/services/ocr/model/IdcardRecognitionResponse.java new file mode 100644 index 00000000..103652d0 --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/IdcardRecognitionResponse.java @@ -0,0 +1,81 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +import com.baidubce.model.AbstractBceResponse; +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.math.BigInteger; +import java.util.Map; + +/** + * Created by lvsiyuan on 16/11/23. + */ +public class IdcardRecognitionResponse extends AbstractBceResponse { + + /* + * The unique log id. + */ + @JsonProperty("log_id") + private BigInteger logId; + + public BigInteger getLogId() { + return logId; + } + + public void setLogId(BigInteger logId) { + this.logId = logId; + } + + /* + * The number represents image direction. (-1/0/1/2/3) + */ + private Integer direction; + + public Integer getDirection() { + return direction; + } + + public void setDirection(Integer direction) { + this.direction = direction; + } + + /* + * The number of words detected. + */ + @JsonProperty("words_result_num") + private Long resultNum; + + public Long getResultNum() { + return resultNum; + } + + public void setResultNum(Long resultNum) { + this.resultNum = resultNum; + } + + /* + * The words detected. + */ + @JsonProperty("words_result") + private Map result; + + public Map getResult() { + return result; + } + + public void setResult(Map result) { + this.result = result; + } +} diff --git a/src/main/java/com/baidubce/services/ocr/model/IdcardWordsResult.java b/src/main/java/com/baidubce/services/ocr/model/IdcardWordsResult.java new file mode 100644 index 00000000..9f5acb85 --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/IdcardWordsResult.java @@ -0,0 +1,46 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +/** + * Created by lvsiyuan on 16/11/23. + */ +public class IdcardWordsResult { + + /* + * The character location within the image resource. + */ + private Location location; + + public Location getLocation() { + return location; + } + + public void setLocation(Location location) { + this.location = location; + } + + /* + * The words detected from the image resource. + */ + private String words; + + public String getWords() { + return words; + } + + public void setWords(String words) { + this.words = words; + } +} diff --git a/src/main/java/com/baidubce/services/ocr/model/Location.java b/src/main/java/com/baidubce/services/ocr/model/Location.java new file mode 100644 index 00000000..292a2ff5 --- /dev/null +++ b/src/main/java/com/baidubce/services/ocr/model/Location.java @@ -0,0 +1,60 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.ocr.model; + +/** + * Created by lvsiyuan on 16/11/22. + */ +public class Location { + + public Integer getLeft() { + return left; + } + + public void setLeft(Integer left) { + this.left = left; + } + + public Integer getTop() { + return top; + } + + public void setTop(Integer top) { + this.top = top; + } + + public Integer getWidth() { + return width; + } + + public void setWidth(Integer width) { + this.width = width; + } + + public Integer getHeight() { + return height; + } + + public void setHeight(Integer height) { + this.height = height; + } + + private Integer left; + + private Integer top; + + private Integer width; + + private Integer height; +} diff --git a/src/main/java/com/baidubce/services/ruleengine/RuleEngineClient.java b/src/main/java/com/baidubce/services/ruleengine/RuleEngineClient.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/CreateRuleRequest.java b/src/main/java/com/baidubce/services/ruleengine/model/CreateRuleRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/DeleteRulesRequest.java b/src/main/java/com/baidubce/services/ruleengine/model/DeleteRulesRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/Destination.java b/src/main/java/com/baidubce/services/ruleengine/model/Destination.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java b/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/ListRuleRequest.java b/src/main/java/com/baidubce/services/ruleengine/model/ListRuleRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/ListRuleResponse.java b/src/main/java/com/baidubce/services/ruleengine/model/ListRuleResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/Rule.java b/src/main/java/com/baidubce/services/ruleengine/model/Rule.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/RuleState.java b/src/main/java/com/baidubce/services/ruleengine/model/RuleState.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/RuleTestRequest.java b/src/main/java/com/baidubce/services/ruleengine/model/RuleTestRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ruleengine/model/UpdateRuleRequest.java b/src/main/java/com/baidubce/services/ruleengine/model/UpdateRuleRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ses/SesClient.java b/src/main/java/com/baidubce/services/ses/SesClient.java old mode 100755 new mode 100644 index 70d9612a..48ebeb2e --- a/src/main/java/com/baidubce/services/ses/SesClient.java +++ b/src/main/java/com/baidubce/services/ses/SesClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/SesClientConfiguration.java b/src/main/java/com/baidubce/services/ses/SesClientConfiguration.java old mode 100755 new mode 100644 index dde96943..c184c2c7 --- a/src/main/java/com/baidubce/services/ses/SesClientConfiguration.java +++ b/src/main/java/com/baidubce/services/ses/SesClientConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/SesClientSupport.java b/src/main/java/com/baidubce/services/ses/SesClientSupport.java old mode 100755 new mode 100644 index 86f72069..51823486 --- a/src/main/java/com/baidubce/services/ses/SesClientSupport.java +++ b/src/main/java/com/baidubce/services/ses/SesClientSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/SesConstant.java b/src/main/java/com/baidubce/services/ses/SesConstant.java old mode 100755 new mode 100644 index 8f35f729..af141880 --- a/src/main/java/com/baidubce/services/ses/SesConstant.java +++ b/src/main/java/com/baidubce/services/ses/SesConstant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/DeleteVerifiedDomainRequest.java b/src/main/java/com/baidubce/services/ses/model/DeleteVerifiedDomainRequest.java old mode 100755 new mode 100644 index 0fa447ee..2e9e190d --- a/src/main/java/com/baidubce/services/ses/model/DeleteVerifiedDomainRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/DeleteVerifiedDomainRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/DeleteVerifiedEmailRequest.java b/src/main/java/com/baidubce/services/ses/model/DeleteVerifiedEmailRequest.java old mode 100755 new mode 100644 index b4a62dad..15336195 --- a/src/main/java/com/baidubce/services/ses/model/DeleteVerifiedEmailRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/DeleteVerifiedEmailRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/DkimAttrModel.java b/src/main/java/com/baidubce/services/ses/model/DkimAttrModel.java old mode 100755 new mode 100644 index fd4d25df..b80b050e --- a/src/main/java/com/baidubce/services/ses/model/DkimAttrModel.java +++ b/src/main/java/com/baidubce/services/ses/model/DkimAttrModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/DkimAttrModelTokenModel.java b/src/main/java/com/baidubce/services/ses/model/DkimAttrModelTokenModel.java old mode 100755 new mode 100644 index c26d0374..6b9ffb06 --- a/src/main/java/com/baidubce/services/ses/model/DkimAttrModelTokenModel.java +++ b/src/main/java/com/baidubce/services/ses/model/DkimAttrModelTokenModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/DomainAttrModel.java b/src/main/java/com/baidubce/services/ses/model/DomainAttrModel.java old mode 100755 new mode 100644 index 7c095ca8..93d880a7 --- a/src/main/java/com/baidubce/services/ses/model/DomainAttrModel.java +++ b/src/main/java/com/baidubce/services/ses/model/DomainAttrModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/DomainDetailModel.java b/src/main/java/com/baidubce/services/ses/model/DomainDetailModel.java old mode 100755 new mode 100644 index 437a45c5..b4b0e1a6 --- a/src/main/java/com/baidubce/services/ses/model/DomainDetailModel.java +++ b/src/main/java/com/baidubce/services/ses/model/DomainDetailModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/EmailDetailModel.java b/src/main/java/com/baidubce/services/ses/model/EmailDetailModel.java old mode 100755 new mode 100644 index 2c13bf21..16050a52 --- a/src/main/java/com/baidubce/services/ses/model/EmailDetailModel.java +++ b/src/main/java/com/baidubce/services/ses/model/EmailDetailModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/EnableDKIMRequest.java b/src/main/java/com/baidubce/services/ses/model/EnableDKIMRequest.java old mode 100755 new mode 100644 index 117603fd..ed1d69e6 --- a/src/main/java/com/baidubce/services/ses/model/EnableDKIMRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/EnableDKIMRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/GetFailedReasonResponse.java b/src/main/java/com/baidubce/services/ses/model/GetFailedReasonResponse.java old mode 100755 new mode 100644 index 9144c31a..94af4ed3 --- a/src/main/java/com/baidubce/services/ses/model/GetFailedReasonResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/GetFailedReasonResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/GetFeedbackResponse.java b/src/main/java/com/baidubce/services/ses/model/GetFeedbackResponse.java old mode 100755 new mode 100644 index 3be05fd3..2110207d --- a/src/main/java/com/baidubce/services/ses/model/GetFeedbackResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/GetFeedbackResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/GetQuotaResponse.java b/src/main/java/com/baidubce/services/ses/model/GetQuotaResponse.java old mode 100755 new mode 100644 index b82d7073..d3a7e741 --- a/src/main/java/com/baidubce/services/ses/model/GetQuotaResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/GetQuotaResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/GetVerifiedDomainRequest.java b/src/main/java/com/baidubce/services/ses/model/GetVerifiedDomainRequest.java old mode 100755 new mode 100644 index 07aebf48..304caadd --- a/src/main/java/com/baidubce/services/ses/model/GetVerifiedDomainRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/GetVerifiedDomainRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/GetVerifiedDomainResponse.java b/src/main/java/com/baidubce/services/ses/model/GetVerifiedDomainResponse.java old mode 100755 new mode 100644 index ab8b18bc..455edc68 --- a/src/main/java/com/baidubce/services/ses/model/GetVerifiedDomainResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/GetVerifiedDomainResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/GetVerifiedEmailRequest.java b/src/main/java/com/baidubce/services/ses/model/GetVerifiedEmailRequest.java old mode 100755 new mode 100644 index ecf46a55..3251ae71 --- a/src/main/java/com/baidubce/services/ses/model/GetVerifiedEmailRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/GetVerifiedEmailRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/GetVerifiedEmailResponse.java b/src/main/java/com/baidubce/services/ses/model/GetVerifiedEmailResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/ses/model/IsInRecipientBlacklistRequest.java b/src/main/java/com/baidubce/services/ses/model/IsInRecipientBlacklistRequest.java old mode 100755 new mode 100644 index 23eff9fa..3e00933c --- a/src/main/java/com/baidubce/services/ses/model/IsInRecipientBlacklistRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/IsInRecipientBlacklistRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/IsInRecipientBlacklistResponse.java b/src/main/java/com/baidubce/services/ses/model/IsInRecipientBlacklistResponse.java old mode 100755 new mode 100644 index 11ff90b8..03c63e14 --- a/src/main/java/com/baidubce/services/ses/model/IsInRecipientBlacklistResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/IsInRecipientBlacklistResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/ListRecipientBlacklistResponse.java b/src/main/java/com/baidubce/services/ses/model/ListRecipientBlacklistResponse.java old mode 100755 new mode 100644 index aab332cf..b10bcba8 --- a/src/main/java/com/baidubce/services/ses/model/ListRecipientBlacklistResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/ListRecipientBlacklistResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/ListVerifiedDomainResponse.java b/src/main/java/com/baidubce/services/ses/model/ListVerifiedDomainResponse.java old mode 100755 new mode 100644 index de1ba5fb..fa9e41b8 --- a/src/main/java/com/baidubce/services/ses/model/ListVerifiedDomainResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/ListVerifiedDomainResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/ListVerifiedEmailResponse.java b/src/main/java/com/baidubce/services/ses/model/ListVerifiedEmailResponse.java old mode 100755 new mode 100644 index f39a5c88..fa695cf7 --- a/src/main/java/com/baidubce/services/ses/model/ListVerifiedEmailResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/ListVerifiedEmailResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/RecptModel.java b/src/main/java/com/baidubce/services/ses/model/RecptModel.java old mode 100755 new mode 100644 index 3c3dd0b4..210650e0 --- a/src/main/java/com/baidubce/services/ses/model/RecptModel.java +++ b/src/main/java/com/baidubce/services/ses/model/RecptModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/SendEmailRequest.java b/src/main/java/com/baidubce/services/ses/model/SendEmailRequest.java old mode 100755 new mode 100644 index 22f60186..c7c395dd --- a/src/main/java/com/baidubce/services/ses/model/SendEmailRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/SendEmailRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/SendEmailResponse.java b/src/main/java/com/baidubce/services/ses/model/SendEmailResponse.java old mode 100755 new mode 100644 index 968cf6b2..3e6dea1c --- a/src/main/java/com/baidubce/services/ses/model/SendEmailResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/SendEmailResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/SesRequest.java b/src/main/java/com/baidubce/services/ses/model/SesRequest.java old mode 100755 new mode 100644 index 7b1dc4d6..d602e552 --- a/src/main/java/com/baidubce/services/ses/model/SesRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/SesRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/SesResponse.java b/src/main/java/com/baidubce/services/ses/model/SesResponse.java old mode 100755 new mode 100644 index 1a81869b..f0779e76 --- a/src/main/java/com/baidubce/services/ses/model/SesResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/SesResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/SetFeedbackRequest.java b/src/main/java/com/baidubce/services/ses/model/SetFeedbackRequest.java old mode 100755 new mode 100644 index b358be91..cac904aa --- a/src/main/java/com/baidubce/services/ses/model/SetFeedbackRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/SetFeedbackRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/SetQuotaRequest.java b/src/main/java/com/baidubce/services/ses/model/SetQuotaRequest.java old mode 100755 new mode 100644 index 7ab849ad..4bbeb6a6 --- a/src/main/java/com/baidubce/services/ses/model/SetQuotaRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/SetQuotaRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/TokenModel.java b/src/main/java/com/baidubce/services/ses/model/TokenModel.java old mode 100755 new mode 100644 index 5a86c254..c19f291f --- a/src/main/java/com/baidubce/services/ses/model/TokenModel.java +++ b/src/main/java/com/baidubce/services/ses/model/TokenModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/VerifyDKIMRequest.java b/src/main/java/com/baidubce/services/ses/model/VerifyDKIMRequest.java old mode 100755 new mode 100644 index 66698031..3432dc14 --- a/src/main/java/com/baidubce/services/ses/model/VerifyDKIMRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/VerifyDKIMRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/VerifyDKIMResponse.java b/src/main/java/com/baidubce/services/ses/model/VerifyDKIMResponse.java old mode 100755 new mode 100644 index 2841fbf4..0d86cfb3 --- a/src/main/java/com/baidubce/services/ses/model/VerifyDKIMResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/VerifyDKIMResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/VerifyDomainRequest.java b/src/main/java/com/baidubce/services/ses/model/VerifyDomainRequest.java old mode 100755 new mode 100644 index 2e245a67..45d51ab2 --- a/src/main/java/com/baidubce/services/ses/model/VerifyDomainRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/VerifyDomainRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/VerifyDomainResponse.java b/src/main/java/com/baidubce/services/ses/model/VerifyDomainResponse.java old mode 100755 new mode 100644 index 719741d9..28f0b2c7 --- a/src/main/java/com/baidubce/services/ses/model/VerifyDomainResponse.java +++ b/src/main/java/com/baidubce/services/ses/model/VerifyDomainResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/ses/model/VerifyEmailRequest.java b/src/main/java/com/baidubce/services/ses/model/VerifyEmailRequest.java old mode 100755 new mode 100644 index 988c03c4..e7760f81 --- a/src/main/java/com/baidubce/services/ses/model/VerifyEmailRequest.java +++ b/src/main/java/com/baidubce/services/ses/model/VerifyEmailRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/SmsClient.java b/src/main/java/com/baidubce/services/sms/SmsClient.java old mode 100755 new mode 100644 index 9ccf77ba..f2304278 --- a/src/main/java/com/baidubce/services/sms/SmsClient.java +++ b/src/main/java/com/baidubce/services/sms/SmsClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/SmsClientConfiguration.java b/src/main/java/com/baidubce/services/sms/SmsClientConfiguration.java old mode 100755 new mode 100644 index d31d2826..39dd679a --- a/src/main/java/com/baidubce/services/sms/SmsClientConfiguration.java +++ b/src/main/java/com/baidubce/services/sms/SmsClientConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/SmsClientSupport.java b/src/main/java/com/baidubce/services/sms/SmsClientSupport.java old mode 100755 new mode 100644 index afa6b100..0829171e --- a/src/main/java/com/baidubce/services/sms/SmsClientSupport.java +++ b/src/main/java/com/baidubce/services/sms/SmsClientSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/SmsConstant.java b/src/main/java/com/baidubce/services/sms/SmsConstant.java old mode 100755 new mode 100644 index 0a0cfb3e..468897fd --- a/src/main/java/com/baidubce/services/sms/SmsConstant.java +++ b/src/main/java/com/baidubce/services/sms/SmsConstant.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/BaseResponse.java b/src/main/java/com/baidubce/services/sms/model/BaseResponse.java old mode 100755 new mode 100644 index 30a0ca22..ff328fd6 --- a/src/main/java/com/baidubce/services/sms/model/BaseResponse.java +++ b/src/main/java/com/baidubce/services/sms/model/BaseResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/CreateTemplateRequest.java b/src/main/java/com/baidubce/services/sms/model/CreateTemplateRequest.java old mode 100755 new mode 100644 index 2f18ea9f..a5c5a813 --- a/src/main/java/com/baidubce/services/sms/model/CreateTemplateRequest.java +++ b/src/main/java/com/baidubce/services/sms/model/CreateTemplateRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/CreateTemplateResponse.java b/src/main/java/com/baidubce/services/sms/model/CreateTemplateResponse.java old mode 100755 new mode 100644 index d5f44ccb..26d352c5 --- a/src/main/java/com/baidubce/services/sms/model/CreateTemplateResponse.java +++ b/src/main/java/com/baidubce/services/sms/model/CreateTemplateResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/DeleteTemplateRequest.java b/src/main/java/com/baidubce/services/sms/model/DeleteTemplateRequest.java old mode 100755 new mode 100644 index 09dcd71b..ba5895c2 --- a/src/main/java/com/baidubce/services/sms/model/DeleteTemplateRequest.java +++ b/src/main/java/com/baidubce/services/sms/model/DeleteTemplateRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/GetTemplateDetailRequest.java b/src/main/java/com/baidubce/services/sms/model/GetTemplateDetailRequest.java old mode 100755 new mode 100644 index 27e60d77..41221214 --- a/src/main/java/com/baidubce/services/sms/model/GetTemplateDetailRequest.java +++ b/src/main/java/com/baidubce/services/sms/model/GetTemplateDetailRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/GetTemplateDetailResponse.java b/src/main/java/com/baidubce/services/sms/model/GetTemplateDetailResponse.java old mode 100755 new mode 100644 index 5ba41485..f86eceea --- a/src/main/java/com/baidubce/services/sms/model/GetTemplateDetailResponse.java +++ b/src/main/java/com/baidubce/services/sms/model/GetTemplateDetailResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/ListTemplateResponse.java b/src/main/java/com/baidubce/services/sms/model/ListTemplateResponse.java old mode 100755 new mode 100644 index ad9a29a1..18bd5138 --- a/src/main/java/com/baidubce/services/sms/model/ListTemplateResponse.java +++ b/src/main/java/com/baidubce/services/sms/model/ListTemplateResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/QueryMessageDetailRequest.java b/src/main/java/com/baidubce/services/sms/model/QueryMessageDetailRequest.java old mode 100755 new mode 100644 index 11e7c0dd..73bb04b4 --- a/src/main/java/com/baidubce/services/sms/model/QueryMessageDetailRequest.java +++ b/src/main/java/com/baidubce/services/sms/model/QueryMessageDetailRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/QueryMessageDetailResponse.java b/src/main/java/com/baidubce/services/sms/model/QueryMessageDetailResponse.java old mode 100755 new mode 100644 index 9e8b93d8..78a61309 --- a/src/main/java/com/baidubce/services/sms/model/QueryMessageDetailResponse.java +++ b/src/main/java/com/baidubce/services/sms/model/QueryMessageDetailResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/QueryQuotaResponse.java b/src/main/java/com/baidubce/services/sms/model/QueryQuotaResponse.java old mode 100755 new mode 100644 index d057ad0e..8412e0a9 --- a/src/main/java/com/baidubce/services/sms/model/QueryQuotaResponse.java +++ b/src/main/java/com/baidubce/services/sms/model/QueryQuotaResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/SendMessageRequest.java b/src/main/java/com/baidubce/services/sms/model/SendMessageRequest.java old mode 100755 new mode 100644 index 69b97b2d..cf33bacb --- a/src/main/java/com/baidubce/services/sms/model/SendMessageRequest.java +++ b/src/main/java/com/baidubce/services/sms/model/SendMessageRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/SendMessageResponse.java b/src/main/java/com/baidubce/services/sms/model/SendMessageResponse.java old mode 100755 new mode 100644 index 3f0ba9d8..948bcfc2 --- a/src/main/java/com/baidubce/services/sms/model/SendMessageResponse.java +++ b/src/main/java/com/baidubce/services/sms/model/SendMessageResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/SendMessageV2Request.java b/src/main/java/com/baidubce/services/sms/model/SendMessageV2Request.java old mode 100755 new mode 100644 index 832e62c3..5b955c84 --- a/src/main/java/com/baidubce/services/sms/model/SendMessageV2Request.java +++ b/src/main/java/com/baidubce/services/sms/model/SendMessageV2Request.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/SendMessageV2Response.java b/src/main/java/com/baidubce/services/sms/model/SendMessageV2Response.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/sms/model/SendStatModel.java b/src/main/java/com/baidubce/services/sms/model/SendStatModel.java old mode 100755 new mode 100644 index 8bc7791f..d813a698 --- a/src/main/java/com/baidubce/services/sms/model/SendStatModel.java +++ b/src/main/java/com/baidubce/services/sms/model/SendStatModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/SmsRequest.java b/src/main/java/com/baidubce/services/sms/model/SmsRequest.java old mode 100755 new mode 100644 index 93e2f558..b6e22373 --- a/src/main/java/com/baidubce/services/sms/model/SmsRequest.java +++ b/src/main/java/com/baidubce/services/sms/model/SmsRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/SmsResponse.java b/src/main/java/com/baidubce/services/sms/model/SmsResponse.java old mode 100755 new mode 100644 index cea1735a..0a8fcab0 --- a/src/main/java/com/baidubce/services/sms/model/SmsResponse.java +++ b/src/main/java/com/baidubce/services/sms/model/SmsResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/StatReceiverRequest.java b/src/main/java/com/baidubce/services/sms/model/StatReceiverRequest.java old mode 100755 new mode 100644 index 82a0a1af..824b4daa --- a/src/main/java/com/baidubce/services/sms/model/StatReceiverRequest.java +++ b/src/main/java/com/baidubce/services/sms/model/StatReceiverRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/StatReceiverResponse.java b/src/main/java/com/baidubce/services/sms/model/StatReceiverResponse.java old mode 100755 new mode 100644 index 25c53367..0d962e88 --- a/src/main/java/com/baidubce/services/sms/model/StatReceiverResponse.java +++ b/src/main/java/com/baidubce/services/sms/model/StatReceiverResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sms/model/TemplateStatus.java b/src/main/java/com/baidubce/services/sms/model/TemplateStatus.java old mode 100755 new mode 100644 index f838e68b..bb5b2280 --- a/src/main/java/com/baidubce/services/sms/model/TemplateStatus.java +++ b/src/main/java/com/baidubce/services/sms/model/TemplateStatus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sts/BceStsJsonResponseHandler.java b/src/main/java/com/baidubce/services/sts/BceStsJsonResponseHandler.java old mode 100755 new mode 100644 index 1e9664b1..f4a16092 --- a/src/main/java/com/baidubce/services/sts/BceStsJsonResponseHandler.java +++ b/src/main/java/com/baidubce/services/sts/BceStsJsonResponseHandler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sts/StsClient.java b/src/main/java/com/baidubce/services/sts/StsClient.java old mode 100755 new mode 100644 index 65dba5b4..ae215a07 --- a/src/main/java/com/baidubce/services/sts/StsClient.java +++ b/src/main/java/com/baidubce/services/sts/StsClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sts/example/StsExample.java b/src/main/java/com/baidubce/services/sts/example/StsExample.java old mode 100755 new mode 100644 index 31ad9fae..f9ff191d --- a/src/main/java/com/baidubce/services/sts/example/StsExample.java +++ b/src/main/java/com/baidubce/services/sts/example/StsExample.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sts/model/GetSessionTokenRequest.java b/src/main/java/com/baidubce/services/sts/model/GetSessionTokenRequest.java old mode 100755 new mode 100644 index 2ab9e984..a0fe1f0a --- a/src/main/java/com/baidubce/services/sts/model/GetSessionTokenRequest.java +++ b/src/main/java/com/baidubce/services/sts/model/GetSessionTokenRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/sts/model/GetSessionTokenResponse.java b/src/main/java/com/baidubce/services/sts/model/GetSessionTokenResponse.java old mode 100755 new mode 100644 index a4be06e5..35fd8f81 --- a/src/main/java/com/baidubce/services/sts/model/GetSessionTokenResponse.java +++ b/src/main/java/com/baidubce/services/sts/model/GetSessionTokenResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Baidu.com, Inc. All Rights Reserved + * Copyright 2016 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/tsdb/TsdbClient.java b/src/main/java/com/baidubce/services/tsdb/TsdbClient.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java b/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java old mode 100755 new mode 100644 index 4d0223c5..4a2b8c43 --- a/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java +++ b/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java @@ -41,4 +41,8 @@ public class TsdbConstants { public static String TYPE_LONG = "Long"; public static String TYPE_DOUBLE = "Double"; public static String TYPE_STRING = "String"; + + // Query order. + public static String ORDER_ASC = "Asc"; + public static String ORDER_DESC = "Desc"; } diff --git a/src/main/java/com/baidubce/services/tsdb/model/Aggregator.java b/src/main/java/com/baidubce/services/tsdb/model/Aggregator.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/Datapoint.java b/src/main/java/com/baidubce/services/tsdb/model/Datapoint.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/Filters.java b/src/main/java/com/baidubce/services/tsdb/model/Filters.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/GetMetricsRequest.java b/src/main/java/com/baidubce/services/tsdb/model/GetMetricsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/GetMetricsResponse.java b/src/main/java/com/baidubce/services/tsdb/model/GetMetricsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/GetTagsRequest.java b/src/main/java/com/baidubce/services/tsdb/model/GetTagsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/GetTagsResponse.java b/src/main/java/com/baidubce/services/tsdb/model/GetTagsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/Group.java b/src/main/java/com/baidubce/services/tsdb/model/Group.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/GroupBy.java b/src/main/java/com/baidubce/services/tsdb/model/GroupBy.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/GroupInfo.java b/src/main/java/com/baidubce/services/tsdb/model/GroupInfo.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/Query.java b/src/main/java/com/baidubce/services/tsdb/model/Query.java old mode 100755 new mode 100644 index 42ae5986..188a315b --- a/src/main/java/com/baidubce/services/tsdb/model/Query.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Query.java @@ -40,6 +40,12 @@ public class Query { */ private List aggregators; + /** + * Optional. + * The order: Asc or Desc, default is Asc. + */ + private String order; + public String getMetric() { return metric; } @@ -79,7 +85,15 @@ public List getAggregators() { public void setAggregators(List aggregators) { this.aggregators = aggregators; } - + + public String getOrder() { + return order; + } + + public void setOrder(String order) { + this.order = order; + } + public Query withMetric(String metric) { this.metric = metric; return this; @@ -104,13 +118,18 @@ public Query withAggregators(List aggregators) { this.aggregators = aggregators; return this; } - + + public Query withOrder(String order) { + this.order = order; + return this; + } + public Query addAggregator(Aggregator aggregator) { initialAggregators(); this.aggregators.add(aggregator); return this; } - + private void initialAggregators() { if (aggregators == null) { aggregators = Lists.newArrayList(); diff --git a/src/main/java/com/baidubce/services/tsdb/model/QueryDatapointsRequest.java b/src/main/java/com/baidubce/services/tsdb/model/QueryDatapointsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/QueryDatapointsResponse.java b/src/main/java/com/baidubce/services/tsdb/model/QueryDatapointsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/Result.java b/src/main/java/com/baidubce/services/tsdb/model/Result.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/ValueFilter.java b/src/main/java/com/baidubce/services/tsdb/model/ValueFilter.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/WriteDatapointsRequest.java b/src/main/java/com/baidubce/services/tsdb/model/WriteDatapointsRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/tsdb/model/WriteDatapointsResponse.java b/src/main/java/com/baidubce/services/tsdb/model/WriteDatapointsResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/vod/FileUploadSession.java b/src/main/java/com/baidubce/services/vod/FileUploadSession.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/vod/VodClient.java b/src/main/java/com/baidubce/services/vod/VodClient.java old mode 100755 new mode 100644 index b7902bec..4a9e5593 --- a/src/main/java/com/baidubce/services/vod/VodClient.java +++ b/src/main/java/com/baidubce/services/vod/VodClient.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -51,14 +51,12 @@ import com.baidubce.services.vod.model.GenerateMediaIdResponse; import com.baidubce.services.vod.model.GetMediaResourceRequest; import com.baidubce.services.vod.model.GetMediaResourceResponse; -import com.baidubce.services.vod.model.GetPlayableUrlRequest; -import com.baidubce.services.vod.model.GetPlayableUrlResponse; -import com.baidubce.services.vod.model.GetPlayerCodeRequest; -import com.baidubce.services.vod.model.GetPlayerCodeResponse; import com.baidubce.services.vod.model.InternalCreateMediaRequest; import com.baidubce.services.vod.model.InternalCreateMediaResponse; import com.baidubce.services.vod.model.ListMediaResourceRequest; import com.baidubce.services.vod.model.ListMediaResourceResponse; +import com.baidubce.services.vod.model.ListMediaResourceByMarkerRequest; +import com.baidubce.services.vod.model.ListMediaResourceByMarkerResponse; import com.baidubce.services.vod.model.PublishMediaResourceRequest; import com.baidubce.services.vod.model.PublishMediaResourceResponse; import com.baidubce.services.vod.model.StopMediaResourceRequest; @@ -75,6 +73,14 @@ import com.baidubce.services.vod.model.ReTranscodeResponse; import com.baidubce.services.vod.model.GetMediaSourceDownloadRequest; import com.baidubce.services.vod.model.GetMediaSourceDownloadResponse; +import com.baidubce.services.vod.model.CreateNotificationRequest; +import com.baidubce.services.vod.model.CreateNotificationResponse; +import com.baidubce.services.vod.model.GetNotificationRequest; +import com.baidubce.services.vod.model.GetNotificationResponse; +import com.baidubce.services.vod.model.ListNotificationsRequest; +import com.baidubce.services.vod.model.ListNotificationsResponse; +import com.baidubce.services.vod.model.DeleteNotificationRequest; +import com.baidubce.services.vod.model.DeleteNotificationResponse; import com.baidubce.util.HttpUtils; import com.baidubce.util.JsonUtils; @@ -92,6 +98,8 @@ public class VodClient extends AbstractBceClient { */ private static final String PATH_MEDIA = "media"; + private static final String PATH_NOTIFICATION = "notification"; + private static final String PATH_INTERNAL_MEDIA = "media/internal"; /** @@ -130,10 +138,14 @@ public class VodClient extends AbstractBceClient { private static final String PARA_TITLE = "title"; private static final String START_TIME = "startTime"; private static final String END_TIME = "endTime"; + private static final String PARAM_MAX_SIZE = "maxSize"; + private static final String PARAM_MARKER = "marker"; + private static final String PARAM_TRANSCODING_PRESET_NAME = "transcodingPresetName"; private static final String AGGREGATE = "aggregate"; private static final String PARA_RERUN = "rerun"; private static final String PARA_DOWNLOAD = "sourcedownload"; private static final String PARA_EXPIREDINSECONDS = "expiredInSeconds"; + private static final String VALID_EXTENSION_PATTERN = "[0-9a-zA-Z]{0,10}"; private static final int LIST_MAX_PAGESIZE = 1000; private static final int LIST_MIN_PAGESIZE = 1; private static final int MAX_SOURCE_EXTENSION_LENGTH = 10; @@ -182,11 +194,18 @@ public VodClient(BceClientConfiguration vodConfig) { /** * Uploads the specified file to Bos under the specified bucket and key name. * - * @param file The file containing the data to be uploaded to VOD + * @param title media titile. + * @param description media description. + * @param file The file containing the data to be uploaded to VOD. + * @param transcodingPresetGroupName set transcoding presetgroup name, if NULL, use default * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. * @throws FileNotFoundException */ - public CreateMediaResourceResponse createMediaResource(String title, String description, File file) + public CreateMediaResourceResponse createMediaResource( + String title, + String description, + File file, + String transcodingPresetGroupName) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The media file " + file.getAbsolutePath() + " doesn't exist!"); @@ -194,27 +213,28 @@ public CreateMediaResourceResponse createMediaResource(String title, String desc // try get file extension String sourceExtension = null; String filename = file.getName(); - if (filename.lastIndexOf(".") != -1) { - sourceExtension = filename.substring(filename.lastIndexOf(".") + 1); - if (sourceExtension.length() <= 0 || sourceExtension.length() > MAX_SOURCE_EXTENSION_LENGTH) { - sourceExtension = null; - } - } + sourceExtension = getFileExtension(filename); // get a BOS bucket and extract mediaId from it GenerateMediaIdResponse generateMediaIdresponse = applyMedia(); String bosKey = generateMediaIdresponse.getSourceKey(); String mediaId = generateMediaIdresponse.getMediaId(); String bucket = generateMediaIdresponse.getSourceBucket(); - logger.info("[bucket] = " + bucket + ", [bosKey] = " + bosKey + ", [mediaId] = " + mediaId); + logger.info("[bucket] = " + bucket + + ", [bosKey] = " + bosKey + + ", [mediaId] = " + mediaId); // upload the file FileUploadSession session = new FileUploadSession(bosClient); CreateMediaResourceResponse response = new CreateMediaResourceResponse(); if (session.upload(file, bucket, bosKey)) { InternalCreateMediaRequest request = - new InternalCreateMediaRequest().withMediaId(mediaId).withTitle(title) - .withDescription(description).withSourceExtension(sourceExtension); + new InternalCreateMediaRequest() + .withMediaId(mediaId) + .withTitle(title) + .withDescription(description) + .withSourceExtension(sourceExtension) + .withTranscodingPresetGroupName(transcodingPresetGroupName); InternalCreateMediaResponse internalResponse = processMedia(request); response.setMediaId(internalResponse.getMediaId()); } @@ -230,28 +250,28 @@ public CreateMediaResourceResponse createMediaResource(String title, String desc * @param sourceKey The key name of the media resource in BOS * @param title The title string of the media resource * @param description The description string of the media resource - * + * @param transcodingPresetGroupName set transcoding presetgroup name, if NULL, use default * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. * @throws FileNotFoundException */ public CreateMediaResourceResponse createMediaResource( - String sourceBucket, String sourceKey, String title, String description) { + String sourceBucket, + String sourceKey, + String title, + String description, + String transcodingPresetGroupName) { checkStringNotEmpty(sourceBucket, "sourceBucket should not be null or empty!"); checkStringNotEmpty(sourceKey, "key should not be null or empty!"); // check if the key exist ObjectMetadata metaData = bosClient.getObjectMetadata(sourceBucket, sourceKey); checkIsTrue(metaData != null && metaData.getContentLength() > 0, - "The object corresponding to [bucket] = " + sourceBucket + ", [key] = " + sourceKey + " doesn't exist."); + "The object corresponding to [bucket] = " + + sourceBucket + ", [key] = " + sourceKey + " doesn't exist."); // try get file extension String sourceExtension = null; - if (sourceKey.lastIndexOf(".") != -1) { - sourceExtension = sourceKey.substring(sourceKey.lastIndexOf(".") + 1); - if (sourceExtension.length() <= 0 || sourceExtension.length() > MAX_SOURCE_EXTENSION_LENGTH) { - sourceExtension = null; - } - } + sourceExtension = getFileExtension(sourceKey); // generate media Id GenerateMediaIdResponse generateMediaIdresponse = applyMedia(); String mediaId = generateMediaIdresponse.getMediaId(); @@ -263,8 +283,12 @@ public CreateMediaResourceResponse createMediaResource( // create mediaId InternalCreateMediaRequest request = - new InternalCreateMediaRequest().withMediaId(mediaId).withTitle(title) - .withDescription(description).withSourceExtension(sourceExtension); + new InternalCreateMediaRequest() + .withMediaId(mediaId) + .withTitle(title) + .withDescription(description) + .withSourceExtension(sourceExtension) + .withTranscodingPresetGroupName(transcodingPresetGroupName); InternalCreateMediaResponse internalResponse = processMedia(request); CreateMediaResourceResponse response = new CreateMediaResourceResponse(); @@ -323,42 +347,97 @@ public GetMediaResourceResponse getMediaResource(GetMediaResourceRequest request /** * List the properties of all media resource managed by VOD service. + * recommend use marker mode to get high performance * *

* The caller must authenticate with a valid BCE Access Key / Private Key pair. * + * @param pageNo The pageNo need to list, must >0 + * @param pageSize The pageSize ,must in range [LIST_MIN_PAGESIZE,LIST_MAX_PAGESIZE] + * @pagam status The media status, can be null + * @param begin The media create date after begin + * @param end The media create date before end + * @param title The media title, use prefix search * @return The properties of all specific media resources */ - @Deprecated - public ListMediaResourceResponse listMediaResources() { - ListMediaResourceRequest request = new ListMediaResourceRequest(); + public ListMediaResourceResponse listMediaResources( + int pageNo, + int pageSize, + String status, + Date begin, + Date end, + String title) { + ListMediaResourceRequest request = + new ListMediaResourceRequest() + .withPageNo(pageNo) + .withPageSize(pageSize) + .withStatus(status) + .withBegin(begin) + .withEnd(end) + .withTitle(title); + + return listMediaResources(request); + } + + /** + * List the properties of all media resource managed by VOD service. + * + *

+ * The caller must authenticate with a valid BCE Access Key / Private Key pair. + * + * @param request The request wrapper object containing all options. + * @return The properties of all specific media resources + */ + public ListMediaResourceResponse listMediaResources(ListMediaResourceRequest request) { + checkIsTrue(request.getPageNo() > 0, "pageNo should greater than 0!"); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PATH_MEDIA); + internalRequest.addParameter(PARA_PAGENO, String.valueOf(request.getPageNo())); + internalRequest.addParameter(PARA_PAGESIZE, String.valueOf(request.getPageSize())); + if (request.getStatus() != null) { + internalRequest.addParameter(PARA_STATUS, request.getStatus()); + } + if (request.getBegin() != null) { + internalRequest.addParameter(PARA_BEGIN, DateUtils.formatAlternateIso8601Date(request.getBegin())); + } + if (request.getEnd() != null) { + internalRequest.addParameter(PARA_END, DateUtils.formatAlternateIso8601Date(request.getEnd())); + } + if (request.getTitle() != null) { + internalRequest.addParameter(PARA_TITLE, request.getTitle()); + } return invokeHttpClient(internalRequest, ListMediaResourceResponse.class); } /** - * List the properties of all media resource managed by VOD service. + * Use marker mode to List the properties of all media resource managed by VOD service. + * If media size beyond 1000, strongly recommend to use marker mode * *

* The caller must authenticate with a valid BCE Access Key / Private Key pair. * - * @param pageNo The pageNo need to list, must >0 - * @param pageSize The pageSize ,must in range [LIST_MIN_PAGESIZE,LIST_MAX_PAGESIZE] + * @param marker The marker labels the query begining; first query use NULL. + * @param maxSize The maxSize returned ,must in range [LIST_MIN_PAGESIZE,LIST_MAX_PAGESIZE] * @pagam status The media status, can be null * @param begin The media create date after begin * @param end The media create date before end * @param title The media title, use prefix search * @return The properties of all specific media resources */ - public ListMediaResourceResponse listMediaResources(int pageNo, int pageSize, String status, - Date begin, Date end, String title) { - ListMediaResourceRequest request = - new ListMediaResourceRequest().withPageNo(pageNo).withPageSize(pageSize) - .withStatus(status).withBegin(begin).withEnd(end).withTitle(title); + public ListMediaResourceByMarkerResponse listMediaResourcesByMarker( + String marker, + int maxSize, + String status, + Date begin, + Date end, + String title) { + ListMediaResourceByMarkerRequest request = + new ListMediaResourceByMarkerRequest().withMarker(marker).withMaxSize(maxSize) + .withStatus(status).withBegin(begin).withEnd(end).withTitle(title); - return listMediaResources(request); + return listMediaResourcesByMarker(request); } /** @@ -370,15 +449,13 @@ public ListMediaResourceResponse listMediaResources(int pageNo, int pageSize, St * @param request The request wrapper object containing all options. * @return The properties of all specific media resources */ - public ListMediaResourceResponse listMediaResources(ListMediaResourceRequest request) { - checkIsTrue(request.getPageNo() > 0, "pageNo should greater than 0!"); - checkIsTrue(request.getPageSize() >= LIST_MIN_PAGESIZE - && request.getPageSize() <= LIST_MAX_PAGESIZE, "pageSize is not Valid!"); - + public ListMediaResourceByMarkerResponse listMediaResourcesByMarker(ListMediaResourceByMarkerRequest request) { InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PATH_MEDIA); - internalRequest.addParameter(PARA_PAGENO, String.valueOf(request.getPageNo())); - internalRequest.addParameter(PARA_PAGESIZE, String.valueOf(request.getPageSize())); + internalRequest.addParameter(PARAM_MAX_SIZE, String.valueOf(request.getMaxSize())); + if (request.getMarker() != null) { + internalRequest.addParameter(PARAM_MARKER, String.valueOf(request.getMarker())); + } if (request.getStatus() != null) { internalRequest.addParameter(PARA_STATUS, request.getStatus()); } @@ -392,9 +469,10 @@ public ListMediaResourceResponse listMediaResources(ListMediaResourceRequest req internalRequest.addParameter(PARA_TITLE, request.getTitle()); } - return invokeHttpClient(internalRequest, ListMediaResourceResponse.class); + return invokeHttpClient(internalRequest, ListMediaResourceByMarkerResponse.class); } + /** * Update the title and description for the specific media resource managed by VOD service. * @@ -520,71 +598,6 @@ public DeleteMediaResourceResponse deleteMediaResource(DeleteMediaResourceReques return invokeHttpClient(internalRequest, DeleteMediaResourceResponse.class); } - /** - * Get the playable URL address of specific media resource managed by VOD service. - * - * @param mediaId The unique ID for each media resource - * @return the playable URL address - */ - @Deprecated - public GetPlayableUrlResponse getPlayableUrl(String mediaId) { - GetPlayableUrlRequest request = new GetPlayableUrlRequest().withMediaId(mediaId); - return getPlayableUrl(request); - } - - /** - * Get the playable URL address of specific media resource managed by VOD service. - * - * @param request The request object containing all the options on how to - * @return the playable URL address - */ - @Deprecated - public GetPlayableUrlResponse getPlayableUrl(GetPlayableUrlRequest request) { - checkStringNotEmpty(request.getMediaId(), "Media ID should not be null or empty!"); - InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PATH_SERVICE_FILE); - internalRequest.addParameter(PARA_MEDIA_ID, request.getMediaId()); - - return invokeHttpClient(internalRequest, GetPlayableUrlResponse.class); - } - - /** - * Get the Flash and HTML5 code snippet (encoded in Base64) to play the specific media resource. - * - * @param mediaId The unique ID for each media resource - * @param width The width of player view - * @param height The height of player view - * @param autoStart Indicate whether or not play the media resource automatically when web page is loaded. - * @return The Flash and HTML5 code snippet - */ - @Deprecated - public GetPlayerCodeResponse getPlayerCode(String mediaId, int width, int height, boolean autoStart) { - GetPlayerCodeRequest request = new GetPlayerCodeRequest() - .withMediaId(mediaId).withWidth(width).withHeight(height).withAutoStart(autoStart); - return getPlayerCode(request); - } - - /** - * Get the Flash and HTML5 codes snippet (encoded in Base64) to play the specific media resource. - * - * @param request The request object containing all the options on how to - * @return The Flash and HTML5 code snippet - */ - @Deprecated - public GetPlayerCodeResponse getPlayerCode(GetPlayerCodeRequest request) { - - checkStringNotEmpty(request.getMediaId(), "Media ID should not be null or empty!"); - checkIsTrue(request.getHeight() > 0, "Height of playback view should be positive!"); - checkIsTrue(request.getWidth() > 0, "Width of playback view should be positive!"); - - InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PATH_SERVICE_CODE); - internalRequest.addParameter(PARA_MEDIA_ID, request.getMediaId()); - internalRequest.addParameter(PARA_WIDTH, Integer.toString(request.getWidth())); - internalRequest.addParameter(PARA_HEIGHT, Integer.toString(request.getHeight())); - internalRequest.addParameter(PARA_AUTO_START, Boolean.toString(request.isAutoStart())); - - return invokeHttpClient(internalRequest, GetPlayerCodeResponse.class); - } - /** * Generate media delivery info by media ID. *

@@ -593,8 +606,10 @@ public GetPlayerCodeResponse getPlayerCode(GetPlayerCodeRequest request) { * @param mediaId The unique ID for each media resource * @return media delivery info */ - public GenerateMediaDeliveryInfoResponse generateMediaDeliveryInfo(String mediaId) { - GenerateMediaDeliveryInfoRequest request = new GenerateMediaDeliveryInfoRequest().withMediaId(mediaId); + public GenerateMediaDeliveryInfoResponse generateMediaDeliveryInfo(String mediaId, String transcodingPresetName) { + GenerateMediaDeliveryInfoRequest request = new GenerateMediaDeliveryInfoRequest() + .withMediaId(mediaId) + .withTranscodingPresetName(transcodingPresetName); return generateMediaDeliveryInfo(request); } @@ -610,6 +625,7 @@ public GenerateMediaDeliveryInfoResponse generateMediaDeliveryInfo(GenerateMedia checkStringNotEmpty(request.getMediaId(), "Media ID should not be null or empty!"); InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PATH_MEDIA, request.getMediaId(), PARA_GENDELIVERY); + internalRequest.addParameter(PARAM_TRANSCODING_PRESET_NAME, request.getTranscodingPresetName()); return invokeHttpClient(internalRequest, GenerateMediaDeliveryInfoResponse.class); } @@ -623,9 +639,12 @@ public GenerateMediaDeliveryInfoResponse generateMediaDeliveryInfo(GenerateMedia * @return The Flash and HTML5 code snippet */ public GenerateMediaPlayerCodeResponse generateMediaPlayerCode(String mediaId, int width, - int height, boolean autoStart) { + int height, boolean autoStart, + String transcodingPresetName) { GenerateMediaPlayerCodeRequest request = new GenerateMediaPlayerCodeRequest() - .withMediaId(mediaId).withWidth(width).withHeight(height).withAutoStart(autoStart); + .withMediaId(mediaId).withWidth(width) + .withHeight(height).withAutoStart(autoStart) + .withTranscodingPresetName(transcodingPresetName); return generateMediaPlayerCode(request); } @@ -647,6 +666,7 @@ public GenerateMediaPlayerCodeResponse generateMediaPlayerCode(GenerateMediaPlay internalRequest.addParameter(PARA_HEIGHT, Integer.toString(request.getHeight())); internalRequest.addParameter(PARA_AUTO_START_NEW, Boolean.toString(request.isAutoStart())); internalRequest.addParameter(PARA_AK, config.getCredentials().getAccessKeyId()); + internalRequest.addParameter(PARAM_TRANSCODING_PRESET_NAME, request.getTranscodingPresetName()); return invokeHttpClient(internalRequest, GenerateMediaPlayerCodeResponse.class); } @@ -662,12 +682,15 @@ public GenerateMediaPlayerCodeResponse generateMediaPlayerCode(GenerateMediaPlay * @pagam aggregate, if need aggregate, default: true * @return The media statistic info */ - public GetMediaStatisticResponse getMediaStatistic(String mediaId, - Date startTime, Date endTime, boolean aggregate) { + public GetMediaStatisticResponse getMediaStatistic( + String mediaId, + Date startTime, + Date endTime, + boolean aggregate) { GetMediaStatisticRequest request = new GetMediaStatisticRequest().withMediaId(mediaId) - .withStartTime(startTime).withEndTime(endTime) - .withAggregate(aggregate); + .withStartTime(startTime).withEndTime(endTime) + .withAggregate(aggregate); return getMediaStatistic(request); } @@ -735,8 +758,8 @@ public ReTranscodeResponse reTranscode(ReTranscodeRequest request) { */ public GetMediaSourceDownloadResponse getMediaSourceDownload(String mediaId, long expiredInSeconds) { GetMediaSourceDownloadRequest request = new GetMediaSourceDownloadRequest() - .withMediaId(mediaId) - .withExpiredInSeconds(expiredInSeconds); + .withMediaId(mediaId) + .withExpiredInSeconds(expiredInSeconds); return getMediaSourceDownload(request); } @@ -758,13 +781,116 @@ public GetMediaSourceDownloadResponse getMediaSourceDownload(GetMediaSourceDownl return invokeHttpClient(internalRequest, GetMediaSourceDownloadResponse.class); } + /** + * List all your doc notifications. + * + * @return The list of all your doc notifications + */ + public ListNotificationsResponse listNotifications() { + ListNotificationsRequest request = new ListNotificationsRequest(); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PATH_NOTIFICATION); + return invokeHttpClient(internalRequest, ListNotificationsResponse.class); + } + + /** + * Delete your doc notification by doc notification name. + * + * @param name doc notification name. + * + */ + public DeleteNotificationResponse deleteNotification(String name) { + DeleteNotificationRequest request = new DeleteNotificationRequest(); + request.setName(name); + return deleteNotification(request); + } + + /** + * Delete your doc notification by doc notification name. + * + * @param request The request object containing all parameters for deleting dco notification. + * + */ + public DeleteNotificationResponse deleteNotification(DeleteNotificationRequest request) { + checkStringNotEmpty(request.getName(), "The parameter name should NOT be null or empty string."); + InternalRequest internalRequest = createRequest(HttpMethodName.DELETE, request, PATH_NOTIFICATION, request + .getName()); + return invokeHttpClient(internalRequest, DeleteNotificationResponse.class); + } + + /** + * Get your doc notification by doc notification name. + * + * @param name doc notification name. + * + * @return Your doc notification. + */ + public GetNotificationResponse getNotification(String name) { + GetNotificationRequest request = new GetNotificationRequest(); + request.setName(name); + return getNotification(request); + } + + /** + * Get your doc notification by doc notification name. + * + * @param request The request object containing all parameters for getting doc notification. + * + * @return Your doc notification. + */ + public GetNotificationResponse getNotification(GetNotificationRequest request) { + checkStringNotEmpty(request.getName(), "The parameter name should NOT be null or empty string."); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, PATH_NOTIFICATION, + request.getName()); + return invokeHttpClient(internalRequest, GetNotificationResponse.class); + } + + /** + * Create a doc notification in the doc stream service. + * + * @param name The name of notification. + * @param endpoint The address to receive notification message. + * + */ + public CreateNotificationResponse createNotification(String name, String endpoint) { + CreateNotificationRequest request = new CreateNotificationRequest(); + request.withName(name).withEndpoint(endpoint); + return createNotification(request); + } + + /** + * Create a doc notification in the doc stream service. + * + * @param request The request object containing all options for creating doc notification. + */ + public CreateNotificationResponse createNotification(CreateNotificationRequest request) { + + checkStringNotEmpty(request.getName(), + "The parameter name should NOT be null or empty string."); + checkStringNotEmpty(request.getEndpoint(), + "The parameter endpoint should NOT be null or empty string."); + + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, PATH_NOTIFICATION); + String strJson = JsonUtils.toJsonString(request); + byte[] requestJson = null; + try { + requestJson = strJson.getBytes(DEFAULT_ENCODING); + } catch (UnsupportedEncodingException e) { + throw new BceClientException("Unsupported encode.", e); + } + + internalRequest.addHeader(Headers.CONTENT_LENGTH, String.valueOf(requestJson.length)); + internalRequest.addHeader(Headers.CONTENT_TYPE, DEFAULT_CONTENT_TYPE); + internalRequest.setContent(RestartableInputStream.wrap(requestJson)); + return invokeHttpClient(internalRequest, CreateNotificationResponse.class); + } + /** * Creates and initializes a new request object for the specified resource. This method is responsible for * determining HTTP method, URI path, credentials and request body for POST method. *

* Note: The Query parameters in URL should be specified by caller method. *

- * + * * @param httpMethod The HTTP method to use when sending the request. * @param request The original request, as created by the user. * @param pathVariables The optional variables in URI path. @@ -815,6 +941,21 @@ private InternalRequest fillRequestPayload(InternalRequest internalRequest, Abst return internalRequest; } + + private String getFileExtension(String filename) { + if (filename != null && filename.lastIndexOf(".") != -1) { + String extension = filename.substring(filename.lastIndexOf(".") + 1); + if (extension.length() <= 0 || extension.length() > MAX_SOURCE_EXTENSION_LENGTH) { + return null; + } + if (!extension.matches(VALID_EXTENSION_PATTERN)) { + return null; + } + return extension; + } + return null; + } + /* * VOD is global service, doesn't support region. */ diff --git a/src/main/java/com/baidubce/services/vod/model/Attributes.java b/src/main/java/com/baidubce/services/vod/model/Attributes.java old mode 100755 new mode 100644 index 98683f31..7ac63dd7 --- a/src/main/java/com/baidubce/services/vod/model/Attributes.java +++ b/src/main/java/com/baidubce/services/vod/model/Attributes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -17,7 +17,9 @@ public class Attributes { private String title; private String description; - + + private String sourceExtension; + public String getTitle() { return title; } @@ -33,12 +35,21 @@ public String getDescription() { public void setDescription(String description) { this.description = description; } - + + public String getSourceExtension() { + return sourceExtension; + } + + public void setSourceExtension(String sourceExtension) { + this.sourceExtension = sourceExtension; + } + @Override public String toString() { StringBuilder sb = new StringBuilder("Attributes { \n"); sb.append(" title = ").append(title).append("\n"); sb.append(" description = ").append(description).append("\n"); + sb.append(" sourceExtension = ").append(sourceExtension).append("\n"); sb.append(" }"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/vod/model/CreateMediaResourceRequest.java b/src/main/java/com/baidubce/services/vod/model/CreateMediaResourceRequest.java old mode 100755 new mode 100644 index bd0f06a3..b579a36d --- a/src/main/java/com/baidubce/services/vod/model/CreateMediaResourceRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/CreateMediaResourceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/CreateMediaResourceResponse.java b/src/main/java/com/baidubce/services/vod/model/CreateMediaResourceResponse.java old mode 100755 new mode 100644 index 18052963..f69cb844 --- a/src/main/java/com/baidubce/services/vod/model/CreateMediaResourceResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/CreateMediaResourceResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/CreateNotificationRequest.java b/src/main/java/com/baidubce/services/vod/model/CreateNotificationRequest.java new file mode 100644 index 00000000..bb210731 --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/CreateNotificationRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.vod.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class CreateNotificationRequest extends AbstractBceRequest { + + /** + * 通知名称 + **/ + private String name = null; + + /** + * 通知消息接收地址 + **/ + private String endpoint = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public CreateNotificationRequest withName(String name) { + this.name = name; + return this; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public CreateNotificationRequest withEndpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + + public CreateNotificationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationRequest {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" endpoint: ").append(endpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/vod/model/CreateNotificationResponse.java b/src/main/java/com/baidubce/services/vod/model/CreateNotificationResponse.java new file mode 100644 index 00000000..c0125a8b --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/CreateNotificationResponse.java @@ -0,0 +1,26 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.vod.model; + +import com.baidubce.model.AbstractBceResponse; + +public class CreateNotificationResponse extends AbstractBceResponse { + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationResponse {\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/vod/model/DeleteMediaResourceRequest.java b/src/main/java/com/baidubce/services/vod/model/DeleteMediaResourceRequest.java old mode 100755 new mode 100644 index 8fcfd8a3..f4fde34f --- a/src/main/java/com/baidubce/services/vod/model/DeleteMediaResourceRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/DeleteMediaResourceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/DeleteMediaResourceResponse.java b/src/main/java/com/baidubce/services/vod/model/DeleteMediaResourceResponse.java old mode 100755 new mode 100644 index ef2e4c5b..1b1ee13a --- a/src/main/java/com/baidubce/services/vod/model/DeleteMediaResourceResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/DeleteMediaResourceResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/DeleteNotificationRequest.java b/src/main/java/com/baidubce/services/vod/model/DeleteNotificationRequest.java new file mode 100644 index 00000000..db40cdf5 --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/DeleteNotificationRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.vod.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class DeleteNotificationRequest extends AbstractBceRequest { + /** + * 通知名称 + **/ + private String name = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DeleteNotificationRequest withName(String name) { + this.name = name; + return this; + } + + public DeleteNotificationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class DeleteNotificationRequest {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/vod/model/DeleteNotificationResponse.java b/src/main/java/com/baidubce/services/vod/model/DeleteNotificationResponse.java new file mode 100644 index 00000000..79aa37f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/DeleteNotificationResponse.java @@ -0,0 +1,26 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.vod.model; + +import com.baidubce.model.AbstractBceResponse; + +public class DeleteNotificationResponse extends AbstractBceResponse { + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class DeleteNotificationResponse {\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/vod/model/GenerateMediaDeliveryInfoRequest.java b/src/main/java/com/baidubce/services/vod/model/GenerateMediaDeliveryInfoRequest.java old mode 100755 new mode 100644 index 0c969a37..17b8a255 --- a/src/main/java/com/baidubce/services/vod/model/GenerateMediaDeliveryInfoRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/GenerateMediaDeliveryInfoRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -22,6 +22,8 @@ public class GenerateMediaDeliveryInfoRequest extends AbstractBceRequest { */ private String mediaId; + private String transcodingPresetName; + public String getMediaId() { return mediaId; } @@ -30,11 +32,24 @@ public void setMediaId(String mediaId) { this.mediaId = mediaId; } + public String getTranscodingPresetName() { + return transcodingPresetName; + } + + public void setTranscodingPresetName(String transcodingPresetName) { + this.transcodingPresetName = transcodingPresetName; + } + public GenerateMediaDeliveryInfoRequest withMediaId(String mediaId) { this.mediaId = mediaId; return this; } + public GenerateMediaDeliveryInfoRequest withTranscodingPresetName(String transcodingPresetName) { + this.transcodingPresetName = transcodingPresetName; + return this; + } + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); @@ -45,6 +60,7 @@ public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { public String toString() { StringBuilder sb = new StringBuilder("GenerateMediaDeliveryInfoRequest { \n"); sb.append(" mediaId = ").append(mediaId).append("\n"); + sb.append(" transcodingPresetName = ").append(transcodingPresetName).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/vod/model/GenerateMediaDeliveryInfoResponse.java b/src/main/java/com/baidubce/services/vod/model/GenerateMediaDeliveryInfoResponse.java old mode 100755 new mode 100644 index f98e7f74..04ba5ac5 --- a/src/main/java/com/baidubce/services/vod/model/GenerateMediaDeliveryInfoResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/GenerateMediaDeliveryInfoResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GenerateMediaIdRequest.java b/src/main/java/com/baidubce/services/vod/model/GenerateMediaIdRequest.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/vod/model/GenerateMediaIdResponse.java b/src/main/java/com/baidubce/services/vod/model/GenerateMediaIdResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/vod/model/GenerateMediaPlayerCodeRequest.java b/src/main/java/com/baidubce/services/vod/model/GenerateMediaPlayerCodeRequest.java old mode 100755 new mode 100644 index fb1da7fe..5ef055da --- a/src/main/java/com/baidubce/services/vod/model/GenerateMediaPlayerCodeRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/GenerateMediaPlayerCodeRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -42,7 +42,24 @@ public class GenerateMediaPlayerCodeRequest extends AbstractBceRequest { */ private String ak; + private String transcodingPresetName; + public Boolean getAutoStart() { + return autoStart; + } + + public String getTranscodingPresetName() { + return transcodingPresetName; + } + + public void setTranscodingPresetName(String transcodingPresetName) { + this.transcodingPresetName = transcodingPresetName; + } + + public GenerateMediaPlayerCodeRequest withTranscodingPresetName(String transcodingPresetName) { + this.transcodingPresetName = transcodingPresetName; + return this; + } @Override public String toString() { @@ -52,6 +69,7 @@ public String toString() { sb.append(" height = ").append(height).append("\n"); sb.append(" autoStart = ").append(autoStart).append("\n"); sb.append(" ak = ").append(ak).append("\n"); + sb.append(" transcodingPresetName = ").append(transcodingPresetName).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/vod/model/GenerateMediaPlayerCodeResponse.java b/src/main/java/com/baidubce/services/vod/model/GenerateMediaPlayerCodeResponse.java old mode 100755 new mode 100644 index b7ff77c5..3218c16c --- a/src/main/java/com/baidubce/services/vod/model/GenerateMediaPlayerCodeResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/GenerateMediaPlayerCodeResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GetMediaResourceRequest.java b/src/main/java/com/baidubce/services/vod/model/GetMediaResourceRequest.java old mode 100755 new mode 100644 index 26656666..4624e235 --- a/src/main/java/com/baidubce/services/vod/model/GetMediaResourceRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/GetMediaResourceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GetMediaResourceResponse.java b/src/main/java/com/baidubce/services/vod/model/GetMediaResourceResponse.java old mode 100755 new mode 100644 index 913ecae5..fdba27f1 --- a/src/main/java/com/baidubce/services/vod/model/GetMediaResourceResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/GetMediaResourceResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at @@ -14,6 +14,9 @@ import com.baidubce.model.AbstractBceResponse; +import java.util.ArrayList; +import java.util.List; + /* * Gets the properties of specific media resource managed by VOD service. */ @@ -51,6 +54,14 @@ public class GetMediaResourceResponse extends AbstractBceResponse { */ private String createTime; + private String transcodingPresetGroupName; + + private String source; + + private List playableUrlList = new ArrayList(); + + private List thumbnailList = new ArrayList(); + public String getMediaId() { return mediaId; } @@ -107,6 +118,38 @@ public void setError(VodError error) { this.error = error; } + public String getTranscodingPresetGroupName() { + return transcodingPresetGroupName; + } + + public void setTranscodingPresetGroupName(String transcodingPresetGroupName) { + this.transcodingPresetGroupName = transcodingPresetGroupName; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public List getPlayableUrlList() { + return playableUrlList; + } + + public void setPlayableUrlList(List playableUrlList) { + this.playableUrlList = playableUrlList; + } + + public List getThumbnailList() { + return thumbnailList; + } + + public void setThumbnailList(List thumbnailList) { + this.thumbnailList = thumbnailList; + } + @Override public String toString() { StringBuilder sb = new StringBuilder("GetMediaResourceResponse { \n"); @@ -116,6 +159,17 @@ public String toString() { sb.append(" meta = ").append(meta).append("\n"); sb.append(" createTime = ").append(createTime).append("\n"); sb.append(" publishTime = ").append(publishTime).append("\n"); + sb.append(" transcodingPresetGroupName = ").append(transcodingPresetGroupName).append("\n"); + sb.append(" source = ").append(source).append("\n"); + sb.append(" playableUrlList = [").append("\n"); + for (PlayableUrl url : playableUrlList) { + sb.append(url.toString()).append("\n"); + } + sb.append("] \n"); + sb.append(" thumbnailList = [").append("\n"); + for (String thumbnail : thumbnailList) { + sb.append(" thumbnail =").append(thumbnail).append("\n"); + } if (this.error != null) { sb.append(this.error).append("\n"); } diff --git a/src/main/java/com/baidubce/services/vod/model/GetMediaSourceDownloadRequest.java b/src/main/java/com/baidubce/services/vod/model/GetMediaSourceDownloadRequest.java old mode 100755 new mode 100644 index a1de0f6b..936d938a --- a/src/main/java/com/baidubce/services/vod/model/GetMediaSourceDownloadRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/GetMediaSourceDownloadRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GetMediaSourceDownloadResponse.java b/src/main/java/com/baidubce/services/vod/model/GetMediaSourceDownloadResponse.java old mode 100755 new mode 100644 index d8901197..16ce52a1 --- a/src/main/java/com/baidubce/services/vod/model/GetMediaSourceDownloadResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/GetMediaSourceDownloadResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GetMediaStatisticRequest.java b/src/main/java/com/baidubce/services/vod/model/GetMediaStatisticRequest.java old mode 100755 new mode 100644 index a0e873a3..89c89984 --- a/src/main/java/com/baidubce/services/vod/model/GetMediaStatisticRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/GetMediaStatisticRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GetMediaStatisticResponse.java b/src/main/java/com/baidubce/services/vod/model/GetMediaStatisticResponse.java old mode 100755 new mode 100644 index f016bfa4..4f148eb1 --- a/src/main/java/com/baidubce/services/vod/model/GetMediaStatisticResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/GetMediaStatisticResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GetNotificationRequest.java b/src/main/java/com/baidubce/services/vod/model/GetNotificationRequest.java new file mode 100644 index 00000000..1b873ed9 --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/GetNotificationRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.vod.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class GetNotificationRequest extends AbstractBceRequest { + /** + * 通知名称 + **/ + private String name = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public GetNotificationRequest withName(String name) { + this.name = name; + return this; + } + + public GetNotificationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetNotificationRequest {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/vod/model/GetNotificationResponse.java b/src/main/java/com/baidubce/services/vod/model/GetNotificationResponse.java new file mode 100644 index 00000000..730d63ca --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/GetNotificationResponse.java @@ -0,0 +1,54 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.vod.model; + +import com.baidubce.model.AbstractBceResponse; + +public class GetNotificationResponse extends AbstractBceResponse { + /** + * 通知名称 + **/ + private String name = null; + + /** + * 通知消息接收地址 + **/ + private String endpoint = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetNotificationResponse {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" endpoint: ").append(endpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/vod/model/GetPlayableUrlRequest.java b/src/main/java/com/baidubce/services/vod/model/GetPlayableUrlRequest.java old mode 100755 new mode 100644 index f3269f46..3840d1a1 --- a/src/main/java/com/baidubce/services/vod/model/GetPlayableUrlRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/GetPlayableUrlRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GetPlayableUrlResponse.java b/src/main/java/com/baidubce/services/vod/model/GetPlayableUrlResponse.java old mode 100755 new mode 100644 index 9bd6f5fb..c3b69f42 --- a/src/main/java/com/baidubce/services/vod/model/GetPlayableUrlResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/GetPlayableUrlResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GetPlayerCodeRequest.java b/src/main/java/com/baidubce/services/vod/model/GetPlayerCodeRequest.java old mode 100755 new mode 100644 index b2b657ff..77801b74 --- a/src/main/java/com/baidubce/services/vod/model/GetPlayerCodeRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/GetPlayerCodeRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/GetPlayerCodeResponse.java b/src/main/java/com/baidubce/services/vod/model/GetPlayerCodeResponse.java old mode 100755 new mode 100644 index b1c0607d..a3c10529 --- a/src/main/java/com/baidubce/services/vod/model/GetPlayerCodeResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/GetPlayerCodeResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaRequest.java b/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaRequest.java old mode 100755 new mode 100644 index a10bad07..1cd4584d --- a/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaRequest.java @@ -1,3 +1,16 @@ +/* + * Copyright 2015 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + package com.baidubce.services.vod.model; import com.baidubce.auth.BceCredentials; @@ -27,6 +40,8 @@ public class InternalCreateMediaRequest extends AbstractBceRequest { */ private String sourceExtension; + private String transcodingPresetGroupName; + @Override public String toString() { StringBuilder sb = new StringBuilder("InternalCreateMediaRequest { \n"); @@ -59,11 +74,25 @@ public void setTitle(String title) { this.title = title; } + public InternalCreateMediaRequest withTitle(String title) { this.title = title; return this; } + public String getTranscodingPresetGroupName() { + return transcodingPresetGroupName; + } + + public void setTranscodingPresetGroupName(String transcodingPresetGroupName) { + this.transcodingPresetGroupName = transcodingPresetGroupName; + } + + public InternalCreateMediaRequest withTranscodingPresetGroupName(String transcodingPresetGroupName) { + this.transcodingPresetGroupName = transcodingPresetGroupName; + return this; + } + public String getDescription() { return description; } diff --git a/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaResponse.java b/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaResponse.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/vod/model/ListMediaResourceByMarkerRequest.java b/src/main/java/com/baidubce/services/vod/model/ListMediaResourceByMarkerRequest.java new file mode 100644 index 00000000..c5f274b9 --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/ListMediaResourceByMarkerRequest.java @@ -0,0 +1,165 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.vod.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.Date; + +/** + * List the properties of all media resource managed by VOD service. + */ +public class ListMediaResourceByMarkerRequest extends AbstractBceRequest { + + /* + * The marker returned by first query + */ + private String marker; + + /* + * The max size returned + */ + private int maxSize; + /* + * The media status + */ + private String status; + /* + * The begin date + */ + private Date begin; + /* + * The end date + */ + private Date end; + /* + * The title string for preifix search + */ + private String title; + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public int getMaxSize() { + return maxSize; + } + + public void setMaxSize(int maxSize) { + this.maxSize = maxSize; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public Date getBegin() { + return begin; + } + + public void setBegin(Date begin) { + this.begin = begin; + } + + public Date getEnd() { + return end; + } + + public void setEnd(Date end) { + this.end = end; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + /** + * set marker + * + * @param marker The marker. + */ + public ListMediaResourceByMarkerRequest withMarker(String marker) { + this.marker = marker; + return this; + } + + /** + * set maxSize + * + * @param maxSize The maxSize. + */ + public ListMediaResourceByMarkerRequest withMaxSize(int maxSize) { + this.maxSize = maxSize; + return this; + } + + /** + * set status + * + * @param status The status. + */ + public ListMediaResourceByMarkerRequest withStatus(String status) { + this.status = status; + return this; + } + + /** + * set begin + * + * @param begin The begin date. + */ + public ListMediaResourceByMarkerRequest withBegin(Date begin) { + this.begin = begin; + return this; + } + + /** + * set end + * + * @param end The end date. + */ + public ListMediaResourceByMarkerRequest withEnd(Date end) { + this.end = end; + return this; + } + + /** + * set title + * + * @param title The title. + */ + public ListMediaResourceByMarkerRequest withTitle(String title) { + this.title = title; + return this; + } + + @Override + public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/vod/model/ListMediaResourceByMarkerResponse.java b/src/main/java/com/baidubce/services/vod/model/ListMediaResourceByMarkerResponse.java new file mode 100644 index 00000000..457aaa40 --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/ListMediaResourceByMarkerResponse.java @@ -0,0 +1,89 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ +package com.baidubce.services.vod.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.ArrayList; +import java.util.List; + +/** + * List the properties of all media resource managed by VOD service. + */ +public class ListMediaResourceByMarkerResponse extends AbstractBceResponse { + + /* + * The list of all media resources managed by VOD service + */ + private List media = new ArrayList(); + + /* + * The request marker + */ + private String marker; + + /* + * The rest of media's marker, if isTruncated false, nextMarker=null + */ + private String nextMarker; + + /* + * whether there has more media, if true, means has more, use nextMarker to retrieve + */ + private boolean isTruncated; + + + public List getMedia() { + return media; + } + + public void setMedia(List media) { + this.media = media; + } + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + + public String getNextMarker() { + return nextMarker; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } + + public boolean getIsTruncated() { + return isTruncated; + } + + public void setIsTruncated(boolean truncated) { + isTruncated = truncated; + } + + public String toString() { + StringBuilder sb = new StringBuilder("ListMediaResourceResponse { \n"); + + for (MediaResource mediaResource : getMedia()) { + sb.append(mediaResource).append("\n"); + } + sb.append("}\n"); + return sb.toString(); + + } + +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/vod/model/ListMediaResourceRequest.java b/src/main/java/com/baidubce/services/vod/model/ListMediaResourceRequest.java old mode 100755 new mode 100644 index cfa64ff6..87ca2841 --- a/src/main/java/com/baidubce/services/vod/model/ListMediaResourceRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/ListMediaResourceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/ListMediaResourceResponse.java b/src/main/java/com/baidubce/services/vod/model/ListMediaResourceResponse.java old mode 100755 new mode 100644 index efe3fda6..bfd6e8bb --- a/src/main/java/com/baidubce/services/vod/model/ListMediaResourceResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/ListMediaResourceResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/ListNotificationsRequest.java b/src/main/java/com/baidubce/services/vod/model/ListNotificationsRequest.java new file mode 100644 index 00000000..76331ea9 --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/ListNotificationsRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.vod.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +public class ListNotificationsRequest extends AbstractBceRequest { + + public ListNotificationsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ListNotificationsRequest {\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/vod/model/ListNotificationsResponse.java b/src/main/java/com/baidubce/services/vod/model/ListNotificationsResponse.java new file mode 100644 index 00000000..5b343c4c --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/ListNotificationsResponse.java @@ -0,0 +1,40 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.vod.model; + +import com.baidubce.model.AbstractBceResponse; +import com.baidubce.services.doc.model.Notification; + +import java.util.List; + +public class ListNotificationsResponse extends AbstractBceResponse { + private List notifications = null; + + public List getNotifications() { + return notifications; + } + + public void setNotifications(List notifications) { + this.notifications = notifications; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ListNotificationsResponse {\n"); + sb.append(" notifications: ").append(notifications).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/vod/model/MediaMeta.java b/src/main/java/com/baidubce/services/vod/model/MediaMeta.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/vod/model/MediaResource.java b/src/main/java/com/baidubce/services/vod/model/MediaResource.java old mode 100755 new mode 100644 index be246424..5f5e9add --- a/src/main/java/com/baidubce/services/vod/model/MediaResource.java +++ b/src/main/java/com/baidubce/services/vod/model/MediaResource.java @@ -1,5 +1,20 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ package com.baidubce.services.vod.model; +import java.util.ArrayList; +import java.util.List; + public class MediaResource { private String mediaId; @@ -9,6 +24,14 @@ public class MediaResource { private String publishTime; private String createTime; + private String transcodingPresetGroupName; + + private String source; + + private List playableUrlList = new ArrayList(); + + private List thumbnailList = new ArrayList(); + public String getMediaId() { return mediaId; } @@ -57,6 +80,38 @@ public void setAttributes(Attributes attributes) { this.attributes = attributes; } + public String getTranscodingPresetGroupName() { + return transcodingPresetGroupName; + } + + public void setTranscodingPresetGroupName(String transcodingPresetGroupName) { + this.transcodingPresetGroupName = transcodingPresetGroupName; + } + + public String getSource() { + return source; + } + + public void setSource(String source) { + this.source = source; + } + + public List getPlayableUrlList() { + return playableUrlList; + } + + public void setPlayableUrlList(List playableUrlList) { + this.playableUrlList = playableUrlList; + } + + public List getThumbnailList() { + return thumbnailList; + } + + public void setThumbnailList(List thumbnailList) { + this.thumbnailList = thumbnailList; + } + @Override public String toString() { StringBuilder sb = new StringBuilder(" MediaResource { \n"); @@ -66,6 +121,17 @@ public String toString() { sb.append(" meta = ").append(meta).append("\n"); sb.append(" createTime = ").append(createTime).append("\n"); sb.append(" publishTime = ").append(publishTime).append("\n"); + sb.append(" transcodingPresetGroupName = ").append(transcodingPresetGroupName).append("\n"); + sb.append(" source = ").append(source).append("\n"); + sb.append(" playableUrlList = [").append("\n"); + for (PlayableUrl url : playableUrlList) { + sb.append(url.toString()).append("\n"); + } + sb.append("] \n"); + sb.append(" thumbnailList = [").append("\n"); + for (String thumbnail : thumbnailList) { + sb.append(" thumbnail =").append(thumbnail).append("\n"); + } sb.append(" }\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/vod/model/MediaStatisticsElement.java b/src/main/java/com/baidubce/services/vod/model/MediaStatisticsElement.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/vod/model/Notification.java b/src/main/java/com/baidubce/services/vod/model/Notification.java new file mode 100644 index 00000000..618ba81a --- /dev/null +++ b/src/main/java/com/baidubce/services/vod/model/Notification.java @@ -0,0 +1,62 @@ +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.baidubce.services.vod.model; + +public class Notification { + /** + * 通知名称 + **/ + private String name = null; + + /** + * 通知消息接收地址 + **/ + private String endpoint = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Notification withName(String name) { + this.name = name; + return this; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public Notification withEndpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Notification {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" endpoint: ").append(endpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/vod/model/PlayableUrl.java b/src/main/java/com/baidubce/services/vod/model/PlayableUrl.java old mode 100755 new mode 100644 index ad6aca04..11f23590 --- a/src/main/java/com/baidubce/services/vod/model/PlayableUrl.java +++ b/src/main/java/com/baidubce/services/vod/model/PlayableUrl.java @@ -1,52 +1,45 @@ -package com.baidubce.services.vod.model; +/* + * Copyright 2016 Baidu, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ -import com.fasterxml.jackson.annotation.JsonProperty; +package com.baidubce.services.vod.model; public class PlayableUrl { - /* - * The unique ID of media resource managed by VOD service. - */ - @JsonProperty(value = "media_id") - private String mediaId; - - /* - * Media resource's playable URL address. - */ - private String file; - - private String cover; + private String transcodingPresetName; - public String getMediaId() { - return mediaId; - } - - public void setMediaId(String mediaId) { - this.mediaId = mediaId; - } + private String url; - public String getFile() { - return file; + public String getTranscodingPresetName() { + return transcodingPresetName; } - public void setFile(String file) { - this.file = file; + public void setTranscodingPresetName(String transcodingPresetName) { + this.transcodingPresetName = transcodingPresetName; } - public String getCover() { - return cover; + public String getUrl() { + return url; } - public void setCover(String cover) { - this.cover = cover; + public void setUrl(String url) { + this.url = url; } @Override public String toString() { final StringBuilder sb = new StringBuilder("PlayableUrl { \n"); - sb.append(" mediaId = ").append(mediaId).append("\n"); - sb.append(" file = ").append(file).append("\n"); - sb.append(" cover = ").append(cover).append("\n"); + sb.append(" transcodingPresetName = ").append(transcodingPresetName).append("\n"); + sb.append(" url = ").append(url).append("\n"); sb.append(" }\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/vod/model/PlaybackCode.java b/src/main/java/com/baidubce/services/vod/model/PlaybackCode.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/services/vod/model/PublishMediaResourceRequest.java b/src/main/java/com/baidubce/services/vod/model/PublishMediaResourceRequest.java old mode 100755 new mode 100644 index 9e19b6ef..f8e93857 --- a/src/main/java/com/baidubce/services/vod/model/PublishMediaResourceRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/PublishMediaResourceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/PublishMediaResourceResponse.java b/src/main/java/com/baidubce/services/vod/model/PublishMediaResourceResponse.java old mode 100755 new mode 100644 index 6edb4371..1f9c08ff --- a/src/main/java/com/baidubce/services/vod/model/PublishMediaResourceResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/PublishMediaResourceResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/ReTranscodeRequest.java b/src/main/java/com/baidubce/services/vod/model/ReTranscodeRequest.java old mode 100755 new mode 100644 index 17d651b4..d3a076be --- a/src/main/java/com/baidubce/services/vod/model/ReTranscodeRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/ReTranscodeRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/ReTranscodeResponse.java b/src/main/java/com/baidubce/services/vod/model/ReTranscodeResponse.java old mode 100755 new mode 100644 index d2aea2e2..aca55aae --- a/src/main/java/com/baidubce/services/vod/model/ReTranscodeResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/ReTranscodeResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/StopMediaResourceRequest.java b/src/main/java/com/baidubce/services/vod/model/StopMediaResourceRequest.java old mode 100755 new mode 100644 index 24748da5..fac5fb39 --- a/src/main/java/com/baidubce/services/vod/model/StopMediaResourceRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/StopMediaResourceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/StopMediaResourceResponse.java b/src/main/java/com/baidubce/services/vod/model/StopMediaResourceResponse.java old mode 100755 new mode 100644 index 9013b145..62fb48ba --- a/src/main/java/com/baidubce/services/vod/model/StopMediaResourceResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/StopMediaResourceResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/UpdateMediaResourceRequest.java b/src/main/java/com/baidubce/services/vod/model/UpdateMediaResourceRequest.java old mode 100755 new mode 100644 index d8adc452..43bcae85 --- a/src/main/java/com/baidubce/services/vod/model/UpdateMediaResourceRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/UpdateMediaResourceRequest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/UpdateMediaResourceResponse.java b/src/main/java/com/baidubce/services/vod/model/UpdateMediaResourceResponse.java old mode 100755 new mode 100644 index daf4bd03..949cc96f --- a/src/main/java/com/baidubce/services/vod/model/UpdateMediaResourceResponse.java +++ b/src/main/java/com/baidubce/services/vod/model/UpdateMediaResourceResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/services/vod/model/VodError.java b/src/main/java/com/baidubce/services/vod/model/VodError.java old mode 100755 new mode 100644 diff --git a/src/main/java/com/baidubce/util/DateUtils.java b/src/main/java/com/baidubce/util/DateUtils.java old mode 100755 new mode 100644 index 00f7df9d..624d85e6 --- a/src/main/java/com/baidubce/util/DateUtils.java +++ b/src/main/java/com/baidubce/util/DateUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/util/HashUtils.java b/src/main/java/com/baidubce/util/HashUtils.java old mode 100755 new mode 100644 index ad212f0b..0e7e32d3 --- a/src/main/java/com/baidubce/util/HashUtils.java +++ b/src/main/java/com/baidubce/util/HashUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/util/HttpUtils.java b/src/main/java/com/baidubce/util/HttpUtils.java old mode 100755 new mode 100644 index 901cb854..008778d1 --- a/src/main/java/com/baidubce/util/HttpUtils.java +++ b/src/main/java/com/baidubce/util/HttpUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/util/JsonUtils.java b/src/main/java/com/baidubce/util/JsonUtils.java old mode 100755 new mode 100644 index 9d32a209..b8372440 --- a/src/main/java/com/baidubce/util/JsonUtils.java +++ b/src/main/java/com/baidubce/util/JsonUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/util/LengthCheckInputStream.java b/src/main/java/com/baidubce/util/LengthCheckInputStream.java old mode 100755 new mode 100644 index b38e853f..5639d706 --- a/src/main/java/com/baidubce/util/LengthCheckInputStream.java +++ b/src/main/java/com/baidubce/util/LengthCheckInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/util/MD5DigestCalculatingInputStream.java b/src/main/java/com/baidubce/util/MD5DigestCalculatingInputStream.java old mode 100755 new mode 100644 index d17864c0..5d4d30c3 --- a/src/main/java/com/baidubce/util/MD5DigestCalculatingInputStream.java +++ b/src/main/java/com/baidubce/util/MD5DigestCalculatingInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/util/Mimetypes.java b/src/main/java/com/baidubce/util/Mimetypes.java old mode 100755 new mode 100644 index 082c269d..10bbce95 --- a/src/main/java/com/baidubce/util/Mimetypes.java +++ b/src/main/java/com/baidubce/util/Mimetypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved + * Copyright 2014 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/java/com/baidubce/util/Validate.java b/src/main/java/com/baidubce/util/Validate.java old mode 100755 new mode 100644 index d1e1f107..f5efe3b8 --- a/src/main/java/com/baidubce/util/Validate.java +++ b/src/main/java/com/baidubce/util/Validate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * Copyright 2015 Baidu, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at diff --git a/src/main/resources/mime.types b/src/main/resources/mime.types old mode 100755 new mode 100644 diff --git a/src/test/java/com/baidubce/BceClientConfigurationTest.java b/src/test/java/com/baidubce/BceClientConfigurationTest.java deleted file mode 100755 index cb17bd45..00000000 --- a/src/test/java/com/baidubce/BceClientConfigurationTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.baidubce; - - -import org.junit.Assert; -import org.junit.Test; - - -import com.baidubce.services.bos.BosClientConfiguration; - -public class BceClientConfigurationTest { - @Test - public void testProtocolInProvidedUrl() { - BceClientConfiguration config = null; - - // http - String endpoint = "http://bcebos.com"; - - config = new BosClientConfiguration(); - config.setEndpoint(endpoint); - config.setProtocol(Protocol.HTTPS); - // protocol does not take effect to endpiont - Assert.assertEquals(config.getEndpoint(), endpoint); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "https"); - - config = new BosClientConfiguration(); - config.setProtocol(Protocol.HTTPS); - config.setEndpoint(endpoint); - // protocol does not take effect to endpiont - Assert.assertEquals(config.getEndpoint(), endpoint); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "https"); - - config = new BosClientConfiguration(); - config.setEndpoint(endpoint); - Assert.assertEquals(config.getEndpoint(), endpoint); - // default protocol is http - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "http"); - - // https - endpoint = "https://bcebos.com"; - - config = new BosClientConfiguration(); - config.setEndpoint(endpoint); - config.setProtocol(Protocol.HTTP); - // protocol does not take effect to endpiont - Assert.assertEquals(config.getEndpoint(), endpoint); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "http"); - - config = new BosClientConfiguration(); - config.setProtocol(Protocol.HTTP); - config.setEndpoint(endpoint); - // protocol does not take effect to endpiont - Assert.assertEquals(config.getEndpoint(), endpoint); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "http"); - - config = new BosClientConfiguration(); - config.setEndpoint(endpoint); - Assert.assertEquals(config.getEndpoint(), endpoint); - // default protocol is http - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "http"); - } - - @Test - public void testProtocolNotInProvidedUrl() { - // https - String endpoint = "bcebos.com"; - BosClientConfiguration config = null; - - config = new BosClientConfiguration(); - config.setEndpoint(endpoint); - config.setProtocol(Protocol.HTTP); - // protocol take effect to endpiont - Assert.assertEquals(config.getEndpoint(), "http://" + endpoint); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "http"); - - config = new BosClientConfiguration(); - config.setProtocol(Protocol.HTTP); - config.setEndpoint(endpoint); - // protocol take effect to endpiont - Assert.assertEquals(config.getEndpoint(), "http://" + endpoint); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "http"); - - config = new BosClientConfiguration(); - config.setEndpoint(endpoint); - config.setProtocol(Protocol.HTTPS); - // protocol take effect to endpiont - Assert.assertEquals(config.getEndpoint(), "https://" + endpoint); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "https"); - - config = new BosClientConfiguration(); - config.setProtocol(Protocol.HTTPS); - config.setEndpoint(endpoint); - // protocol take effect to endpiont - Assert.assertEquals(config.getEndpoint(), "https://" + endpoint); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "https"); - - // default protocal - config = new BosClientConfiguration(); - config.setEndpoint(endpoint); - Assert.assertEquals(config.getEndpoint(), "http://" + endpoint); - // default protocol is http - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "http"); - } - - @Test - public void testProtocolOnly() { - BosClientConfiguration config = null; - - config = new BosClientConfiguration(); - config.setProtocol(Protocol.HTTP); - // protocol take effect to endpiont - Assert.assertEquals(config.getEndpoint(), null); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "http"); - - config = new BosClientConfiguration(); - config.setProtocol(Protocol.HTTPS); - // protocol take effect to endpiont - Assert.assertEquals(config.getEndpoint(), null); - Assert.assertEquals(config.getProtocol().toString().toLowerCase(), "https"); - - } -} diff --git a/src/test/java/com/baidubce/TestUtils.java b/src/test/java/com/baidubce/TestUtils.java deleted file mode 100755 index 6777e791..00000000 --- a/src/test/java/com/baidubce/TestUtils.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce; - -import org.hamcrest.CustomTypeSafeMatcher; - -import java.util.Date; - -public class TestUtils { - public static TimeMatcher timeGapInSecondsLessThan(Date expectedTime, int deltaInSeconds) { - return new TimeMatcher(expectedTime, deltaInSeconds, true); - } - - public static TimeMatcher timeGapInSecondsGreaterThan(Date expectedTime, int deltaInSeconds) { - return new TimeMatcher(expectedTime, deltaInSeconds, false); - } - - static class TimeMatcher extends CustomTypeSafeMatcher { - private Date expectedTime; - private int deltaInMillis; - private boolean lessThan; - - public TimeMatcher(Date expectedTime, int deltaInSeconds, boolean lessThan) { - super(String.format("the gap to %s is %s %d seconds", - expectedTime, - lessThan ? "less than" : "greater than", - deltaInSeconds)); - this.expectedTime = expectedTime; - this.deltaInMillis = deltaInSeconds * 1000; - this.lessThan = lessThan; - } - - @Override - protected boolean matchesSafely(Date item) { - long timeGapInMillis = Math.abs(item.getTime() - this.expectedTime.getTime()); - if (this.lessThan) { - return timeGapInMillis < this.deltaInMillis; - } else { - return timeGapInMillis > this.deltaInMillis; - } - } - } -} diff --git a/src/test/java/com/baidubce/conf/BmrConf.java b/src/test/java/com/baidubce/conf/BmrConf.java deleted file mode 100755 index 56003d4b..00000000 --- a/src/test/java/com/baidubce/conf/BmrConf.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.conf; - -public class BmrConf { -// qasandbox - public static final String BMR_ENDPOINT = "http://bmr.bce-api.baidu.com"; - public static final String BMR_AK = "8e93c6c470cf47e287c30db89b0eee47"; - public static final String BMR_SK = "e9ddc6246b4249bfa1830ff4592d611e"; - -// online: liukun01 -// public static final String BMR_ENDPOINT = "http://bmr.bj.baidubce.com"; -// public static final String BMR_AK = "64b0e7820b9a405a81fca0d199b93db1"; -// public static final String BMR_SK = "7ae445ef9ae1452ab23658ee20ae6ace"; -} diff --git a/src/test/java/com/baidubce/conf/LssConf.java b/src/test/java/com/baidubce/conf/LssConf.java deleted file mode 100755 index 70033230..00000000 --- a/src/test/java/com/baidubce/conf/LssConf.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.baidubce.conf; - -public class LssConf { - - public static final String BMC_ENDPOINT = "http://lss.bce-testinternal.baidu.com"; -// yuanlong's key - public static final String BMC_AK = "699abbfa0f9a4afe9e44202da09e47e6"; - public static final String BMC_SK = "8c7bc45ab088447eb559e7f8e4f6a495"; - public static String BUCKET = "livetest"; - public static String USER_DOMAIN = "livetest.bos.qasandbox.bcetest.baidu.com"; - public static String END_POINT = "http://10.216.121.59:8099/"; -} diff --git a/src/test/java/com/baidubce/conf/MediaConf.java b/src/test/java/com/baidubce/conf/MediaConf.java deleted file mode 100755 index 94303e58..00000000 --- a/src/test/java/com/baidubce/conf/MediaConf.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.baidubce.conf; - -public class MediaConf { - - public static final String BMC_ENDPOINT = "http://multimedia.bce-testinternal.baidu.com"; -// public static final String BMC_ENDPOINT = "http://10.105.97.59"; -// public static final String BMC_AK = "11f9634810b743ad9255266b064ddba1"; -// public static final String BMC_SK = "d5b8dd75acca40f8bb6cd75269305a1c"; -// public static String SOURCE_BUCKET = "sdk-input"; -// public static String TARGET_BUCKET = "sdk-output"; -// public static String bucket = SOURCE_BUCKET; - -// yuanlong's key - public static final String BMC_AK = "699abbfa0f9a4afe9e44202da09e47e6"; - public static final String BMC_SK = "8c7bc45ab088447eb559e7f8e4f6a495"; - public static String SOURCE_BUCKET = "sourcebucket"; - public static String TARGET_BUCKET = "targetbucket"; - public static String bucket = SOURCE_BUCKET; - -} diff --git a/src/test/java/com/baidubce/conf/SesConf.java b/src/test/java/com/baidubce/conf/SesConf.java deleted file mode 100755 index b3669099..00000000 --- a/src/test/java/com/baidubce/conf/SesConf.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baidubce.conf; - -public class SesConf { - //nmg09 - public static final String SES_ENDPOINT = "http://nmg02-bce-test9.nmg02.baidu.com:8886"; - public static final String SES_AK = "11f9634810b743ad9255266b064ddba1"; - public static final String SES_SK = "d5b8dd75acca40f8bb6cd75269305a1c"; - public static final String SES_REDIS_HOST="10.107.37.45"; - public static final int SES_REDIS_PORT=8885; - public static final String SES_ACCOUNT_ID="6060ca9dce5c48dd98e53ccca6c4eb58"; - public static final String MAIL_CERT_INFO_KEY="ses_bes:account:"+SES_ACCOUNT_ID+":mailAddrCert"; - public static final String MAIL_CERT_STATUS_KEY="ses_bes:account:"+SES_ACCOUNT_ID+":mailCertStatus"; - public static final String DOMAIN_CERT_INFO_KEY="ses_bes:account:"+SES_ACCOUNT_ID+":mailDomainCert"; - public static final String DKIM_CERT_INFO_KEY="ses_bes:account:"+SES_ACCOUNT_ID+":mailDkimCert"; - public static final String DKIM_ENABLE_KEY="ses_bes:account:"+SES_ACCOUNT_ID+":dkimEnable"; - public static final String MAIL_QUOTA_KEY="ses_qos:"+SES_ACCOUNT_ID+":mailQuota:production"; - public static final String MAIL_RATE_LIMIT_KEY="ses_qos:"+SES_ACCOUNT_ID+":rateLimit:production"; - public static final String MAIL_SEND_COUNT_KEY="ses_qos:"+SES_ACCOUNT_ID+":mailSendCounter:production"; - public static final String RECP_BLACKLIST_KEY="ses_qos:"+SES_ACCOUNT_ID+":recipientBlacklist"; -// public static final String SES_REDIS = "./redis-cli -h 10.58.140.31 -p 5001 -n 0"; -} diff --git a/src/test/java/com/baidubce/conf/SmsConf.java b/src/test/java/com/baidubce/conf/SmsConf.java deleted file mode 100755 index f5ec69f6..00000000 --- a/src/test/java/com/baidubce/conf/SmsConf.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baidubce.conf; - -public class SmsConf { - - // public static final String SMS_ENDPOINT = "http://localhost:8888"; - //public static final String SMS_ENDPOINT = "http://db-bkm-smsdb03.db01.baidu.com:8714"; - public static final String SMS_ENDPOINT = "http://nmg02-bce-test8.nmg02.baidu.com:8887"; - - - public static final String SMS_AK = "2009f87ec5b543d596dec65078ca358c"; - public static final String SMS_SK = "ff3e9e8255824f8081586c6d8a72d092"; - -// public static final String SMS_AK = "a1c32642748d4a3298a77e608f861ad3"; -// public static final String SMS_SK = "76734dede5b643ec999d6f1742d61f96"; - - - public static final String SMS_REDIS_HOST="10.107.37.45"; - public static final int SMS_REDIS_PORT=6379; - public static final String SMS_ACCOUNT_ID="6060ca9dce5c48dd98e53ccca6c4eb58"; - // public static final String - // SMS_DB="mysql/bin/mysql -h10.40.25.35 -P3306 -uroot -p123456 bms"; - // public static final String SMS_REDIS = - // "./redis-cli -h 10.40.25.254 -p 8112 -n 0"; -} diff --git a/src/test/java/com/baidubce/services/bmr/AbstractBmrClientTest.java b/src/test/java/com/baidubce/services/bmr/AbstractBmrClientTest.java deleted file mode 100755 index 608a3cb9..00000000 --- a/src/test/java/com/baidubce/services/bmr/AbstractBmrClientTest.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.services.bmr; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.BmrConf; - -public class AbstractBmrClientTest { - protected BmrClient bmrClient; - - public void setUp() { - BceClientConfiguration config = new BceClientConfiguration(); - config.setCredentials(new DefaultBceCredentials( - BmrConf.BMR_AK, BmrConf.BMR_SK - )); - config.setEndpoint(BmrConf.BMR_ENDPOINT); - this.bmrClient = new BmrClient(config); - } -} diff --git a/src/test/java/com/baidubce/services/bmr/BmrClientTest.java b/src/test/java/com/baidubce/services/bmr/BmrClientTest.java deleted file mode 100755 index b186a7c2..00000000 --- a/src/test/java/com/baidubce/services/bmr/BmrClientTest.java +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.services.bmr; - -import com.baidubce.BceServiceException; -import com.baidubce.services.bmr.model.JavaStepConfig; -import com.baidubce.services.bmr.model.AddStepsRequest; -import com.baidubce.services.bmr.model.AddStepsResponse; -import com.baidubce.services.bmr.model.CreateClusterRequest; -import com.baidubce.services.bmr.model.CreateClusterResponse; -import com.baidubce.services.bmr.model.GetClusterResponse; -import com.baidubce.services.bmr.model.GetStepResponse; -import com.baidubce.services.bmr.model.InstanceGroupConfig; -import com.baidubce.services.bmr.model.ListClustersRequest; -import com.baidubce.services.bmr.model.ListClustersResponse; -import com.baidubce.services.bmr.model.ListStepsRequest; -import com.baidubce.services.bmr.model.ListStepsResponse; -import com.baidubce.util.JsonUtils; -import com.fasterxml.jackson.core.JsonProcessingException; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; - -public class BmrClientTest extends AbstractBmrClientTest { - private String clusterId = null; - private String clusterName; - private String imageType; - private String imageVersion; - private boolean autoTerminate; - private String logUri; - - private JavaStepConfig javaStepConfig; - private String stepId = null; - private int stepCount; - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - super.setUp(); - this.clusterName = "java-sdk-cluster"; - this.imageType = "hadoop"; - this.imageVersion = "0.1.0"; - this.autoTerminate = true; - this.logUri = "bos://liukun01/sdk/"; - - this.stepCount = 1; - this.javaStepConfig = new JavaStepConfig() - .withName("java-step") - .withActionOnFailure("Continue") - .withJar("bos://benchmark/hadoop/hadoop-mapreduce-examples.jar") - .withMainClass("org.apache.hadoop.examples.WordCount") - .withArguments("bos://liukun01/add_minus_shell.sh bos://liukun01/sdk/output_java/out2"); - } - - @Test - public void testCreateCluster() { - CreateClusterResponse response = this.bmrClient.createCluster( - new CreateClusterRequest() - .withName(this.clusterName) - .withImageType(this.imageType) - .withImageVersion(this.imageVersion) - .withAutoTerminate(this.autoTerminate) - .withLogUri(this.logUri) - .withInstanceGroup(new InstanceGroupConfig() - .withType("Master") - .withInstanceType("g.small") - .withInstanceCount(1)) - .withInstanceGroup(new InstanceGroupConfig() - .withType("Core") - .withInstanceType("g.small") - .withInstanceCount(2)) - .withStep(new JavaStepConfig() - .withName("init-step") - .withActionOnFailure("Continue") - .withJar("bos://bmr/samples/mapreduce/libs/hadoop-mapreduce-examples.jar") - .withMainClass("org.apache.hadoop.examples.WordCount") - .withArguments("bos://bmr/samples/mapreduce/wordcount/hamlet.txt bos://liukun01/out")) - ); - try { - System.out.println(JsonUtils.toJsonPrettyString(response)); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - assertThat(response, hasProperty("clusterId")); - this.clusterId = response.getClusterId(); - - testAddStep(); - testGetStep(); - testListSteps(); - } - - @Test - public void testListClusters() { - int maxKeys = 1; - ListClustersResponse response = this.bmrClient.listClusters( - new ListClustersRequest().withMaxKeys(maxKeys) - ); - try { - System.out.println(JsonUtils.toJsonPrettyString(response)); - } catch (JsonProcessingException e) { - e.printStackTrace(); - } - assertThat(response.getMaxKeys(), is(maxKeys)); - assertThat(response.getClusters(), hasSize(maxKeys)); - } - - @Test - public void testGetCluster() { - if (this.clusterId != null) { - GetClusterResponse response = this.bmrClient.getCluster(this.clusterId); - assertThat(response.getId(), is(this.clusterId)); - assertThat(response.getImageType(), is(this.imageType)); - assertThat(response.getImageVersion(), is(this.imageVersion)); - } else { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("The parameter clusterId should not be null or empty string."); - GetClusterResponse response = this.bmrClient.getCluster(this.clusterId); - } - } - - public void testAddStep() { - AddStepsResponse response = this.bmrClient.addSteps( - new AddStepsRequest().withClusterId(this.clusterId) - .withStep(this.javaStepConfig) - ); - assertThat(response.getStepIds(), hasSize(this.stepCount)); - this.stepId = response.getStepIds().get(0); - } - - public void testListSteps() { - ListStepsResponse response = this.bmrClient.listSteps( - new ListStepsRequest().withClusterId(this.clusterId).withMaxKeys(this.stepCount) - ); - assertThat(response.getSteps(), hasSize(this.stepCount)); - String stepId = response.getSteps().get(0).getId(); - GetStepResponse response2 = this.bmrClient.getStep(this.clusterId, stepId); - assertThat(response2, hasProperty("id")); - assertThat(response2, hasProperty("name")); - assertThat(response2, hasProperty("actionOnFailure")); - assertThat(response2, hasProperty("type")); - assertThat(response2, hasProperty("status")); - assertThat(response2, hasProperty("id")); - } - - public void testGetStep() { - if (this.stepId != null) { - GetStepResponse response = this.bmrClient.getStep(this.clusterId, this.stepId); - assertThat(response.getId(), is(this.stepId)); - } else { - this.thrown.expect(IllegalArgumentException.class); - this.thrown.expectMessage("The parameter stepId should not be null or empty string."); - GetStepResponse response = this.bmrClient.getStep(this.clusterId, this.stepId); - } - } - - @Test - public void testTerminateCluster() { - if (this.clusterId != null) { - boolean terminated = false; - int tryTime = 0; - while (!terminated && tryTime <= 5) { - try { - this.bmrClient.terminateCluster(this.clusterId); - terminated = true; - } catch (BceServiceException e) { - System.out.println("Try to terminate cluster failed: " + e.getErrorMessage()); - tryTime += 1; - try { - Thread.sleep(60 * 3); - } catch (InterruptedException ex) { - ex.printStackTrace(); - } - } - } - } - } -} diff --git a/src/test/java/com/baidubce/services/bos/BosClientTest.java b/src/test/java/com/baidubce/services/bos/BosClientTest.java deleted file mode 100755 index 510bac73..00000000 --- a/src/test/java/com/baidubce/services/bos/BosClientTest.java +++ /dev/null @@ -1,2369 +0,0 @@ -/* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.services.bos; - -import com.baidubce.BceClientException; -import com.baidubce.BceServiceException; -import com.baidubce.TestUtils; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.http.HttpMethodName; -import com.baidubce.internal.RestartableFileInputStream; -import com.baidubce.model.User; -import com.baidubce.services.bos.model.BosObject; -import com.baidubce.services.bos.model.BosObjectSummary; -import com.baidubce.services.bos.model.BucketSummary; -import com.baidubce.services.bos.model.CannedAccessControlList; -import com.baidubce.services.bos.model.CompleteMultipartUploadRequest; -import com.baidubce.services.bos.model.CompleteMultipartUploadResponse; -import com.baidubce.services.bos.model.CopyObjectRequest; -import com.baidubce.services.bos.model.CopyObjectResponse; -import com.baidubce.services.bos.model.CreateBucketRequest; -import com.baidubce.services.bos.model.DeleteBucketRequest; -import com.baidubce.services.bos.model.DoesBucketExistRequest; -import com.baidubce.services.bos.model.GeneratePresignedUrlRequest; -import com.baidubce.services.bos.model.GetBucketAclRequest; -import com.baidubce.services.bos.model.GetBucketAclResponse; -import com.baidubce.services.bos.model.GetObjectRequest; -import com.baidubce.services.bos.model.Grant; -import com.baidubce.services.bos.model.Grantee; -import com.baidubce.services.bos.model.InitiateMultipartUploadRequest; -import com.baidubce.services.bos.model.InitiateMultipartUploadResponse; -import com.baidubce.services.bos.model.ListBucketsRequest; -import com.baidubce.services.bos.model.ListBucketsResponse; -import com.baidubce.services.bos.model.ListMultipartUploadsRequest; -import com.baidubce.services.bos.model.ListMultipartUploadsResponse; -import com.baidubce.services.bos.model.ListObjectsRequest; -import com.baidubce.services.bos.model.ListObjectsResponse; -import com.baidubce.services.bos.model.ListPartsRequest; -import com.baidubce.services.bos.model.ListPartsResponse; -import com.baidubce.services.bos.model.MultipartUploadSummary; -import com.baidubce.services.bos.model.ObjectMetadata; -import com.baidubce.services.bos.model.PartETag; -import com.baidubce.services.bos.model.PartSummary; -import com.baidubce.services.bos.model.Permission; -import com.baidubce.services.bos.model.PutObjectRequest; -import com.baidubce.services.bos.model.PutObjectResponse; -import com.baidubce.services.bos.model.ResponseHeaderOverrides; -import com.baidubce.services.bos.model.SetBucketAclRequest; -import com.baidubce.services.bos.model.UploadPartRequest; -import com.baidubce.services.bos.model.UploadPartResponse; -import com.baidubce.util.HashUtils; -import com.baidubce.util.JsonUtils; -import com.google.common.base.Objects; -import com.google.common.base.Strings; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; -import org.apache.commons.codec.binary.Hex; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.hamcrest.CustomMatcher; -import org.hamcrest.Matchers; -import org.hamcrest.beans.SamePropertyValuesAs; -import org.joda.time.DateTime; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.RandomAccessFile; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.security.NoSuchAlgorithmException; -import java.util.ArrayList; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Random; -import java.util.SortedMap; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.allOf; -import static org.hamcrest.Matchers.empty; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.not; -import static org.hamcrest.Matchers.notNullValue; - -@RunWith(Enclosed.class) -public class BosClientTest { - - @Ignore - public static class Base { - @Rule - public ExpectedException thrown = ExpectedException.none(); - - protected static final String BUCKET_PREFIX = "ut" + Long.toHexString(new Random().nextLong()) + "-"; - // protected static final String ENDPOINT = "http://10.26.208.32:8918"; - protected static String ENDPOINT = "http://10.105.97.15"; - - protected BosClient client; - protected User owner; - protected Grantee grantee; - protected Grantee anonymous; - protected String bucketName; - protected BosClientConfiguration config; - protected Date createTime; - - @Before - public void setUp() { - this.bucketName = BUCKET_PREFIX + Long.toHexString(new Random().nextLong()); - this.config = new BosClientConfiguration(); - this.config.setCredentials(new DefaultBceCredentials("b5db8b624200403a933b0f5a527368ae", - "3a02670d81c94d209d728bfc4f445641")); - this.config.setEndpoint(ENDPOINT); - this.client = new BosClient(this.config); - this.owner = new User("ef820bcc574e4dd09c47c0427f40b24b", "PASSPORT:1800208914"); - this.grantee = new Grantee("ef820bcc574e4dd09c47c0427f40b24b"); - this.anonymous = new Grantee("*"); - this.client.createBucket(this.bucketName); - this.createTime = new Date(); - } - - @After - public void tearDown() { - this.client = new BosClient(this.config); - for (BucketSummary bucket : this.client.listBuckets().getBuckets()) { - String bucketName = bucket.getName(); - if (bucketName.startsWith("ut")) { - while (true) { - List objectList = this.client.listObjects(bucketName).getContents(); - if (objectList.size() < 1) { - break; - } - for (BosObjectSummary object : objectList) { - String key = object.getKey(); - this.client.deleteObject(bucketName, key); - } - } - this.client.deleteBucket(bucket.getName()); - } - } - this.client.shutdown(); - } - - protected void expectBceServiceException(final int statusCode, final String errorCode) { - this.thrown.expect(new CustomMatcher( - "BceServiceException [ statusCode=" + statusCode + ", errorCode=" + errorCode + "]") { - @Override - public boolean matches(Object item) { - return (item instanceof BceServiceException) - && ((BceServiceException) item).getStatusCode() == statusCode - && Objects.equal(((BceServiceException) item).getErrorCode(), errorCode); - } - }); - } - } - - public static class CommonTest extends Base { - @Test - public void test_RequestWithInvalidCredential() { - this.expectBceServiceException(403, "SignatureDoesNotMatch"); - this.client.listBuckets(new ListBucketsRequest() - .withRequestCredentials(new DefaultBceCredentials("test", "test"))); - } - } - - public static class GetBosAccountOwnerTest extends Base { - @Test - public void testOrdinary() { - assertThat(this.client.getBosAccountOwner(), is(this.owner)); - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.getBosAccountOwner(null); - } - } - - public static class ListBucketsTest extends Base { - - @Test - public void testOrdinary() { - for (int i = 0; i < 10; ++i) { - this.client.createBucket(this.bucketName + "-" + i); - } - ListBucketsResponse listBucketsResponse = this.client.listBuckets(); - List buckets = listBucketsResponse.getBuckets(); - assertThat(listBucketsResponse, hasProperty("owner", is(this.owner))); - for (int i = 0; i < 10; ++i) { - assertThat(buckets, Matchers.hasItem(allOf( - hasProperty("creationDate", TestUtils.timeGapInSecondsLessThan(this.createTime, 30)), - hasProperty("name", is(this.bucketName + "-" + i))))); - } - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.listBuckets(null); - } - } - - public static class CreateBucketTest extends Base { - - @Test - public void testOrdinary() { - String bucketName = this.bucketName + "other"; - this.client.createBucket(bucketName); - GetBucketAclResponse response = this.client.getBucketAcl(bucketName); - - List expectedGrant = new ArrayList(); - List expectedGrantee = new ArrayList(); - expectedGrantee.add(this.grantee); - List expectedPermission = new ArrayList(); - expectedPermission.add(Permission.FULL_CONTROL); - expectedGrant.add(new Grant(expectedGrantee, expectedPermission)); - for (Grant grant : expectedGrant) { - assertThat(response.getAccessControlList(), hasItem(new SamePropertyValuesAs(grant))); - } - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.createBucket((CreateBucketRequest) null); - } - - @Test - public void testDuplicateName() { - this.expectBceServiceException(409, "BucketAlreadyExists"); - this.client.createBucket(this.bucketName); - } - - @Test - public void testTooManyBuckets() { - this.expectBceServiceException(400, "TooManyBuckets"); - for (int i = 0; i < 100; ++i) { - this.client.createBucket(this.bucketName + i); - } - } - - @Test(expected = NullPointerException.class) - public void testBucketWithEmptyName() { - this.client.createBucket(new CreateBucketRequest(null)); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameWithLessThreeLetters() { - String bucketName = "aa"; - this.client.createBucket(bucketName); - } - - @Test - public void testBucketNameWithThreeLetters() { - boolean excepted = false; - String bucketName = "z4g"; - String errorCode = null; - try { - this.client.createBucket(bucketName); - } catch (BceServiceException e) { - excepted = true; - errorCode = e.getErrorCode(); - } - assertThat(excepted, is(true)); - assertThat(errorCode, is("BucketAlreadyExists")); - } - - @Test - public void testBucketNameWith63Letters() { - boolean excepted = false; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < 63; i++) { - sb.append("e"); - } - String bucketName = sb.toString(); - try { - this.client.createBucket(bucketName); - } catch (Exception e) { - excepted = true; - } - Assert.assertFalse(excepted); - - try { - this.client.deleteBucket(bucketName); - } catch (BceServiceException e) { - excepted = true; - } - Assert.assertFalse(excepted); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameWith64Letters() { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < 64; i++) { - sb.append("b"); - } - String bucketName = sb.toString(); - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameWithUppercase() { - String bucketName = "aaaAAaaa"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameStartUppercase() { - String bucketName = "Aaa"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameEndUppercase() { - String bucketName = "aaaA"; - this.client.createBucket(bucketName); - } - - @Test - public void testBucketNameStartNumber() { - boolean excepted = false; - String bucketName = "9aaa" + System.currentTimeMillis() + "a"; - try { - this.client.createBucket(bucketName); - } catch (Exception e) { - excepted = true; - } - Assert.assertFalse(excepted); - - try { - this.client.deleteBucket(bucketName); - } catch (BceServiceException e) { - e.printStackTrace(); - excepted = true; - } - Assert.assertFalse(excepted); - } - - @Test - public void testBucketNameEndNumber() { - boolean excepted = false; - String bucketName = "a" + System.currentTimeMillis() + "aaa9"; - try { - this.client.createBucket(bucketName); - } catch (Exception e) { - excepted = true; - } - Assert.assertFalse(excepted); - - try { - this.client.deleteBucket(bucketName); - } catch (BceServiceException e) { - e.printStackTrace(); - excepted = true; - } - Assert.assertFalse(excepted); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameStartHyphen() { - String bucketName = "-aaa"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameEndHyphen() { - String bucketName = "aaa-"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameContainOtherLetter() { - String bucketName = "abcd!a"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameContainOtherLetter2() { - String bucketName = "abcd{}a"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameContainOtherLetter3() { - String bucketName = "ab=a"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameContainOtherLetter4() { - String bucketName = "ab[]a"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameContainWhiteSpace() { - String bucketName = "aaa aa"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameContainWhiteSpaceT() { - String bucketName = "aaa\taaa"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameContainWhiteSpaceR() { - String bucketName = "aaa\raaa"; - this.client.createBucket(bucketName); - } - - @Test(expected = IllegalArgumentException.class) - public void testBucketNameContainWhiteSpaceN() { - String bucketName = "aaa\naaa"; - this.client.createBucket(bucketName); - } - - @Test - public void testBucketNameContainNumber() { - boolean excepted = false; - String bucketName = "aaa-222-999aa1"; - try { - this.client.createBucket(bucketName); - } catch (Exception e) { - excepted = true; - } - Assert.assertFalse(excepted); - - try { - this.client.deleteBucket(bucketName); - } catch (BceServiceException e) { - e.printStackTrace(); - excepted = true; - } - Assert.assertFalse(excepted); - } - - } - - public static class DoesBucketExistTest extends Base { - - @Test - public void testExist() { - assertThat(this.client.doesBucketExist(this.bucketName), is(true)); - } - - @Test - public void testExistForbidden() { - BosClient bosClient = new BosClient(new BosClientConfiguration() - .withCredentials(new DefaultBceCredentials - ("1899c3f4e2bc4ce2a10dbfe25691a8fd", - "f7f030bdce1f45348e1de94270db1369")) - .withEndpoint(ENDPOINT)); - assertThat(bosClient.doesBucketExist(this.bucketName), is(true)); - } - - @Test - public void testNotExist() { - assertThat(this.client.doesBucketExist(this.bucketName + "notexist"), is(false)); - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.doesBucketExist((DoesBucketExistRequest) null); - } - } - - public static class GetBucketTest extends Base { - - @Test - public void testDefaultAcl() { - GetBucketAclResponse response = this.client.getBucketAcl(this.bucketName); - assertThat(response.getOwner(), is(this.grantee)); - - List grants = new ArrayList(); - List grantee = new ArrayList(); - grantee.add(this.grantee); - List permission = new ArrayList(); - permission.add(Permission.FULL_CONTROL); - grants.add(new Grant(grantee, permission)); - assertThat(response.getAccessControlList(), hasSize(grants.size())); - for (Grant grant : grants) { - assertThat(response.getAccessControlList(), hasItem(new SamePropertyValuesAs(grant))); - } - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.getBucketAcl((GetBucketAclRequest) null); - } - } - - public static class SetBucketAclTest extends Base { - - @Test - public void testPublicReadWrite() { - String objectKey = "objectPublicReadWrite"; - String data = "dataPublicReadWrite"; - - this.client.setBucketAcl(this.bucketName, CannedAccessControlList.PublicReadWrite); - GetBucketAclResponse response = this.client.getBucketAcl(this.bucketName); - assertThat(response.getOwner(), is(this.grantee)); - - List grants = new ArrayList(); - List granteeOwner = new ArrayList(); - granteeOwner.add(this.grantee); - List permissionOwner = new ArrayList(); - permissionOwner.add(Permission.FULL_CONTROL); - grants.add(new Grant(granteeOwner, permissionOwner)); - List granteeAnonymous = new ArrayList(); - granteeAnonymous.add(this.anonymous); - List permissionAnonymous = new ArrayList(); - permissionAnonymous.add(Permission.READ); - permissionAnonymous.add(Permission.WRITE); - grants.add(new Grant(granteeAnonymous, permissionAnonymous)); - - assertThat(response.getAccessControlList(), hasSize(grants.size())); - for (Grant grant : grants) { - assertThat(response.getAccessControlList(), hasItem(new SamePropertyValuesAs(grant))); - } - - this.client.putObject(this.bucketName, objectKey, data); - BosClient bosAnonymous = new BosClient(new BosClientConfiguration().withEndpoint(ENDPOINT)); - assertThat(new String(bosAnonymous.getObjectContent(this.bucketName, objectKey)), is(data)); - - bosAnonymous.putObject(this.bucketName, "anonymous", "dataAnonymous"); - assertThat(new String(bosAnonymous.getObjectContent(this.bucketName, "anonymous")), is("dataAnonymous")); - - bosAnonymous.deleteObject(this.bucketName, objectKey); - this.expectBceServiceException(404, "NoSuchKey"); - bosAnonymous.getObject(this.bucketName, objectKey); - - this.client.setBucketAcl(this.bucketName, CannedAccessControlList.Private); - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.setBucketAcl((SetBucketAclRequest) null); - } - - @Test - public void testPublicRead() throws Exception { - String objectKey = "objectPublicRead"; - String data = "dataPublicRead"; - - this.client.putObject(this.bucketName, objectKey, data); - this.client.setBucketAcl(this.bucketName, CannedAccessControlList.PublicRead); - - BosClient bosAnonymous = new BosClient(new BosClientConfiguration().withEndpoint(ENDPOINT)); - assertThat(new String(bosAnonymous.getObjectContent(this.bucketName, objectKey)), is(data)); - - this.expectBceServiceException(403, "AccessDenied"); - bosAnonymous.putObject(this.bucketName, "anonymous", "dataAnonymous"); - - this.expectBceServiceException(403, "AccessDenied"); - bosAnonymous.deleteObject(this.bucketName, objectKey); - - this.client.setBucketAcl(this.bucketName, CannedAccessControlList.Private); - } - - @Test - public void testSetBucketAclFromBody() throws Exception { - List grants = new ArrayList(); - List grantee = new ArrayList(); - List permission = new ArrayList(); - grantee.add(new Grantee("bf33dc8ef8a942c08f47d94ade6aee7d")); - grantee.add(new Grantee("00000000000000000000000000000000")); - grantee.add(new Grantee("11111111111111111111111111111111")); - permission.add(Permission.READ); - permission.add(Permission.WRITE); - grants.add(new Grant().withGrantee(grantee).withPermission(permission)); - - grantee = new ArrayList(); - permission = new ArrayList(); - grantee.add(new Grantee("bf33dc8ef8a942c08f47d94ade6aee7d")); - grantee.add(this.grantee); - permission.add(Permission.FULL_CONTROL); - grants.add(new Grant().withGrantee(grantee).withPermission(permission)); - SetBucketAclRequest request = new SetBucketAclRequest(this.bucketName, grants); - this.client.setBucketAcl(request); - GetBucketAclResponse response = this.client.getBucketAcl(bucketName); - - GetBucketAclResponse expectedResponse = new GetBucketAclResponse(); - expectedResponse.setOwner(this.grantee); - expectedResponse.setAccessControlList(grants); - assertThat(response.getAccessControlList(), hasSize(expectedResponse.getAccessControlList().size())); - for (Grant grant : expectedResponse.getAccessControlList()) { - assertThat(response.getAccessControlList(), hasItem(new SamePropertyValuesAs(grant))); - } - } - } - - public static class DeleteBucketTest extends Base { - @Test - public void testOrdinary() { - this.client.deleteBucket(this.bucketName); - assertThat(this.client.listBuckets().getBuckets(), not(hasProperty("name", is(this.bucketName)))); - } - - @Test - public void testNotExist() { - this.expectBceServiceException(404, "NoSuchBucket"); - this.client.deleteBucket(this.bucketName + "notexist"); - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.deleteBucket((DeleteBucketRequest) null); - } - - @Test - public void testBucketNotEmpty() { - this.expectBceServiceException(409, "BucketNotEmpty"); - this.client.putObject(this.bucketName, "test", "value"); - this.client.deleteBucket(this.bucketName); - } - } - - @Ignore - public static class ListObjectsBase extends Base { - protected SortedMap expectedContents; - protected List expectedCommonPrefixes; - protected String expectedDelimiter; - protected String expectedMarker; - protected String expectedNextMarker; - protected boolean expectedTruncated; - protected int expectedMaxKeys; - protected String expectedPrefix; - - @Override - @Before - public void setUp() { - super.setUp(); - this.expectedContents = Maps.newTreeMap(); - this.expectedContents.put("dir0/dir1/key0", Strings.repeat("v", 1)); - this.expectedContents.put("dir0/key0", Strings.repeat("v", 2)); - this.expectedContents.put("dir0/key1", Strings.repeat("v", 3)); - this.expectedContents.put("dir1/dir2/key1", Strings.repeat("v", 4)); - this.expectedContents.put("dir1/dir2/key2", Strings.repeat("v", 5)); - this.expectedContents.put("dir1/key0", Strings.repeat("v", 6)); - this.expectedContents.put("dir3/key0", Strings.repeat("v", 7)); - this.expectedContents.put("dir3/key1", Strings.repeat("v", 8)); - this.expectedContents.put("dir4/key0", Strings.repeat("v", 9)); - this.expectedContents.put("key", Strings.repeat("v", 10)); - - for (Map.Entry entry : this.expectedContents.entrySet()) { - this.client.putObject(this.bucketName, entry.getKey(), entry.getValue()); - } - this.expectedCommonPrefixes = null; - this.expectedDelimiter = null; - this.expectedMarker = ""; - this.expectedNextMarker = null; - this.expectedTruncated = false; - this.expectedPrefix = ""; - this.expectedMaxKeys = 1000; - } - - protected void checkResponse(ListObjectsResponse response) { - assertThat(response, hasProperty("bucketName", is(this.bucketName))); - assertThat(response, hasProperty("commonPrefixes", is(this.expectedCommonPrefixes))); - assertThat(response, hasProperty("delimiter", is(this.expectedDelimiter))); - assertThat(response, hasProperty("marker", is(this.expectedMarker))); - assertThat(response, hasProperty("nextMarker", is(this.expectedNextMarker))); - assertThat(response, hasProperty("truncated", is(this.expectedTruncated))); - assertThat(response, hasProperty("maxKeys", is(this.expectedMaxKeys))); - assertThat(response, hasProperty("prefix", is(this.expectedPrefix))); - List objects = response.getContents(); - assertThat(objects, hasSize(this.expectedContents.size())); - Iterator it = objects.iterator(); - for (Map.Entry entry : this.expectedContents.entrySet()) { - BosObjectSummary object = it.next(); - assertThat(object, hasProperty("bucketName", is(this.bucketName))); - assertThat(object, hasProperty("key", is(entry.getKey()))); - assertThat(object, hasProperty("owner", is(this.owner))); - assertThat(object, hasProperty("size", is((long) entry.getValue().length()))); - assertThat(object, - hasProperty("lastModified", TestUtils.timeGapInSecondsLessThan(this.createTime, 30))); - try { - assertThat(object, hasProperty("ETag", is(Hex.encodeHexString(HashUtils - .computeMd5Hash(new ByteArrayInputStream(entry.getValue().getBytes())))))); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public static class ListObjectsTest extends ListObjectsBase { - - @Test - public void testOrdinary() { - this.checkResponse(this.client.listObjects(this.bucketName)); - } - - @Test - public void testPrefix() { - this.expectedContents.remove("key"); - this.expectedPrefix = "d"; - this.checkResponse(this.client.listObjects(this.bucketName, "d")); - } - - @Test - public void testMarker() { - this.expectedContents = this.expectedContents.subMap("dir1", "z"); - this.expectedMarker = "dir1"; - this.checkResponse(this.client.listObjects(new ListObjectsRequest(this.bucketName).withMarker("dir1"))); - } - - @Test - public void testDelimiter() { - this.expectedContents.clear(); - this.expectedContents.put("dir0/key0", Strings.repeat("v", 2)); - this.expectedCommonPrefixes = Lists.newArrayList(); - this.expectedCommonPrefixes.add("dir0/dir1/"); - this.expectedNextMarker = "dir0/key0"; - this.expectedDelimiter = "/"; - this.expectedTruncated = true; - this.expectedMaxKeys = 2; - this.expectedPrefix = "dir0/"; - this.checkResponse(this.client - .listObjects(new ListObjectsRequest(this.bucketName, "dir0/").withDelimiter("/").withMaxKeys(2))); - } - - @Test - public void testMaxKeys() { - this.expectedContents = this.expectedContents.subMap("dir0", "dir1/dir2/key1"); - this.expectedTruncated = true; - this.expectedMaxKeys = 3; - this.expectedNextMarker = "dir0/key1"; - this.checkResponse(this.client.listObjects(new ListObjectsRequest(this.bucketName).withMaxKeys(3))); - } - - @Test - public void testNegativeMaxKeys() { - this.checkResponse(this.client.listObjects(new ListObjectsRequest(this.bucketName).withMaxKeys(-1))); - } - - @Test - public void testCombination() { - this.expectedContents = this.expectedContents.subMap("dir1", "dir3/key0"); - this.expectedTruncated = true; - this.expectedMarker = "dir1"; - this.expectedMaxKeys = 3; - this.expectedPrefix = "d"; - this.expectedNextMarker = "dir1/key0"; - this.checkResponse(this.client.listObjects(new ListObjectsRequest(this.bucketName).withPrefix("d") - .withMarker("dir1").withMaxKeys(3))); - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.listObjects((ListObjectsRequest) null); - } - } - - public static class ListNextBatchOfObjectsTest extends ListObjectsBase { - protected ListObjectsResponse response; - - @Override - @Before - public void setUp() { - super.setUp(); - this.response = new ListObjectsResponse(); - this.response.setBucketName(this.bucketName); - this.response.setTruncated(true); - this.response.setMaxKeys(1000); - } - - @Test - public void testOrdinary() { - this.checkResponse(this.client.listNextBatchOfObjects(this.response)); - } - - @Test - public void testPrefix() { - this.expectedContents.remove("key"); - this.expectedPrefix = "d"; - this.response.setPrefix("d"); - this.checkResponse(this.client.listNextBatchOfObjects(this.response)); - } - - @Test - public void testMarker() { - this.expectedContents = this.expectedContents.subMap("dir1", "z"); - this.expectedMarker = "dir1"; - this.response.setNextMarker("dir1"); - this.checkResponse(this.client.listNextBatchOfObjects(this.response)); - } - - @Test - public void testDelimiter() { - this.expectedContents.clear(); - this.expectedCommonPrefixes = Lists.newArrayList(); - this.expectedCommonPrefixes.add("dir1/"); - this.expectedCommonPrefixes.add("dir3/"); - this.expectedCommonPrefixes.add("dir4/"); - this.expectedDelimiter = "/"; - this.expectedMaxKeys = 3; - this.expectedNextMarker = "dir4/key0"; - this.expectedTruncated = true; - this.expectedMarker = "dir0/key0"; - - this.response.setDelimiter("/"); - this.response.setMaxKeys(3); - this.response.setNextMarker("dir0/key0"); - this.checkResponse(this.client.listNextBatchOfObjects(this.response)); - } - - @Test - public void testMaxKeys() { - this.expectedContents = this.expectedContents.subMap("dir0", "dir1/dir2/key1"); - this.expectedTruncated = true; - this.expectedMaxKeys = 3; - this.expectedNextMarker = "dir0/key1"; - this.response.setMaxKeys(3); - this.checkResponse(this.client.listNextBatchOfObjects(this.response)); - } - - @Test - public void testCombination() { - this.expectedContents = this.expectedContents.subMap("dir1", "dir3/key0"); - this.expectedTruncated = true; - this.expectedMarker = "dir1"; - this.expectedNextMarker = "dir1/key0"; - this.expectedMaxKeys = 3; - this.expectedPrefix = "d"; - this.response.setPrefix("d"); - this.response.setNextMarker("dir1"); - this.response.setMaxKeys(3); - this.checkResponse(this.client.listNextBatchOfObjects(this.response)); - } - - @Test(expected = NullPointerException.class) - public void testNullResponse() { - this.client.listNextBatchOfObjects((ListObjectsResponse) null); - } - - @Test - public void testNotTruncated() { - this.response.setPrefix("d"); - this.response.setNextMarker("dir1"); - this.response.setMaxKeys(3); - this.response.setTruncated(false); - this.expectedContents.clear(); - this.expectedMarker = "dir1"; - this.expectedPrefix = "d"; - this.expectedMaxKeys = 3; - this.checkResponse(this.client.listNextBatchOfObjects(this.response)); - } - } - - public static class GetObjectTest extends Base { - protected String expectedKey; - protected String expectedValue; - protected ObjectMetadata expectedMetadata; - - @Override - @Before - public void setUp() { - super.setUp(); - this.expectedKey = "key"; - this.expectedValue = "value"; - this.expectedMetadata = new ObjectMetadata(); - this.expectedMetadata.addUserMetadata("uk0", "v0"); - this.expectedMetadata.addUserMetadata("uk1", "v1"); - this.client.putObject(this.bucketName, this.expectedKey, this.expectedValue, this.expectedMetadata); - } - - protected void checkObject(BosObject object) throws IOException { - BosObjectInputStream input = object.getObjectContent(); - try { - assertThat(object, hasProperty("bucketName", is(this.bucketName))); - assertThat(object, hasProperty("key", is(this.expectedKey))); - assertThat(IOUtils.toString(input), is(this.expectedValue)); - ObjectMetadata metadata = object.getObjectMetadata(); - assertThat(metadata.getContentLength(), is((long) this.expectedValue.length())); - assertThat(metadata.getUserMetadata(), is(this.expectedMetadata.getUserMetadata())); - } catch (IOException e) { - input.close(); - } - } - - @Test - public void testOrdinary() throws IOException { - this.checkObject(this.client.getObject(this.bucketName, "key")); - this.client.getObject(this.bucketName, "key").close(); - } - - @Test - public void testNotExist() { - this.expectBceServiceException(404, "NoSuchKey"); - this.client.getObject(this.bucketName, "nosuchkey"); - } - - @Test - public void testRange() throws IOException { - String objectKey = "testRange"; - this.client.putObject(this.bucketName, objectKey, "abcdefghigklmnopqrstuvwxyz"); - this.expectedValue = "abcdef"; - GetObjectRequest request = - new GetObjectRequest().withBucketName(this.bucketName).withKey(objectKey).withRange(0, 5); - InputStream input = this.client.getObject(request).getObjectContent(); - assertThat(IOUtils.toString(input), is(this.expectedValue)); - } - - @Test(expected = IllegalArgumentException.class) - public void testNegativeRange() throws IOException { - GetObjectRequest request = new GetObjectRequest().withRange(-1, 5); - } - - @Test(expected = IllegalArgumentException.class) - public void testErrorRange() throws IOException { - GetObjectRequest request = new GetObjectRequest().withRange(6, 5); - } - - @Test - public void testRangeToFile() throws IOException, NoSuchAlgorithmException { - String objectKey = "testRangeToFile"; - this.client.putObject(this.bucketName, objectKey, "abcdefghigklmnopqrstuvwxyz"); - this.expectedValue = "abcdef"; - File file = new File("test"); - try { - this.client.getObject(new GetObjectRequest(this.bucketName, objectKey).withRange(0, 5), file); - assertThat(HashUtils.computeMd5Hash(new ByteArrayInputStream("abcdef".getBytes())), - is(HashUtils.computeMd5Hash(new FileInputStream(file)))); - } finally { - file.delete(); - } - } - - @Test - public void testObjectToFile() throws IOException, NoSuchAlgorithmException { - String objectKey = "testObjectToFile"; - this.client.putObject(this.bucketName, objectKey, "dataFile"); - File file = new File("test"); - try { - this.client.getObject(this.bucketName, objectKey, file); - assertThat(HashUtils.computeMd5Hash(new ByteArrayInputStream("dataFile".getBytes())), - is(HashUtils.computeMd5Hash(new FileInputStream(file)))); - } finally { - file.delete(); - } - } - - @Test - public void testObjectContent() { - String objectKey = "testObjectContent"; - this.client.putObject(this.bucketName, objectKey, "dataContent"); - assertThat("dataContent".getBytes(), is(this.client.getObjectContent(this.bucketName, objectKey))); - } - } - - public static class GetObjectMetadataTest extends Base { - @Test - public void testOrdinary() { - ObjectMetadata metadata = new ObjectMetadata(); - for (int i = 0; i < 10; ++i) { - metadata.addUserMetadata("key-" + i, "value-" + i); - } - this.client.putObject(this.bucketName, "test", "data", metadata); - metadata = this.client.getObjectMetadata(this.bucketName, "test"); - assertThat(metadata.getContentLength(), is(4L)); - Map userMeta = metadata.getUserMetadata(); - for (int i = 0; i < 10; ++i) { - assertThat(userMeta.get("key-" + i), is("value-" + i)); - } - } - - @Test - public void testNoSuchKey() { - this.client.putObject(this.bucketName, "test", "data"); - this.expectBceServiceException(404, null); - this.client.getObjectMetadata(this.bucketName, "test1"); - } - } - - public static class PutObjectTest extends Base { - @Test - public void testOrdinary() throws IOException, NoSuchAlgorithmException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - PutObjectRequest request = new PutObjectRequest(this.bucketName, "test", file); - ObjectMetadata objectMetadata = new ObjectMetadata(); - objectMetadata.setContentType("text/plain"); - request.setObjectMetadata(objectMetadata); - String eTag = this.client.putObject(request).getETag(); - assertThat(eTag, is(Hex.encodeHexString(HashUtils.computeMd5Hash(new FileInputStream(file))))); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("data")); - } finally { - file.delete(); - } - } - - @Test - public void testNoSuchBucket() throws IOException { - String object = "object" + System.currentTimeMillis(); - String base = "1234567890"; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < 1024 * 40; i++) { - sb.append(base); - } - this.expectBceServiceException(404, "NoSuchBucket"); - this.client.putObject("nosuchbucket111", object, sb.toString()); - } - - @Test - public void testInputStream() throws IOException, NoSuchAlgorithmException { - PutObjectRequest request = - new PutObjectRequest(this.bucketName, "test", new ByteArrayInputStream("data".getBytes())); - ObjectMetadata objectMetadata = new ObjectMetadata(); - objectMetadata.setContentType("text/plain"); - request.setObjectMetadata(objectMetadata); - String eTag = this.client.putObject(request).getETag(); - assertThat(eTag, is(Hex.encodeHexString(HashUtils - .computeMd5Hash(new ByteArrayInputStream("data".getBytes()))))); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("data")); - } - - @Test - public void testInputStreamWithContentLength() throws IOException, NoSuchAlgorithmException { - PutObjectRequest request = - new PutObjectRequest(this.bucketName, "test", new ByteArrayInputStream("data".getBytes())); - ObjectMetadata objectMetadata = new ObjectMetadata(); - objectMetadata.setContentType("text/plain"); - objectMetadata.setContentLength(1); - request.setObjectMetadata(objectMetadata); - String eTag = this.client.putObject(this.bucketName, "test", "data", objectMetadata).getETag(); - assertThat(eTag, is(Hex.encodeHexString(HashUtils - .computeMd5Hash(new ByteArrayInputStream("d".getBytes()))))); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("d")); - } - - @Test - public void testFileInputStream() throws IOException, NoSuchAlgorithmException { - File file = createFile("test", 5 * 1024 * 1024); - try { - String eTag = this.client.putObject(this.bucketName, "test", new FileInputStream(file)).getETag(); - assertThat(eTag, is(Hex.encodeHexString(HashUtils.computeMd5Hash(new FileInputStream(file))))); - } finally { - file.delete(); - } - } - - @Test - public void testRestartableInputStream() throws IOException, NoSuchAlgorithmException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - PutObjectRequest request = - new PutObjectRequest(this.bucketName, "test", new RestartableFileInputStream(file)); - String eTag = this.client.putObject(request).getETag(); - assertThat(eTag, is(Hex.encodeHexString(HashUtils.computeMd5Hash(new FileInputStream(file))))); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("data")); - } finally { - file.delete(); - } - } - - @Test - public void testWrapRestartableInputStream() throws IOException, NoSuchAlgorithmException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - PutObjectRequest request = new PutObjectRequest(this.bucketName, "test", new FileInputStream(file)); - ObjectMetadata objectMetadata = new ObjectMetadata(); - objectMetadata.setContentType("text/plain"); - objectMetadata.setContentLength(4); - request.setObjectMetadata(objectMetadata); - String eTag = this.client.putObject(request).getETag(); - assertThat(eTag, is(Hex.encodeHexString(HashUtils.computeMd5Hash(new FileInputStream(file))))); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("data")); - } finally { - file.delete(); - } - } - - @Test(expected = IllegalArgumentException.class) - public void testEmptyObject() { - this.client.putObject(this.bucketName, "", "data"); - } - - @Test - public void testObjectSpace() { - this.client.putObject(this.bucketName, " ", "data"); - assertThat(new String(this.client.getObjectContent(this.bucketName, " ")), is("data")); - } - - @Test - public void testObjectKeyWithSpecialChar() throws IOException, NoSuchAlgorithmException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - String eTag = - this.client.putObject(this.bucketName, "///~`+_|!@#$%^&*()-=[]{};':':,.<>/?// 、", file) - .getETag(); - assertThat(eTag, is(Hex.encodeHexString(HashUtils.computeMd5Hash(new FileInputStream(file))))); - assertThat(new String(this.client - .getObjectContent(this.bucketName, "///~`+_|!@#$%^&*()-=[]{};':':,.<>/?// 、")), is("data")); - } finally { - file.delete(); - } - } - - @Test - public void testObjectKeyWithChinese() throws IOException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - this.client.putObject(this.bucketName, "百度云", file); - assertThat(new String(this.client.getObjectContent(this.bucketName, "百度云")), is("data")); - } finally { - file.delete(); - } - } - - @Test - public void testObjectKeyWith1024Letter() throws Exception { - StringBuilder sb = new StringBuilder(); - int i = 0; - while (i < 1024) { - sb.append("a"); - i++; - } - String objectKey = sb.toString(); - - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - this.client.putObject(this.bucketName, objectKey, file); - assertThat(new String(this.client.getObjectContent(this.bucketName, objectKey)), is("data")); - } finally { - file.delete(); - } - } - - @Test(expected = IllegalArgumentException.class) - public void testObjectKeyWith1025Letter() throws Exception { - StringBuilder sb = new StringBuilder(); - int i = 0; - while (i < 1025) { - sb.append("a"); - i++; - } - String objectKey = sb.toString(); - - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - this.client.putObject(this.bucketName, objectKey, file); - } finally { - file.delete(); - } - } - - @Test - public void testObjectKeyWithUserMeta() throws IOException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - ObjectMetadata objectMetadata = new ObjectMetadata(); - Map userMetadata = Maps.newHashMap(); - // userMetadata.put("test/a=b/file", "百度 "); - userMetadata.put("test1", "百度 "); - objectMetadata.setUserMetadata(userMetadata); - this.client.putObject(this.bucketName, "test", file, objectMetadata); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("data")); - assertThat(this.client.getObjectMetadata(this.bucketName, "test").getUserMetaDataOf("test1"), - is("百度 ")); - } finally { - file.delete(); - } - } - - @Test - public void testObjectKeyWithUserMetaNonKey() throws IOException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - ObjectMetadata objectMetadata = new ObjectMetadata(); - Map userMetadata = Maps.newHashMap(); - userMetadata.put(null, null); - objectMetadata.setUserMetadata(userMetadata); - this.client.putObject(this.bucketName, "test", file, objectMetadata); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("data")); - } finally { - file.delete(); - } - } - - @Test - public void testObjectKeyWithUserMetaNonValue() throws IOException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - ObjectMetadata objectMetadata = new ObjectMetadata(); - Map userMetadata = Maps.newHashMap(); - userMetadata.put("key", null); - objectMetadata.setUserMetadata(userMetadata); - this.client.putObject(this.bucketName, "test", file, objectMetadata); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("data")); - assertThat(this.client.getObjectMetadata(this.bucketName, "test").getUserMetaDataOf("key"), - is((String) null)); -// assertThat(this.client.getObjectMetadata(this.bucketName, "test").getUserMetaDataOf("key"), -// is((String) "")); - } finally { - file.delete(); - } - } - - @Test - public void testObjectKeyWithUserMeta2048Byte() throws IOException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - ObjectMetadata objectMetadata = new ObjectMetadata(); - Map userMetadata = Maps.newHashMap(); - StringBuilder sb = new StringBuilder(); - int i = 0; - while (i < 2034) { - sb.append("a"); - i++; - } - userMetadata.put("key", sb.toString()); - objectMetadata.setUserMetadata(userMetadata); - this.client.putObject(this.bucketName, "test", file, objectMetadata); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("data")); - } finally { - file.delete(); - } - } - - @Test - public void testObjectKeyWithUserMeta2049Byte() throws IOException { - File file = File.createTempFile("test", null); - try { - FileUtils.writeStringToFile(file, "data"); - ObjectMetadata objectMetadata = new ObjectMetadata(); - Map userMetadata = Maps.newHashMap(); - StringBuilder sb = new StringBuilder(); - int i = 0; - while (i < 2035) { - sb.append("a"); - i++; - } - userMetadata.put("key", sb.toString()); - objectMetadata.setUserMetadata(userMetadata); - try { - this.client.putObject(this.bucketName, "test", file, objectMetadata); - } catch (BceServiceException bse) { - assertThat(bse.getStatusCode(), is(400)); - assertThat(bse.getErrorCode(), is("MetadataTooLarge")); - } - } finally { - file.delete(); - } - } - - @Test(expected = BceClientException.class) - public void testObjectKeyWithUserMetaTooLong() throws IOException { - ObjectMetadata objectMetadata = new ObjectMetadata(); - Map userMetadata = Maps.newHashMap(); - StringBuilder sb = new StringBuilder(); - int i = 0; - while (i < 1024 * 1024) { - sb.append("a"); - i++; - } - userMetadata.put("key", sb.toString()); - objectMetadata.setUserMetadata(userMetadata); - this.client.putObject(this.bucketName, "test", "data", objectMetadata); - } - - @Test - @Ignore - public void testLength5G() throws IOException, NoSuchAlgorithmException { - File file = createFile("test5G", 50 * 1024 * 1024); - try { - PutObjectRequest request = new PutObjectRequest(this.bucketName, "test", file); - ObjectMetadata objectMetadata = new ObjectMetadata(); - objectMetadata.setContentType("text/plain"); - request.setObjectMetadata(objectMetadata); - String eTag = this.client.putObject(request).getETag(); - assertThat(eTag, is(Hex.encodeHexString(HashUtils.computeMd5Hash(new FileInputStream(file))))); - } finally { - file.delete(); - } - } - - @Test - @Ignore - public void testLengthMoreThan5G() throws IOException { - File file = createFile("test", 5 * 1024 * 1024 * 1024L + 1); - try { - this.expectBceServiceException(400, "EntityTooLarge"); - this.client.putObject(this.bucketName, "test", file); - } finally { - file.delete(); - } - } - - @Test - public void testPutObjectStanardIA() throws IOException { - - File file = createFile("ia_object", 1024 * 1024); - try { - PutObjectRequest request = - new PutObjectRequest(this.bucketName, "ia_test", file); - request.withStorageClass(BosClient.STORAGE_CLASS_STANDARD_IA); - this.client.putObject(request); - ObjectMetadata meta = this.client.getObjectMetadata(this.bucketName, "ia_test"); - assertThat(meta.getStorageClass(), is(BosClient.STORAGE_CLASS_STANDARD_IA)); - } finally { - file.delete(); - } - } - - @Test - public void testPutObjectStanard() throws IOException { - - File file = createFile("standard_object", 1024 * 1024); - try { - PutObjectRequest request = - new PutObjectRequest(this.bucketName, "standard_test", file); - request.withStorageClass(""); - this.client.putObject(request); - ObjectMetadata meta = this.client.getObjectMetadata(this.bucketName, "standard_test"); - assertThat(meta.getStorageClass(), is(BosClient.STORAGE_CLASS_STANDARD)); - } finally { - file.delete(); - } - } - - @Test - public void testPutObjectStanardWithNoArg() throws IOException { - - File file = createFile("standard_object", 1024 * 1024); - try { - PutObjectRequest request = - new PutObjectRequest(this.bucketName, "standard_test_noarg", file); - this.client.putObject(request); - ObjectMetadata meta = this.client.getObjectMetadata(this.bucketName, "standard_test_noarg"); - assertThat(meta.getStorageClass(), is(BosClient.STORAGE_CLASS_STANDARD)); - } finally { - file.delete(); - } - } - - } - - public static class CopyObjectTest extends Base { - @Test - public void testSameBucket() throws IOException { - // this.client.putObject(this.bucketName, "test", "data"); - // this.client.copyObject(this.bucketName, "test", this.bucketName, "test1"); - - this.client.putObject(this.bucketName, "你好", "data"); - this.client.copyObject(this.bucketName, "你好", this.bucketName, "test1"); - - assertThat(new String(this.client.getObjectContent(this.bucketName, "test1")), is("data")); - } - - @Test - public void testETagMatch() throws IOException, NoSuchAlgorithmException { - String eTag = this.client.putObject(this.bucketName, "test", "data").getETag(); - CopyObjectRequest copyObjectRequest = - new CopyObjectRequest(this.bucketName, "test", this.bucketName, "test1"); - CopyObjectResponse response = this.client.copyObject(copyObjectRequest.withETag(eTag)); - assertThat(response.getETag(), is(Hex.encodeHexString(HashUtils.computeMd5Hash - (new ByteArrayInputStream("data".getBytes()))))); - assertThat(new String(this.client.getObjectContent(this.bucketName, "test")), is("data")); - } - - @Test - public void testETagNotMatch() { - this.expectBceServiceException(412, "PreconditionFailed"); - this.client.putObject(this.bucketName, "test", "data").getETag(); - CopyObjectRequest copyObjectRequest = - new CopyObjectRequest(this.bucketName, "test", this.bucketName, "test1"); - this.client.copyObject(copyObjectRequest.withETag("111111111183bf192b57a4afc76fa632")); - } - - @Test - public void testKeyWithSpecialChar() { - String sourceKey = " test/A=B/file "; - String eTag = this.client.putObject(this.bucketName, sourceKey, "data").getETag(); - CopyObjectRequest copyObjectRequest = - new CopyObjectRequest(this.bucketName, sourceKey, this.bucketName, " test/C=d/file1 "); - this.client.copyObject(copyObjectRequest.withETag(eTag)); - assertThat(new String(this.client.getObjectContent(this.bucketName, " test/C=d/file1 ")), is("data")); - } - - @Test - public void testSyncCopySuccess() { - this.client.putObject(this.bucketName, "test", "data").getETag(); - CopyObjectRequest req = new CopyObjectRequest(bucketName, "test", bucketName, "test1"); - req.withStorageClass(BosClient.STORAGE_CLASS_STANDARD_IA); - this.client.copyObject(req); - ObjectMetadata meta = this.client.getObjectMetadata(this.bucketName, "test1"); - assertThat(meta.getStorageClass(), is(BosClient.STORAGE_CLASS_STANDARD_IA)); - } - - @Test - public void testMetaReplace() throws Exception { - String sourceBucketName = this.bucketName; - String sourceKey = "testCopyObjectMetaCopySrc"; - String destinationBucketName = this.bucketName; - String destinationKey = "testCopyObjectMetaCopyDest"; - boolean excepted = false; - String userMetadataKeySrc = "meta-key-src"; - String userMetadataKeyDest = "meta-key-dest"; - String userMetadataValueSrc = "meta-value-src"; - String userMetadataValueDest = "meta-value-dest"; - String resultUserMetadataValueSrc = null; - String resultUserMetadataValueDest = null; - - try { - // Source Object With Metadata - ObjectMetadata objectMetadata = new ObjectMetadata(); - Map userMetadata = new HashMap(); - userMetadata.put(userMetadataKeySrc, userMetadataValueSrc); - objectMetadata.setUserMetadata(userMetadata); - PutObjectResponse putObjectResult = - this.client.putObject(this.bucketName, sourceKey, "value", objectMetadata); - - // Destination Object With NewMetadata - CopyObjectRequest copyObjectRequest = - new CopyObjectRequest(sourceBucketName, sourceKey, destinationBucketName, destinationKey); - ObjectMetadata objectNewMetadata = new ObjectMetadata(); - Map userNewMetadata = new HashMap(); - userNewMetadata.put(userMetadataKeyDest, userMetadataValueDest); - objectNewMetadata.setUserMetadata(userNewMetadata); - copyObjectRequest.withNewObjectMetadata(objectNewMetadata); - this.client.copyObject(copyObjectRequest); - - - resultUserMetadataValueSrc = - this.client.getObjectMetadata(bucketName, sourceKey).getUserMetadata() - .get(userMetadataKeySrc); -// userMetadataKeyDest = userMetadataKeyDest.toLowerCase(); - resultUserMetadataValueDest = - this.client.getObjectMetadata(bucketName, destinationKey).getUserMetadata() - .get(userMetadataKeyDest); - } catch (BceServiceException bse) { - excepted = true; - } catch (BceClientException bce) { - excepted = true; - } - Assert.assertFalse(excepted); - Assert.assertEquals(userMetadataValueSrc, resultUserMetadataValueSrc); - Assert.assertEquals(userMetadataValueDest, resultUserMetadataValueDest); - } - - @Test - public void testSourceKeyNotExist() { - this.expectBceServiceException(404, "NoSuchKey"); - this.client.copyObject(this.bucketName, "noSuchKey", this.bucketName, "dest"); - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.copyObject((CopyObjectRequest) null); - } - - @Test(expected = IllegalArgumentException.class) - public void testEmptyKey() { - this.client.copyObject(this.bucketName, "", this.bucketName, "test1"); - } - } - - public static class DeleteObjectTest extends Base { - @Test - public void testOrdinary() { - this.client.putObject(this.bucketName, "test", "data"); - this.client.deleteObject(this.bucketName, "test"); - assertThat(this.client.listObjects(this.bucketName).getContents(), empty()); - } - - @Test - public void testNoSuchKey() { - this.expectBceServiceException(404, "NoSuchKey"); - this.client.deleteObject(this.bucketName, "noSuchKey"); - } - - @Test(expected = IllegalArgumentException.class) - public void testEmptyKey() { - this.client.deleteObject(this.bucketName, ""); - } - } - - public static class InitiateMultipartUploadTest extends Base { - @Test - public void testOrdinary() { - InitiateMultipartUploadResponse response = this.client.initiateMultipartUpload(this.bucketName, "test"); - assertThat(response.getBucketName(), is(this.bucketName)); - assertThat(response.getKey(), is("test")); - String uploadId = response.getUploadId(); - List uploads = - this.client.listMultipartUploads(this.bucketName).getMultipartUploads(); - assertThat(uploads, hasSize(1)); - assertThat(uploads.get(0).getUploadId(), is(uploadId)); - } - } - - public static class UploadPartTest extends Base { - @Test - public void testOrdinary() { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - UploadPartResponse response = this.client.uploadPart(new UploadPartRequest().withBucketName(this.bucketName) - .withKey("test").withUploadId(uploadId).withPartNumber(1).withPartSize(4) - .withInputStream(new ByteArrayInputStream("data".getBytes()))); - assertThat(response.getPartNumber(), is(1)); - assertThat(response.getETag(), notNullValue()); - List parts = this.client.listParts(this.bucketName, "test", uploadId).getParts(); - assertThat(parts, hasSize(1)); - PartSummary part = parts.get(0); - assertThat(part, notNullValue()); - assertThat(part.getETag(), is(response.getETag())); - assertThat(part.getSize(), is(4L)); - } - - @Test - public void testNoSuchBucket() { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - // this.expectBceServiceException(404, "NoSuchUpload"); - this.expectBceServiceException(404, "NoSuchBucket"); - String base = "1234567890"; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < 1024 * 40; i++) { - sb.append(base); - } - String bucketName = "nosuchbucket" + DateTime.now().getMinuteOfDay(); - this.client.uploadPart(new UploadPartRequest().withBucketName(bucketName) - .withKey("test").withUploadId(uploadId).withPartNumber(1) - .withPartSize(sb.length()) - .withInputStream(new ByteArrayInputStream(sb.toString().getBytes()))); - } - - @Test - public void testNoSuchUpload() { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - this.client.abortMultipartUpload(this.bucketName, "test", uploadId); - this.expectBceServiceException(404, "NoSuchUpload"); - String base = "1234567890"; - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < 1024 * 40; i++) { - sb.append(base); - } - this.client.uploadPart(new UploadPartRequest().withBucketName(this.bucketName).withKey("test") - .withUploadId(uploadId).withPartNumber(1) - .withPartSize(sb.length()) - .withInputStream(new ByteArrayInputStream(sb.toString().getBytes()))); - } - - @Test(expected = IllegalArgumentException.class) - public void testPartNumberZero() throws IOException { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - this.client.uploadPart(new UploadPartRequest(this.bucketName, "test", uploadId, 0, 4, - new ByteArrayInputStream("data".getBytes()))); - } - - @Test - public void testPartNumber10000() { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - UploadPartResponse response = this.client - .uploadPart(new UploadPartRequest(this.bucketName, "test", uploadId, 10000, 4, - new ByteArrayInputStream("data".getBytes()))); - assertThat(response.getPartNumber(), is(10000)); - } - - @Test - public void testPartNumber10001() { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - this.expectBceServiceException(400, "InvalidArgument"); - this.client.uploadPart(new UploadPartRequest(this.bucketName, "test", uploadId, 10001, 4, - new ByteArrayInputStream("data".getBytes()))); - } - - @Test - public void testPartSizeLessThan5M() throws IOException, NoSuchAlgorithmException { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - UploadPartResponse uploadPartResponse = this.client - .uploadPart(new UploadPartRequest(this.bucketName, "test", uploadId, 1, 4, - new ByteArrayInputStream("data".getBytes()))); - List partETags = Lists.newArrayList(); - partETags.add(uploadPartResponse.getPartETag()); - assertThat(uploadPartResponse.getPartNumber(), is(1)); - assertThat(uploadPartResponse.getETag(), is(Hex.encodeHexString(HashUtils - .computeMd5Hash(new ByteArrayInputStream("data".getBytes()))))); - this.client.completeMultipartUpload(this.bucketName, "test", uploadId, partETags); - assertThat(this.client.getObjectContent(this.bucketName, "test"), is("data".getBytes())); - } - - @Test - public void testEntityTooSmall() throws IOException { - String objectKey = "partSize"; - String uploadId = this.client.initiateMultipartUpload(this.bucketName, objectKey).getUploadId(); - List partETags = new ArrayList(); - for (int i = 0; i < 2; i++) { - UploadPartRequest uploadPartRequest = - new UploadPartRequest(bucketName, objectKey, uploadId, i + 1, 4, - new ByteArrayInputStream("data".getBytes())); - UploadPartResponse uploadPartResult = client.uploadPart(uploadPartRequest); - partETags.add(uploadPartResult.getPartETag()); - } - - this.expectBceServiceException(400, "EntityTooSmall"); - this.client.completeMultipartUpload(this.bucketName, objectKey, uploadId, partETags); - } - - @Test - @Ignore - public void testPartSizeMoreThan5G() throws IOException { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - File file = createFile("test", 5 * 1024 * 1024 * 1024L + 1); - boolean excepted = false; - try { - UploadPartResponse response = this.client - .uploadPart(new UploadPartRequest(this.bucketName, "test", uploadId, 1, file.length(), - new FileInputStream(file))); - } catch (BceClientException bce) { - excepted = true; - } finally { - file.delete(); - } - assertThat(excepted, is(true)); - } - } - - public static class ListPartsTest extends Base { - - @Test - public void testOrdinary() { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - List eTags = Lists.newArrayList(); - for (int i = 0; i < 10; ++i) { - eTags.add(this.client.uploadPart(new UploadPartRequest(this.bucketName, "test", uploadId, i + 1, i, - new ByteArrayInputStream(Strings.repeat("v", i).getBytes()))).getETag()); - } - ListPartsResponse response = this.client.listParts(this.bucketName, "test", uploadId); - assertThat(response.getBucketName(), is(this.bucketName)); - assertThat(response.isTruncated(), is(false)); - assertThat(response.getKey(), is("test")); - assertThat(response.getMaxParts(), is(1000)); - assertThat(response.getNextPartNumberMarker(), is(10)); - assertThat(response.getOwner(), is(this.owner)); - assertThat(response.getPartNumberMarker(), is(0)); - assertThat(response.getUploadId(), is(uploadId)); - List parts = response.getParts(); - assertThat(parts, hasSize(10)); - for (int i = 0; i < 10; ++i) { - PartSummary part = parts.get(i); - assertThat(part.getETag(), is(eTags.get(i))); - assertThat(part.getPartNumber(), is(i + 1)); - assertThat(part.getSize(), is((long) i)); - assertThat(part.getLastModified(), is(TestUtils.timeGapInSecondsLessThan(this.createTime, 30))); - } - } - - @Test - public void testMaxParts() { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - List eTags = Lists.newArrayList(); - for (int i = 0; i < 10; ++i) { - eTags.add(this.client.uploadPart(new UploadPartRequest(this.bucketName, "test", uploadId, i + 1, i, - new ByteArrayInputStream(Strings.repeat("v", i).getBytes()))).getETag()); - } - ListPartsResponse response = - this.client.listParts(new ListPartsRequest(this.bucketName, "test", uploadId).withMaxParts(3)); - assertThat(response.getBucketName(), is(this.bucketName)); - assertThat(response.isTruncated(), is(true)); - assertThat(response.getKey(), is("test")); - assertThat(response.getMaxParts(), is(3)); - assertThat(response.getNextPartNumberMarker(), is(3)); - assertThat(response.getOwner(), is(this.owner)); - assertThat(response.getPartNumberMarker(), is(0)); - assertThat(response.getUploadId(), is(uploadId)); - List parts = response.getParts(); - assertThat(parts, hasSize(3)); - for (int i = 0; i < 3; ++i) { - PartSummary part = parts.get(i); - assertThat(part.getETag(), is(eTags.get(i))); - assertThat(part.getPartNumber(), is(i + 1)); - assertThat(part.getSize(), is((long) i)); - assertThat(part.getLastModified(), is(TestUtils.timeGapInSecondsLessThan(this.createTime, 30))); - } - } - - @Test - public void testPartNumberMarker() { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "test").getUploadId(); - List eTags = Lists.newArrayList(); - for (int i = 0; i < 10; ++i) { - eTags.add(this.client.uploadPart(new UploadPartRequest(this.bucketName, "test", uploadId, i + 1, i, - new ByteArrayInputStream(Strings.repeat("v", i).getBytes()))).getETag()); - } - ListPartsResponse response = this.client.listParts( - new ListPartsRequest(this.bucketName, "test", uploadId).withPartNumberMarker(3)); - assertThat(response.getBucketName(), is(this.bucketName)); - assertThat(response.isTruncated(), is(false)); - assertThat(response.getKey(), is("test")); - assertThat(response.getMaxParts(), is(1000)); - assertThat(response.getNextPartNumberMarker(), is(10)); - assertThat(response.getOwner(), is(this.owner)); - assertThat(response.getPartNumberMarker(), is(3)); - assertThat(response.getUploadId(), is(uploadId)); - List parts = response.getParts(); - assertThat(parts, hasSize(7)); - for (int i = 0; i < 7; ++i) { - PartSummary part = parts.get(i); - assertThat(part.getETag(), is(eTags.get(i + 3))); - assertThat(part.getPartNumber(), is(i + 1 + 3)); - assertThat(part.getSize(), is((long) (i + 3))); - assertThat(part.getLastModified(), is(TestUtils.timeGapInSecondsLessThan(this.createTime, 30))); - } - } - } - - public static class CompleteMultipartUploadTest extends Base { - @Test - public void testOrdinary() { - ObjectMetadata objectMetadata = new ObjectMetadata(); - objectMetadata.setContentType("text/plain"); - InitiateMultipartUploadRequest initRequest = new InitiateMultipartUploadRequest - (this.bucketName, "test").withMetadata(objectMetadata); - String uploadId = this.client.initiateMultipartUpload(initRequest).getUploadId(); - List partETags = Lists.newArrayList(); - for (int i = 0; i < 1; ++i) { - int size = i + 5 * 1024 * 1024; - String eTag = this.client.uploadPart( - new UploadPartRequest(this.bucketName, "test", uploadId, i + 1, size, - new ByteArrayInputStream(Strings.repeat("v", size).getBytes()))).getETag(); - partETags.add(new PartETag(i + 1, eTag)); - } - objectMetadata = new ObjectMetadata(); - Map userMetadata = new HashMap(); - userMetadata.put("meta-key", "meta-value"); - objectMetadata.setUserMetadata(userMetadata); - objectMetadata.setContentType("text/json"); - CompleteMultipartUploadRequest request = - new CompleteMultipartUploadRequest().withBucketName(this.bucketName).withKey("test") - .withUploadId(uploadId).withPartETags(partETags).withObjectMetadata(objectMetadata); - CompleteMultipartUploadResponse response = this.client.completeMultipartUpload(request); - assertThat(response.getBucketName(), is(this.bucketName)); - assertThat(response.getKey(), is("test")); - assertThat(response.getETag(), notNullValue()); - assertThat(response.getLocation(), notNullValue()); - ObjectMetadata metadata = this.client.getObjectMetadata(bucketName, "test"); - assertThat(metadata.getContentType(), is("text/plain")); -// String resultUserMeta = metadata.getUserMetadata().get("metaKey".toLowerCase()); - String resultUserMeta = metadata.getUserMetadata().get("meta-key"); - - assertThat(resultUserMeta, is("meta-value")); - } - - @Test - public void TestMultiUploadWithStorageClass() throws IOException { - String storageClass = "STANDARD"; - String objectName = "test"; - List parts = new ArrayList(); - byte[] part1 = new byte[5 * 1024 * 1024]; - for (int i = 0; i < part1.length; ++i) { - part1[i] = (byte) (i & 0xff); - } - byte[] part2 = new byte[5 * 1024 * 1024]; - for (int i = 0; i < part2.length; ++i) { - part2[i] = (byte) (i & 0xff); - } - byte[] part3 = new byte[1023]; - for (int i = 0; i < part3.length; ++i) { - part3[i] = (byte) (i & 0xff); - } - parts.add(part1); - parts.add(part2); - parts.add(part3); - InitiateMultipartUploadRequest iniReq = null; - iniReq = new InitiateMultipartUploadRequest(bucketName, objectName).withStorageClass(storageClass); - - InitiateMultipartUploadResponse iniRes = client.initiateMultipartUpload(iniReq); - String uploadId = iniRes.getUploadId(); - for (int i = 0; i < parts.size(); ++i) { - UploadPartRequest req = new UploadPartRequest(); - req.setBucketName(bucketName); - req.setPartNumber(i + 1); - req.setKey(objectName); - req.setUploadId(uploadId); - InputStream input = new ByteArrayInputStream(parts.get(i)); - req.setInputStream(input); - req.setPartSize(input.available()); - client.uploadPart(req); - } - ListPartsResponse res = client.listParts(bucketName, objectName, uploadId); - assertThat(storageClass, is(res.getStorageClass())); - List partETags = new ArrayList(); - for (PartSummary each : res.getParts()) { - PartETag tmp = new PartETag(); - tmp.setETag(each.getETag()); - tmp.setPartNumber(each.getPartNumber()); - partETags.add(tmp); - } - client.completeMultipartUpload(bucketName, objectName, uploadId, partETags); - ObjectMetadata meta = client.getObjectMetadata(bucketName, objectName); - assertThat(storageClass, is(meta.getStorageClass())); - } - - @Test - public void TestMultiUploadWithStorageClassIA() throws IOException { - String storageClass = "STANDARD_IA"; - String objectName = "test"; - List parts = new ArrayList(); - byte[] part1 = new byte[5 * 1024 * 1024]; - for (int i = 0; i < part1.length; ++i) { - part1[i] = (byte) (i & 0xff); - } - byte[] part2 = new byte[5 * 1024 * 1024]; - for (int i = 0; i < part2.length; ++i) { - part2[i] = (byte) (i & 0xff); - } - byte[] part3 = new byte[1023]; - for (int i = 0; i < part3.length; ++i) { - part3[i] = (byte) (i & 0xff); - } - parts.add(part1); - parts.add(part2); - parts.add(part3); - InitiateMultipartUploadRequest iniReq = null; - iniReq = new InitiateMultipartUploadRequest(bucketName, objectName).withStorageClass(storageClass); - - InitiateMultipartUploadResponse iniRes = client.initiateMultipartUpload(iniReq); - String uploadId = iniRes.getUploadId(); - for (int i = 0; i < parts.size(); ++i) { - UploadPartRequest req = new UploadPartRequest(); - req.setBucketName(bucketName); - req.setPartNumber(i + 1); - req.setKey(objectName); - req.setUploadId(uploadId); - InputStream input = new ByteArrayInputStream(parts.get(i)); - req.setInputStream(input); - req.setPartSize(input.available()); - client.uploadPart(req); - } - ListPartsResponse res = client.listParts(bucketName, objectName, uploadId); - assertThat(storageClass, is(res.getStorageClass())); - List partETags = new ArrayList(); - for (PartSummary each : res.getParts()) { - PartETag tmp = new PartETag(); - tmp.setETag(each.getETag()); - tmp.setPartNumber(each.getPartNumber()); - partETags.add(tmp); - } - client.completeMultipartUpload(bucketName, objectName, uploadId, partETags); - ObjectMetadata meta = client.getObjectMetadata(bucketName, objectName); - assertThat(storageClass, is(meta.getStorageClass())); - } - } - - public static class AbortMultipartUploadTest extends Base { - @Test - public void testOrdinary() { - String uploadId = this.client.initiateMultipartUpload(this.bucketName, "abortMultipartTest").getUploadId(); - for (int i = 0; i < 10; ++i) { - this.client.uploadPart(new UploadPartRequest(this.bucketName, "abortMultipartTest", uploadId, i + 1, i, - new ByteArrayInputStream(Strings.repeat("v", i).getBytes()))).getETag(); - } - List uploads = - this.client.listMultipartUploads(this.bucketName).getMultipartUploads(); - this.client.abortMultipartUpload(this.bucketName, "abortMultipartTest", uploadId); - uploads = this.client.listMultipartUploads(this.bucketName).getMultipartUploads(); - assertThat(uploads, hasSize(0)); - } - } - - @Ignore - public static class ListMultipartUploadsBase extends Base { - protected SortedMap expectedUploadsId; - protected List expectedCommonPrefixes; - protected String expectedDelimiter; - protected String expectedKeyMarker; - protected String expectedNextKeyMarker; - protected boolean expectedTruncated; - protected int expectedMaxUploads; - protected String expectedPrefix; - - @Override - @Before - public void setUp() { - super.setUp(); - this.expectedUploadsId = Maps.newTreeMap(); - this.expectedUploadsId.put("dir0/dir1/key0", ""); - this.expectedUploadsId.put("dir0/key0", ""); - this.expectedUploadsId.put("dir0/key1", ""); - this.expectedUploadsId.put("dir1/dir2/key1", ""); - this.expectedUploadsId.put("dir1/dir2/key2", ""); - this.expectedUploadsId.put("dir1/key0", ""); - this.expectedUploadsId.put("dir3/key0", ""); - this.expectedUploadsId.put("dir3/key1", ""); - this.expectedUploadsId.put("key", ""); - for (Map.Entry entry : this.expectedUploadsId.entrySet()) { - this.expectedUploadsId.put(entry.getKey(), - this.client.initiateMultipartUpload(this.bucketName, entry.getKey()).getUploadId()); - } - this.expectedCommonPrefixes = null; - this.expectedDelimiter = null; - this.expectedKeyMarker = ""; - this.expectedNextKeyMarker = null; - this.expectedTruncated = false; - this.expectedPrefix = ""; - this.expectedMaxUploads = 1000; - } - - protected void checkResponse(ListMultipartUploadsResponse response) { - assertThat(response, hasProperty("bucketName", is(this.bucketName))); - assertThat(response, hasProperty("commonPrefixes", is(this.expectedCommonPrefixes))); - assertThat(response, hasProperty("keyMarker", is(this.expectedKeyMarker))); -// assertThat(response, hasProperty("nextKeyMarker", is(this.expectedNextKeyMarker))); - assertThat(response, hasProperty("delimiter", is(this.expectedDelimiter))); - assertThat(response, hasProperty("truncated", is(this.expectedTruncated))); - assertThat(response, hasProperty("maxUploads", is(this.expectedMaxUploads))); - assertThat(response, hasProperty("prefix", is(this.expectedPrefix))); - List multipartUploadSummaries = response.getMultipartUploads(); - assertThat(multipartUploadSummaries, hasSize(this.expectedUploadsId.size())); - Iterator it = multipartUploadSummaries.iterator(); - for (Map.Entry entry : this.expectedUploadsId.entrySet()) { - MultipartUploadSummary multipartUploadSummary = it.next(); - assertThat(multipartUploadSummary, hasProperty("key", is(entry.getKey()))); - assertThat(multipartUploadSummary, hasProperty("owner", is(this.owner))); - assertThat(multipartUploadSummary, hasProperty("uploadId", is(entry.getValue()))); - assertThat(multipartUploadSummary, - hasProperty("initiated", TestUtils.timeGapInSecondsLessThan(this.createTime, 30))); - } - } - } - - public static class ListMultipartUploadsTest extends ListMultipartUploadsBase { - @Test - public void testOrdinary() { - this.checkResponse(this.client.listMultipartUploads(this.bucketName)); - } - - @Test - public void testPrefix() { - this.expectedUploadsId.remove("key"); - this.expectedPrefix = "d"; - this.checkResponse(this.client.listMultipartUploads(new ListMultipartUploadsRequest(this.bucketName) - .withPrefix("d"))); - } - - @Test - public void testKeyMarker() { - this.expectedUploadsId = this.expectedUploadsId.subMap("dir1", "z"); - this.expectedKeyMarker = "dir1"; - this.checkResponse(this.client.listMultipartUploads(new ListMultipartUploadsRequest(this.bucketName) - .withKeyMarker("dir1"))); - } - - @Test - public void testDelimiter() { - String tempUploadId = this.expectedUploadsId.get("dir0/key0"); - this.expectedUploadsId.clear(); - this.expectedUploadsId.put("dir0/key0", tempUploadId); - - this.expectedCommonPrefixes = Lists.newArrayList(); - this.expectedCommonPrefixes.add("dir0/dir1/"); - this.expectedDelimiter = "/"; - this.expectedMaxUploads = 2; - this.expectedTruncated = true; - this.expectedNextKeyMarker = "dir0/key0"; - this.expectedPrefix = "dir0/"; - this.checkResponse( - this.client.listMultipartUploads( - new ListMultipartUploadsRequest( - this.bucketName, "dir0/").withDelimiter("/").withMaxUploads(2))); - - } - - @Test - public void testMaxUploads() { - this.expectedUploadsId = this.expectedUploadsId.subMap("dir0", "dir1/dir2/key1"); - this.expectedTruncated = true; - this.expectedMaxUploads = 3; - this.checkResponse(this.client.listMultipartUploads(new ListMultipartUploadsRequest(this.bucketName) - .withMaxUploads(3))); - } - - @Test - public void testNegativeMaxUploads() { - this.checkResponse(this.client.listMultipartUploads(new ListMultipartUploadsRequest(this.bucketName) - .withMaxUploads(-1))); - } - - @Test - public void testCombination() { - this.expectedUploadsId = this.expectedUploadsId.subMap("dir1", "dir3/key0"); - this.expectedTruncated = true; - this.expectedKeyMarker = "dir1"; - this.expectedMaxUploads = 3; - this.expectedPrefix = "d"; - this.checkResponse(this.client.listMultipartUploads(new ListMultipartUploadsRequest(this.bucketName) - .withPrefix("d").withKeyMarker("dir1").withMaxUploads(3))); - } - - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.listMultipartUploads((ListMultipartUploadsRequest) null); - } - } - - @Ignore - public static class GeneratePresignedUrlBase extends Base { - protected SortedMap expectedContents; - protected List expectedCommonPrefixes; - protected String expectedDelimiter; - protected String expectedMarker; - protected String expectedNextMarker; - protected boolean expectedTruncated; - protected int expectedMaxKeys; - protected String expectedPrefix; - - @Override - @Before - public void setUp() { - super.setUp(); - this.expectedContents = Maps.newTreeMap(); - this.expectedContents.put("dir0/dir1/key0", Strings.repeat("v", 1)); - this.expectedContents.put("dir0/key0", Strings.repeat("v", 2)); - this.expectedContents.put("dir0/key1", Strings.repeat("v", 3)); - this.expectedContents.put("dir1/dir2/key1", Strings.repeat("v", 4)); - this.expectedContents.put("dir1/dir2/key2", Strings.repeat("v", 5)); - this.expectedContents.put("dir1/key0", Strings.repeat("v", 6)); - this.expectedContents.put("dir3/key0", Strings.repeat("v", 7)); - this.expectedContents.put("dir3/key1", Strings.repeat("v", 8)); - this.expectedContents.put("dir4/key0", Strings.repeat("v", 9)); - this.expectedContents.put("key", Strings.repeat("v", 10)); - - for (Map.Entry entry : this.expectedContents.entrySet()) { - this.client.putObject(this.bucketName, entry.getKey(), entry.getValue()); - } - this.expectedCommonPrefixes = null; - this.expectedDelimiter = null; - this.expectedMarker = ""; - this.expectedNextMarker = null; - this.expectedTruncated = false; - this.expectedPrefix = ""; - this.expectedMaxKeys = 1000; - } - - protected void checkResponse(ListObjectsResponse response) { - assertThat(response, hasProperty("bucketName", is(this.bucketName))); - assertThat(response, hasProperty("commonPrefixes", is(this.expectedCommonPrefixes))); - assertThat(response, hasProperty("delimiter", is(this.expectedDelimiter))); - assertThat(response, hasProperty("marker", is(this.expectedMarker))); -// assertThat(response, hasProperty("nextMarker", is(this.expectedNextMarker))); - assertThat(response, hasProperty("truncated", is(this.expectedTruncated))); - assertThat(response, hasProperty("maxKeys", is(this.expectedMaxKeys))); - assertThat(response, hasProperty("prefix", is(this.expectedPrefix))); - List objects = response.getContents(); - assertThat(objects, hasSize(this.expectedContents.size())); - Iterator it = objects.iterator(); - for (Map.Entry entry : this.expectedContents.entrySet()) { - BosObjectSummary object = it.next(); - assertThat(object, hasProperty("key", is(entry.getKey()))); - assertThat(object, hasProperty("owner", is(this.owner))); - assertThat(object, hasProperty("size", is((long) entry.getValue().length()))); - assertThat(object, - hasProperty("lastModified", TestUtils.timeGapInSecondsLessThan(this.createTime, 30))); - try { - assertThat(object, hasProperty("ETag", is(Hex.encodeHexString(HashUtils - .computeMd5Hash(new ByteArrayInputStream(entry.getValue().getBytes())))))); - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public static class GeneratePresignedUrlTest extends GeneratePresignedUrlBase { - @Test(expected = NullPointerException.class) - public void testNullRequest() { - this.client.generatePresignedUrl((GeneratePresignedUrlRequest) null); - } - - @Test - public void testOrdinary() { - String objectKey = "test"; - String value = "value1" + "\n" + "value2"; - this.client.putObject(this.bucketName, objectKey, value); - GeneratePresignedUrlRequest request = - new GeneratePresignedUrlRequest(this.bucketName, objectKey, HttpMethodName.GET); - request.setResponseHeaders(new ResponseHeaderOverrides()); - request.setExpiration(1800); - URL url = this.client.generatePresignedUrl(request); - BufferedReader bufferedReader = null; - try { - HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); - urlConnection.setRequestMethod("GET"); - bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); - StringBuilder result = new StringBuilder(); - String inputLine; - if ((inputLine = bufferedReader.readLine()) != null) { - result.append(inputLine); - while ((inputLine = bufferedReader.readLine()) != null) { - result.append("\n" + inputLine); - } - } - assertThat(result.toString(), is(value)); - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - @Test - public void testPutBucketAcl() { - List grants = new ArrayList(); - List grantee = new ArrayList(); - grantee.add(this.grantee); - List permission = new ArrayList(); - permission.add(Permission.FULL_CONTROL); - grants.add(new Grant(grantee, permission)); - for (Grant grant : grants) { - assertThat(this.client.getBucketAcl(this.bucketName).getAccessControlList(), - hasItem(new SamePropertyValuesAs(grant))); - } - GeneratePresignedUrlRequest request = - new GeneratePresignedUrlRequest(this.bucketName, null, HttpMethodName.PUT); - request.addRequestParameter("acl", null); - request.addRequestHeaders("x-bce-acl", "public-read-write"); - request.setExpiration(1800); - URL url = this.client.generatePresignedUrl(request); - BufferedReader bufferedReader = null; - try { - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setDoInput(true); - connection.setDoOutput(true); - connection.setRequestMethod("PUT"); - connection.setRequestProperty("x-bce-acl", "public-read-write"); - connection.connect(); - bufferedReader = new BufferedReader(new InputStreamReader(connection.getInputStream())); - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - List expectedGrants = new ArrayList(); - List granteeOwner = new ArrayList(); - granteeOwner.add(this.grantee); - List permissionOwner = new ArrayList(); - permissionOwner.add(Permission.FULL_CONTROL); - expectedGrants.add(new Grant(granteeOwner, permissionOwner)); - List granteeAnonymous = new ArrayList(); - granteeAnonymous.add(this.anonymous); - List permissionAnonymous = new ArrayList(); - permissionAnonymous.add(Permission.READ); - permissionAnonymous.add(Permission.WRITE); - expectedGrants.add(new Grant(granteeAnonymous, permissionAnonymous)); - GetBucketAclResponse response = this.client.getBucketAcl(this.bucketName); - assertThat(response.getAccessControlList(), hasSize(expectedGrants.size())); - for (Grant grant : grants) { - assertThat(response.getAccessControlList(), hasItem(new SamePropertyValuesAs(grant))); - } - - } - - @Test - public void testListMultipart() { - String objectKey = "test"; - this.client.initiateMultipartUpload(this.bucketName, objectKey); - GeneratePresignedUrlRequest request = - new GeneratePresignedUrlRequest(bucketName, null, HttpMethodName.PUT); - request.addRequestParameter("uploads", null); - request.setExpiration(1800); - URL url = this.client.generatePresignedUrl(request); - BufferedReader bufferedReader = null; - try { - URLConnection urlConnection = url.openConnection(); - bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); - String inputLine; - if ((inputLine = bufferedReader.readLine()) != null) { - ListMultipartUploadsResponse response = - JsonUtils.fromJsonString(inputLine, ListMultipartUploadsResponse.class); - } - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - @Test - public void testParameter() { - this.expectedContents = this.expectedContents.subMap("dir1", "dir3/key0"); - this.expectedTruncated = true; - this.expectedMarker = "dir1"; - this.expectedMaxKeys = 3; - this.expectedPrefix = "d"; - - GeneratePresignedUrlRequest request = - new GeneratePresignedUrlRequest(this.bucketName, null, HttpMethodName.GET); - request.addRequestParameter("maxKeys", "3"); - request.addRequestParameter("prefix", "d"); - request.addRequestParameter("marker", "dir1"); - URL url = this.client.generatePresignedUrl(request); - BufferedReader bufferedReader = null; - try { - URLConnection urlConnection = url.openConnection(); - bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); - String inputLine; - if ((inputLine = bufferedReader.readLine()) != null) { - ListObjectsResponse response = JsonUtils.fromJsonString(inputLine, ListObjectsResponse.class); - this.checkResponse(response); - } - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - @Test - public void testResponseOverrides() { - String bucketName = this.bucketName + "-other"; - String objectKey = "test"; - String value = "value" + System.currentTimeMillis(); - this.client.createBucket(bucketName); - this.client.putObject(bucketName, objectKey, value); - GeneratePresignedUrlRequest request = - new GeneratePresignedUrlRequest(bucketName, objectKey, HttpMethodName.GET); - request.setResponseHeaders( - new ResponseHeaderOverrides().withContentDisposition("attachment;filename=name.txt") - .withCacheControl("no-cache").withContentEncoding("utf-8") - .withContentLanguage("zh-CN").withContentType("text/plain").withExpires("1")); - URL url = this.client.generatePresignedUrl(request); - BufferedReader bufferedReader = null; - try { - URLConnection urlConnection = url.openConnection(); - bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); - String inputLine; - if ((inputLine = bufferedReader.readLine()) != null) { - assertThat(inputLine, is(value)); - } - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - this.client.deleteObject(bucketName, objectKey); - this.client.deleteBucket(bucketName); - } - - @Test - public void testPublicRead() throws IOException, NoSuchAlgorithmException { - String objectKey = "test"; - String value = "value" + System.currentTimeMillis(); - this.client.putObject(this.bucketName, objectKey, value); - this.client.setBucketAcl(this.bucketName, CannedAccessControlList.PublicRead); - BosClient bosAnonymous = new BosClient(new BosClientConfiguration().withEndpoint(ENDPOINT)); - GeneratePresignedUrlRequest request = new GeneratePresignedUrlRequest(this.bucketName, objectKey); - request.setExpiration(300); - request.setContentType("text/plain"); - request.setContentMd5(Hex.encodeHexString(HashUtils - .computeMd5Hash(new ByteArrayInputStream(value.getBytes())))); - URL url = bosAnonymous.generatePresignedUrl(request); - BufferedReader bufferedReader = null; - try { - URLConnection urlConnection = url.openConnection(); - bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); - String inputLine; - if ((inputLine = bufferedReader.readLine()) != null) { - assertThat(inputLine, is(value)); - } - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - } - - private static File createFile(String fileName, long length) throws IOException { - File file = new File(fileName); - RandomAccessFile r = null; - try { - r = new RandomAccessFile(file, "rw"); - r.setLength(length); - } finally { - if (r != null) { - try { - r.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return file; - } - -} diff --git a/src/test/java/com/baidubce/services/doc/AbstractDocTest.java b/src/test/java/com/baidubce/services/doc/AbstractDocTest.java deleted file mode 100755 index 302d0098..00000000 --- a/src/test/java/com/baidubce/services/doc/AbstractDocTest.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.baidubce.services.doc; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; - - -public abstract class AbstractDocTest { - - static final String DOC_END_POINT = "http://doc.bce-testinternal.baidu.com"; - - // Linqing's account - static String AK = "6107180b80ae42c0a821a5fe53ba615e"; - static String SK = "a88ed698c0fd4774a4f1bdcebcae5922"; - - protected DocClient docClient; - - protected String mediaId; - - public void setUp() throws Exception { - DefaultBceCredentials cred = new DefaultBceCredentials(AK, SK); - - BceClientConfiguration docConfig = - new BceClientConfiguration().withCredentials(cred).withEndpoint(DOC_END_POINT); - - - docClient = new DocClient(docConfig); - - } - -} diff --git a/src/test/java/com/baidubce/services/doc/ut/CreateDocumentTest.java b/src/test/java/com/baidubce/services/doc/ut/CreateDocumentTest.java deleted file mode 100755 index 7903272c..00000000 --- a/src/test/java/com/baidubce/services/doc/ut/CreateDocumentTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baidubce.services.doc.ut; - -import com.baidubce.services.doc.model.CreateDocumentResponse; -import com.baidubce.services.doc.AbstractDocTest; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.io.File; -import java.io.FileNotFoundException; - -public class CreateDocumentTest extends AbstractDocTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void uploadSmallFileTest() throws FileNotFoundException { - File file = new File("/Users/baidu/Downloads/Python代码编码和vim工具配置.pptx"); - String title = "Python代码编码和vim工具配置"; - CreateDocumentResponse response = docClient.createDocument(file, title); - String docId = response.getDocumentId(); - System.out.println("docId = " + docId); - } - - @Test - public void createPrivateDocumentTest() throws FileNotFoundException { - File file = new File("/Users/baidu/Downloads/Python代码编码和vim工具配置.pptx"); - String title = "Python代码编码和vim工具配置"; - CreateDocumentResponse response = docClient.createDocument(file, title, "pptx", null, "PRIVATE"); - String docId = response.getDocumentId(); - System.out.println("docId = " + docId); - } - - -} diff --git a/src/test/java/com/baidubce/services/doc/ut/CreateNotificationTest.java b/src/test/java/com/baidubce/services/doc/ut/CreateNotificationTest.java deleted file mode 100755 index 58efaacc..00000000 --- a/src/test/java/com/baidubce/services/doc/ut/CreateNotificationTest.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.baidubce.services.doc.ut; - -import com.baidubce.services.doc.AbstractDocTest; -import com.baidubce.services.doc.model.CreateNotificationResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.io.FileNotFoundException; - -public class CreateNotificationTest extends AbstractDocTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void createNotificationTest() throws FileNotFoundException { - String url = "http://www.baidu.com"; - String title = "testnotification"; - CreateNotificationResponse response = docClient.createNotification(title, url); - System.out.println(response.toString()); - } - - -} diff --git a/src/test/java/com/baidubce/services/doc/ut/GetDocumentTest.java b/src/test/java/com/baidubce/services/doc/ut/GetDocumentTest.java deleted file mode 100755 index 11c05e8d..00000000 --- a/src/test/java/com/baidubce/services/doc/ut/GetDocumentTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baidubce.services.doc.ut; - -import com.baidubce.services.doc.AbstractDocTest; -import com.baidubce.services.doc.model.GetDocumentResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - - -public class GetDocumentTest extends AbstractDocTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void getDocumentTest() { - String docId = "doc-ginrck7f8uwbumv"; - GetDocumentResponse response = docClient.getDocument(docId); - System.out.println(response.toString()); - } - - -} diff --git a/src/test/java/com/baidubce/services/doc/ut/GetNotificationTest.java b/src/test/java/com/baidubce/services/doc/ut/GetNotificationTest.java deleted file mode 100755 index a9f8e348..00000000 --- a/src/test/java/com/baidubce/services/doc/ut/GetNotificationTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baidubce.services.doc.ut; - -import com.baidubce.services.doc.AbstractDocTest; -import com.baidubce.services.doc.model.GetNotificationResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class GetNotificationTest extends AbstractDocTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void getNotificationTest() { - String name = "testnotification"; - - GetNotificationResponse response = docClient.getNotification(name); - System.out.println(response.toString()); - } - - -} diff --git a/src/test/java/com/baidubce/services/doc/ut/ListDocumentTest.java b/src/test/java/com/baidubce/services/doc/ut/ListDocumentTest.java deleted file mode 100755 index 3671f682..00000000 --- a/src/test/java/com/baidubce/services/doc/ut/ListDocumentTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baidubce.services.doc.ut; - -import com.baidubce.services.doc.AbstractDocTest; -import com.baidubce.services.doc.model.ListDocumentsResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ListDocumentTest extends AbstractDocTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void listDocumentTest() { - ListDocumentsResponse response = docClient.listDocuments(); - System.out.println(response.toString()); - } - - -} diff --git a/src/test/java/com/baidubce/services/doc/ut/ListNotificationTest.java b/src/test/java/com/baidubce/services/doc/ut/ListNotificationTest.java deleted file mode 100755 index d6168e02..00000000 --- a/src/test/java/com/baidubce/services/doc/ut/ListNotificationTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baidubce.services.doc.ut; - -import com.baidubce.services.doc.AbstractDocTest; -import com.baidubce.services.doc.model.ListNotificationsResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ListNotificationTest extends AbstractDocTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void listNotificationTest() { - ListNotificationsResponse response = docClient.listNotifications(); - System.out.println(response.toString()); - } - - -} diff --git a/src/test/java/com/baidubce/services/doc/ut/ReadDocumentTest.java b/src/test/java/com/baidubce/services/doc/ut/ReadDocumentTest.java deleted file mode 100755 index 2b618e5f..00000000 --- a/src/test/java/com/baidubce/services/doc/ut/ReadDocumentTest.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.baidubce.services.doc.ut; - -import com.baidubce.services.doc.AbstractDocTest; -import com.baidubce.services.doc.model.ReadDocumentResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -public class ReadDocumentTest extends AbstractDocTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void readDocumentTest() { - String docId = "doc-ggesvh5y6v45mnv"; - ReadDocumentResponse response = docClient.readDocument(docId); - System.out.println(response.toString()); - } - - @Test - public void readDocumentWithExpiredTimeTest() { - String docId = "doc-ginrck7f8uwbumv"; - ReadDocumentResponse response = docClient.readDocument(docId, 60); - System.out.println(response.toString()); - } - - -} diff --git a/src/test/java/com/baidubce/services/iotdm/IotDmClientTest.java b/src/test/java/com/baidubce/services/iotdm/IotDmClientTest.java deleted file mode 100755 index 80572101..00000000 --- a/src/test/java/com/baidubce/services/iotdm/IotDmClientTest.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright 2016 Baidu, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.services.iotdm; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.notNullValue; -import static org.hamcrest.Matchers.nullValue; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; - -import java.util.Arrays; -import java.util.List; -import java.util.UUID; - -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.iotdm.model.CreateDevicesRequest; -import com.baidubce.services.iotdm.model.CreateDevicesResponse; -import com.baidubce.services.iotdm.model.CreateGroupRequest; -import com.baidubce.services.iotdm.model.DeviceAccessDetail; -import com.baidubce.services.iotdm.model.DeviceOperation; -import com.baidubce.services.iotdm.model.DeviceOperationRequest; -import com.baidubce.services.iotdm.model.DeviceProfileResponse; -import com.baidubce.services.iotdm.model.DeviceQueryRequest; -import com.baidubce.services.iotdm.model.DeviceQueryResponse; -import com.baidubce.services.iotdm.model.GroupInfoResponse; -import com.baidubce.services.iotdm.model.GroupListResponse; -import com.baidubce.services.iotdm.model.Page; -import com.baidubce.services.iotdm.model.RemoveDevicesRequest; -import com.baidubce.services.iotdm.model.UpdateDeviceProfileRequest; -import com.baidubce.services.iotdm.model.UpdateDeviceRegistryRequest; -import com.baidubce.services.iotdm.model.UpdateGroupRequest; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -/** - * Unit test for iot device management client. - */ -public class IotDmClientTest { - - // qa-sandbox - private static final String ACCESSKEY = "30dce1fd5b584210905fe8ef3042bc46"; - private static final String SECRETKEY = "51dfc469a93249d88b36be3249412a2a"; - private static final String ENDPOINT = "10.73.203.34:8010"; - - private static final String TEST_DEVICE_NAME = "my_test_device"; - private static final String TEST_GROUP_NAME = "my_test_group"; - - private IotDmClient client; - - @Before - public void setUp() { - BceClientConfiguration config = new BceClientConfiguration() - .withCredentials(new DefaultBceCredentials(ACCESSKEY, SECRETKEY)) - .withEndpoint(ENDPOINT); - client = new IotDmClient(config); - } - - @Test - public void testCreateDevices() { - clean(); - CreateDevicesResponse response = createDevices(2, false, null); - assertThat(response.getAmount(), equalTo(2)); - assertThat(response.getDevices().size(), equalTo(2)); - assertThat(response.getThings(), nullValue()); - clean(); - } - - @Test - public void testCreateDevicesWithThing() { - clean(); - CreateDevicesResponse response = createDevices(1, true, Arrays.asList(TEST_DEVICE_NAME)); - assertThat(response.getAmount(), equalTo(1)); - assertThat(response.getDevices().size(), equalTo(1)); - assertThat(response.getThings().size(), equalTo(1)); - removeDevcies(Arrays.asList(TEST_DEVICE_NAME), true); - - DeviceQueryResponse deviceQueryResponse = client.getDeviceProfiles(new DeviceQueryRequest() - .withCondition("{}") - .withPage(new Page())); - assertThat(deviceQueryResponse.getAmount(), equalTo(0)); - } - - @Test - public void testGetDeviceProfile() { - clean(); - createDevices(1, false, Arrays.asList(TEST_DEVICE_NAME)); - DeviceProfileResponse response = client.getDeviceProfile(TEST_DEVICE_NAME); - assertThat(response.getName(), equalTo(TEST_DEVICE_NAME)); - assertThat(response.getId(), notNullValue()); - assertThat(response.isEnable(), equalTo(true)); - clean(); - } - - @Test - public void testGetDeviceProfiles() { - clean(); - createDevices(3, false, null); - DeviceQueryResponse response = client.getDeviceProfiles(new DeviceQueryRequest().withCondition("{}")); - assertThat(response.getAmount(), equalTo(3)); - assertThat(response.getDeviceProfiles().size(), equalTo(3)); - clean(); - } - - @Test - public void testGetDeviceAccessDetail() { - clean(); - createDevices(1, false, Arrays.asList(TEST_DEVICE_NAME)); - DeviceAccessDetail detail = client.getDeviceAccessDetail(TEST_DEVICE_NAME); - assertThat(detail.getProtocol(), equalTo("mqtt")); - assertThat(detail.getDeviceName(), equalTo(TEST_DEVICE_NAME)); - clean(); - } - - @Test - public void testUpdateDeviceProfile() { - clean(); - createDevices(1, false, Arrays.asList(TEST_DEVICE_NAME)); - ObjectNode attributes = new ObjectMapper().createObjectNode(); - attributes.put("test", "123"); - client.updateDeviceProfile(new UpdateDeviceProfileRequest() - .withAttributes(attributes) - .withDeviceOperation(new DeviceOperation().withDevices(Arrays.asList(TEST_DEVICE_NAME)))); - DeviceProfileResponse response = client.getDeviceProfile(TEST_DEVICE_NAME); - assertThat(response.getAttributes().get("test").asText(), equalTo("123")); - clean(); - } - - @Test - public void testUpdateDeviceRegistry() { - clean(); - createDevices(1, false, Arrays.asList(TEST_DEVICE_NAME)); - client.updateDeviceRegistry(new UpdateDeviceRegistryRequest() - .withDescription("test") - .withDeviceOperation(new DeviceOperation().withDevices(Arrays.asList(TEST_DEVICE_NAME)))); - DeviceProfileResponse response = client.getDeviceProfile(TEST_DEVICE_NAME); - assertThat(response.getDescription(), equalTo("test")); - } - - @Test - public void testDisableDevice() { - clean(); - createDevices(1, false, Arrays.asList(TEST_DEVICE_NAME)); - client.disableDevices(new DeviceOperationRequest().withDevices(Arrays.asList(TEST_DEVICE_NAME))); - DeviceProfileResponse response = client.getDeviceProfile(TEST_DEVICE_NAME); - assertThat(response.isEnable(), equalTo(false)); - - client.enableDevices(new DeviceOperationRequest().withDevices(Arrays.asList(TEST_DEVICE_NAME))); - response = client.getDeviceProfile(TEST_DEVICE_NAME); - assertThat(response.isEnable(), equalTo(true)); - clean(); - } - - @Test - public void testRebootDevice() { - clean(); - createDevices(1, false, Arrays.asList(TEST_DEVICE_NAME)); - client.rebootDevices(new DeviceOperationRequest().withDevices(Arrays.asList(TEST_DEVICE_NAME))); - clean(); - } - - @Test - public void testCreateGroup() { - GroupInfoResponse response = client.createGroup( - new CreateGroupRequest().withUri(TEST_GROUP_NAME), UUID.randomUUID().toString()); - assertThat(response.getName(), equalTo(TEST_GROUP_NAME)); - assertThat(response.getId(), notNullValue()); - client.removeGroup(response.getId()); - } - - @Test - public void testUpdateGroup() { - GroupInfoResponse groupInfo = client.createGroup( - new CreateGroupRequest().withUri(TEST_GROUP_NAME), UUID.randomUUID().toString()); - client.updateGroup(groupInfo.getId(), new UpdateGroupRequest().withDescription("group description")); - GroupInfoResponse response = client.getGroup(groupInfo.getId()); - assertThat(response.getDescription(), equalTo("group description")); - client.removeGroup(groupInfo.getId()); - } - - @Test - public void testGetGroup() { - GroupInfoResponse groupInfo = client.createGroup( - new CreateGroupRequest().withUri(TEST_GROUP_NAME), UUID.randomUUID().toString()); - GroupInfoResponse response = client.getGroup(groupInfo.getId()); - assertThat(response.getId(), equalTo(groupInfo.getId())); - assertThat(response.getName(), equalTo(groupInfo.getName())); - assertThat(response.getUri(), equalTo(groupInfo.getUri())); - assertThat(response.getDevices(), equalTo(groupInfo.getDevices())); - assertThat(response.getParent(), equalTo(groupInfo.getParent())); - assertThat(response.getDescription(), equalTo(groupInfo.getDescription())); - client.removeGroup(groupInfo.getId()); - } - - @Test - public void testGetChildGroups() { - GroupInfoResponse groupInfo = client.createGroup( - new CreateGroupRequest().withUri(TEST_GROUP_NAME), UUID.randomUUID().toString()); - GroupListResponse response = client.getChildGroups(groupInfo.getId()); - assertThat(response.getGroups().size(), equalTo(0)); - client.removeGroup(groupInfo.getId()); - } - - @Test - public void testGetRootGroups() { - GroupInfoResponse groupInfo = client.createGroup( - new CreateGroupRequest().withUri(TEST_GROUP_NAME), UUID.randomUUID().toString()); - GroupListResponse response = client.getRootGroups(); - assertThat(response.getGroups().size(), greaterThanOrEqualTo(1)); - client.removeGroup(groupInfo.getId()); - } - - @Test - public void testGetDeviceGroups() { - GroupInfoResponse groupInfo = client.createGroup( - new CreateGroupRequest().withUri(TEST_GROUP_NAME), UUID.randomUUID().toString()); - GroupListResponse response = client.getDeviceGroups(); - assertThat(response.getGroups().size(), greaterThanOrEqualTo(1)); - client.removeGroup(groupInfo.getId()); - } - - private CreateDevicesResponse createDevices(int amount, boolean bootstrap, List devices) { - CreateDevicesRequest request = new CreateDevicesRequest() - .withAmount(amount) - .withBootstrap(bootstrap); - if (devices != null) { - request.setDevices(devices); - } - - return client.createDevices(request, UUID.randomUUID().toString()); - } - - private void removeDevcies(List devices, boolean cleanThing) { - RemoveDevicesRequest request = new RemoveDevicesRequest() - .withDeviceOperation(new DeviceOperation().withDevices(devices)) - .withCleanThing(cleanThing); - client.removeDevices(request); - } - - private void clean() { - RemoveDevicesRequest request = new RemoveDevicesRequest() - .withDeviceOperation(new DeviceOperation().withCondition("{}")); - client.removeDevices(request); - } - -} diff --git a/src/test/java/com/baidubce/services/iothub/IotHubClientTest.java b/src/test/java/com/baidubce/services/iothub/IotHubClientTest.java deleted file mode 100755 index 1d39e599..00000000 --- a/src/test/java/com/baidubce/services/iothub/IotHubClientTest.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2016 Baidu, Inc. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.services.iothub; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; - -import com.baidubce.services.iothub.model.BaseResponse; -import com.baidubce.services.iothub.model.CreatePrincipalResponse; -import com.baidubce.services.iothub.model.ListPermissionResponse; -import com.baidubce.services.iothub.model.ListResponse; -import com.baidubce.services.iothub.model.Operation; -import com.baidubce.services.iothub.model.QueryEndpointResponse; -import com.baidubce.services.iothub.model.QueryPermissionResponse; -import com.baidubce.services.iothub.model.QueryThingResponse; -import com.baidubce.services.iothub.model.QueryPolicyResponse; -import com.baidubce.services.iothub.model.QueryPrincipalResponse; - -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; - -/** - * Unit test for iot hub client. - */ - -public class IotHubClientTest { - - // qa-sandbox - private static final String AK = "a6efb01da029490e9dd9e9605698f36c"; - private static final String SK = "6db5c95fd8504352b2da1e2afe52b59e"; - private static final String ENDPOINT = "http://nmg01-hpc-w1134.nmg01.baidu.com:8004"; - - private static final String TEST_ENDPOINT_NAME = "sdk_test_endpoint_01"; - private static final String TEST_THING_NAME = "sdk_test_thing_01"; - private static final String TEST_PRINCIPAL_NAME = "sdk_test_principal_01"; - private static final String TEST_POLICY_NAME = "sdk_test_policy_01"; - - private static final String TEST_TOPIC = "abc"; - - private IotHubClient iotHubClient; - - @Before - public void setUp() { - BceClientConfiguration config = new BceClientConfiguration() - .withCredentials(new DefaultBceCredentials(AK, SK)) - .withEndpoint(ENDPOINT); - iotHubClient = new IotHubClient(config); - } - - @Test - public void endpointTest() throws Exception { - QueryEndpointResponse responseQuery = iotHubClient.createEndpoint(TEST_ENDPOINT_NAME); - assertThat(responseQuery.getEndpointName(), is(TEST_ENDPOINT_NAME)); - assertThat(responseQuery, hasProperty("websocketHostname")); - assertThat(responseQuery, hasProperty("mqttHostname")); - assertThat(responseQuery, hasProperty("mqttTlsHostname")); - assertThat(responseQuery, hasProperty("accountUuid")); - - ListResponse responseList = iotHubClient.listEndpoints(); - assertThat(responseList.getResult(), is(notNullValue())); - assertThat(responseList.getTotalCount(), is(1)); - - responseQuery = iotHubClient.queryEndpoint(TEST_ENDPOINT_NAME); - assertThat(responseQuery.getEndpointName(), is(TEST_ENDPOINT_NAME)); - assertThat(responseQuery, hasProperty("websocketHostname")); - assertThat(responseQuery, hasProperty("mqttHostname")); - assertThat(responseQuery, hasProperty("mqttTlsHostname")); - assertThat(responseQuery, hasProperty("accountUuid")); - - BaseResponse responseBase = iotHubClient.deleteEndpoint(TEST_ENDPOINT_NAME); - assertThat(responseBase.getMetadata().getContentLength(), is(-1L)); - - responseList = iotHubClient.listEndpoints(); - assertThat(responseList.getTotalCount(), is(0)); - } - - @Test - public void thingTest() throws Exception { - iotHubClient.createEndpoint(TEST_ENDPOINT_NAME); - QueryThingResponse responseQuery = iotHubClient.createThing(TEST_ENDPOINT_NAME, TEST_THING_NAME); - assertThat(responseQuery.getThingName(), is(TEST_THING_NAME)); - - ListResponse responseList = iotHubClient.listThings(TEST_ENDPOINT_NAME); - assertThat(responseList.getResult(), is(notNullValue())); - assertThat(responseList.getTotalCount(), is(1)); - - responseQuery = iotHubClient.queryThing(TEST_ENDPOINT_NAME, TEST_THING_NAME); - assertThat(responseQuery.getThingName(), is(TEST_THING_NAME)); - - BaseResponse responseBase = iotHubClient.deleteThing(TEST_ENDPOINT_NAME, TEST_THING_NAME); - assertThat(responseBase.getMetadata().getContentLength(), is(-1L)); - - responseList = iotHubClient.listThings(TEST_ENDPOINT_NAME); - assertThat(responseList.getTotalCount(), is(0)); - iotHubClient.deleteEndpoint(TEST_ENDPOINT_NAME); - } - - - @Test - public void principalTest() throws Exception { - iotHubClient.createEndpoint(TEST_ENDPOINT_NAME); - iotHubClient.createThing(TEST_ENDPOINT_NAME, TEST_THING_NAME); - - CreatePrincipalResponse responseCreate = iotHubClient.createPrincipal(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME); - assertThat(responseCreate.getPrincipalName(), is(TEST_PRINCIPAL_NAME)); - - ListResponse responseList = iotHubClient.listPrincipals(TEST_ENDPOINT_NAME); - assertThat(responseList.getResult(), is(notNullValue())); - assertThat(responseList.getTotalCount(), is(1)); - - responseList = iotHubClient.listPrincipals(TEST_ENDPOINT_NAME, TEST_THING_NAME); - assertThat(responseList.getTotalCount(), is(0)); - - iotHubClient.attachThingToPrincipal(TEST_ENDPOINT_NAME, TEST_THING_NAME, TEST_PRINCIPAL_NAME); - responseList = iotHubClient.listPrincipals(TEST_ENDPOINT_NAME, TEST_THING_NAME); - assertThat(responseList.getTotalCount(), is(1)); - - responseCreate = iotHubClient.regenerateCert(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME, "cert"); - assertThat(responseCreate.getCert(), is(notNullValue())); - - QueryPrincipalResponse responseQuery = iotHubClient.queryPrincipal(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME); - assertThat(responseQuery.getPrincipalName(), is(TEST_PRINCIPAL_NAME)); - - BaseResponse responseBase = iotHubClient.deletePrincipal(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME); - assertThat(responseBase.getMetadata().getContentLength(), is(-1L)); - - responseList = iotHubClient.listPrincipals(TEST_ENDPOINT_NAME); - assertThat(responseList.getTotalCount(), is(0)); - iotHubClient.deleteEndpoint(TEST_ENDPOINT_NAME); - } - - @Test - public void policyTest() throws Exception { - iotHubClient.createEndpoint(TEST_ENDPOINT_NAME); - iotHubClient.createThing(TEST_ENDPOINT_NAME, TEST_THING_NAME); - iotHubClient.createPrincipal(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME); - - QueryPolicyResponse responseQuery = iotHubClient.createPolicy(TEST_ENDPOINT_NAME, TEST_POLICY_NAME); - assertThat(responseQuery.getPolicyName(), is(TEST_POLICY_NAME)); - - ListResponse responseList = iotHubClient.listPolicy(TEST_ENDPOINT_NAME); - assertThat(responseList.getResult(), is(notNullValue())); - assertThat(responseList.getTotalCount(), is(1)); - - responseList = iotHubClient.listPolicy(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME); - assertThat(responseList.getTotalCount(), is(0)); - - iotHubClient.attachPrincipalToPolicy(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME, TEST_POLICY_NAME); - responseList = iotHubClient.listPolicy(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME); - assertThat(responseList.getTotalCount(), is(1)); - - responseQuery = iotHubClient.queryPolicy(TEST_ENDPOINT_NAME, TEST_POLICY_NAME); - assertThat(responseQuery.getPolicyName(), is(TEST_POLICY_NAME)); - - BaseResponse responseBase = iotHubClient.deletePolicy(TEST_ENDPOINT_NAME, TEST_POLICY_NAME); - assertThat(responseBase.getMetadata().getContentLength(), is(-1L)); - - responseList = iotHubClient.listPolicy(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME); - assertThat(responseList.getTotalCount(), is(0)); - - iotHubClient.deleteEndpoint(TEST_ENDPOINT_NAME); - } - - @Test - public void permissionTest() throws Exception { - preCreate(); - List operations = new ArrayList(); - operations.add(Operation.PUBLISH); - operations.add(Operation.SUBSCRIBE); - QueryPermissionResponse response = iotHubClient.createPermission(TEST_ENDPOINT_NAME, - TEST_POLICY_NAME, - operations, - "abc"); - assertThat(response.getPermissionUuid(), is(notNullValue())); - String permissionUuid = response.getPermissionUuid(); - response = iotHubClient.updatePermission(TEST_ENDPOINT_NAME, permissionUuid, null, TEST_TOPIC); - assertThat(response.getTopic(), is(TEST_TOPIC)); - ListPermissionResponse listPermissionResponse = iotHubClient.listPermission(TEST_ENDPOINT_NAME, - TEST_POLICY_NAME); - assertThat(listPermissionResponse.getTotalCount(), is(1)); - assertThat(listPermissionResponse.getResult().get(0), hasProperty("operations")); - assertThat(listPermissionResponse.getResult().get(0), hasProperty("topic")); - assertThat(listPermissionResponse.getResult().get(0), hasProperty("policyUuid")); - assertThat(listPermissionResponse.getResult().get(0), hasProperty("permissionUuid")); - QueryPermissionResponse responseQuery = iotHubClient.queryPermission(TEST_ENDPOINT_NAME, permissionUuid); - assertThat(responseQuery.getPermissionUuid(), is(permissionUuid)); - iotHubClient.deleteEndpoint(TEST_ENDPOINT_NAME); - } - - @Test - public void actionTest() throws Exception { - preCreate(); - BaseResponse response; - response = iotHubClient.attachThingToPrincipal(TEST_ENDPOINT_NAME, TEST_THING_NAME, TEST_PRINCIPAL_NAME); - assertThat(response.getMessage(), is("ok")); - response = iotHubClient.attachPrincipalToPolicy(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME, TEST_POLICY_NAME); - assertThat(response.getMessage(), is("ok")); - response = iotHubClient.removePrincipalToPolicy(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME, TEST_POLICY_NAME); - assertThat(response.getMessage(), is("ok")); - response = iotHubClient.removeThingToPrincipal(TEST_ENDPOINT_NAME, TEST_THING_NAME, TEST_PRINCIPAL_NAME); - assertThat(response.getMessage(), is("ok")); - iotHubClient.deleteEndpoint(TEST_ENDPOINT_NAME); - } - - private void preCreate() { - iotHubClient.createEndpoint(TEST_ENDPOINT_NAME); - iotHubClient.createThing(TEST_ENDPOINT_NAME, TEST_THING_NAME); - iotHubClient.createPrincipal(TEST_ENDPOINT_NAME, TEST_PRINCIPAL_NAME); - iotHubClient.createPolicy(TEST_ENDPOINT_NAME, TEST_POLICY_NAME); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/AbstractLssTest.java b/src/test/java/com/baidubce/services/lss/cases/AbstractLssTest.java deleted file mode 100755 index 759d68ea..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/AbstractLssTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.lss.LssClient; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public abstract class AbstractLssTest { -// static String AK = "5f7a9eda9d9b45eda8e64699b807f15a"; -// static String SK = "0f25bd473abe4151a11d97c6882b16f0"; -// static String END_POINT = "http://lss.bce-testinternal.baidu.com"; - - static String AK = "b24b86af9f1c443bb31b10e64e47f87b"; - static String SK = "90ecc503acb341d0ad0c7033e88c739b"; - static String END_POINT = "http://lss.bj.baidubce.com"; - - - static String preNotification = "java_sdk_lss_notification"; - static String prePresetName = "java_sdk_lss_preset"; - static String preSessionDescription = "java_sdk_session_description"; - - LssClient lssClient = null; - - public void setUp() throws Exception { - DefaultBceCredentials cred = new DefaultBceCredentials(AK, SK); - BceClientConfiguration config = new BceClientConfiguration() - .withCredentials(cred).withEndpoint(END_POINT) - .withMaxConnections(10); - lssClient = new LssClient(config); - - } - - protected String convertName(String key) { - return (key + "_" + System.currentTimeMillis()); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/CreateLiveNotificationTest.java b/src/test/java/com/baidubce/services/lss/cases/CreateLiveNotificationTest.java deleted file mode 100755 index 6f6e0f57..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/CreateLiveNotificationTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.CreateNotificationRequest; -import com.baidubce.services.lss.model.GetNotificationResponse; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class CreateLiveNotificationTest extends AbstractLssTest { - @Before - public void setUp() throws Exception { - super.setUp(); - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - System.out.println(session.toString()); - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - System.out.println(resp2); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - } - - @After - public void tearDown() throws Exception { - ListNotificationsResponse resp = lssClient.listNotifications(); - String name = null; - for (Notification notification : resp.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void testNormal1() { - CreateNotificationRequest createNotificationRequest = new CreateNotificationRequest(); - String name = convertName(preNotification); - createNotificationRequest.withName(name).withEndpoint("http://www.baidu.com"); - lssClient.createNotification(createNotificationRequest); - GetNotificationResponse getNotificationResponse = lssClient.getNotification(name); - assertEquals(getNotificationResponse.getEndpoint(), "http://www.baidu.com"); - } - - @Test - public void testNormal2() { - String name = convertName(preNotification); - lssClient.createNotification(name, "http://www.baidu.com"); - GetNotificationResponse getNotificationResponse = lssClient.getNotification(name); - assertEquals(getNotificationResponse.getEndpoint(), "http://www.baidu.com"); - } - - @Test - public void testAbnormal1() { - CreateNotificationRequest createNotificationRequest = new CreateNotificationRequest(); - createNotificationRequest.setName("notification_test_12_notification_test123"); - createNotificationRequest.setEndpoint("http://www.baidu.com"); - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.createNotification(createNotificationRequest); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/CreateLivePresetTest.java b/src/test/java/com/baidubce/services/lss/cases/CreateLivePresetTest.java deleted file mode 100755 index c35283cf..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/CreateLivePresetTest.java +++ /dev/null @@ -1,278 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.Capture; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreatePresetRequest; -import com.baidubce.services.lss.model.GetPresetResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LiveThumbnail; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Target; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class CreateLivePresetTest extends AbstractLssTest { - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - ListPresetsResponse resp = lssClient.listPresets(); - String presetName = null; - for (LivePreset preset : resp.getPresets()) { - presetName = preset.getName(); - if (presetName.startsWith(prePresetName)) { - System.out.println(presetName); - lssClient.deletePreset(presetName); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void testNormal1() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - GetPresetResponse response = lssClient.getPreset(presetName); - assertEquals("test", response.getDescription()); - assertEquals("128000", response.getAudio().getBitRateInBps().toString()); - assertEquals("2", response.getAudio().getChannels().toString()); - assertEquals("44100", response.getAudio().getSampleRateInHz().toString()); - assertEquals("h264", response.getVideo().getCodec()); - assertEquals("high", response.getVideo().getCodecOptions().getProfile()); - assertEquals("1600000", response.getVideo().getBitRateInBps().toString()); - assertEquals("30.0", response.getVideo().getMaxFrameRate().toString()); - assertEquals("1280", response.getVideo().getMaxWidthInPixel().toString()); - assertEquals("720", response.getVideo().getMaxHeightInPixel().toString()); - assertEquals("stretch", response.getVideo().getSizingPolicy()); - assertEquals("6", response.getHls().getSegmentTimeInSecond().toString()); - assertEquals("6", response.getHls().getSegmentListSize().toString()); - assertEquals("true", response.getHls().getAdaptive().toString()); - assertEquals("true", response.getRtmp().getGopCache().toString()); - } - - @Test - public void testCreatePresetNormalAllParams2() { - CreatePresetRequest request = new CreatePresetRequest(); - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - LiveThumbnail thumbnail = new LiveThumbnail(); - Target target = new Target(); - Capture capture = new Capture(); - target.setFormat("jpg"); - target.setHeightInPixel(640); - target.setWidthInPixel(640); - target.setSizingPolicy("stretch"); - capture.setMode("manual"); - capture.setStartTimeInSecond(5); - capture.setIntervalInSecond(1); - capture.setEndTimeInSecond(10); - thumbnail.setTarget(target); - thumbnail.setCapture(capture); - request.setName(presetName); - request.setDescription(description); - request.setAudio(audio); - request.setVideo(video); - request.setHls(hls); - request.setRtmp(rtmp); - request.setThumbnail(thumbnail); - lssClient.createPreset(request); - GetPresetResponse response = lssClient.getPreset(presetName); - assertEquals("test", response.getDescription()); - assertEquals("128000", response.getAudio().getBitRateInBps().toString()); - assertEquals("2", response.getAudio().getChannels().toString()); - assertEquals("44100", response.getAudio().getSampleRateInHz().toString()); - assertEquals("h264", response.getVideo().getCodec()); - assertEquals("high", response.getVideo().getCodecOptions().getProfile()); - assertEquals("1600000", response.getVideo().getBitRateInBps().toString()); - assertEquals("30.0", response.getVideo().getMaxFrameRate().toString()); - assertEquals("1280", response.getVideo().getMaxWidthInPixel().toString()); - assertEquals("720", response.getVideo().getMaxHeightInPixel().toString()); - assertEquals("stretch", response.getVideo().getSizingPolicy()); - assertEquals("6", response.getHls().getSegmentTimeInSecond().toString()); - assertEquals("6", response.getHls().getSegmentListSize().toString()); - assertEquals("true", response.getHls().getAdaptive().toString()); - assertEquals("true", response.getRtmp().getGopCache().toString()); - } - - - @Test - public void testForwardOnlyNormal1() { - String presetName = convertName(prePresetName); - String description = "test"; - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(false); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - LiveThumbnail thumbnail = new LiveThumbnail(); - Target target = new Target(); - Capture capture = new Capture(); - target.setFormat("jpg"); - target.setHeightInPixel(640); - target.setWidthInPixel(640); - target.setSizingPolicy("stretch"); - capture.setMode("manual"); - capture.setStartTimeInSecond(5); - capture.setIntervalInSecond(1); - capture.setEndTimeInSecond(10); - thumbnail.setTarget(target); - thumbnail.setCapture(capture); - lssClient.createForwardOnlyPreset(presetName, description, hls, rtmp, thumbnail, null); - - GetPresetResponse response = lssClient.getPreset(presetName); - assertEquals("true", response.getForwardOnly().toString()); - assertEquals("test", response.getDescription()); - assertEquals("6", response.getHls().getSegmentTimeInSecond().toString()); - assertEquals("6", response.getHls().getSegmentListSize().toString()); - assertEquals("false", response.getHls().getAdaptive().toString()); - assertEquals("true", response.getRtmp().getGopCache().toString()); - - } - - @Test - public void testCreatePresetNormalAllParams3() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - LiveThumbnail thumbnail = new LiveThumbnail(); - Target target = new Target(); - Capture capture = new Capture(); - target.setFormat("jpg"); - target.setHeightInPixel(640); - target.setWidthInPixel(640); - target.setSizingPolicy("stretch"); - capture.setMode("manual"); - capture.setStartTimeInSecond(5); - capture.setIntervalInSecond(1); - capture.setEndTimeInSecond(10); - thumbnail.setTarget(target); - thumbnail.setCapture(capture); - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, thumbnail, null); - GetPresetResponse response = lssClient.getPreset(presetName); - assertEquals("false", response.getForwardOnly().toString()); - assertEquals("test", response.getDescription()); - assertEquals("128000", response.getAudio().getBitRateInBps().toString()); - assertEquals("2", response.getAudio().getChannels().toString()); - assertEquals("44100", response.getAudio().getSampleRateInHz().toString()); - assertEquals("h264", response.getVideo().getCodec()); - assertEquals("high", response.getVideo().getCodecOptions().getProfile()); - assertEquals("1600000", response.getVideo().getBitRateInBps().toString()); - assertEquals("30.0", response.getVideo().getMaxFrameRate().toString()); - assertEquals("1280", response.getVideo().getMaxWidthInPixel().toString()); - assertEquals("720", response.getVideo().getMaxHeightInPixel().toString()); - assertEquals("stretch", response.getVideo().getSizingPolicy()); - assertEquals("6", response.getHls().getSegmentTimeInSecond().toString()); - assertEquals("6", response.getHls().getSegmentListSize().toString()); - assertEquals("true", response.getHls().getAdaptive().toString()); - assertEquals("true", response.getRtmp().getGopCache().toString()); - } - - @Test - public void testCreatePresetForwardOnly1() { - CreatePresetRequest request = new CreatePresetRequest(); - String presetName = convertName(prePresetName); - String description = "test"; - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(false); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - request.setName(presetName); - request.setDescription(description); - request.setHls(hls); - request.setRtmp(rtmp); - request.setForwardOnly(true); - lssClient.createPreset(request); - GetPresetResponse response = lssClient.getPreset(presetName); - assertEquals("true", response.getForwardOnly().toString()); - assertEquals("test", response.getDescription()); - assertEquals(null, response.getAudio()); - assertEquals(null, response.getVideo()); - assertEquals("6", response.getHls().getSegmentTimeInSecond().toString()); - assertEquals("6", response.getHls().getSegmentListSize().toString()); - assertEquals("false", response.getHls().getAdaptive().toString()); - assertEquals("true", response.getRtmp().getGopCache().toString()); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/CreateLiveSessionTest.java b/src/test/java/com/baidubce/services/lss/cases/CreateLiveSessionTest.java deleted file mode 100755 index 6547c493..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/CreateLiveSessionTest.java +++ /dev/null @@ -1,227 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.GetSessionRequest; -import com.baidubce.services.lss.model.GetSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; -import com.baidubce.services.lss.model.Watermarks; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import static org.junit.Assert.assertEquals; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class CreateLiveSessionTest extends AbstractLssTest { - private String presetName = null; - private String presetName1 = null; - private List presetList = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - presetName = convertName(prePresetName); - presetName1 = convertName(prePresetName) + "_1"; - presetList = new ArrayList(); - presetList.add(presetName); - presetList.add(presetName1); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - lssClient.createPreset(presetName1, description, audio, video, hls, rtmp, null, null); - } - - @After - public void tearDown() throws Exception { - - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void testCreateSessionAllParam1() { - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - System.out.println(resp.toString()); - String sessionId = resp.getSessionId(); - - assertEquals(resp.getPreset(), presetName); - assertEquals(resp.getDescription(), description); - assertEquals(resp.getNotification(), notification); - assertEquals(resp.getSecurityPolicy(), "default"); - assertEquals(resp.getPublish().getRegion(), "bj"); - - assertEquals(resp.getStatus(), "READY"); - - } - - @Test - public void testCreateSessionWithRecording() { - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, - "lss_java_sdk", publish); - System.out.println(resp.toString()); - String sessionId = resp.getSessionId(); - - assertEquals(resp.getPreset(), presetName); - assertEquals(resp.getDescription(), description); - assertEquals(resp.getNotification(), notification); - assertEquals(resp.getSecurityPolicy(), "default"); - assertEquals(resp.getPublish().getRegion(), "bj"); - assertEquals(resp.getRecording(), "lss_java_sdk"); - - assertEquals(resp.getStatus(), "READY"); - - } - - @Test - public void testCreateSessionWithPresets() { - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetList, notification, null, - "lss_java_sdk", publish); - System.out.println(resp.toString()); - assertEquals(resp.getDescription(), description); - assertEquals(resp.getNotification(), notification); - assertEquals(resp.getSecurityPolicy(), "default"); - assertEquals(resp.getPublish().getRegion(), "bj"); - assertEquals(resp.getRecording(), "lss_java_sdk"); - assertEquals(resp.getStatus(), "READY"); - - String sessionId = resp.getSessionId(); - GetSessionRequest getSessionRequest = new GetSessionRequest(); - getSessionRequest.setSessionId(sessionId); - GetSessionResponse response = lssClient.getSession(getSessionRequest); - System.out.println(response.toString()); - assertEquals(response.getPresets().size(), 2); - assertEquals(response.getPresets().get("L0"), presetName); - assertEquals(response.getPresets().get("L1"), presetName1); - - System.out.println(lssClient.refreshSession(sessionId)); - } - - @Test - public void testCreateSessionWithThumbnailAndWatermarks() { - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - Watermarks watermarks = new Watermarks(); - watermarks.setImage(Arrays.asList("lss_sdk_java_imw")); - watermarks.setTimestamp(Arrays.asList("lss_sdk_java_tsw")); - CreateSessionResponse resp = lssClient.createSession(description, presetList, notification, null, - "lss_java_sdk", publish, "lss_java_sdk_thumbnail", watermarks); - System.out.println(resp.toString()); - String sessionId = resp.getSessionId(); - - assertEquals(resp.getDescription(), description); - assertEquals(resp.getNotification(), notification); - assertEquals(resp.getSecurityPolicy(), "default"); - assertEquals(resp.getPublish().getRegion(), "bj"); - assertEquals(resp.getRecording(), "lss_java_sdk"); - assertEquals(resp.getThumbnail(), "lss_java_sdk_thumbnail"); - assertEquals(resp.getWatermarks().getImage().size(), 1); - assertEquals(resp.getWatermarks().getImage().get(0), "lss_sdk_java_imw"); - assertEquals(resp.getWatermarks().getTimestamp().size(), 1); - assertEquals(resp.getWatermarks().getTimestamp().get(0), "lss_sdk_java_tsw"); - assertEquals(resp.getPresets().size(), 2); - assertEquals(resp.getPresets().get("L0"), presetName); - assertEquals(resp.getPresets().get("L1"), presetName1); - assertEquals(resp.getStatus(), "READY"); - - GetSessionRequest getSessionRequest = new GetSessionRequest(); - getSessionRequest.setSessionId(sessionId); - GetSessionResponse response = lssClient.getSession(getSessionRequest); - System.out.println(response.toString()); - assertEquals(response.getThumbnail(), "lss_java_sdk_thumbnail"); - assertEquals(response.getWatermarks().getImage().size(), 1); - assertEquals(response.getWatermarks().getImage().get(0), "lss_sdk_java_imw"); - assertEquals(response.getWatermarks().getTimestamp().size(), 1); - assertEquals(resp.getWatermarks().getTimestamp().get(0), "lss_sdk_java_tsw"); - - } - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/CreateStreamTest.java b/src/test/java/com/baidubce/services/lss/cases/CreateStreamTest.java deleted file mode 100755 index 22912828..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/CreateStreamTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.CreateStreamRequest; -import com.baidubce.services.lss.model.CreateStreamResponse; -import com.baidubce.services.lss.model.Watermarks; -import org.junit.Before; -import org.junit.Test; - -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; - -/** - * Created by wuyafei on 16/10/14. - */ -public class CreateStreamTest extends AbstractLssTest { - - private String playDomain = "play.testsdk.iefay.xyz"; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @Test - public void createStreamWithLeastParams() { - String app = "test"; - String stream = "test" + System.currentTimeMillis() / 1000; - CreateStreamResponse response = lssClient.createStream(playDomain, app, stream); - - assertEquals(playDomain, response.getPlayDomain()); - assertEquals(app, response.getApp()); - assertEquals(stream, response.getPublish().getPushStream()); - assertEquals(response.getThumbnail(), "lss_java_sdk_thumbnail"); - assertEquals(response.getRecording(), "lss_java_sdk"); - } - - @Test - public void createStream() { - String app = "test"; - String stream = "test" + System.currentTimeMillis() / 1000; - - CreateStreamRequest request = new CreateStreamRequest(); - Watermarks watermarks = new Watermarks(); - watermarks.setTimestamp(Arrays.asList("lss_sdk_java_tsw2")); - watermarks.setImage(Arrays.asList("lss_sdk_java_imw")); - request.withPlayDomain(playDomain) - .withApp(app) - .withPublish(new CreateStreamRequest.PublishInfo().withPushStream(stream)) - .withWatermarks(watermarks); - CreateStreamResponse response = lssClient.createStream(request); - // System.out.println(response); - assertEquals(playDomain, response.getPlayDomain()); - assertEquals(app, response.getApp()); - assertEquals(stream, response.getPublish().getPushStream()); - assertEquals(response.getThumbnail(), "lss_java_sdk_thumbnail"); - assertEquals(response.getRecording(), "lss_java_sdk"); - assertEquals(response.getWatermarks().getTimestamp().contains("lss_sdk_java_tsw2"), true); - assertEquals(response.getWatermarks().getImage().contains("lss_sdk_java_imw"), true); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/DeleteLiveNotificationTest.java b/src/test/java/com/baidubce/services/lss/cases/DeleteLiveNotificationTest.java deleted file mode 100755 index e18d6514..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/DeleteLiveNotificationTest.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.baidubce.services.lss.cases; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.DeleteNotificationRequest; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class DeleteLiveNotificationTest extends AbstractLssTest { - String notification = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - lssClient.getNotification(notification); - } - - @After - public void tearDown() throws Exception { - - - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * DeleteNotificationResponse deleteNotification(String name) - */ - @Test - public void testDeleteNotificaitonNormal1() { - lssClient.deleteNotification(notification); - } - - /** - * DeleteNotificationResponse deleteNotification(request) - */ - @Test - public void testDeleteNotificaitonNormal2() { - - DeleteNotificationRequest request = new DeleteNotificationRequest(); - request.withName(notification); - lssClient.deleteNotification(request); - } - - /** - * DeleteNotificationResponse deleteNotification(String name) - */ - @Test - public void testNotificaitonNull() { - notification = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter name should NOT be null or empty string"); - lssClient.deleteNotification(notification); - } - - /** - * DeleteNotificationResponse deleteNotification(String name) - */ - @Test - public void testNotificaitonEmpty() { - notification = ""; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter name should NOT be null or empty string"); - lssClient.deleteNotification(notification); - } - - /** - * DeleteNotificationResponse deleteNotification(String name) - */ - @Test - public void testRequestNull() { - - DeleteNotificationRequest request = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter request should NOT be null"); - lssClient.deleteNotification(request); - } - - /** - * DeleteNotificationResponse deleteNotification(String name) - */ - @Test - public void testNotificaitonStringNull() { - notification = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("does not exist"); - lssClient.deleteNotification(notification); - } - - /** - * DeleteNotificationResponse deleteNotification(String name) - */ - @Test - public void testNotificaitonDeleted() { - lssClient.deleteNotification(notification); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("does not exist"); - lssClient.deleteNotification(notification); - } - - /** - * DeleteNotificationResponse deleteNotification(String name) - */ - @Test - public void testNotificaitonNotExist() { - notification = "not_exist_notification"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("does not exist"); - lssClient.deleteNotification(notification); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/DeleteLivePresetTest.java b/src/test/java/com/baidubce/services/lss/cases/DeleteLivePresetTest.java deleted file mode 100755 index 8a978fa9..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/DeleteLivePresetTest.java +++ /dev/null @@ -1,206 +0,0 @@ -package com.baidubce.services.lss.cases; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.DeletePresetRequest; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class DeleteLivePresetTest extends AbstractLssTest { - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * DeletePresetResponse deletePreset(String presetName) - */ - @Test - public void testDeletePresetNormal1() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - lssClient.deletePreset(presetName); - } - - /** - * DeletePresetResponse deletePreset(DeletePresetRequest request) - */ - @Test - public void testDeletePresetNormal2() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - DeletePresetRequest request = new DeletePresetRequest(); - - request.setName(presetName); - lssClient.deletePreset(request); - - } - - /** - * DeletePresetResponse deletePreset(String presetName) - */ - @Test - public void testDeletePresetNotExist() { - String presetName = convertName(prePresetName); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("The requested preset does not exist"); - lssClient.deletePreset(presetName); - } - - /** - * DeletePresetResponse deletePreset(String presetName) - */ - @Test - public void testDeletePresetDeleted() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - lssClient.deletePreset(presetName); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("The requested preset does not exist"); - lssClient.deletePreset(presetName); - } - - /** - * DeletePresetResponse deletePreset(String presetName) - */ - @Test - public void testDeleteSystemPreset() { - String presetName = "lss.rtmp_hls_1280x720"; - - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("The requested preset does not exist"); - lssClient.deletePreset(presetName); - } - - /** - * DeletePresetResponse deletePreset(String presetName) - */ - @Test - public void testPresetNameNull() { - String presetName = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter name should NOT be null or empty string."); - lssClient.deletePreset(presetName); - } - - /** - * DeletePresetResponse deletePreset(request) - */ - @Test - public void testRequestNull() { - DeletePresetRequest request = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter request should NOT be null"); - lssClient.deletePreset(request); - } - - - /** - * DeletePresetResponse deletePreset(String presetName) - */ - @Test - public void testPresetNameEmpty() { - String presetName = ""; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter name should NOT be null or empty string."); - lssClient.deletePreset(presetName); - } - - /** - * DeletePresetResponse deletePreset(String presetName) - */ - @Test - public void testPresetNameStringNull() { - String presetName = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("The requested preset does not exist"); - lssClient.deletePreset(presetName); - } - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/DeleteLiveSessionTest.java b/src/test/java/com/baidubce/services/lss/cases/DeleteLiveSessionTest.java deleted file mode 100755 index fe06a575..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/DeleteLiveSessionTest.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.DeleteSessionRequest; -import com.baidubce.services.lss.model.GetSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class DeleteLiveSessionTest extends AbstractLssTest { - private String sessionId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - sessionId = resp.getSessionId(); - } - - @After - public void tearDown() throws Exception { - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * DeleteSessionResponse deleteSession(String sessionId) - */ - @Test - public void testDeleteSessionNormal1() { - GetSessionResponse resp1 = lssClient.getSession(sessionId); - assertEquals(resp1.getStatus(), "READY"); - lssClient.deleteSession(sessionId); - } - - /** - * DeleteSessionResponse deleteSession(DeleteSessionRequest request) - */ - @Test - public void testDeleteSessionNormal2() { - GetSessionResponse resp1 = lssClient.getSession(sessionId); - assertEquals(resp1.getStatus(), "READY"); - DeleteSessionRequest request = new DeleteSessionRequest(); - request.setSessionId(sessionId); - lssClient.deleteSession(request); - } - - /** - * DeleteSessionResponse deleteSession(String sessionId) - */ - @Test - public void tesSessionIdNull() { - sessionId = null; - bceEx.expect(IllegalArgumentException.class); - lssClient.deleteSession(sessionId); - } - - /** - * DeleteSessionResponse deleteSession(DeleteSessionRequest request) - */ - @Test - public void testRequestNull() { - - DeleteSessionRequest request = null; - bceEx.expect(IllegalArgumentException.class); - lssClient.deleteSession(request); - - } - - /** - * DeleteSessionResponse deleteSession(String sessionId) - */ - @Test - public void tesSessionIdStringNull() { - sessionId = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.deleteSession(sessionId); - } - - /** - * DeleteSessionResponse deleteSession(String sessionId) - */ - @Test - public void tesSessionIdEmpty() { - sessionId = ""; - bceEx.expect(IllegalArgumentException.class); - lssClient.deleteSession(sessionId); - } - - /** - * DeleteSessionResponse deleteSession(String sessionId) - */ - @Test - public void tesSessionIdNotExist() { - sessionId = "session_not_exist"; - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.deleteSession(sessionId); - } - - /** - * DeleteSessionResponse deleteSession(String sessionId) - */ - @Test - public void testDeleteSessionPaused() { - lssClient.pauseSession(sessionId); - GetSessionResponse resp1 = lssClient.getSession(sessionId); - assertEquals(resp1.getStatus(), "PAUSED"); - lssClient.deleteSession(sessionId); - } - - /** - * DeleteSessionResponse deleteSession(String sessionId) - */ - @Test - public void testDeleteSessionDeleted() { - lssClient.deleteSession(sessionId); - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.deleteSession(sessionId); - - } - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/DomainStatisticsTest.java b/src/test/java/com/baidubce/services/lss/cases/DomainStatisticsTest.java deleted file mode 100755 index e212831c..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/DomainStatisticsTest.java +++ /dev/null @@ -1,192 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.GetAllDomainsBandwidthResponse; -import com.baidubce.services.lss.model.GetAllDomainsPlayCountResponse; -import com.baidubce.services.lss.model.GetAllDomainsStatisticsRequest; -import com.baidubce.services.lss.model.GetAllDomainsTrafficResponse; -import com.baidubce.services.lss.model.GetDomainStatisticsRequest; -import com.baidubce.services.lss.model.GetDomainStatisticsResponse; -import com.baidubce.services.lss.model.GetDomainSummaryStatisticsRequest; -import com.baidubce.services.lss.model.GetDomainSummaryStatisticsResponse; -import com.baidubce.services.lss.model.GetOneDomainBandwidthResponse; -import com.baidubce.services.lss.model.GetOneDomainPlayCountResponse; -import com.baidubce.services.lss.model.GetOneDomainStatisticsRequest; -import com.baidubce.services.lss.model.GetOneDomainTrafficResponse; -import com.baidubce.services.lss.model.GetStreamStatisticsRequest; -import com.baidubce.services.lss.model.GetStreamStatisticsResponse; -import com.baidubce.services.lss.model.ListDomainStatisticsRequest; -import com.baidubce.services.lss.model.ListDomainStatisticsResponse; -import com.baidubce.services.lss.model.ListStreamResponse; -import com.baidubce.services.lss.model.ListStreamStatisticsRequest; -import com.baidubce.services.lss.model.ListStreamStatisticsResponse; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -/** - * Created by wuyafei on 16/10/19. - */ -public class DomainStatisticsTest extends AbstractLssTest { - - private String domain = "play.testsdk.iefay.xyz"; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @Test - public void testGetDomainStatistics() { - GetDomainStatisticsRequest request = new GetDomainStatisticsRequest(); - request.withDomain(domain).withStartDate("20161018").withEndDate("20161019").withAggregate(Boolean.TRUE); - GetDomainStatisticsResponse response = lssClient.getDomainStatistics(request); - // System.out.println(response); - assertEquals(response.getDomain(), domain); - assertEquals(response.getAggregate().getDownstreamInByte() == 0, true); - assertEquals(response.getAggregate().getPlayCount() == 0, true); - assertNull(response.getStatistics()); - request.setAggregate(Boolean.FALSE); - response = lssClient.getDomainStatistics(request); - // System.out.println(response); - assertNull(response.getAggregate()); - assertEquals(response.getStatistics().size(), 0); - } - - @Test - public void testGetDomainSummaryStatistics() { - GetDomainSummaryStatisticsRequest request = new GetDomainSummaryStatisticsRequest(); - request.withStartTime("2016-10-18T01:00:00Z").withEndTime("2016-10-19T00:00:00Z"); - GetDomainSummaryStatisticsResponse response = lssClient.getDomainSummaryStatistics(request); - // System.out.println(response); - assertEquals(response.getSummary().getPlayCount() == 0, true); - assertEquals(response.getSummary().getDurationInMinute() == 0, true); - assertEquals(response.getSummary().getDownStreamInByte() == 0, true); - assertEquals(response.getEndTime(), "2016-10-19T00:00:00Z"); - } - - @Test - public void testGetAllDomainsPlayCount() { - GetAllDomainsStatisticsRequest request = new GetAllDomainsStatisticsRequest(); - request.withStartTime("2016-10-17T16:00:00Z").withEndTime("2016-10-19T00:00:00Z").withTimeInterval("LONG_TERM"); - GetAllDomainsPlayCountResponse response = lssClient.getAllDomainsPlayCount(request); - // System.out.println(response); - assertEquals(response.getTimeInterval(), "LONG_TERM"); - assertEquals(response.getFlvStatistics().size(), 2); - assertEquals(response.getHlsStatistics().size(), 2); - assertEquals(response.getRtmpStatistics().size(), 2); - assertEquals(response.getFlvStatistics().get(0).getPlayCount() == 0, true); - assertEquals(response.getHlsStatistics().get(0).getPlayCount() == 0, true); - assertEquals(response.getRtmpStatistics().get(0).getPlayCount() == 0, true); - } - - @Test - public void testGetOneDomainPlayCount() { - GetOneDomainStatisticsRequest request = new GetOneDomainStatisticsRequest(); - request.withDomain(domain).withStartTime("2016-09-18T00:00:00Z") - .withEndTime("2016-09-18T08:00:00Z").withTimeInterval("MID_TERM"); - GetOneDomainPlayCountResponse response = lssClient.getOneDomainPlayCount(request); - // System.out.println(response); - assertEquals(response.getFlvStatistics().size(), 8); - assertEquals(response.getRtmpStatistics().get(0).getPlayCount() == 0, true); - assertEquals(response.getHlsStatistics().get(0).getTimestamp(), "2016-09-18T00:00:00Z"); - } - - @Test - public void testGetAllDomainsBandwidth() { - GetAllDomainsStatisticsRequest request = new GetAllDomainsStatisticsRequest(); - request.withStartTime("2016-10-18T00:00:00Z") - .withEndTime("2016-10-18T00:20:00Z").withTimeInterval("SHORT_TERM"); - GetAllDomainsBandwidthResponse response = lssClient.getAllDomainsBandwidth(request); - // System.out.println(response); - assertEquals(response.getTimeInterval(), "SHORT_TERM"); - assertEquals(response.getStatistics().size(), 4); - assertEquals(response.getStatistics().get(0).getBandwidthInBps() == 0, true); - assertEquals(response.getStatistics().get(0).getTimestamp(), "2016-10-18T00:00:00Z"); - } - - @Test - public void testGetOneDomainBandwidth() { - GetOneDomainStatisticsRequest request = new GetOneDomainStatisticsRequest(); - request.withDomain(domain).withStartTime("2016-10-18T00:00:00Z") - .withEndTime("2016-10-18T00:20:00Z").withTimeInterval("SHORT_TERM"); - GetOneDomainBandwidthResponse response = lssClient.getOneDomainBandwidth(request); - // System.out.println(response); - assertEquals(response.getTimeInterval(), "SHORT_TERM"); - assertEquals(response.getStatistics().size(), 4); - assertEquals(response.getStatistics().get(0).getBandwidthInBps() == 0, true); - assertEquals(response.getStatistics().get(0).getTimestamp(), "2016-10-18T00:00:00Z"); - } - - @Test - public void testGetAllDomainsTraffic() { - GetAllDomainsStatisticsRequest request = new GetAllDomainsStatisticsRequest(); - request.withStartTime("2016-10-17T16:00:00Z").withEndTime("2016-10-20T04:00:00Z").withTimeInterval("LONG_TERM"); - GetAllDomainsTrafficResponse response = lssClient.getAllDomainsTraffic(request); - // System.out.println(response); - assertEquals(response.getEndTime(), "2016-10-20T04:00:00Z"); - assertEquals(response.getStatistics().size(), 3); - assertEquals(response.getStatistics().get(0).getTimestamp(), "2016-10-17T16:00:00Z"); - assertEquals(response.getStatistics().get(0).getDownstreamInByte() == 0, true); - } - - @Test - public void testGetOneDomainTraffic() { - GetOneDomainStatisticsRequest request = new GetOneDomainStatisticsRequest(); - request.withDomain(domain).withStartTime("2016-10-18T04:00:00Z").withTimeInterval("LONG_TERM"); - GetOneDomainTrafficResponse response = lssClient.getOneDomainTraffic(request); - // System.out.println(response); - assertEquals(response.getDomain(), domain); - assertEquals(response.getStatistics().get(0).getDownstreamInByte() == 0, true); - assertEquals(response.getStatistics().get(0).getTimestamp(), "2016-10-18T16:00:00Z"); - - } - - @Test - public void testListDomainStatistics() { - ListDomainStatisticsRequest request = new ListDomainStatisticsRequest(); - request.withStartTime("2016-10-18T04:00:00Z") - .withEndTime("2016-10-20T04:00:00Z") - .withKeywordType("domain") - .withKeyword("test") - .withOrderBy("duration desc"); - ListDomainStatisticsResponse response = lssClient.listDomainStatistics(request); - // System.out.println(response); - assertEquals(response.getDomainStatisticsList().size(), 0); - } - - @Test - public void testListStreamStatistics() { - ListStreamStatisticsRequest request = new ListStreamStatisticsRequest(); - request.withDomain(domain).withApp("test") - .withStartTime("2016-10-18T04:00:00Z").withEndTime("2016-10-20T04:00:00Z") - .withKeyword("stream").withOrderBy("downstream") - .withPageNo(1).withPageSize(5); - ListStreamStatisticsResponse response = lssClient.listStreamStatistics(request); - // System.out.println(response); - assertEquals(response.getStreamStatisticsList().size(), 0); - assertEquals(response.getTotalCount() == 0, true); - } - - @Test - public void testGetStreamStatistics() { - GetStreamStatisticsRequest request = new GetStreamStatisticsRequest(); - ListStreamResponse listStreamResponse = lssClient.listStream(domain); - // System.out.println(listStreamResponse); - if (listStreamResponse.getStreams().size() > 0) { - String app = listStreamResponse.getStreams().get(0).getApp(); - String stream = listStreamResponse.getStreams().get(0).getPublish().getPushStream(); - request.withDomain(domain).withApp(app).withStream(stream).withAggregate(false) - .withStartDate("20161019").withEndDate("20161020"); - GetStreamStatisticsResponse response = lssClient.getStreamStatistics(request); - // System.out.println(response); - assertEquals(response.getApp(), app); - assertEquals(response.getStream(), stream); - assertEquals(response.getStatistics().size(), 0); - } - } - - - - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/GetLiveNotificationTest.java b/src/test/java/com/baidubce/services/lss/cases/GetLiveNotificationTest.java deleted file mode 100755 index ce54329e..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/GetLiveNotificationTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.GetNotificationRequest; -import com.baidubce.services.lss.model.GetNotificationResponse; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.Notification; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class GetLiveNotificationTest extends AbstractLssTest { - String notification = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - } - - @After - public void tearDown() throws Exception { - ListNotificationsResponse resp = lssClient.listNotifications(); - String name = null; - for (Notification noti : resp.getNotifications()) { - name = noti.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - - /** - * GetNotificationResponse getNotification(String name) - */ - @Test - public void testGetNotificationNormal1() { - GetNotificationResponse resp = lssClient.getNotification(notification); - assertEquals(resp.getEndpoint(), END_POINT); - } - - /** - * GetNotificationResponse getNotification(String name) - */ - @Test - public void testGetNotificationNormal2() { - GetNotificationRequest request = new GetNotificationRequest(); - request.withName(notification); - GetNotificationResponse resp = lssClient.getNotification(request); - assertEquals(resp.getEndpoint(), END_POINT); - } - - /** - * GetNotificationResponse getNotification(String name) - */ - @Test - public void testNotificationNotExist() { - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("does not exist"); - lssClient.getNotification("not_exist_notification"); - } - - /** - * GetNotificationResponse getNotification(String name) - */ - @Test - public void testNotificationNull() { - notification = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter name should NOT be null or empty string"); - lssClient.getNotification(notification); - } - - /** - * GetNotificationResponse getNotification(String name) - */ - @Test - public void testRequestNull() { - GetNotificationRequest request = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter request should NOT be null"); - lssClient.getNotification(request); - } - - /** - * GetNotificationResponse getNotification(String name) - */ - @Test - public void testNotificationEmpty() { - notification = ""; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter name should NOT be null or empty string"); - lssClient.getNotification(notification); - } - - /** - * GetNotificationResponse getNotification(String name) - */ - @Test - public void testNotificationStringNull() { - notification = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("does not exist"); - lssClient.getNotification(notification); - } - - /** - * GetNotificationResponse getNotification(String name) - */ - @Test - public void testNotificationDeleted() { - lssClient.deleteNotification(notification); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("does not exist"); - lssClient.getNotification(notification); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/GetLivePresetTest.java b/src/test/java/com/baidubce/services/lss/cases/GetLivePresetTest.java deleted file mode 100755 index adca608c..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/GetLivePresetTest.java +++ /dev/null @@ -1,241 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.GetPresetRequest; -import com.baidubce.services.lss.model.GetPresetResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class GetLivePresetTest extends AbstractLssTest { - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - ListPresetsResponse resp = lssClient.listPresets(); - String presetName; - for (LivePreset preset : resp.getPresets()) { - presetName = preset.getName(); - if (presetName.startsWith(prePresetName)) { - lssClient.deletePreset(presetName); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * GetPresetResponse getPreset(String presetName) - */ - @Test - public void testGetPresetNormal1() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - GetPresetResponse response = lssClient.getPreset(presetName); - assertEquals(presetName, response.getName()); - assertEquals("test", response.getDescription()); - assertEquals("128000", response.getAudio().getBitRateInBps().toString()); - assertEquals("2", response.getAudio().getChannels().toString()); - assertEquals("44100", response.getAudio().getSampleRateInHz().toString()); - assertEquals("h264", response.getVideo().getCodec()); - assertEquals("high", response.getVideo().getCodecOptions().getProfile()); - assertEquals("1600000", response.getVideo().getBitRateInBps().toString()); - assertEquals("30.0", response.getVideo().getMaxFrameRate().toString()); - assertEquals("1280", response.getVideo().getMaxWidthInPixel().toString()); - assertEquals("720", response.getVideo().getMaxHeightInPixel().toString()); - assertEquals("stretch", response.getVideo().getSizingPolicy()); - assertEquals("6", response.getHls().getSegmentTimeInSecond().toString()); - assertEquals("6", response.getHls().getSegmentListSize().toString()); - assertEquals("true", response.getHls().getAdaptive().toString()); - assertEquals("true", response.getRtmp().getGopCache().toString()); - - } - - /** - * GetPresetResponse getPreset(GetPresetRequest request) - */ - @Test - public void testGetPresetNormal2() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - GetPresetRequest request = new GetPresetRequest(); - request.setName(presetName); - GetPresetResponse response = lssClient.getPreset(request); - assertEquals(presetName, response.getName()); - assertEquals("test", response.getDescription()); - assertEquals("128000", response.getAudio().getBitRateInBps().toString()); - assertEquals("2", response.getAudio().getChannels().toString()); - assertEquals("44100", response.getAudio().getSampleRateInHz().toString()); - assertEquals("h264", response.getVideo().getCodec()); - assertEquals("high", response.getVideo().getCodecOptions().getProfile()); - assertEquals("1600000", response.getVideo().getBitRateInBps().toString()); - assertEquals("30.0", response.getVideo().getMaxFrameRate().toString()); - assertEquals("1280", response.getVideo().getMaxWidthInPixel().toString()); - assertEquals("720", response.getVideo().getMaxHeightInPixel().toString()); - assertEquals("stretch", response.getVideo().getSizingPolicy()); - assertEquals("6", response.getHls().getSegmentTimeInSecond().toString()); - assertEquals("6", response.getHls().getSegmentListSize().toString()); - assertEquals("true", response.getHls().getAdaptive().toString()); - assertEquals("true", response.getRtmp().getGopCache().toString()); - - } - - /** - * GetPresetResponse getPreset(String presetName) - */ - @Test - public void testPresetNotExist() { - String presetName = convertName(prePresetName); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("The requested preset does not exist"); - lssClient.getPreset(presetName); - } - - /** - * GetPresetResponse getPreset(String presetName) - */ - @Test - public void testPresetDeleted() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - lssClient.deletePreset(presetName); - - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("The requested preset does not exist"); - lssClient.getPreset(presetName); - } - - /** - * GetPresetResponse getPreset(String presetName) - */ - @Test - public void testPresetNameNull() { - String presetName = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter name should NOT be null or empty string"); - lssClient.getPreset(presetName); - } - - /** - * GetPresetResponse getPreset(request) - */ - @Test - public void testRequestNull() { - GetPresetRequest request = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter request should NOT be null"); - lssClient.getPreset(request); - } - - /** - * GetPresetResponse getPreset(String presetName) - */ - @Test - public void testPresetNameEmpty() { - String presetName = ""; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter name should NOT be null or empty string"); - lssClient.getPreset(presetName); - } - - /** - * GetPresetResponse getPreset(String presetName) - */ - @Test - public void testPresetNameStringNull() { - String presetName = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("The requested preset does not exist"); - lssClient.getPreset(presetName); - } - - - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/GetLiveRecordingTest.java b/src/test/java/com/baidubce/services/lss/cases/GetLiveRecordingTest.java deleted file mode 100755 index a397796e..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/GetLiveRecordingTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.GetRecordingResponse; - -/** - * Created by shidaiting01 on 2016/3/15. - */ -public class GetLiveRecordingTest extends AbstractLssTest { - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void testNormal() { - GetRecordingResponse response = lssClient.getRecording("lss_java_sdk"); - System.out.println(response); - assertEquals(response.getName(), "lss_java_sdk"); - } - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/GetLiveSecurityPolicyTest.java b/src/test/java/com/baidubce/services/lss/cases/GetLiveSecurityPolicyTest.java deleted file mode 100755 index 5c606ca8..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/GetLiveSecurityPolicyTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baidubce.services.lss.cases; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.GetSecurityPolicyResponse; - -/** - * Created by shidaiting01 on 2016/1/13. - */ -public class GetLiveSecurityPolicyTest extends AbstractLssTest { - private String sessionId; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void test() { - GetSecurityPolicyResponse resp = lssClient.getSecurityPolicy("default"); - System.out.println(resp.toString()); - Assert.assertEquals(resp.getName(), "default"); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/GetLiveSessionTest.java b/src/test/java/com/baidubce/services/lss/cases/GetLiveSessionTest.java deleted file mode 100755 index 0055b2c8..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/GetLiveSessionTest.java +++ /dev/null @@ -1,349 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.AntiLeech; -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.Auth; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.Encryption; -import com.baidubce.services.lss.model.GetSecurityPolicyResponse; -import com.baidubce.services.lss.model.GetSessionRequest; -import com.baidubce.services.lss.model.GetSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.HlsEncryption; -import com.baidubce.services.lss.model.IP; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.Refer; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.UpdateSecurityPolicyRequest; -import com.baidubce.services.lss.model.Video; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.ArrayList; -import java.util.List; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class GetLiveSessionTest extends AbstractLssTest { - private String presetName = null; - private String presetName1 = null; - private List presetList = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - presetName = convertName(prePresetName); - presetName1 = convertName(prePresetName) + "_1"; - presetList = new ArrayList(); - presetList.add(presetName); - presetList.add(presetName1); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - lssClient.createPreset(presetName1, description, audio, video, hls, rtmp, null, null); - } - - @After - public void tearDown() throws Exception { - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * GetSessionResponse getSession(String sessionId) - */ - @Test - public void testGetSessionNormal1() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = resp.getSessionId(); - - GetSessionResponse resp1 = lssClient.getSession(sessionId); - - assertEquals(resp1.getPreset(), presetName); - assertEquals(resp1.getDescription(), description); - assertEquals(resp1.getNotification(), notification); - - assertEquals(resp1.getStatus(), "READY"); - } - - /** - * GetSessionResponse getSession(GetSessionRequest request) - */ - @Test - public void testGetSessionNormal2() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = resp.getSessionId(); - - GetSessionRequest request = new GetSessionRequest(); - request.setSessionId(sessionId); - GetSessionResponse resp1 = lssClient.getSession(request); - assertEquals(resp1.getPreset(), presetName); - assertEquals(resp1.getDescription(), description); - assertEquals(resp1.getNotification(), notification); - - assertEquals(resp1.getStatus(), "READY"); - } - - /** - * GetSessionResponse getSession(String sessionId) - */ - @Test - public void testSessionIdNotExist() { - - String sessionId = "not_exist_session"; - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.getSession(sessionId); - } - - /** - * GetSessionResponse getSession(String sessionId) - */ - @Test - public void testSessionIdNull() { - - String sessionId = null; - bceEx.expect(IllegalArgumentException.class); - lssClient.getSession(sessionId); - } - - /** - * GetSessionResponse getSession(String sessionId) - */ - @Test - public void testSessionIdStringNull() { - - String sessionId = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.getSession(sessionId); - } - - /** - * GetSessionResponse getSession(GetSessionRequest request) - */ - @Test - public void testRequestNull() { - GetSessionRequest request = null; - bceEx.expect(IllegalArgumentException.class); - lssClient.getSession(request); - - } - - /** - * GetSessionResponse getSession(String sessionId) - */ - @Test - public void testSessionIdEmpty() { - String sessionId = ""; - bceEx.expect(IllegalArgumentException.class); - lssClient.getSession(sessionId); - } - - /** - * GetSessionResponse getSession(String sessionId) - */ - @Test - public void testSessionIdPaused() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = resp.getSessionId(); - - lssClient.pauseSession(sessionId); - GetSessionResponse resp1 = lssClient.getSession(sessionId); - assertEquals(resp1.getPreset(), presetName); - assertEquals(resp1.getDescription(), description); - assertEquals(resp1.getNotification(), notification); - - assertEquals(resp1.getStatus(), "PAUSED"); - } - - - @Test - public void testGetEncryptedSession1() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = resp.getSessionId(); - - GetSessionResponse resp1 = lssClient.getSessionWithToken(sessionId, null); - - - - assertEquals(resp1.getPreset(), presetName); - assertEquals(resp1.getDescription(), description); - assertEquals(resp1.getNotification(), notification); - - assertEquals(resp1.getStatus(), "READY"); - - GetSessionResponse resp2 = lssClient.getSessionWithToken(sessionId, 10); - System.out.println(resp2.toString()); - } - - @Test - public void testGetEncryptedSession2() { - Auth auth = new Auth().withPlay(true).withPush(true); - - List black = new ArrayList(); - black.add("http://refer.demo.com"); - List white = new ArrayList(); - white.add("8.8.8.8"); - - Refer refer = new Refer().withBlacklist(black); - IP ip = new IP().withWhitelist(white); - - AntiLeech antiLeech = new AntiLeech().withRefer(refer).withIp(ip); - - // SafeCode safeCode = new SafeCode().withPlayerType("web").withSafeCode("code1"); - // List safeCodes = new ArrayList(); - // safeCodes.add(safeCode); - - HlsEncryption hlsEncryption = new HlsEncryption().withStrategy("PlayerBinding"); - Encryption encryption = new Encryption().withHls(hlsEncryption); - - lssClient.updateSecurityPolicy("default", auth, antiLeech, encryption); - - GetSecurityPolicyResponse response = lssClient.getSecurityPolicy("default"); - - System.out.println(response.toString()); - assertEquals(response.getName(), "default"); - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = resp.getSessionId(); - - GetSessionResponse resp2 = lssClient.getSessionWithToken(sessionId, 10); - System.out.println(resp2.toString()); - - lssClient.updateSecurityPolicy(new UpdateSecurityPolicyRequest().withName("default")); - } - - @Test - public void testGetEncryptedSessionWithPresets() { - Auth auth = new Auth().withPlay(true).withPush(true); - List black = new ArrayList(); - black.add("http://refer.demo.com"); - List white = new ArrayList(); - white.add("8.8.8.8"); - Refer refer = new Refer().withBlacklist(black); - IP ip = new IP().withWhitelist(white); - AntiLeech antiLeech = new AntiLeech().withRefer(refer).withIp(ip); - HlsEncryption hlsEncryption = new HlsEncryption().withStrategy("PlayerBinding"); - Encryption encryption = new Encryption().withHls(hlsEncryption); - - lssClient.updateSecurityPolicy("default", auth, antiLeech, encryption); - GetSecurityPolicyResponse response = lssClient.getSecurityPolicy("default"); - System.out.println(response.toString()); - assertEquals(response.getName(), "default"); - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetList, notification, null, - "lss_java_sdk", publish); - String sessionId = resp.getSessionId(); - System.out.println(resp.toString()); - - GetSessionResponse resp1 = lssClient.getSessionWithToken(sessionId, 10); - System.out.println(resp1.toString()); - assertNotNull(resp1.getPlay().getRtmpUrls()); - assertNotNull(resp1.getPlay().getHlsUrls()); - assertNotNull(resp1.getPlay().getFlvUrls()); - } - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/GetSessionStatisticsTest.java b/src/test/java/com/baidubce/services/lss/cases/GetSessionStatisticsTest.java deleted file mode 100755 index 39caf2a9..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/GetSessionStatisticsTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.Video; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.GetSessionStatisticsResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.text.SimpleDateFormat; -import java.util.Date; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -/** - * Created by wuyafei on 16/7/11. - */ -public class GetSessionStatisticsTest extends AbstractLssTest { - private String sessionId = null; - private String presetName = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - CreateSessionResponse response = lssClient.createSession(null, presetName, null, null, null, null); - sessionId = response.getSessionId(); - } - - @Test - public void testGetSessionStatistics() { - GetSessionStatisticsResponse response = lssClient.getSessionStatistics(sessionId, - "20160705", "20160708", true); - assertEquals(response.getStatistics(), null); - assertTrue(response.getAggregate().getDownstreamInByte() == 0L); - assertTrue(response.getAggregate().getDurationInMinute() == 0L); - assertEquals(response.getStartDate(), "20160705"); - assertEquals(response.getEndDate(), "20160708"); - assertEquals(response.getSessionId(), sessionId); - - GetSessionStatisticsResponse response1 = lssClient.getSessionStatistics(sessionId, - "20160705", "20160708", false); - assertEquals(response1.getAggregate(), null); - assertTrue(response1.getStatistics().size() == 0); - - Date now = new Date(); - SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); - GetSessionStatisticsResponse response2 = lssClient.getSessionStatistics(sessionId, - null, null, null); - assertEquals(response2.getStartDate(), sdf.format(now)); - assertEquals(response2.getEndDate(), sdf.format(now)); - assertEquals(response2.getAggregate(), null); - assertTrue(response2.getStatistics().size() == 0); - } - - @After - public void tearDown() throws Exception { - lssClient.deleteSession(sessionId); - lssClient.deletePreset(presetName); - } - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/GetSourceInfoTest.java b/src/test/java/com/baidubce/services/lss/cases/GetSourceInfoTest.java deleted file mode 100755 index 35a1e675..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/GetSourceInfoTest.java +++ /dev/null @@ -1,134 +0,0 @@ -package com.baidubce.services.lss.cases; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.GetSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2016/3/15. - */ -public class GetSourceInfoTest extends AbstractLssTest { - private String sessionId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - String presetName = convertName(prePresetName); - - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - System.out.println(presetName); - - description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - publish.setPullUrl("rtmp://10.216.121.59/vod/sample.flv"); - - System.out.println(presetName); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - sessionId = resp.getSessionId(); - lssClient.startPullSession(sessionId); - - for (int i = 0; i < 10; i++) { - - try { - Thread.sleep(2000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - GetSessionResponse response = lssClient.getSession(sessionId); - if (response.getStreamingStatus() != null && response.getStreamingStatus().equals("STREAMING")) { - System.out.println(response); - break; - } - - } - - - } - - @After - public void tearDown() throws Exception { - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void testNormal() { - System.out.println(lssClient.getSessionSourceInfo(sessionId)); - - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/GetStreamTest.java b/src/test/java/com/baidubce/services/lss/cases/GetStreamTest.java deleted file mode 100755 index 2ebf3e65..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/GetStreamTest.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.GetStreamRequest; -import com.baidubce.services.lss.model.GetStreamResponse; -import com.baidubce.services.lss.model.ListStreamResponse; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertEquals; - -/** - * Created by wuyafei on 16/10/14. - */ -public class GetStreamTest extends AbstractLssTest { - - private String playDomain = "play.testsdk.iefay.xyz"; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @Test - public void testGetStream() { - String app = "test"; - ListStreamResponse listStreamResponse = lssClient.listStream(playDomain); - if (listStreamResponse.getStreams().size() >= 1) { - String stream = listStreamResponse.getStreams().get(0).getPublish().getPushStream(); - GetStreamResponse response = lssClient.getStream(playDomain, app, stream); - // System.out.println(response); - assertEquals(response.getApp(), app); - assertEquals(response.getPublish().getPushStream(), stream); - assertEquals(response.getPlayDomain(), playDomain); - } - } - - @Test - public void testGetStreamWithRequest() { - String app = "test"; - ListStreamResponse listStreamResponse = lssClient.listStream(playDomain); - if (listStreamResponse.getStreams().size() >= 1) { - String stream = listStreamResponse.getStreams().get(0).getPublish().getPushStream(); - GetStreamRequest request = new GetStreamRequest(); - request.withPlayDomain(playDomain).withApp(app).withStream(stream); - GetStreamResponse response = lssClient.getStream(request); - // System.out.println(response); - assertEquals(response.getPlayDomain(), playDomain); - assertEquals(response.getAudit(), "default"); - String rtmpPlayUrl = "rtmp://" + playDomain + "/" + app + "/" + stream; - if (response.getPlay().getRtmpUrl() != null) { - assertEquals(response.getPlay().getRtmpUrl(), rtmpPlayUrl); - } else if (!response.getPlay().getRtmpUrls().isEmpty()) { - assertEquals(response.getPlay().getRtmpUrls().get("L0"), rtmpPlayUrl); - } - assertEquals(response.getStatistics().getBandwidthInBps() == 0, true); - assertEquals(response.getStatistics().getPlayCount() == 0, true); - } - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/InsertCuePointTest.java b/src/test/java/com/baidubce/services/lss/cases/InsertCuePointTest.java deleted file mode 100755 index d0002d4b..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/InsertCuePointTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.baidubce.services.lss.cases; - -import java.util.HashMap; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.Rtmp; - -/** - * Created by shidaiting01 on 2016/4/7. - */ -public class InsertCuePointTest extends AbstractLssTest { - private String sessionId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - String presetName = convertName(prePresetName); - - String description = preSessionDescription; - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createForwardOnlyPreset(presetName, description, null, rtmp, null, null); - System.out.println(presetName); - - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - publish.setPullUrl("rtmp://10.216.121.59/vod/sample.flv"); - - System.out.println(presetName); - CreateSessionResponse resp = lssClient.createSession(description, presetName, null, null, null, - publish); - sessionId = resp.getSessionId(); - - - } - - @After - public void tearDown() throws Exception { - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void testNormal() { - bceEx.expect(com.baidubce.BceServiceException.class); - System.out.println(lssClient.insertCuePoint(sessionId, "callback", new HashMap())); - - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/ListDomainAppTest.java b/src/test/java/com/baidubce/services/lss/cases/ListDomainAppTest.java deleted file mode 100755 index b50c4ca6..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/ListDomainAppTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.ListDomainAppRequest; -import com.baidubce.services.lss.model.ListDomainAppResponse; -import org.junit.Before; -import org.junit.Test; -import static org.junit.Assert.assertNotNull; - -/** - * Created by wuyafei on 16/10/14. - */ -public class ListDomainAppTest extends AbstractLssTest { - - private String playDomain = "play.testsdk.iefay.xyz"; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @Test - public void testListDomainApp() { - ListDomainAppResponse response = lssClient.listDomainApp(playDomain); - // System.out.println(response); - assertNotNull(response.getAppList()); - } - - @Test - public void testListDomainAppWithRequest() { - ListDomainAppRequest request = new ListDomainAppRequest(); - request.setPlayDomain(playDomain); - ListDomainAppResponse response = lssClient.listDomainApp(request); - // System.out.println(response); - assertNotNull(response.getAppList()); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/ListLiveNotificationTest.java b/src/test/java/com/baidubce/services/lss/cases/ListLiveNotificationTest.java deleted file mode 100755 index 1a0315bd..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/ListLiveNotificationTest.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.Notification; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class ListLiveNotificationTest extends AbstractLssTest { - String notification = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - - } - - @After - public void tearDown() throws Exception { - ListNotificationsResponse resp = lssClient.listNotifications(); - String name = null; - for (Notification noti : resp.getNotifications()) { - name = noti.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * ListNotificationsResponse listNotifications() - */ - @Test - public void testListNotificationCount() { - int count = 0; - ListNotificationsResponse resp = lssClient.listNotifications(); - System.out.println(resp); - count = resp.getNotifications().size(); - String notification1 = convertName(preNotification); - lssClient.createNotification(notification1, END_POINT); - String notification2 = convertName(preNotification); - lssClient.createNotification(notification2, END_POINT); - resp = lssClient.listNotifications(); - System.out.println(resp); - int count1 = -1; - count1 = resp.getNotifications().size(); - assertEquals(count + 2, count1); - int flag1 = 0; - int flag2 = 0; - String name = null; - for (Notification noti : resp.getNotifications()) { - name = noti.getName(); - if (name.equals(notification1)) { - flag1 = 1; - } - if (name.equals(notification2)) { - flag2 = 1; - } - } - assertEquals(flag1, 1); - assertEquals(flag2, 1); - } - - /** - * ListNotificationsResponse listNotifications() - */ - @Test - public void testListNotificationInfo() { - - ListNotificationsResponse resp = lssClient.listNotifications(); - int flag = 0; - String name = null; - for (Notification noti : resp.getNotifications()) { - name = noti.getName(); - if (name.equals(notification)) { - flag = 1; - assertEquals(noti.getEndpoint(), END_POINT); - } - } - assertEquals(flag, 1); - } - - /** - * ListNotificationsResponse listNotifications() - */ - @Test - public void testDeletedNotificationNotList() { - lssClient.deleteNotification(notification); - ListNotificationsResponse resp = lssClient.listNotifications(); - int flag = 1; - String name = null; - for (Notification noti : resp.getNotifications()) { - name = noti.getName(); - if (name.equals(notification)) { - flag = 0; - } - } - assertEquals(flag, 1); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/ListLivePresetTest.java b/src/test/java/com/baidubce/services/lss/cases/ListLivePresetTest.java deleted file mode 100755 index 9b1aa29b..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/ListLivePresetTest.java +++ /dev/null @@ -1,204 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class ListLivePresetTest extends AbstractLssTest { - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - ListPresetsResponse resp = lssClient.listPresets(); - String presetName; - for (LivePreset preset : resp.getPresets()) { - presetName = preset.getName(); - if (presetName.startsWith(prePresetName)) { - System.out.println(presetName); - lssClient.deletePreset(presetName); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * ListPresetsResponse listPresets() - */ - @Test - public void testListPresetCount() { - int count0 = 0; - ListPresetsResponse resp = lssClient.listPresets(); - List presets = resp.getPresets(); - count0 = presets.size(); - String presetName1 = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName1, description, audio, video, hls, rtmp, null, null); - - String presetName2 = convertName(prePresetName); - lssClient.createPreset(presetName2, description, audio, video, hls, rtmp, null, null); - - resp = lssClient.listPresets(); - presets = resp.getPresets(); - int count1 = -1; - count1 = presets.size(); - assertEquals(count0 + 2, count1); - String presetName; - int flag1 = 0; - int flag2 = 0; - for (LivePreset preset : resp.getPresets()) { - presetName = preset.getName(); - if (presetName.equals(presetName1) ) { - flag1 = 1; - } else if (presetName.equals(presetName2)) { - flag2 = 1; - } - } - assertEquals(flag1, 1); - assertEquals(flag2, 1); - } - - /** - * ListPresetsResponse listPresets() - */ - @Test - public void testListPresetInfo() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - ListPresetsResponse response = lssClient.listPresets(); - int flag = 0; - String name; - for (LivePreset preset : response.getPresets()) { - name = preset.getName(); - if (name.equals(presetName) ) { - flag = 1; - assertEquals("test", preset.getDescription()); - assertEquals("128000", preset.getAudio().getBitRateInBps().toString()); - assertEquals("2", preset.getAudio().getChannels().toString()); - assertEquals("44100", preset.getAudio().getSampleRateInHz().toString()); - assertEquals("h264", preset.getVideo().getCodec()); - assertEquals("high", preset.getVideo().getCodecOptions().getProfile()); - assertEquals("1600000", preset.getVideo().getBitRateInBps().toString()); - assertEquals("30.0", preset.getVideo().getMaxFrameRate().toString()); - assertEquals("1280", preset.getVideo().getMaxWidthInPixel().toString()); - assertEquals("720", preset.getVideo().getMaxHeightInPixel().toString()); - assertEquals("stretch", preset.getVideo().getSizingPolicy()); - assertEquals("6", preset.getHls().getSegmentTimeInSecond().toString()); - assertEquals("6", preset.getHls().getSegmentListSize().toString()); - assertEquals("true", preset.getHls().getAdaptive().toString()); - assertEquals("true", preset.getRtmp().getGopCache().toString()); - } - } - assertEquals(flag, 1); - } - - /** - * ListPresetsResponse listPresets() - */ - @Test - public void testDeletedPresetNotList() { - String presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - lssClient.deletePreset(presetName); - - ListPresetsResponse response = lssClient.listPresets(); - int flag = 1; - String name; - for (LivePreset preset : response.getPresets()) { - name = preset.getName(); - if (name.equals(presetName)) { - flag = 0; - } - } - assertEquals(flag, 1); - } - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/ListLiveRecordingTest.java b/src/test/java/com/baidubce/services/lss/cases/ListLiveRecordingTest.java deleted file mode 100755 index 04e5e7ea..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/ListLiveRecordingTest.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.baidubce.services.lss.cases; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -/** - * Created by shidaiting01 on 2016/3/15. - */ -public class ListLiveRecordingTest extends AbstractLssTest { - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void testNormal() { - System.out.println(lssClient.listRecordings()); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/ListLiveSecurityPolicyTest.java b/src/test/java/com/baidubce/services/lss/cases/ListLiveSecurityPolicyTest.java deleted file mode 100755 index 315a2c0a..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/ListLiveSecurityPolicyTest.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.baidubce.services.lss.cases; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.ListSecurityPoliciesResponse; - -/** - * Created by shidaiting01 on 2016/1/13. - */ -public class ListLiveSecurityPolicyTest extends AbstractLssTest { - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void test() { - ListSecurityPoliciesResponse resp = lssClient.listSecurityPolicies(); - Assert.assertTrue(resp.getSecurityPolicies() != null); - Assert.assertTrue(resp.getSecurityPolicies().size() > 0); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/ListLiveSessionTest.java b/src/test/java/com/baidubce/services/lss/cases/ListLiveSessionTest.java deleted file mode 100755 index a1c14e1c..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/ListLiveSessionTest.java +++ /dev/null @@ -1,436 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.GetSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsRequest; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class ListLiveSessionTest extends AbstractLssTest { - private String presetName = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - } - - @After - public void tearDown() throws Exception { - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testListSessionNormal1() { - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = response.getSessionId(); - int flag = 0; - ListSessionsResponse resp = lssClient.listSessions(); - for (LiveSession session : resp.getSessions()) { - String sessionId1 = session.getSessionId(); - if (sessionId1.equals(sessionId)) { - - flag = 1; - } - } - assertEquals(flag, 1); - } - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testListSessionNormal2() { - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = response.getSessionId(); - int flag = 0; - ListSessionsRequest request = new ListSessionsRequest(); - ListSessionsResponse resp = lssClient.listSessions(request); - - for (LiveSession session : resp.getSessions()) { - String sessionId1 = session.getSessionId(); - if (sessionId1.equals(sessionId)) { - - flag = 1; - } - } - assertEquals(flag, 1); - } - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testListSessionReady1() { - String status = "READY"; - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = response.getSessionId(); - int flag = 0; - ListSessionsResponse resp = lssClient.listSessions(status); - for (LiveSession session : resp.getSessions()) { - String sessionId1 = session.getSessionId(); - if (sessionId1.equals(sessionId)) { - - flag = 1; - } - } - assertEquals(flag, 1); - } - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testListSessionReady2() { - String status = "READY"; - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = response.getSessionId(); - int flag = 0; - ListSessionsRequest request = new ListSessionsRequest(); - request.setStatus(status); - ListSessionsResponse resp = lssClient.listSessions(request); - for (LiveSession session : resp.getSessions()) { - String sessionId1 = session.getSessionId(); - if (sessionId1.equals(sessionId)) { - - flag = 1; - } - } - assertEquals(flag, 1); - } - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testListSessionPaused1() { - String status = "PAUSED"; - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = response.getSessionId(); - lssClient.pauseSession(sessionId); - GetSessionResponse response1 = lssClient.getSession(sessionId); - assertEquals(response1.getStatus(), "PAUSED"); - int flag = 0; - ListSessionsResponse resp = lssClient.listSessions(status); - - for (LiveSession session : resp.getSessions()) { - String sessionId1 = session.getSessionId(); - if (sessionId1.equals(sessionId)) { - - flag = 1; - } - } - assertEquals(flag, 1); - } - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testListSessionPaused2() { - String status = "PAUSED"; - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = response.getSessionId(); - lssClient.pauseSession(sessionId); - GetSessionResponse response1 = lssClient.getSession(sessionId); - assertEquals(response1.getStatus(), "PAUSED"); - int flag = 0; - ListSessionsRequest request = new ListSessionsRequest(); - request.setStatus(status); - ListSessionsResponse resp = lssClient.listSessions(request); - for (LiveSession session : resp.getSessions()) { - String sessionId1 = session.getSessionId(); - if (sessionId1.equals(sessionId)) { - - flag = 1; - } - } - assertEquals(flag, 1); - } - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testListSessionCount() { - int count = 0; - int count1 = -1; - ListSessionsResponse resp = lssClient.listSessions(); - count = resp.getSessions().size(); - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId1 = response.getSessionId(); - response = lssClient.createSession(description, presetName, notification, null, null, publish); - String sessionId2 = response.getSessionId(); - lssClient.pauseSession(sessionId2); - int flag1 = 0; - int flag2 = 0; - resp = lssClient.listSessions(); - count1 = resp.getSessions().size(); - - for (LiveSession session : resp.getSessions()) { - String sessionId3 = session.getSessionId(); - if (sessionId3.equals(sessionId1)) { - flag1 = 1; - } - if (sessionId3.equals(sessionId2)) { - flag2 = 1; - } - } - assertEquals(flag1, 1); - assertEquals(flag2, 1); - assertEquals(count1, count + 2); - } - - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testListSessionInfo() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = response.getSessionId(); - ListSessionsResponse resp = lssClient.listSessions(); - int flag = 0; - for (LiveSession session : resp.getSessions()) { - String sessionId1 = session.getSessionId(); - if (sessionId1.equals(sessionId)) { - flag = 1; - assertEquals(session.getPreset(), presetName); - assertEquals(session.getDescription(), description); - assertEquals(session.getNotification(), notification); - - assertEquals(session.getStatus(), "READY"); - } - } - assertEquals(flag, 1); - } - - - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testClosedSessionNotList() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = response.getSessionId(); - lssClient.deleteSession(sessionId); - ListSessionsResponse resp = lssClient.listSessions(); - int flag = 1; - for (LiveSession session : resp.getSessions()) { - String sessionId1 = session.getSessionId(); - if (sessionId1.equals(sessionId)) { - - flag = 1; - } - } - assertEquals(flag, 1); - } - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testRequestNull() { - - ListSessionsRequest request = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter request should NOT be null"); - lssClient.listSessions(request); - } - - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testStatusNull() { - - String status = null; - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse response = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = response.getSessionId(); - lssClient.pauseSession(sessionId); - GetSessionResponse response1 = lssClient.getSession(sessionId); - assertEquals(response1.getStatus(), "PAUSED"); - int flag = 0; - ListSessionsResponse resp = lssClient.listSessions(status); - for (LiveSession session : resp.getSessions()) { - String sessionId1 = session.getSessionId(); - if (sessionId1.equals(sessionId)) { - - flag = 1; - } - } - assertEquals(flag, 1); - } - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testStatusEmpty() { - - String status = ""; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("The parameter status should NOT be empty string"); - lssClient.listSessions(status); - } - - /** - *ListSessionsResponse listSessions() - */ - @Test - public void testStatusStringNull() { - - String status = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("No enum constant"); - lssClient.listSessions(status); - } - - - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/ListStreamTest.java b/src/test/java/com/baidubce/services/lss/cases/ListStreamTest.java deleted file mode 100755 index 795a80f9..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/ListStreamTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.ListStreamRequest; -import com.baidubce.services.lss.model.ListStreamResponse; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -/** - * Created by wuyafei on 16/10/14. - */ -public class ListStreamTest extends AbstractLssTest { - - private String playDomain = "play.testsdk.iefay.xyz"; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @Test - public void testListStreamWithLeastParams() { - ListStreamResponse response = lssClient.listStream(playDomain); - System.out.println(response); - assertNull(response.getMarker()); - assertNotNull(response.getStreams()); - } - - @Test - public void testListStream() { - ListStreamRequest request = new ListStreamRequest(); - String status = "READY"; - request.withPlayDomain(playDomain).withMaxSize(1).withStatus(status); - ListStreamResponse response = lssClient.listStream(request); - // System.out.println(response); - assertEquals(response.getStreams().size() <= 1, true); - assertNull(response.getMarker()); - if (response.getStreams().size() == 1) { - assertNotNull(response.getNextMarker()); - assertTrue(response.getIsTruncated()); - assertEquals(response.getStreams().get(0).getStatus(), status); - request.withMarker(response.getNextMarker()).withMaxSize(3); - response = lssClient.listStream(request); - assertEquals(response.getStreams().size() <= 3, true); - if (response.getStreams().size() != 0) { - assertNotNull(response.getNextMarker()); - } - } - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/PauseAppStreamTest.java b/src/test/java/com/baidubce/services/lss/cases/PauseAppStreamTest.java deleted file mode 100755 index cd676a4d..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/PauseAppStreamTest.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.PauseAppStreamRequest; -import com.baidubce.services.lss.model.ResumeAppStreamRequest; -import org.junit.Before; -import org.junit.Test; - - -/** - * Created by wuyafei on 16/6/26. - */ -public class PauseAppStreamTest extends AbstractLssTest { - - @Before - public void setUp() throws Exception { - AK = "6107180b80ae42c0a821a5fe53ba615e"; - SK = "a88ed698c0fd4774a4f1bdcebcae5922"; - END_POINT = "http://10.65.3.79:80"; - super.setUp(); - } - - @Test - public void testPauseAppStreamByRequest() { - PauseAppStreamRequest request = new PauseAppStreamRequest(); - request.setApp("test_app"); - request.setStream("teststream"); - lssClient.pauseAppStream(request); - } - - @Test - public void testResumeAppStreamByRequest() { - ResumeAppStreamRequest request = new ResumeAppStreamRequest(); - request.setApp("test_app"); - request.setStream("teststream"); - lssClient.resumeAppStream(request); - } - - @Test - public void testPauseAppStreamByAppAndStream() { - lssClient.pauseAppStream("test_app", "hello"); - } - - @Test - public void testResumeAppStreamByAppAndStream() { - lssClient.resumeAppStream("test_app", "hello"); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/PauseLiveSessionTest.java b/src/test/java/com/baidubce/services/lss/cases/PauseLiveSessionTest.java deleted file mode 100755 index 20e031a3..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/PauseLiveSessionTest.java +++ /dev/null @@ -1,244 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.GetSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.PauseSessionRequest; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2015/9/18. - */ -public class PauseLiveSessionTest extends AbstractLssTest { - private String presetName = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - presetName = convertName(prePresetName); - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - - } - - @After - public void tearDown() throws Exception { - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * PauseSessionResponse pauseSession(String sessionId) - */ - @Test - public void testPauseSessionNormal1() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = resp.getSessionId(); - - GetSessionResponse resp1 = lssClient.getSession(sessionId); - assertEquals(resp1.getStatus(), "READY"); - lssClient.pauseSession(sessionId); - GetSessionResponse resp2 = lssClient.getSession(sessionId); - assertEquals(resp2.getStatus(), "PAUSED"); - } - - /** - * PauseSessionResponse pauseSession(request) - */ - @Test - public void testPauseSessionNormal2() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = resp.getSessionId(); - - GetSessionResponse resp1 = lssClient.getSession(sessionId); - assertEquals(resp1.getStatus(), "READY"); - PauseSessionRequest request = new PauseSessionRequest(); - request.setSessionId(sessionId); - lssClient.pauseSession(request); - GetSessionResponse resp2 = lssClient.getSession(sessionId); - assertEquals(resp2.getStatus(), "PAUSED"); - } - - /** - * PauseSessionResponse pauseSession(sessionId) - */ - @Test - public void testSessionIdNull() { - String sessionId = null; - bceEx.expect(IllegalArgumentException.class); - lssClient.pauseSession(sessionId); - } - - /** - * PauseSessionResponse pauseSession(sessionId) - */ - @Test - public void testRequestNull() { - PauseSessionRequest request = null; - bceEx.expect(IllegalArgumentException.class); - lssClient.pauseSession(request); - } - - /** - * PauseSessionResponse pauseSession(sessionId) - */ - @Test - public void testSessionIdEmpty() { - String sessionId = ""; - bceEx.expect(IllegalArgumentException.class); - lssClient.pauseSession(sessionId); - } - - /** - * PauseSessionResponse pauseSession(sessionId) - */ - @Test - public void testSessionIdSringNull() { - String sessionId = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.pauseSession(sessionId); - } - - /** - * PauseSessionResponse pauseSession(sessionId) - */ - @Test - public void testSessionIdNotExist() { - String sessionId = "session_not_exist"; - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.pauseSession(sessionId); - } - - /** - * PauseSessionResponse pauseSession(String sessionId) - */ - @Test - public void testPauseSessionPaused() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = resp.getSessionId(); - - GetSessionResponse resp1 = lssClient.getSession(sessionId); - assertEquals(resp1.getStatus(), "READY"); - lssClient.pauseSession(sessionId); - GetSessionResponse resp2 = lssClient.getSession(sessionId); - assertEquals(resp2.getStatus(), "PAUSED"); - bceEx.expect(com.baidubce.BceServiceException.class); - - lssClient.pauseSession(sessionId); - } - - /** - * PauseSessionResponse pauseSession(String sessionId) - */ - @Test - public void testPauseSessionDeleted() { - - String description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - String sessionId = resp.getSessionId(); - - GetSessionResponse resp1 = lssClient.getSession(sessionId); - assertEquals(resp1.getStatus(), "READY"); - lssClient.deleteSession(sessionId); - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.pauseSession(sessionId); - } - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/PauseResumeDomainStreamTest.java b/src/test/java/com/baidubce/services/lss/cases/PauseResumeDomainStreamTest.java deleted file mode 100755 index 6ba93710..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/PauseResumeDomainStreamTest.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.GetStreamResponse; -import com.baidubce.services.lss.model.ListStreamResponse; -import com.baidubce.services.lss.model.LiveStream; -import com.baidubce.services.lss.model.ResumeDomainStreamRequest; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Created by wuyafei on 16/10/17. - */ -public class PauseResumeDomainStreamTest extends AbstractLssTest { - - private String domain = "play.testsdk.iefay.xyz"; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @Test - public void testPauseResumeStream() { - ListStreamResponse response = lssClient.listStream(domain); - for (LiveStream liveStream : response.getStreams()) { - if (!("PAUSED".equals(liveStream.getStatus()) || "CLOSED".equals(liveStream.getStatus()))) { - String app = liveStream.getApp(); - String stream = liveStream.getPublish().getPushStream(); - lssClient.pauseDomainStream(domain, app, stream); - GetStreamResponse getStreamResponse = lssClient.getStream(domain, app, stream); - // System.out.println(getStreamResponse); - assertEquals(getStreamResponse.getStatus(), "PAUSED"); - ResumeDomainStreamRequest request = new ResumeDomainStreamRequest(); - request.withApp(app).withDomain(domain).withStream(stream); - lssClient.resumeDomainStream(request); - getStreamResponse = lssClient.getStream(domain, app, stream); - // System.out.println(getStreamResponse); - assertEquals(getStreamResponse.getStatus(), "READY"); - break; - } - } - - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/QueryAppTest.java b/src/test/java/com/baidubce/services/lss/cases/QueryAppTest.java deleted file mode 100755 index d5f912f8..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/QueryAppTest.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.baidubce.services.lss.cases; - -import com.baidubce.services.lss.model.GetAppResponse; -import com.baidubce.services.lss.model.GetAppStreamResponse; -import com.baidubce.services.lss.model.ListAppResponse; -import com.baidubce.services.lss.model.ListAppStreamsResponse; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -/** - * Created by wuyafei on 16/6/29. - */ -public class QueryAppTest extends AbstractLssTest { - @Before - public void setUp() throws Exception { - AK = "6107180b80ae42c0a821a5fe53ba615e"; - SK = "a88ed698c0fd4774a4f1bdcebcae5922"; - END_POINT = "http://10.65.3.79:80"; - super.setUp(); - } - - @Test - public void testQueryApp() { - GetAppResponse response = lssClient.queryApp("test_app"); - assertEquals(response.getName(), "test_app"); - } - - @Test - public void testQueryAppStream() { - GetAppStreamResponse response = lssClient.queryAppStream("test_app", "teststream"); - assertEquals(response.getPublish().getPushStream(), "teststream"); - } - - @Test - public void testListAppStreams() { - ListAppStreamsResponse response = lssClient.listAppStreams("test_app"); - assertEquals(response.getSessions().size(), 2); - - if (response.getSessions().get(0).getStatus().equals("READY")) { - lssClient.pauseAppStream("test_app", response.getSessions().get(0).getPublish().getPushStream()); - } - ListAppStreamsResponse response1 = lssClient.listAppStreams("test_app", "READY"); - assertEquals(response1.getSessions().size(), 1); - } - - @Test - public void testListApp() { - ListAppResponse response = lssClient.listApp(); - assertEquals(response.getApps().size(), 3); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/RefreshLiveSessionTest.java b/src/test/java/com/baidubce/services/lss/cases/RefreshLiveSessionTest.java deleted file mode 100755 index 03a63322..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/RefreshLiveSessionTest.java +++ /dev/null @@ -1,226 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.GetSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.RefreshSessionRequest; -import com.baidubce.services.lss.model.RefreshSessionResponse; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class RefreshLiveSessionTest extends AbstractLssTest { - private String sessionId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - String presetName = convertName(prePresetName); - - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - System.out.println(presetName); - - description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - - System.out.println(presetName); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - sessionId = resp.getSessionId(); - - } - - @After - public void tearDown() throws Exception { - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - *RefreshSessionResponse refreshSession(String sessionId) - */ - @Test - public void testRefreshSessionNormal1() { - GetSessionResponse response = lssClient.getSession(sessionId); - String pusUrl1 = response.getPublish().getPushUrl(); - RefreshSessionResponse resp = lssClient.refreshSession(sessionId); - - response = lssClient.getSession(sessionId); - String pusUrl2 = response.getPublish().getPushUrl(); - assertNotEquals(pusUrl1, pusUrl2); - } - - /** - *RefreshSessionResponse refreshSession(RefreshSessionRequest request) - */ - @Test - public void testRefreshSessionNormal2() { - GetSessionResponse response = lssClient.getSession(sessionId); - String pusUrl1 = response.getPublish().getPushUrl(); - RefreshSessionRequest request = new RefreshSessionRequest(); - request.setSessionId(sessionId); - lssClient.refreshSession(request); - response = lssClient.getSession(sessionId); - String pusUrl2 = response.getPublish().getPushUrl(); - assertNotEquals(pusUrl1, pusUrl2); - } - - /** - *RefreshSessionResponse refreshSession(String sessionId) - */ - @Test - public void testSessionIdNotExist() { - sessionId = "not_exist_sesssion"; - bceEx.expect(com.baidubce.BceServiceException.class); - - lssClient.refreshSession(sessionId); - } - - /** - *RefreshSessionResponse refreshSession(String sessionId) - */ - @Test - public void testSessionIdNull() { - sessionId = null; - bceEx.expect(IllegalArgumentException.class); - - lssClient.refreshSession(sessionId); - } - - /** - *RefreshSessionResponse refreshSession(String sessionId) - */ - @Test - public void testRequestNull() { - RefreshSessionRequest request = null; - bceEx.expect(IllegalArgumentException.class); - - lssClient.refreshSession(request); - } - - /** - *RefreshSessionResponse refreshSession(String sessionId) - */ - @Test - public void testSessionIdEmpty() { - sessionId = ""; - bceEx.expect(IllegalArgumentException.class); - - lssClient.refreshSession(sessionId); - } - - /** - *RefreshSessionResponse refreshSession(String sessionId) - */ - @Test - public void testSessionIdStringNull() { - sessionId = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - - lssClient.refreshSession(sessionId); - } - - /** - *RefreshSessionResponse refreshSession(String sessionId) - */ - @Test - public void testRefreshSessionPaused() { - lssClient.pauseSession(sessionId); - GetSessionResponse response = lssClient.getSession(sessionId); - assertEquals(response.getStatus(), "PAUSED"); - String pusUrl1 = response.getPublish().getPushUrl(); - lssClient.refreshSession(sessionId); - response = lssClient.getSession(sessionId); - String pusUrl2 = response.getPublish().getPushUrl(); - assertNotEquals(pusUrl1, pusUrl2); - } - - /** - *RefreshSessionResponse refreshSession(String sessionId) - */ - @Test - public void testRefreshSessionClosed() { - lssClient.deleteSession(sessionId); - bceEx.expect(com.baidubce.BceServiceException.class); - - lssClient.refreshSession(sessionId); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/ResumeLiveSessionTest.java b/src/test/java/com/baidubce/services/lss/cases/ResumeLiveSessionTest.java deleted file mode 100755 index 33f64d68..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/ResumeLiveSessionTest.java +++ /dev/null @@ -1,217 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.GetSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.ResumeSessionRequest; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2015/9/17. - */ -public class ResumeLiveSessionTest extends AbstractLssTest { - private String sessionId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - String presetName = convertName(prePresetName); - - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - System.out.println(presetName); - - description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - - System.out.println(presetName); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - sessionId = resp.getSessionId(); - - } - - @After - public void tearDown() throws Exception { - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - *ResumeSessionResponse resumeSession(String sessionId) - */ - @Test - public void testResumeSessionNormal1() { - - lssClient.pauseSession(sessionId); - GetSessionResponse response = lssClient.getSession(sessionId); - assertEquals(response.getStatus(), "PAUSED"); - lssClient.resumeSession(sessionId); - response = lssClient.getSession(sessionId); - assertEquals(response.getStatus(), "READY"); - } - - /** - *ResumeSessionResponse resumeSession(ResumeSessionRequest request) - */ - @Test - public void testResumeSessionNormal2() { - - lssClient.pauseSession(sessionId); - GetSessionResponse response = lssClient.getSession(sessionId); - assertEquals(response.getStatus(), "PAUSED"); - ResumeSessionRequest request = new ResumeSessionRequest(); - request.setSessionId(sessionId); - lssClient.resumeSession(request); - response = lssClient.getSession(sessionId); - assertEquals(response.getStatus(), "READY"); - } - - /** - * ResumeSessionResponse resumeSession(String sessionId) - */ - @Test - public void testSessionIdNotExist() { - String sessionId = "not_exist_session"; - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.resumeSession(sessionId); - } - - /** - * ResumeSessionResponse resumeSession(String sessionId) - */ - @Test - public void testSessionIdNull() { - String sessionId = null; - bceEx.expect(IllegalArgumentException.class); - lssClient.resumeSession(sessionId); - } - - - /** - *ResumeSessionResponse resumeSession(ResumeSessionRequest request) - */ - @Test - public void testRequestNull() { - ResumeSessionRequest request = null; - bceEx.expect(IllegalArgumentException.class); - lssClient.resumeSession(request); - } - - /** - *ResumeSessionResponse resumeSession(String sessionId) - */ - @Test - public void testSessionIdEmpty() { - String sessionId = ""; - bceEx.expect(IllegalArgumentException.class); - lssClient.resumeSession(sessionId); - } - - /** - *ResumeSessionResponse resumeSession(String sessionId) - */ - @Test - public void testSessionIdStringNull() { - String sessionId = "null"; - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.resumeSession(sessionId); - } - - /** - *ResumeSessionResponse resumeSession(String sessionId) - */ - @Test - public void testResumeSessionReady() { - - GetSessionResponse response = lssClient.getSession(sessionId); - assertEquals(response.getStatus(), "READY"); - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.resumeSession(sessionId); - } - - /** - *ResumeSessionResponse resumeSession(String sessionId) - */ - @Test - public void testResumeSessionClosed() { - lssClient.deleteSession(sessionId); - bceEx.expect(com.baidubce.BceServiceException.class); - lssClient.resumeSession(sessionId); - } - -} diff --git a/src/test/java/com/baidubce/services/lss/cases/StartPullLiveSessionTest.java b/src/test/java/com/baidubce/services/lss/cases/StartPullLiveSessionTest.java deleted file mode 100755 index 82a251d4..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/StartPullLiveSessionTest.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.GetSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2016/1/13. - */ -public class StartPullLiveSessionTest extends AbstractLssTest { - private String sessionId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - String presetName = convertName(prePresetName); - - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - System.out.println(presetName); - - description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - publish.setPullUrl("http://livedemo.baidu.com/pull/live.m3u8"); - - System.out.println(presetName); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - sessionId = resp.getSessionId(); - - } - - @After - public void tearDown() throws Exception { - for (int i = 0; i < 60; i++) { - ListSessionsResponse resp1 = lssClient.listSessions("CONNECTING"); - if (resp1.getSessions().size() != 0) { - System.out.println(resp1.toString()); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } else { - break; - } - } - - - ListSessionsResponse resp2 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp3 = lssClient.listSessions(); - for (LiveSession session : resp3.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void test() { - GetSessionResponse response = lssClient.getSession(sessionId); - - System.out.println(response.toString()); - - lssClient.startPullSession(sessionId); - response = lssClient.getSession(sessionId); - - System.out.println(response.toString()); - assertEquals(response.getStatus(), "CONNECTING"); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/StartStopRecordingTest.java b/src/test/java/com/baidubce/services/lss/cases/StartStopRecordingTest.java deleted file mode 100755 index cecc6188..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/StartStopRecordingTest.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.baidubce.services.lss.cases; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.Audio; -import com.baidubce.services.lss.model.CodecOptions; -import com.baidubce.services.lss.model.CreateSessionResponse; -import com.baidubce.services.lss.model.Hls; -import com.baidubce.services.lss.model.ListNotificationsResponse; -import com.baidubce.services.lss.model.ListPresetsResponse; -import com.baidubce.services.lss.model.ListSessionsResponse; -import com.baidubce.services.lss.model.LivePreset; -import com.baidubce.services.lss.model.LivePublishInfo; -import com.baidubce.services.lss.model.LiveSession; -import com.baidubce.services.lss.model.Notification; -import com.baidubce.services.lss.model.Rtmp; -import com.baidubce.services.lss.model.Video; - -/** - * Created by shidaiting01 on 2016/3/15. - */ -public class StartStopRecordingTest extends AbstractLssTest { - private String sessionId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - String presetName = convertName(prePresetName); - - String description = "test"; - Audio audio = new Audio(); - audio.setBitRateInBps(128000); - audio.setChannels(2); - audio.setSampleRateInHz(44100); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(1600000); - video.setMaxFrameRate(30f); - video.setMaxHeightInPixel(720); - video.setMaxWidthInPixel(1280); - video.setSizingPolicy("stretch"); - Hls hls = new Hls(); - hls.setSegmentTimeInSecond(6); - hls.setSegmentListSize(6); - hls.setAdaptive(true); - Rtmp rtmp = new Rtmp(); - rtmp.setGopCache(true); - - lssClient.createPreset(presetName, description, audio, video, hls, rtmp, null, null); - System.out.println(presetName); - - description = preSessionDescription; - String notification = convertName(preNotification); - lssClient.createNotification(notification, END_POINT); - LivePublishInfo publish = new LivePublishInfo(); - publish.setRegion("bj"); - publish.setPullUrl("http://livedemo.baidu.com/pull/live.m3u8"); - - System.out.println(presetName); - CreateSessionResponse resp = lssClient.createSession(description, presetName, notification, null, null, - publish); - sessionId = resp.getSessionId(); - - } - - @After - public void tearDown() throws Exception { - for (int i = 0; i < 60; i++) { - ListSessionsResponse resp = lssClient.listSessions("CONNECTING"); - if (resp.getSessions().size() != 0) { - System.out.println(resp.toString()); - try { - Thread.sleep(10000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } else { - break; - } - } - ListSessionsResponse resp1 = lssClient.listSessions("ONGOING"); - for (LiveSession session : resp1.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.pauseSession(session.getSessionId()); - } - } - - ListSessionsResponse resp2 = lssClient.listSessions(); - for (LiveSession session : resp2.getSessions()) { - if (session.getDescription().equals(preSessionDescription)) { - lssClient.deleteSession(session.getSessionId()); - } - } - - ListPresetsResponse resp = lssClient.listPresets(); - String name; - for (LivePreset preset : resp.getPresets()) { - name = preset.getName(); - - if (name.startsWith(prePresetName)) { - lssClient.deletePreset(name); - } - } - - ListNotificationsResponse resp4 = lssClient.listNotifications(); - for (Notification notification : resp4.getNotifications()) { - name = notification.getName(); - if (name.startsWith(preNotification)) { - lssClient.deleteNotification(name); - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void test() { - System.out.println(sessionId); - lssClient.startRecording(sessionId, "lss_java_sdk"); - lssClient.stopRecording(sessionId); - } -} diff --git a/src/test/java/com/baidubce/services/lss/cases/UpdateLiveSecurityPolicyTest.java b/src/test/java/com/baidubce/services/lss/cases/UpdateLiveSecurityPolicyTest.java deleted file mode 100755 index 0a06702c..00000000 --- a/src/test/java/com/baidubce/services/lss/cases/UpdateLiveSecurityPolicyTest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.baidubce.services.lss.cases; - -import static org.junit.Assert.assertEquals; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.lss.model.AntiLeech; -import com.baidubce.services.lss.model.Auth; -import com.baidubce.services.lss.model.Encryption; -import com.baidubce.services.lss.model.GetSecurityPolicyResponse; -import com.baidubce.services.lss.model.HlsEncryption; -import com.baidubce.services.lss.model.IP; -import com.baidubce.services.lss.model.Refer; -import com.baidubce.services.lss.model.UpdateSecurityPolicyRequest; - -/** - * Created by shidaiting01 on 2016/1/13. - */ -public class UpdateLiveSecurityPolicyTest extends AbstractLssTest { - private String sessionId; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - @Test - public void test() { - - Auth auth = new Auth().withPlay(true).withPush(true); - - List black = new ArrayList(); - black.add("http://refer.demo.com"); - List white = new ArrayList(); - white.add("8.8.8.8"); - - Refer refer = new Refer().withBlacklist(black); - IP ip = new IP().withWhitelist(white); - - AntiLeech antiLeech = new AntiLeech().withRefer(refer).withIp(ip); - - // SafeCode safeCode = new SafeCode().withPlayerType("web").withSafeCode("code1"); - // List safeCodes = new ArrayList(); - // safeCodes.add(safeCode); - - HlsEncryption hlsEncryption = new HlsEncryption().withStrategy("PlayerBinding"); - Encryption encryption = new Encryption().withHls(hlsEncryption); - - lssClient.updateSecurityPolicy("default", auth, antiLeech, encryption); - - GetSecurityPolicyResponse response = lssClient.getSecurityPolicy("default"); - System.out.println(response.toString()); - assertEquals(response.getName(), "default"); - - - - lssClient.updateSecurityPolicy(new UpdateSecurityPolicyRequest().withName("default")); - - - } -} diff --git a/src/test/java/com/baidubce/services/media/AbstractMediaTest.java b/src/test/java/com/baidubce/services/media/AbstractMediaTest.java deleted file mode 100755 index be779e72..00000000 --- a/src/test/java/com/baidubce/services/media/AbstractMediaTest.java +++ /dev/null @@ -1,187 +0,0 @@ -/* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.baidubce.services.media; - -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.util.HashSet; -import java.util.Set; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.bos.BosClient; -import com.baidubce.services.bos.BosClientConfiguration; -import com.baidubce.services.media.model.Audio; -import com.baidubce.services.media.model.Clip; -import com.baidubce.services.media.model.CreateJobResponse; -import com.baidubce.services.media.model.CreatePipelineRequest; -import com.baidubce.services.media.model.CreatePresetRequest; -import com.baidubce.services.media.model.GetPresetResponse; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.PipelineConfig; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.Video; - -public abstract class AbstractMediaTest { - // jianbing's key -// static String MEDIA_AK = "46bd9968a6194b4bbdf0341f2286ccce"; -// static String MEDIA_SK = "ec7f4e0174254f6f9020f9680fb1da9f"; - - // hudapeng's key - static String MEDIA_AK = "5976ebbb80ff49e7984bb3c1061a657d"; - static String MEDIA_SK = "6a15cc0d7083446590a6a46df55a5e98"; - - - // hudapeng's key - // static String MEDIA_AK = "5976ebbb80ff49e7984bb3c1061a657d"; - // static String MEDIA_SK = "6a15cc0d7083446590a6a46df55a5e98"; - // static String END_POINT = "http://multimedia.bce-testinternal.baidu.com"; - static String MEDIA_END_POINT = "http://multimedia.bce-testinternal.baidu.com/"; - static String BOS_END_POINT = "http://10.105.97.15"; - - MediaClient mediaClient; - BosClient bosClient; - - String pipelineName = null; - String jobId = null; - String sourceBucket = null; - String targetBucket = null; - String sourceKey = null; - String targetKey = null; - String presetName = null; - - public void setUp() throws Exception { - DefaultBceCredentials cred = new DefaultBceCredentials(MEDIA_AK, - MEDIA_SK); - BceClientConfiguration config = new BceClientConfiguration() - .withCredentials(cred).withEndpoint(MEDIA_END_POINT) - .withMaxConnections(10); - mediaClient = new MediaClient(config); - - BosClientConfiguration bosConfig = new BosClientConfiguration() - .withCredentials(cred).withEndpoint(BOS_END_POINT); - bosClient = new BosClient(bosConfig); - } - - public void tearDown() throws Exception { - if (presetName != null) { - mediaClient.deletePreset(presetName); - checkPresetExist(presetName, false); - presetName = null; - } - - if (jobId != null) { - jobId = null; - } - - if (pipelineName != null) { - mediaClient.deletePipeline(pipelineName); - checkPipelineExist(pipelineName, false); - pipelineName = null; - } - - } - - protected void createPipeline() { - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineName); - request.setDescription("For testing"); - request.setSourceBucket("jianbininput"); - request.setTargetBucket("jianbinoutput"); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(10); - request.setConfig(config); - mediaClient.createPipeline(request); - - } - - protected void createPreset() { - - CreatePresetRequest request = new CreatePresetRequest(); - request.setPresetName(presetName); - request.setDescription("HDP - For sandbox testing"); - request.setContainer("m4a"); - request.setTransmux(true); - Clip clip = new Clip(); - clip.setStartTimeInSecond(10); - clip.setDurationInSecond(100); - request.setClip(clip); - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - request.setAudio(audio); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(64000); - video.setMaxFrameRate(30f); - video.setMaxWidthInPixel(4096); - video.setMaxHeightInPixel(3072); - video.setSizingPolicy("keep"); - request.setVideo(video); - - mediaClient.createPreset(request); - checkPresetExist(presetName, true); - } - - protected String createJob() { - CreateJobResponse resp = mediaClient.createJob(pipelineName, sourceKey, - targetKey, presetName); - return resp.getJobId(); - } - - /* - * 1. pipeline don't support capital letters 2. in current version, pipeline - * cannot be duplicated even after it is removed - */ - protected String convertName(String key) { - return (key.toLowerCase() + "_" + System.currentTimeMillis()); - } - - protected void checkPipelineExist(String expectedPipelineName, - boolean expected) { - ListPipelinesResponse resp = mediaClient.listPipelines(); - System.err.println(resp); - - Set names = new HashSet(); - for (PipelineStatus pipe : resp.getPipelines()) { - names.add(pipe.getPipelineName()); - } - - if (expected) { - assertTrue("Failed to find expected pipeline: " - + expectedPipelineName + ". \n " + resp, - names.contains(expectedPipelineName)); - } else { - assertFalse("The pipeline: " + expectedPipelineName - + " still exists. \n " + resp, - names.contains(expectedPipelineName)); - } - } - - protected void checkPresetExist(String expectedPresetName, boolean expected) { - GetPresetResponse resp = mediaClient.getPreset(expectedPresetName); - - if (expected) { - assertTrue("Failed to find expected preset: " + expectedPresetName, - resp.getState().equalsIgnoreCase("ACTIVE")); - } else { - assertTrue( - "The pipeline: " + expectedPresetName + " still exists.", - resp.getState().equalsIgnoreCase("INACTIVE")); - } - } - -} diff --git a/src/test/java/com/baidubce/services/media/JobClientTeset.java b/src/test/java/com/baidubce/services/media/JobClientTeset.java deleted file mode 100755 index 301053a0..00000000 --- a/src/test/java/com/baidubce/services/media/JobClientTeset.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.baidubce.services.media; - -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.media.model.GetJobResponse; -import com.baidubce.services.media.model.GetTranscodingJobResponse; -import com.baidubce.services.media.model.Job; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.util.JsonUtils; -import com.fasterxml.jackson.core.JsonProcessingException; - -public class JobClientTeset extends AbstractMediaTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - @Test - public void testGetJobWithPipelineName() { - List pipelines = mediaClient.listPipelines().getPipelines(); - for (PipelineStatus ps : pipelines) { - List jobs = mediaClient.listTranscodingJobs(ps.getPipelineName()).getJobs(); - for (Job job : jobs) { - System.out.println(job); - } - } - } - - @Test - public void testCreateJob() throws Exception { - String pipelineName = "chaipipe"; - String sourceKey = "36A2014.mp4"; - String targetKey = "36A2014_1.mp4"; - String presetName = "bce.video_hls_320x240_240kbps"; - String jobId = mediaClient.createTranscodingJob(pipelineName, sourceKey, targetKey, presetName).getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - GetTranscodingJobResponse resp = mediaClient.getTranscodingJob(jobId); - System.out.println(JsonUtils.toJsonPrettyString(resp)); - } - - @Test - public void testGetJob() throws Exception { - List pipelines = mediaClient.listPipelines().getPipelines(); - for (PipelineStatus ps : pipelines) { - List jobs = mediaClient.listTranscodingJobs(ps.getPipelineName()).getJobs(); - for (Job job : jobs) { - GetTranscodingJobResponse resp = mediaClient.getTranscodingJob(job.getJobId()); - System.out.println(JsonUtils.toJsonPrettyString(resp)); - } - } - } - - @Test - public void getAllPipelines() { - List list = mediaClient.listPipelines().getPipelines(); - for (PipelineStatus ps : list) { - System.out.println(ps); - } - } - -} diff --git a/src/test/java/com/baidubce/services/media/MediaInfoClientTest.java b/src/test/java/com/baidubce/services/media/MediaInfoClientTest.java deleted file mode 100755 index c9708631..00000000 --- a/src/test/java/com/baidubce/services/media/MediaInfoClientTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.baidubce.services.media; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.bos.model.BosObjectSummary; -import com.baidubce.services.media.model.GetMediaInfoOfFileResponse; - -public class MediaInfoClientTest extends AbstractMediaTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - @Test - public void listResource() { - // List resp = bosClient.listBuckets().getBuckets(); - // for (BucketSummary s : resp){ - // System.out.println(s); - // } - List objs = bosClient.listObjects("jianbininput").getContents(); - for (BosObjectSummary obj : objs) { - System.out.println(obj); - } - } - - @Test - public void testGetMediaInfoOfFile() { - - String bucket = "jianbininput"; - List objs = bosClient.listObjects("jianbininput").getContents(); - for (BosObjectSummary obj : objs) { - String key = obj.getKey(); - if (key.endsWith("/")) { - continue; - } - System.out.println("\nkey = " + key); - GetMediaInfoOfFileResponse mediaInfo = mediaClient.getMediaInfoOfFile(bucket, key); - System.out.println("Bucket: " + mediaInfo.getBucket()); - System.out.println("Key: " + mediaInfo.getKey()); - System.out.println("Type: " + mediaInfo.getType()); - System.out.println("Etag: " + mediaInfo.getEtag()); - System.out.println("fileSizInByte: " + mediaInfo.getFileSizeInByte()); - System.out.println("Audio: " + mediaInfo.getAudio()); - System.out.println("Video: " + mediaInfo.getVideo()); - } - - } - -} diff --git a/src/test/java/com/baidubce/services/media/PipelineClientTest.java b/src/test/java/com/baidubce/services/media/PipelineClientTest.java deleted file mode 100755 index b353d64e..00000000 --- a/src/test/java/com/baidubce/services/media/PipelineClientTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.baidubce.services.media; - -import static org.junit.Assert.assertTrue; - -import java.util.HashSet; -import java.util.Set; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.media.model.GetPipelineResponse; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.PipelineStatus; - -public class PipelineClientTest extends AbstractMediaTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - @Test - public void showAllPipelines() { - ListPipelinesResponse resp = mediaClient.listPipelines(); - System.err.println(resp); - } - - @Test - public void testGetAllPipelines() { - pipelineName = convertName("ForTestGetAllPipelines"); - checkPipelineExist(pipelineName, false); - - createPipeline(); - - ListPipelinesResponse resp = mediaClient.listPipelines(); - System.err.println(resp); - - Set names = new HashSet(); - for (PipelineStatus pipe : resp.getPipelines()) { - names.add(pipe.getPipelineName()); - } - assertTrue("Failed to get expected pipelines: " + pipelineName, - names.contains(pipelineName)); - } - - @Test - public void testGetPipeline() { - pipelineName = convertName("ForTestGetPipeline"); - createPipeline(); - checkPipelineExist(pipelineName, true); - - GetPipelineResponse resp = mediaClient.getPipeline(pipelineName); - System.out.println(resp); - assertTrue("Failed to get pipeline: " + pipelineName, resp != null - && resp.getPipelineName().equals(pipelineName)); - } - - @Test - public void testCreatePipeline() { - pipelineName = convertName("ForTestCreatePipeline"); - createPipeline(); - checkPipelineExist(pipelineName, true); - } - - @Test - public void testRemovePipeline() { - pipelineName = convertName("ForTestRemovePipeline"); - createPipeline(); - // pipelineName = "fortestremovepipeline_1429001608289"; - checkPipelineExist(pipelineName, true); - - mediaClient.deletePipeline(pipelineName); - - checkPipelineExist(pipelineName, false); - pipelineName = null; - } - -} diff --git a/src/test/java/com/baidubce/services/media/PresetClientTest.java b/src/test/java/com/baidubce/services/media/PresetClientTest.java deleted file mode 100755 index fff812b4..00000000 --- a/src/test/java/com/baidubce/services/media/PresetClientTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.baidubce.services.media; - -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.media.model.GetPresetResponse; -import com.baidubce.services.media.model.ListPresetsResponse; - -public class PresetClientTest extends AbstractMediaTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - @Test - public void testListPresets() { - ListPresetsResponse resp = mediaClient.listPresets(); - for (GetPresetResponse preset : resp.getPresets()) { - System.out.println(preset.getPresetName()); - } - } - - @Test - public void testCreatePreset() { - presetName = convertName("ForTestCreatePreset"); - createPreset(); - } - - @Test - public void testGetPreset() { - for (GetPresetResponse preset : mediaClient.listPresets().getPresets()) { - GetPresetResponse resp = mediaClient.getPreset(preset.getPresetName()); - System.out.println(resp); - assertTrue("Failed to get preset: " + preset.getPresetName(), resp - .getPresetName().equals(preset.getPresetName())); - } - } - - @Test - public void testDeletePreset() { - presetName = convertName("ForTestRemovePreset"); - createPreset(); - mediaClient.deletePreset(presetName); - checkPresetExist(presetName, false); - presetName = null; - } - -} diff --git a/src/test/java/com/baidubce/services/media/ThumbnailTest.java b/src/test/java/com/baidubce/services/media/ThumbnailTest.java deleted file mode 100755 index 7c4bca61..00000000 --- a/src/test/java/com/baidubce/services/media/ThumbnailTest.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.baidubce.services.media; - -import static org.junit.Assert.fail; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.media.model.GetThumbnailJobResponse; -import com.baidubce.services.media.model.ListThumbnailJobsResponse; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.ThumbnailCapture; -import com.baidubce.services.media.model.ThumbnailJobStatus; -import com.baidubce.services.media.model.ThumbnailTarget; -import com.baidubce.util.JsonUtils; -import com.fasterxml.jackson.core.JsonProcessingException; - -public class ThumbnailTest extends AbstractMediaTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - } - - @Test - public void testCreateThumbnailJobs1() { - String pipelineName = "chaipipe"; - String sourceKey = "10706_csdn.mp4"; - String jobId = mediaClient.createThumbnailJob(pipelineName, sourceKey).getJobId(); - - GetThumbnailJobResponse resp = mediaClient.getThumbnailJob(jobId); - try { - System.out.println(JsonUtils.toJsonPrettyString(resp)); - System.out.println(" jobId = " + resp.getJobId()); - System.out.println(" pipelineName = " + resp.getPipelineName()); - System.out.println(" jobStatus = " + resp.getJobStatus()); - System.out.println(" source.key = " + resp.getSource().getKey()); - System.out.println(" target.keyPrefix = " + resp.getTarget().getKeyPrefix()); - System.out.println(" target.format = " + resp.getTarget().getFormat()); - System.out.println(" target.sizingPolicy = " + resp.getTarget().getSizingPolicy()); - System.out.println(" target.heightInPixel = " + resp.getTarget().getHeightInPixel()); - System.out.println(" target.widthInPixel = " + resp.getTarget().getWidthInPixel()); - System.out.println(" target.keys = " + resp.getTarget().getKeys()); - System.out.println(" capture.mode = " + resp.getCapture().getMode()); - System.out.println(" capture.startTimeInSecond = " + resp.getCapture().getStartTimeInSecond()); - System.out.println(" capture.endTimeInSecond = " + resp.getCapture().getEndTimeInSecond()); - System.out.println(" capture.IntervalInSecond = " + resp.getCapture().getIntervalInSecond()); - - } catch (JsonProcessingException e) { - fail("Failed to read the result."); - } - - } - - @Test - public void testCreateThumbnailJobs2() { - String pipelineName = "chaipipe"; - String sourceKey = "10706_csdn.mp4"; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual"); - - try { - String jobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - fail("This test case should fail."); - } catch (Exception e) { - e.printStackTrace(System.out); - } - - } - @Test - public void testCreateThumbnailJobs3() { - String pipelineName = "chaipipe"; - String sourceKey = "10706_csdn.mp4"; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = - new ThumbnailCapture().withMode("manual").withStartTimeInSecond(0).withEndTimeInSecond(5) - .withIntervalInSecond(1); - String jobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - - GetThumbnailJobResponse resp = mediaClient.getThumbnailJob(jobId); - try { - System.out.println(JsonUtils.toJsonPrettyString(resp)); - System.out.println(" jobId = " + resp.getJobId()); - System.out.println(" pipelineName = " + resp.getPipelineName()); - System.out.println(" jobStatus = " + resp.getJobStatus()); - System.out.println(" source.key = " + resp.getSource().getKey()); - System.out.println(" target.keyPrefix = " + resp.getTarget().getKeyPrefix()); - System.out.println(" target.format = " + resp.getTarget().getFormat()); - System.out.println(" target.sizingPolicy = " + resp.getTarget().getSizingPolicy()); - System.out.println(" target.heightInPixel = " + resp.getTarget().getHeightInPixel()); - System.out.println(" target.widthInPixel = " + resp.getTarget().getWidthInPixel()); - System.out.println(" target.keys = " + resp.getTarget().getKeys()); - System.out.println(" capture.mode = " + resp.getCapture().getMode()); - System.out.println(" capture.startTimeInSecond = " + resp.getCapture().getStartTimeInSecond()); - System.out.println(" capture.endTimeInSecond = " + resp.getCapture().getEndTimeInSecond()); - System.out.println(" capture.IntervalInSecond = " + resp.getCapture().getIntervalInSecond()); - - } catch (JsonProcessingException e) { - fail("Failed to read the result."); - } - - } - - @Test - public void testListThumbnailJobs() { - - for (PipelineStatus ps : mediaClient.listPipelines().getPipelines()) { - try { - ListThumbnailJobsResponse resp = mediaClient.listThumbnailJobs(ps.getPipelineName()); - if (resp.getThumbnails().size() == 0) { - continue; - } - - System.out.println(JsonUtils.toJsonPrettyString(resp)); - System.out.println(); - for (ThumbnailJobStatus job : resp.getThumbnails()) { - - System.out.println(" jobId = " + job.getJobId()); - System.out.println(" pipelineName = " + job.getPipelineName()); - System.out.println(" jobStatus = " + job.getJobStatus()); - System.out.println(" source.key = " + job.getSource().getKey()); - System.out.println(" target.keyPrefix = " + job.getTarget().getKeyPrefix()); - System.out.println(" target.format = " + job.getTarget().getFormat()); - System.out.println(" target.sizingPolicy = " + job.getTarget().getSizingPolicy()); - System.out.println(" target.heightInPixel = " + job.getTarget().getHeightInPixel()); - System.out.println(" target.widthInPixel = " + job.getTarget().getWidthInPixel()); - System.out.println(" target.keys = " + job.getTarget().getKeys()); - System.out.println(" capture.mode = " + job.getCapture().getMode()); - System.out.println(" capture.startTimeInSecond = " + job.getCapture().getStartTimeInSecond()); - System.out.println(" capture.endTimeInSecond = " + job.getCapture().getEndTimeInSecond()); - System.out.println(" capture.IntervalInSecond = " + job.getCapture().getIntervalInSecond()); - System.out.println(); - - } - } catch (Exception e) { - fail("Failed to read the result."); - } - } - } - - @Test - public void testGetThumbnailJob() { - String jobId = "job-ffam2ne6b3k6i66x"; - GetThumbnailJobResponse resp = mediaClient.getThumbnailJob(jobId); - try { - System.out.println(JsonUtils.toJsonPrettyString(resp)); - System.out.println(" jobId = " + resp.getJobId()); - System.out.println(" pipelineName = " + resp.getPipelineName()); - System.out.println(" jobStatus = " + resp.getJobStatus()); - System.out.println(" source.key = " + resp.getSource().getKey()); - System.out.println(" target.keyPrefix = " + resp.getTarget().getKeyPrefix()); - System.out.println(" target.format = " + resp.getTarget().getFormat()); - System.out.println(" target.sizingPolicy = " + resp.getTarget().getSizingPolicy()); - System.out.println(" target.heightInPixel = " + resp.getTarget().getHeightInPixel()); - System.out.println(" target.widthInPixel = " + resp.getTarget().getWidthInPixel()); - System.out.println(" target.keys = " + resp.getTarget().getKeys()); - System.out.println(" capture.mode = " + resp.getCapture().getMode()); - System.out.println(" capture.startTimeInSecond = " + resp.getCapture().getStartTimeInSecond()); - System.out.println(" capture.endTimeInSecond = " + resp.getCapture().getEndTimeInSecond()); - System.out.println(" capture.IntervalInSecond = " + resp.getCapture().getIntervalInSecond()); - - } catch (JsonProcessingException e) { - fail("Failed to read the result."); - } - } -} diff --git a/src/test/java/com/baidubce/services/media/WaterMarkTest.java b/src/test/java/com/baidubce/services/media/WaterMarkTest.java deleted file mode 100755 index 70e2d40a..00000000 --- a/src/test/java/com/baidubce/services/media/WaterMarkTest.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.baidubce.services.media; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.media.model.GetWaterMarkResponse; -import com.baidubce.services.media.model.WaterMark; - -public class WaterMarkTest extends AbstractMediaTest { - String watermarkId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - super.tearDown(); - if (watermarkId != null) { - mediaClient.deleteWaterMark(watermarkId); - watermarkId = null; - } - - } - - @Test - public void testListWaterMark() { - List watermarks = mediaClient.listWaterMark().getWatermarks(); - assertTrue("Failed to get watermarks.", watermarks.size() > 0); - for (WaterMark wm : watermarks) { - System.out.println("watermarkId = " + wm.getWatermarkId()); - System.out.println("bucket = " + wm.getBucket()); - System.out.println("key = " + wm.getKey()); - System.out.println("createTime = " + wm.getCreateTime()); - System.out.println("horizontalOffsetInPixel = " + wm.getHorizontalOffsetInPixel()); - System.out.println("VerticalOffsetInPixel = " + wm.getVerticalOffsetInPixel()); - System.out.println(); - } - } - - @Test - public void testGetWaterMark() { - String watermarkId = "wmk-fgnhmagnyzfj2gze"; - GetWaterMarkResponse wm = mediaClient.getWaterMark(watermarkId); - assertEquals("Failed to verify watermarkId", watermarkId, wm.getWatermarkId()); - System.out.println("\nbucket = " + wm.getBucket()); - System.out.println("key = " + wm.getKey()); - System.out.println("createTime = " + wm.getCreateTime()); - System.out.println("horizontalAlignment = " + wm.getHorizontalAlignment()); - System.out.println("verticalAlignment = " + wm.getVerticalAlignment()); - System.out.println("horizontalOffsetInPixel = " + wm.getHorizontalOffsetInPixel()); - System.out.println("verticalOffsetInPixel = " + wm.getVerticalOffsetInPixel()); - } - - @Test - public void testCreateWaterMark1() { - String bucket = "dapeng-test"; - String key = "media-test/sdk-overview.png"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - - watermarkId = - mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel) - .getWatermarkId(); - System.out.println(watermarkId); - - GetWaterMarkResponse wm = mediaClient.getWaterMark(watermarkId); - System.out.println(wm); - assertEquals("Failed verify bucket.", wm.getWatermarkId(), watermarkId); - assertEquals("Failed verify bucket.", wm.getBucket(), bucket); - assertEquals("Failed verify bucket.", wm.getKey(), key); - assertEquals("Failed verify bucket.", wm.getHorizontalOffsetInPixel(), new Integer(horizontalOffsetInPixel)); - assertEquals("Failed verify bucket.", wm.getVerticalOffsetInPixel(), new Integer(verticalOffsetInPixel)); - } - - @Test - public void testCreateWaterMark2() { - String bucket = "dapeng-test"; - String key = "media-test/sdk-overview.png"; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - - watermarkId = - mediaClient.createWaterMark(bucket, key, horizontalAlignment, verticalAlignment) - .getWatermarkId(); - - GetWaterMarkResponse wm = mediaClient.getWaterMark(watermarkId); - System.out.println(wm); - assertEquals("Failed verify bucket.", wm.getWatermarkId(), watermarkId); - assertEquals("Failed verify bucket.", wm.getBucket(), bucket); - assertEquals("Failed verify bucket.", wm.getKey(), key); - assertEquals("Failed verify bucket.", wm.getHorizontalAlignment(), horizontalAlignment); - assertEquals("Failed verify bucket.", wm.getVerticalAlignment(), verticalAlignment); - } - - @Test - public void testCreateWaterMark3() { - String bucket = "dapeng-test"; - String key = "media-test/sdk-overview.png"; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - - watermarkId = - mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel) - .getWatermarkId(); - - GetWaterMarkResponse wm = mediaClient.getWaterMark(watermarkId); - System.out.println(wm); - assertEquals("Failed verify bucket.", wm.getWatermarkId(), watermarkId); - assertEquals("Failed verify bucket.", wm.getBucket(), bucket); - assertEquals("Failed verify bucket.", wm.getKey(), key); - assertEquals("Failed verify bucket.", wm.getHorizontalOffsetInPixel(), new Integer(horizontalOffsetInPixel)); - assertEquals("Failed verify bucket.", wm.getVerticalOffsetInPixel(), new Integer(verticalOffsetInPixel)); - assertEquals("Failed verify bucket.", wm.getHorizontalAlignment(), horizontalAlignment); - assertEquals("Failed verify bucket.", wm.getVerticalAlignment(), verticalAlignment); - } - - @Test - public void testDeleteWaterMark() { - String bucket = "dapeng-test"; - String key = "media-test/sdk-overview.png"; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - - watermarkId = - mediaClient.createWaterMark(bucket, key, horizontalAlignment, verticalAlignment, - horizontalOffsetInPixel, verticalOffsetInPixel) - .getWatermarkId(); - System.out.println(mediaClient.getWaterMark(watermarkId)); - - mediaClient.deleteWaterMark(watermarkId); - try { - System.out.println(mediaClient.getWaterMark(watermarkId)); - fail("The water mark " + watermarkId + "failed to be deleted."); - } catch (Exception e) { - // expect to catch Exception. - } finally { - watermarkId = null; - } - - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/AbstractMediaTest.java b/src/test/java/com/baidubce/services/media/cases/AbstractMediaTest.java deleted file mode 100755 index a0e0fffc..00000000 --- a/src/test/java/com/baidubce/services/media/cases/AbstractMediaTest.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.*; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import com.baidubce.conf.MediaConf; -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.media.MediaClient; -import com.baidubce.services.media.model.GetPresetResponse; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.WaterMark; -import com.baidubce.conf.MediaConf; - -public abstract class AbstractMediaTest { - MediaClient pipelineClient; - MediaClient jobClient; - MediaClient presetClient; - MediaClient mediaInfoClient; - MediaClient mediaClient; - - String pipelineName = null; - String jobId = null; - String thumbNailJobId = null; - String sourceBucket = null; - String targetBucket = null; - String sourceKey = null; - String targetKey = null; - String presetName = null; - - String bucket = MediaConf.bucket; - String expMsg = null; - String expServiceException = "com.baidubce.BceServiceException"; - String expParamException = "java.lang.IllegalArgumentException"; - - static String SOURCE_BUCKET = MediaConf.SOURCE_BUCKET; - static String TARGET_BUCKET = MediaConf.TARGET_BUCKET; - - static String SOURCE_LOGO = "logo.jpg"; - static String SOURCE_LOGO1 = "测试.jpg"; - static String SOURCE_LOGO2 = "t#$@%&^().jpg"; - static String SOURCE_LOGO3 = "test/logo.jpg"; - static String SOURCE_LOGO_PNG = "logo.png"; - static String SOURCE_LOGO_BMP = "logo.bmp"; - static String SOURCE_LOGO_PBM = "logo.pbm"; - static String SOURCE_LOGO_Gif = "logo.gif"; - static String SOURCE_LOGO_TIF = "logo.tif"; - static String SOURCE_LOGO_PSD = "logo.psd"; - - - static String SOURCE_KEY = "test.mp3"; - static String SOURCE_KEY1 = "测试.mp3"; - static String SOURCE_KEY2 = "test#@$%^()&test.mp3"; - static String SOURCE_KEY3 = "testlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtest.mp3"; - static String SOURCE_KEY4 = "test.mp4"; - static String SOURCE_KEY5 = "测试.mp4"; - static String SOURCE_KEY6 = "test#@$%^()&test.mp4"; - static String SOURCE_KEY7 = "testlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlong.mp4"; - static String SOURCE_KEY8 = "test/test.mp4"; - - static String TARGET_KEY = "target.mp3"; - static String TARGET_KEY1 = "target.flv"; - static String PRE_NAME = "mct_java_sdk_"; - - public void setUp() throws Exception { - DefaultBceCredentials cred = new DefaultBceCredentials(MediaConf.BMC_AK, - MediaConf.BMC_SK); - BceClientConfiguration config = new BceClientConfiguration() - .withCredentials(cred).withEndpoint(MediaConf.BMC_ENDPOINT) - .withMaxConnections(10); - pipelineClient = new MediaClient(config); - jobClient = new MediaClient(config); - presetClient = new MediaClient(config); - mediaInfoClient = new MediaClient(config); - - mediaClient = new MediaClient(config); - - } - - /* - * 1. pipeline don't support capital letters 2. in current version, pipeline - * cannot be duplicated even after it is removed - */ - protected String convertName(String key) { - return (key + "_" + System.currentTimeMillis()); - } - - protected void checkPipelineExist(String expectedPipelineName, - boolean expected) { - ListPipelinesResponse resp = pipelineClient.listPipelines(); - System.err.println(resp); - - Set names = new HashSet(); - for (PipelineStatus pipe : resp.getPipelines()) { - names.add(pipe.getPipelineName()); - } - - if (expected) { - assertTrue("Failed to find expected pipeline: " - + expectedPipelineName + ". \n " + resp, - names.contains(expectedPipelineName)); - } else { - assertFalse("The pipeline: " + expectedPipelineName - + " still exists. \n " + resp, - names.contains(expectedPipelineName)); - } - } - - protected void checkPresetExist(String expectedPresetName, boolean expected) { - GetPresetResponse resp = presetClient.getPreset(expectedPresetName); - - if (expected) { - assertTrue("Failed to find expected preset: " + expectedPresetName, - resp.getState().equalsIgnoreCase("ACTIVE")); - } else { - assertTrue( - "The preset: " + expectedPresetName + " still exists.", - resp.getState().equalsIgnoreCase("INACTIVE")); - } - } - - protected void checkWaterMarkExist(String watermarkId, boolean expected){ - - List watermarks = mediaClient.listWaterMark().getWatermarks(); - Set markId = new HashSet(); - for (WaterMark wm : watermarks) { - markId.add(wm.getWatermarkId()); - } - if (expected){ - assertTrue("Failed to find expected water mark id: "+watermarkId, - markId.contains(watermarkId)); - }else{ - assertFalse("Find expected water mark id: "+watermarkId, - markId.contains(watermarkId)); - } - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/CreateJobTest.java b/src/test/java/com/baidubce/services/media/cases/CreateJobTest.java deleted file mode 100755 index 3b0bd79b..00000000 --- a/src/test/java/com/baidubce/services/media/cases/CreateJobTest.java +++ /dev/null @@ -1,933 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.Audio; -import com.baidubce.services.media.model.Clip; -import com.baidubce.services.media.model.CodecOptions; -import com.baidubce.services.media.model.CreateJobRequest; -import com.baidubce.services.media.model.CreatePipelineRequest; -import com.baidubce.services.media.model.CreatePresetRequest; -import com.baidubce.services.media.model.CreateWaterMarkResponse; -import com.baidubce.services.media.model.Encryption; -import com.baidubce.services.media.model.GetJobResponse; -import com.baidubce.services.media.model.GetWaterMarkResponse; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.CreateJobResponse; -import com.baidubce.services.media.model.PipelineConfig; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.Source; -import com.baidubce.services.media.model.Target; -import com.baidubce.services.media.model.Video; - -public class CreateJobTest extends AbstractMediaTest { - - public String pipelineForJob = null; - // the capacity is for the pipeline for job test - public int capacityNumber = 2; - public String watermarkId = null; - // presetNameSystem - public String presetNameSystem = "bce.audio_mp3_320kbps"; - public String presetNameVideoSystem = "bce.video_flv_640x480_620kbps"; - public String presetNameAudioSystem = "bce.audio_hls_128kbps"; - public String prefix = AbstractMediaTest.PRE_NAME + "createjob"; - public String presetName = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - pipelineForJob = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineForJob); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(capacityNumber); - request.setConfig(config); - pipelineClient.createPipeline(request); - checkPipelineExist(pipelineForJob, true); - } - - @After - public void tearDown() throws Exception { - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - while (true) { - try { - pipelineClient.deletePipeline(name); - break; - } catch (Exception e) { - if (e.getMessage().contains("pending/running")) { - Thread.sleep(5000); - } else { - break; - } - - } - } - - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * test create job successfully with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobNormal() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - - /** - * test create job successfully with function createJob(CreateJobRequest request) - */ - @Test - public void testCreateJobNormal1() { - pipelineName = pipelineForJob; - CreateJobRequest request = new CreateJobRequest(); - request.setPipelineName(pipelineName); - Source source = new Source(); - source.setSourceKey(AbstractMediaTest.SOURCE_KEY); - request.setSource(source); - Target target = new Target(); - target.setTargetKey(AbstractMediaTest.TARGET_KEY); - presetName = presetNameSystem; - target.setPresetName(presetName); - request.setTarget(target); - request.setSource(source); - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(request); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - - - /** - * test create job with containser a-hls - */ - @Test - public void testCreateJobPresetContainerA_hls() { - presetName = pipelineForJob; - String container = "a-hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("baseline"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(102400); - video.setMaxFrameRate(30f); - video.setMaxWidthInPixel(4096); - video.setMaxHeightInPixel(3072); - video.setSizingPolicy("keep"); - presetClient.createPreset(presetName, container, audio, video); - checkPresetExist(presetName, true); - pipelineName = pipelineForJob; - CreateJobRequest request = new CreateJobRequest(); - request.setPipelineName(pipelineName); - Source source = new Source(); - source.setSourceKey(AbstractMediaTest.SOURCE_KEY); - request.setSource(source); - Target target = new Target(); - target.setTargetKey(AbstractMediaTest.TARGET_KEY); - target.setPresetName(presetName); - request.setTarget(target); - request.setSource(source); - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(request); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - } - - /** - * test create job with waterMark - */ - @Test - public void testCreateJobWithWaterMark() throws InterruptedException { - - String bucket = AbstractMediaTest.SOURCE_BUCKET; - String key = AbstractMediaTest.SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - presetName = pipelineForJob; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxHeightInPixel(1000); - video.setMaxWidthInPixel(1000); - Encryption encryption = null; - presetClient.createPreset(presetName, container, clip, audio, video, encryption, watermarkId); - checkPresetExist(presetName, true); - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - targetKey = AbstractMediaTest.TARGET_KEY1; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - GetJobResponse resp = jobClient.getJob(jobId); - String jobStatus = resp.getJobStatus(); - while (jobStatus.equals("PENDING") || jobStatus.equals("RUNNING") ) { - Thread.sleep(5000); - resp = jobClient.getJob(jobId); - jobStatus = resp.getJobStatus(); - } - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - mediaClient.deleteWaterMark(watermarkId); - checkWaterMarkExist(watermarkId, false); - assertEquals(jobStatus, "SUCCESS"); - } - - /** - * test create job with waterMark and alignment - */ - @Test - public void testCreateJobWithWaterMarkAndAlignment() throws InterruptedException { - - String bucket = AbstractMediaTest.SOURCE_BUCKET; - String key = AbstractMediaTest.SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, key, - horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, - verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - presetName = pipelineForJob; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxHeightInPixel(1000); - video.setMaxWidthInPixel(1000); - Encryption encryption = null; - presetClient.createPreset(presetName, container, clip, audio, video, encryption, watermarkId); - checkPresetExist(presetName, true); - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - targetKey = AbstractMediaTest.TARGET_KEY1; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - GetJobResponse resp = jobClient.getJob(jobId); - String jobStatus = resp.getJobStatus(); - while (jobStatus.equals("PENDING") || jobStatus.equals("RUNNING") ) { - Thread.sleep(5000); - resp = jobClient.getJob(jobId); - jobStatus = resp.getJobStatus(); - } - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - mediaClient.deleteWaterMark(watermarkId); - checkWaterMarkExist(watermarkId, false); - assertEquals(jobStatus, "SUCCESS"); - - } - /** - * test create job with waterMark and alignment - */ - @Test - public void testCreateJobWithWaterMarkAndAlignmentHorizontalOffsetExceed() throws InterruptedException { - - String bucket = AbstractMediaTest.SOURCE_BUCKET; - String key = AbstractMediaTest.SOURCE_LOGO; - String horizontalAlignment = "right"; - String verticalAlignment = "bottom"; - int horizontalOffsetInPixel = 640; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, - verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - presetName = pipelineForJob; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxHeightInPixel(1000); - video.setMaxWidthInPixel(1000); - Encryption encryption = null; - presetClient.createPreset(presetName, container, clip, audio, video, encryption, watermarkId); - checkPresetExist(presetName, true); - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - targetKey = AbstractMediaTest.TARGET_KEY1; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - GetJobResponse resp = jobClient.getJob(jobId); - String jobStatus = resp.getJobStatus(); - while (jobStatus.equals("PENDING") || jobStatus.equals("RUNNING") ) { - Thread.sleep(5000); - resp = jobClient.getJob(jobId); - System.out.println(resp); - jobStatus = resp.getJobStatus(); - } - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - mediaClient.deleteWaterMark(watermarkId); - checkWaterMarkExist(watermarkId, false); - assertEquals(jobStatus, "FAILED"); - } - /** - * test create job with waterMark VerticalOffsetExceed - */ - @Test - public void testCreateJobWithWaterMarkAndAlignmentVerticalOffsetExceed() throws InterruptedException { - - String bucket = AbstractMediaTest.SOURCE_BUCKET; - String key = AbstractMediaTest.SOURCE_LOGO; - int horizontalOffsetInPixel = 10; - int verticalOffsetInPixel = 1000; - String horizontalAlignment = "right"; - String verticalAlignment = "bottom"; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, - verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - presetName = pipelineForJob; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxHeightInPixel(1000); - video.setMaxWidthInPixel(1000); - Encryption encryption = null; - presetClient.createPreset(presetName, container, clip, audio, video, encryption, watermarkId); - checkPresetExist(presetName, true); - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - targetKey = AbstractMediaTest.TARGET_KEY1; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - GetJobResponse resp = jobClient.getJob(jobId); - String jobStatus = resp.getJobStatus(); - while (jobStatus.equals("PENDING") || jobStatus.equals("RUNNING") ) { - Thread.sleep(5000); - resp = jobClient.getJob(jobId); - jobStatus = resp.getJobStatus(); - } - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - System.out.println(res); - mediaClient.deleteWaterMark(watermarkId); - checkWaterMarkExist(watermarkId, false); - assertEquals(jobStatus, "FAILED"); - } - - - /** - * test create job with waterMark HorizontalOffsetExceed - */ - @Test - public void testCreateJobWithWaterMarkHorizontalOffsetExceed() throws InterruptedException { - - String bucket = AbstractMediaTest.SOURCE_BUCKET; - String key = AbstractMediaTest.SOURCE_LOGO; - int horizontalOffsetInPixel = 640; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - presetName = pipelineForJob; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxHeightInPixel(1000); - video.setMaxWidthInPixel(1000); - Encryption encryption = null; - presetClient.createPreset(presetName, container, clip, audio, video, encryption, watermarkId); - checkPresetExist(presetName, true); - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - targetKey = AbstractMediaTest.TARGET_KEY1; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - GetJobResponse resp = jobClient.getJob(jobId); - String jobStatus = resp.getJobStatus(); - while (jobStatus.equals("PENDING") || jobStatus.equals("RUNNING") ) { - Thread.sleep(5000); - resp = jobClient.getJob(jobId); - System.out.println(resp); - jobStatus = resp.getJobStatus(); - } - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - mediaClient.deleteWaterMark(watermarkId); - checkWaterMarkExist(watermarkId, false); - assertEquals(jobStatus, "FAILED"); - } - - /** - * test create job with waterMark VerticalOffsetExceed - */ - @Test - public void testCreateJobWithWaterMarkVerticalOffsetExceed() throws InterruptedException { - - String bucket = AbstractMediaTest.SOURCE_BUCKET; - String key = AbstractMediaTest.SOURCE_LOGO; - int horizontalOffsetInPixel = 10; - int verticalOffsetInPixel = 1000; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - presetName = pipelineForJob; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxHeightInPixel(1000); - video.setMaxWidthInPixel(1000); - Encryption encryption = null; - presetClient.createPreset(presetName, container, clip, audio, video, encryption, watermarkId); - checkPresetExist(presetName, true); - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - targetKey = AbstractMediaTest.TARGET_KEY1; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - GetJobResponse resp = jobClient.getJob(jobId); - String jobStatus = resp.getJobStatus(); - while (jobStatus.equals("PENDING") || jobStatus.equals("RUNNING") ) { - Thread.sleep(5000); - resp = jobClient.getJob(jobId); - jobStatus = resp.getJobStatus(); - } - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - System.out.println(res); - mediaClient.deleteWaterMark(watermarkId); - checkWaterMarkExist(watermarkId, false); - assertEquals(jobStatus, "FAILED"); - } - - /** - * test method of CreateJobRequest with function createJob(CreateJobRequest request) - */ - @Test - public void testMethodOfCreateJobRequest() { - pipelineName = pipelineForJob; - CreateJobRequest request = new CreateJobRequest(); - request.setPipelineName(pipelineName); - Source source = new Source(); - source.setSourceKey(AbstractMediaTest.SOURCE_KEY); - request.setSource(source); - Target target = new Target(); - target.setTargetKey(AbstractMediaTest.TARGET_KEY); - presetName = presetNameSystem; - target.setPresetName(presetName); - request.setTarget(target); - assertEquals(request.getPipelineName(), pipelineName); - assertEquals(request.getTarget().getPresetName(), presetName); - assertEquals(request.getSource().toString(), source.toString()); - assertEquals(request.getTarget().toString(), target.toString()); - - } - - /** - * test delete pipelineName with job running with function deletePipeline(String pipelineName) - */ - @Test - public void testDeletePipelineJobRunning() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipeline has pending/running jobs"); - pipelineClient.deletePipeline(pipelineName); - - } - - /** - * test create job capacity exceeds with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobCapacityExceeds() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - for (int i = 0; i < capacityNumber; i++) { - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipeline is full"); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - - } - - - /** - * test create job preset deleted with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - - @Test - public void testCreateJobPresetDeleted() { - presetName = pipelineForJob; - CreatePresetRequest request = new CreatePresetRequest(); - request.setPresetName(presetName); - request.setDescription("test"); - request.setContainer("mp3"); - Clip clip = new Clip(); - clip.setStartTimeInSecond(10); - clip.setDurationInSecond(100); - request.setClip(clip); - - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - request.setAudio(audio); - presetClient.createPreset(request); - checkPresetExist(presetName, true); - pipelineName = pipelineForJob; - CreateJobRequest req = new CreateJobRequest(); - req.setPipelineName(pipelineName); - Source source = new Source(); - source.setSourceKey(AbstractMediaTest.SOURCE_KEY); - req.setSource(source); - Target target = new Target(); - target.setTargetKey(AbstractMediaTest.TARGET_KEY); - target.setPresetName(presetName); - req.setTarget(target); - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(req); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - System.out.println(jobId); - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("preset has been deleted"); - jobResp = jobClient.createJob(req); - } - - /** - * test create job preset = '' function createJob(String pipelineName, String sourceKey, - * String targetKey, String presetName) - */ - @Test - public void testCreateJobPresetEmpty() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = ""; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("presetName should NOT be null or empty string"); - CreateJobResponse jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job preset = null with function createJob(String pipelineName, String sourceKey, - * String targetKey, String presetName) - */ - @Test - public void testCreateJobPresetNull() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("presetName should NOT be null or empty string"); - CreateJobResponse jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job preset not exist with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobPresetNotExist() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = "notexistname"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("preset does not exist"); - CreateJobResponse jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - - /** - * test create job pipeline deleted with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - - @Test - public void testCreateJobPipelineDeleted() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - pipelineClient.deletePipeline(pipelineName); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipeline has been deleted"); - CreateJobResponse jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job pipeline not exists with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobPipelineNotExist() { - pipelineName = convertName(prefix); - System.out.println(pipelineName); - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipeline does not exist"); - CreateJobResponse jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job pipeline = "" with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobPipelineEmpty() { - pipelineName = ""; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("pipelineName should NOT be null or empty string"); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job pipeline = null with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobPipelineNull() { - pipelineName = null; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("pipelineName should NOT be null or empty string"); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job souceBucket = '' with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobSourceKeyEmpty() { - pipelineName = pipelineForJob; - sourceKey = ""; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("sourceKey should NOT be null or empty string"); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job souceBucket = null with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobSourceKeyNull() { - pipelineName = pipelineForJob; - sourceKey = null; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("sourceKey should NOT be null or empty string"); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job source file not exist with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobSourceKeyNotExist() { - pipelineName = pipelineForJob; - sourceKey = "notexist.mp3"; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("bos object: notexist.mp3 does not exist"); - CreateJobResponse jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job targetBucket = '' with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobTargetKeyEmpty() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = ""; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("targetKey should NOT be null or empty string"); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job targetBucket = null with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobTargetKeyNull() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = null; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("targetKey should NOT be null or empty string"); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - } - - /** - * test create job Source File Contains Chinese letter with function createJob(String - * pipelineName, String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobSourceKeyContainsChineseChar() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY1; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - - /** - * test create job Source File Contains Special letter with function createJob(String - * pipelineName, String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobSourceKeyContainsSpecialLetter() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY2; - System.out.println(sourceKey); - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - - /** - * test create job target File Contains Chinese letter with function createJob(String - * pipelineName, String sourceKey, String targetKey, String presetName) - */ - - @Test - public void testCreateJobTargetKeyContainsChineseLetter() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = "测试.mp3"; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - - /** - * test create job target File Contains Special letter with function createJob(String - * pipelineName, String sourceKey, String targetKey, String presetName) - */ - - @Test - public void testCreateJobTargetKeyContainsSpecialLetter() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = "test#@$%^()&test.mp3"; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - - /** - * test create job source File long name with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobSourceKeyLongName() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY3; - System.out.println(sourceKey); - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - - /** - * test create job target File long name with function createJob(String pipelineName, - * String sourceKey, String targetKey, String presetName) - */ - @Test - public void testCreateJobTargetKeyLongName() { - pipelineName = pipelineForJob;; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = "testlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtest" - + "longtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtest" - + "longtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtest" - + "longtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtestlongtest" - + "longtestlongtestlongtestlong.mp3"; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - - /** - * test create job preset video with function createJob(String pipelineName, String sourceKey, - * String targetKey, String presetName) - */ - @Test - public void testCreateJobPresetVideo() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = "test.flv"; - presetName = presetNameVideoSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } - - /** - * test create job preset audio with function createJob(String pipelineName, String sourceKey, - * String targetKey, String presetName) - */ - @Test - public void testCreateJobPresetAudio() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = "test.flv"; - presetName = presetNameVideoSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey, presetName); - jobId = jobResp.getJobId(); - assertTrue("Invalid job ID: " + jobId, jobId != null - && jobId.trim().length() > 0); - } -} diff --git a/src/test/java/com/baidubce/services/media/cases/CreatePipelineTest.java b/src/test/java/com/baidubce/services/media/cases/CreatePipelineTest.java deleted file mode 100755 index 1782a39e..00000000 --- a/src/test/java/com/baidubce/services/media/cases/CreatePipelineTest.java +++ /dev/null @@ -1,659 +0,0 @@ -package com.baidubce.services.media.cases; - -import org.junit.rules.ExpectedException; - -import static org.junit.Assert.assertEquals; - -import org.junit.Rule; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import com.baidubce.services.media.model.CreatePipelineRequest; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.PipelineConfig; - - -public class CreatePipelineTest extends AbstractMediaTest { - - public String prefix = AbstractMediaTest.PRE_NAME + "createpipe"; - - @Before - public void setUp() throws Exception { - super.setUp(); - - } - - @After - public void tearDown() throws Exception { - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - pipelineClient.deletePipeline(name); - } - } - } - - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * test illegal Target bucket input with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testTargetBucketIllegal() { - pipelineName = convertName(prefix); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("doesn't exist or isn't in bj region"); - pipelineClient.createPipeline(pipelineName, AbstractMediaTest.SOURCE_BUCKET, "illegalbucket", 5); - } - - /** - * test illegal Target bucket input with function createPipeline( String pipelineName, String description, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testTargetBucketIllegal1() { - pipelineName = convertName(prefix); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("doesn't exist or isn't in bj region"); - pipelineClient.createPipeline(pipelineName, "for test", AbstractMediaTest - .SOURCE_BUCKET, "illegalbucket", 5); - } - - /** - * test illegal Target bucket input with function createPipeline(CreatePipelineRequest request) - */ - @Test - public void testTargetBucketIllegal2() { - - pipelineName = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineName); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket("illegalbucket"); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(5); - request.setConfig(config); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("doesn't exist or isn't in bj region"); - pipelineClient.createPipeline(request); - } - - /** - * test illegal Source bucket input with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testSourceBucketIllegal() { - pipelineName = convertName(prefix); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("doesn't exist or isn't in bj region"); - pipelineClient.createPipeline(pipelineName, "illegalbucket", AbstractMediaTest.TARGET_BUCKET, 5); - } - - /** - * test illegal Source bucket input with function createPipeline( String pipelineName, String description, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testSourceBucketIllegal1() { - pipelineName = convertName(prefix); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("doesn't exist or isn't in bj region"); - pipelineClient.createPipeline(pipelineName, "for test", "illegalbucket", AbstractMediaTest.TARGET_BUCKET, 5); - } - - /** - * test illegal Source bucket input with function createPipeline(CreatePipelineRequest request) - */ - @Test - public void testSourceBucketillegal2() { - pipelineName = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineName); - request.setSourceBucket("illegalbucket"); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(5); - request.setConfig(config); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("doesn't exist or isn't in bj region"); - pipelineClient.createPipeline(request); - } - - - /** - * test create pipeline normal with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testCreatePipelineNormal() { - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - } - - /** - *test create pipeline normal with function createPipeline( String pipelineName, String description, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testCreatePipelineNormal1() { - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName, "for test", - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - } - /** - * test create pipeline normal with function void createPipeline(CreatePipelineRequest request) - */ - @Test - public void testCreatePipelineNormal2() { - - pipelineName = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineName); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - request.setDescription("test"); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(5); - request.setConfig(config); - pipelineClient.createPipeline(request); - checkPipelineExist(pipelineName, true); - } - - - /** - * test duplicate name for pipeline with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - * just test this function, it will call the other two - */ - @Test - public void testPipelineDuplicateName() { - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("duplicated pipeline name"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - } - - /** - * test just digit name for pipeline with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - * just test this function, it will call the other two - */ - @Test - public void testPipelineJustDigit() { - - pipelineName = "123456"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipelineName=must match"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - - } - - /** - * test chinese name for pipeline with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineWithChinese() { - - pipelineName = "测试"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipelineName=must match"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - - } - - /** - * test chinese name for pipeline with function createPipeline(CreatePipelineRequest request) - */ - @Test - public void testPipelineWithChinese2() { - - pipelineName = "测试"; - CreatePipelineRequest request = new CreatePipelineRequest(); - bceEx.expect(com.baidubce.BceServiceException.class); - request.setPipelineName(pipelineName); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(5); - request.setConfig(config); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipelineName=must match"); - pipelineClient.createPipeline(request); - } - - /** - * test pipeline name contain upper letters with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineWithCaptialLetters() { - - pipelineName = "testABC"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipelineName=must match"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - - } - - /** - * test pipeline name starts with digit with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineStartsWithDigit() { - - pipelineName = "123test"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipelineName=must match"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - - } - - /** - * test pipeline name starts with '_' with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineStartsWith_() { - - pipelineName = "_test123"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipelineName=must match"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - - } - - /** - * test pipeline name contains "-" with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineContainsHyphen() { - - pipelineName = "test-123"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipelineName=must match"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - - } - - /** - * test pipeline name contains blank with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineContainsBlank() { - - pipelineName = "test 123"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipelineName=must match"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - - } - - /** - * test pipeline name with 40 letters with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineLetters40() { - pipelineName = convertName(prefix); - pipelineName = pipelineName + "012"; - assertEquals(pipelineName.length(), 40); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - } - /** - * test pipeline name more than 40 letters with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineLettersMoreThan40() { - pipelineName = convertName(prefix); - pipelineName = pipelineName + "test"; - assertEquals(pipelineName.length(), 41); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipelineName=must match"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, false); - } - - /** - *test capacity:0 letters with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineCapacity0() { - pipelineName = convertName(prefix); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("must be greater than or equal"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 0); - checkPipelineExist(pipelineName, false); - } - - /** - *test capacity:-1 letters with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineCapacity_1() { - pipelineName = convertName(prefix); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("must be greater than or equal"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, -1); - checkPipelineExist(pipelineName, false); - } - - /** - *test capacity:100 letters with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineCapacity100() { - pipelineName = convertName(prefix); - int flag = 0; - int used = 0; - try { - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 101); - } catch (Exception e) { - flag = 1; - Pattern p = Pattern.compile("used:(\\d{1,4})"); - Matcher m = p.matcher(e.getMessage()); - if (m.find()) { - used = Integer.valueOf(m.group(1)); - } - } finally { - assertEquals(flag, 1); - } - checkPipelineExist(pipelineName, false); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 100 - used); - checkPipelineExist(pipelineName, true); - } - - /** - *test capacity:100 letters with function createPipeline(String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineCapacity101() { - pipelineName = convertName(prefix); - int flag = 0; - int used = 0; - try { - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 101); - } catch (Exception e) { - flag = 1; - Pattern p = Pattern.compile("used:(\\d{1,4})"); - Matcher m = p.matcher(e.getMessage()); - if (m.find()) { - used = Integer.valueOf(m.group(1)); - } - } finally { - assertEquals(flag, 1); - } - checkPipelineExist(pipelineName, false); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("total pipeline size exceed"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 100 - used + 1); - } - - - /** - * test description length:128letters with function createPipeline( String pipelineName, String description, String sourceBucket, String targetBucket, int capacity) - */ - - @Test - public void testPipelineDescriptionLength128() { - - pipelineName = convertName(prefix); - String description = "testlengthtestlengthtestlengthtestlengthtestlength" - + "testlengthtestlengthtestlengthtestlengthtestlengthtestlengthtestlength12345678"; - pipelineClient.createPipeline(pipelineName, description, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - } - - /** - * test description length: more than 128 letters with function createPipeline( String pipelineName, String description, String sourceBucket, String targetBucket, int capacity) - */ - - @Test - public void testPipelineDescriptionLengthMoreThan128() { - - pipelineName = convertName(prefix); - String description = "testlengthtestlengthtestlengthtestlengthtestlengthtestlength" - + "testlengthtestlengthtestlengthtestlengthtestlengthtestlength123456789"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("description=size must be between 0 and 128"); - pipelineClient.createPipeline(pipelineName, description, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, false); - } - - - /** - * test description = '' with function createPipeline( String pipelineName, String description, String sourceBucket, String targetBucket, int capacity) - */ - - @Test - public void testPipelineDescriptionEmpty() { - - pipelineName = convertName(prefix); - String description = ""; - pipelineClient.createPipeline(pipelineName, description, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - } - - /** - * test without description with function createPipeline( String pipelineName, String description, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineDescriptionNone() { - pipelineName = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineName); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(20); - request.setConfig(config); - pipelineClient.createPipeline(request); - checkPipelineExist(pipelineName, true); - } - - - /** - * test description with special letters with function createPipeline( String pipelineName, String description, String sourceBucket, String targetBucket, int capacity) - */ - - @Test - public void testPipelineDescriptionWithSpecialLetter() { - - pipelineName = convertName(prefix); - String description = "test#$%&^*测试·~>/?()13~ sdljf_ = +"; - pipelineClient.createPipeline(pipelineName, description, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - } - - /** - * test t source bucket = '' with function createPipeline( String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineSourceBucketEmpty() { - - pipelineName = convertName(prefix); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("sourceBucket should NOT be null or empty string"); - pipelineClient.createPipeline(pipelineName, "", AbstractMediaTest.TARGET_BUCKET, 5); - } - - /** - * test source bucket = null with function createPipeline( String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineSourceBucketNull() { - - pipelineName = convertName(prefix); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("sourceBucket should NOT be null or empty string"); - pipelineClient.createPipeline(pipelineName, null, AbstractMediaTest.TARGET_BUCKET, 5); - } - - /** - * test without source bucket with function createPipeline(CreatePipelineRequest request) - */ - @Test - public void testPipelineWithoutSourceBucket() { - pipelineName = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineName); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(20); - request.setConfig(config); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("sourceBucket should NOT be null or empty string"); - pipelineClient.createPipeline(request); - } - - - /** - * test target bucket = '' with function createPipeline( String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineTargetBucketEmpty() { - - pipelineName = convertName(prefix); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("targetBucket should NOT be null or empty string"); - pipelineClient.createPipeline(pipelineName, AbstractMediaTest.SOURCE_BUCKET, "", 5); - } - - /** - * test target bucket = null with function createPipeline( String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineTargetBucketNull() { - - pipelineName = convertName(prefix); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("targetBucket should NOT be null or empty string"); - pipelineClient.createPipeline(pipelineName, AbstractMediaTest.SOURCE_BUCKET, null, 5); - } - - /** - * test without target bucket with function createPipeline(CreatePipelineRequest request) - */ - @Test - public void testPipelineWithoutTargetBucket() { - pipelineName = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineName); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(20); - request.setConfig(config); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("targetBucket should NOT be null or empty string"); - pipelineClient.createPipeline(request); - } - - - /** - * test pipeline = "" with function createPipeline( String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineEmpty() { - - pipelineName = ""; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("pipelineName should NOT be null or empty string"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - } - - /** - * test pipeline = null with function createPipeline( String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineNull() { - - pipelineName = null; - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("pipelineName should NOT be null or empty string"); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - } - - /** - * test without capacity with function createPipeline(CreatePipelineRequest request) - */ - @Test - public void testPipelineWithoutCapacity() { - pipelineName = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineName); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - request.setConfig(config); - pipelineClient.createPipeline(request); - checkPipelineExist(pipelineName, true); - } - - /** - * test pipelineName deleted before with function createPipeline( String pipelineName, String sourceBucket, String targetBucket, int capacity) - */ - @Test - public void testPipelineDeletedBefore() { - - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - pipelineClient.deletePipeline(pipelineName); - pipelineClient.createPipeline(pipelineName, - AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - } - - - /** - * test method of CreatePipelineRequest - */ - @Test - public void testMethodOfCreatePipelineRequest() { - - CreatePipelineRequest request = new CreatePipelineRequest(); - pipelineName = convertName(prefix); - request.setPipelineName(pipelineName); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - request.setDescription("test"); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(20); - request.setConfig(config); - assertEquals(request.getPipelineName(), pipelineName); - assertEquals(request.getDescription(), "test"); - assertEquals(request.getSourceBucket(), AbstractMediaTest.SOURCE_BUCKET); - assertEquals(request.getTargetBucket(), AbstractMediaTest.TARGET_BUCKET); - assertEquals(request.getConfig().toString(), config.toString()); - } - - -} diff --git a/src/test/java/com/baidubce/services/media/cases/CreatePresetTest.java b/src/test/java/com/baidubce/services/media/cases/CreatePresetTest.java deleted file mode 100755 index d0101d3f..00000000 --- a/src/test/java/com/baidubce/services/media/cases/CreatePresetTest.java +++ /dev/null @@ -1,1070 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.regex.Pattern; -import java.util.regex.Matcher; -import com.baidubce.services.media.model.Audio; -import com.baidubce.services.media.model.Clip; -import com.baidubce.services.media.model.CodecOptions; -import com.baidubce.services.media.model.CreatePresetRequest; -import com.baidubce.services.media.model.CreateWaterMarkResponse; -import com.baidubce.services.media.model.Encryption; -import com.baidubce.services.media.model.GetPresetResponse; -import com.baidubce.services.media.model.Video; - -public class CreatePresetTest extends AbstractMediaTest { - - public String prefix = AbstractMediaTest.PRE_NAME + "createpreset"; - String watermarkId = null; - - @Rule - public ExpectedException myExp = ExpectedException.none(); - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - for (GetPresetResponse preset : presetClient.listPresets().getPresets()) { - GetPresetResponse resp = presetClient.getPreset(preset.getPresetName()); - System.out.println(resp); - assertTrue("Failed to get preset: " + preset.getPresetName(), resp - .getPresetName().equals(preset.getPresetName())); - presetName = preset.getPresetName(); - if (presetName.startsWith(prefix)) { - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - } - /* Pattern pattern = Pattern.compile("^bce."); - * Matcher m = pattern.matcher(presetName); - * boolean result = m.find(); - * if (!result) { - * System.out.println("delete preset " + presetName); - * presetClient.deletePreset(presetName); - * checkPresetExist(presetName, false); - * } - */ - } - if (watermarkId != null) { - mediaClient.deleteWaterMark(watermarkId); - watermarkId = null; - } - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCANormal() { - presetName = convertName(prefix); - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio, Video video) - */ - public void testCreatePresetContainerA_hls() { - presetName = convertName(prefix); - String container = "a-hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("baseline"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(102400); - video.setMaxFrameRate(30f); - video.setMaxWidthInPixel(4096); - video.setMaxHeightInPixel(3072); - video.setSizingPolicy("keep"); - presetClient.createPreset(presetName, container, audio, video); - checkPresetExist(presetName, true); - } - - - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCA40char() { - presetName = convertName(prefix); - presetName = presetName + "a"; - System.out.println(presetName.length()); - assertEquals(presetName.length(), 40); - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAOnlyRequiredParam() { - presetName = convertName(prefix); - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - presetClient.createPreset(presetName, container, audio); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAPresetNameNull() throws ClassNotFoundException { - expMsg = "The parameter presetName should NOT be null or empty string"; - myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - presetName = null; - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAPresetNameEmpty() throws ClassNotFoundException { - expMsg = "The parameter presetName should NOT be null or empty string"; - myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - presetName = ""; - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAPresetNameWithChineseName() throws ClassNotFoundException { - expMsg = "preset name must match pattern:[a-z][0-9a-z_]{0,39}"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - presetName = "创建模板"; - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAPresetNameWithUpperLetter() throws ClassNotFoundException { - expMsg = "preset name must match pattern:[a-z][0-9a-z_]{0,39}"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - presetName = "PRESETNAME"; - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAPresetNameWithPureDigital() throws ClassNotFoundException { - expMsg = "preset name must match pattern:[a-z][0-9a-z_]{0,39}"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = "1234567"; - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAPresetNameWithFirstNotChar() throws ClassNotFoundException { - expMsg = "preset name must match pattern:[a-z][0-9a-z_]{0,39}"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = "123preset"; - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAPresetNameWithMidlined() throws ClassNotFoundException { - expMsg = "preset name must match pattern:[a-z][0-9a-z_]{0,39}"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = "preset-1-2"; - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAPresetNameWithBlank() throws ClassNotFoundException { - expMsg = "preset name must match pattern:[a-z][0-9a-z_]{0,39}"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = "preset name"; - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAPresetNameMore40char() throws ClassNotFoundException { - expMsg = "preset name must match pattern:[a-z][0-9a-z_]{0,39}"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; - String container = "mp4"; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAWithNullContainer() throws ClassNotFoundException { - expMsg = "The parameter container should NOT be null"; - myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = null; - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAWithAudioBitRateInBpsAbnormal() throws ClassNotFoundException { - expMsg = "audio.bitRateInBps:audio.bitRateInBps=must be greater than or equal to 1000"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "m4a"; - Audio audio = new Audio(); - audio.setBitRateInBps(10); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAWithAudioSampleRateInHzAbnormal() throws ClassNotFoundException { - expMsg = "audio.sampleRateInHz should in [22050, 32000, 44100, 48000, 96000]"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "m4a"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(3200); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCAWithAudioChannelsAbnormal() throws ClassNotFoundException { - expMsg = "audio.channels:audio.channels=must be less than or equal to 2"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(32000); - audio.setChannels(5); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio) - */ - public void testCreatePresetPCADuplicateName() throws ClassNotFoundException { - expMsg = "duplicated preset name"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(32000); - audio.setChannels(2); - presetClient.createPreset(presetName, container, audio); - checkPresetExist(presetName, true); - presetClient.createPreset(presetName, container, audio); - } - - @Test - /** - * createPreset( - * String presetName, String container, Clip clip, Audio audio, Encryption encryption) - */ - public void testCreatePresetPCCAENormal() { - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - clip.setDurationInSecond(60); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(32000); - audio.setChannels(2); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("abcdefghij123456"); - presetClient.createPreset(presetName, container, clip, audio, encryption); - checkPresetExist(presetName, true); - } - - - @Test - /** - * createPreset( - * String presetName, String container, Clip clip, Audio audio, Encryption encryption) - */ - public void testCreatePresetPCCAEClipLackDurationInSecond() { - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(32000); - audio.setChannels(2); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("abcdefghij123456"); - presetClient.createPreset(presetName, container, clip, audio, encryption); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset( - * String presetName, String container, Clip clip, Audio audio, Encryption encryption) - */ - public void testCreatePresetPCCAEClipNull() { - presetName = convertName(prefix); - String container = "hls"; - Clip clip = null; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(32000); - audio.setChannels(2); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("abcdefghij123456"); - presetClient.createPreset(presetName, container, clip, audio, encryption); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset( - * String presetName, String container, Clip clip, Audio audio, Encryption encryption) - */ - public void testCreatePresetPCCAEClipAbnormal() throws ClassNotFoundException { - expMsg = "clip.durationInSecond:clip.durationInSecond=must be greater than or equal to 1"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - clip.setDurationInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(32000); - audio.setChannels(2); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("abcdefghij123456"); - presetClient.createPreset(presetName, container, clip, audio, encryption); - } - - @Test - /** - * createPreset( - * String presetName, String container, Clip clip, Audio audio, Encryption encryption) - */ - public void testCreatePresetPCCAEEncryptionAesKey() throws ClassNotFoundException { - expMsg = "encryption.aesKey:encryption.aesKey=must match \"[a-zA-Z0-9]{16}\""; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(32000); - audio.setChannels(2); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("abcdefghij123"); - presetClient.createPreset(presetName, container, clip, audio, encryption); - } - - @Test - /** - * createPreset( - * String presetName, String container, Clip clip, Audio audio, Encryption encryption) - */ - public void testCreatePresetPCCAEEncryptionSteategyNull() throws ClassNotFoundException { - expMsg = "encryption.strategy:encryption.strategy=may not be null"; - //myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(32000); - audio.setChannels(2); - Encryption encryption = new Encryption(); - // encryption.setStrategy("Fixed"); - encryption.setAesKey("abcdefghij123456"); - presetClient.createPreset(presetName, container, clip, audio, encryption); - } - - @Test - /** - * createPreset( - * String presetName, String container, Clip clip, Audio audio, Encryption encryption) - */ - public void testCreatePresetPCCAEEncryptionSteategyInvalid() throws ClassNotFoundException { - expMsg = "Could not read JSON: Can not construct instance"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(32000); - audio.setChannels(2); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fix"); - encryption.setAesKey("abcdefghij123456"); - presetClient.createPreset(presetName, container, clip, audio, encryption); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio, Video video) - */ - public void testCreatePresetPCAVVideoNormal() { - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("baseline"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(102400); - video.setMaxFrameRate(30f); - video.setMaxWidthInPixel(4096); - video.setMaxHeightInPixel(3072); - video.setSizingPolicy("keep"); - - presetClient.createPreset(presetName, container, audio, video); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio, Video video) - */ - public void testCreatePresetPCAVVideoSizingPolicyNull() { - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setSizingPolicy(null); - presetClient.createPreset(presetName, container, audio, video); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio, Video video) - */ - public void testCreatePresetPCAVVideoCodecNull() throws ClassNotFoundException { - - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec(null); - video.setBitRateInBps(102400); - video.setMaxFrameRate(30f); - presetClient.createPreset(presetName, container, audio, video); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio, Video video) - */ - public void testCreatePresetPCAVVideoCodecOptionAbnormal() throws ClassNotFoundException { - expMsg = "Could not read JSON"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("baseline1"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(102400); - video.setMaxFrameRate(30f); - presetClient.createPreset(presetName, container, audio, video); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio, Video video) - */ - public void testCreatePresetPCAVVideoBitRateAbnormal() throws ClassNotFoundException { - expMsg = "video.bitRateInBps:video.bitRateInBps=must be greater than or equal to 32000"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(1024); - video.setMaxFrameRate(30f); - presetClient.createPreset(presetName, container, audio, video); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio, Video video) - */ - public void testCreatePresetPCAVVideoMaxFrameRateAbnormal() throws ClassNotFoundException { - expMsg = "video.maxFrameRate should in [10.0, 15.0, 20.0, 23.97, 24.0, 25.0, 29.97, 30.0, 50.0, 60.0]"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(21f); - presetClient.createPreset(presetName, container, audio, video); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio, Video video) - */ - public void testCreatePresetPCAVVideoMaxWidthInPixelAbnormal() throws ClassNotFoundException { - expMsg = "video.maxWidthInPixel:video.maxWidthInPixel=must be greater than or equal to 128"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxWidthInPixel(-1); - presetClient.createPreset(presetName, container, audio, video); - } - - @Test - /** - * createPreset(String presetName, String container, Audio audio, Video video) - */ - public void testCreatePresetPCAVVideoMaxHeightInPixelAbnormal() throws ClassNotFoundException { - expMsg = "video.maxHeightInPixel:video.maxHeightInPixel=must be greater than or equal to 96"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String container = "hls"; - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxHeightInPixel(95); - presetClient.createPreset(presetName, container, audio, video); - } - - @Test - /** - * createPreset(String presetName, String container, Clip clip, Audio audio, Video video, Encryption encryption) - */ - public void testCreatePresetPCCAVENormal() { - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - presetClient.createPreset(presetName, container, clip, audio, video, encryption); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String container, Clip clip, Audio audio, Video video, Encryption encryption, String watermarkId) - */ - public void testCreatePresetWithWaterMark() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxHeightInPixel(1000); - video.setMaxWidthInPixel(1000); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - presetClient.createPreset(presetName, - container, clip, audio, video, encryption, watermarkId); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String container, Clip clip, Audio audio, Video video, Encryption encryption, String watermarkId) - */ - public void testCreatePresetWithWaterMarkDeleted() { - - String tempId = null; - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - tempId = response.getWatermarkId(); - mediaClient.deleteWaterMark(tempId); - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - myExp.expect(com.baidubce.BceServiceException.class); - myExp.expectMessage("does not exist"); - presetClient.createPreset(presetName, - container, clip, audio, video, encryption, tempId); - } - - @Test - /** - * createPreset(String presetName, String container, Clip clip, Audio audio, Video video, Encryption encryption, String watermarkId) - */ - public void testCreatePresetWithWaterMarkNotExist() { - - String tempId = "wmk-notlymani6y5r0ey"; - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - myExp.expect(com.baidubce.BceServiceException.class); - myExp.expectMessage("does not exist"); - presetClient.createPreset(presetName, - container, clip, audio, video, encryption, tempId); - } - - - @Test - /** - * createPreset(String presetName, String container, Clip clip, Audio audio, Video video, Encryption encryption, String watermarkId) - */ - public void testCreatePresetWithWaterMarkNull() { - - watermarkId = null; - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - presetClient.createPreset(presetName, - container, clip, audio, video, encryption, watermarkId); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String container, Clip clip, Audio audio, Video video, Encryption encryption, String watermarkId) - */ - public void testCreatePresetWithWaterMarkEmpty() { - - String tempId = ""; - presetName = convertName(prefix); - String container = "hls"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - myExp.expect(com.baidubce.BceServiceException.class); - myExp.expectMessage("watermark: does not exist"); - presetClient.createPreset(presetName, container, clip, audio, video, encryption, tempId); - } - - @Test - /** - * createPreset(String presetName, String container) - */ - public void testCreatePresetPCNormal() { - presetName = convertName(prefix); - String container = "hls"; - presetClient.createPreset(presetName, container); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String description, String container, boolean transmux, - * Clip clip, Audio audio, Video video, Encryption encryption) - */ - public void testCreatePresetPDCTCAVENormal() { - presetName = convertName(prefix); - String description = "test create preset"; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - clip.setDurationInSecond(60); - - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - audio.setSampleRateInHz(44100); - audio.setChannels(1); - - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("main"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(102400); - video.setMaxFrameRate(24f); - video.setMaxWidthInPixel(4096); - video.setMaxHeightInPixel(96); - video.setSizingPolicy("stretch"); - - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - - presetClient.createPreset(presetName, - description, container, true, clip, audio, video, encryption); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String description, String container, boolean transmux, - * Clip clip, Audio audio, Video video, Encryption encryption) - */ - public void testCreatePresetPDCTCAVEDescWithChinese() { - presetName = convertName(prefix); - String description = "这是一个描述信息,含有中文特殊字符!@¥%……&*()。"; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(102400); - video.setMaxFrameRate(24f); - - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - presetClient.createPreset(presetName, description, container, true, clip, audio, video, encryption); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String description, String container, boolean transmux, - * Clip clip, Audio audio, Video video, Encryption encryption) - */ - public void testCreatePresetPDCTCAVEDescNull() { - presetName = convertName(prefix); - String description = null; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("high"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(102400); - video.setMaxFrameRate(29.97f); - - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - presetClient.createPreset(presetName, description, container, false, clip, audio, video, encryption); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(String presetName, String description, String container, boolean transmux, - * Clip clip, Audio audio, Video video, Encryption encryption) - */ - public void testCreatePresetPDCTCAVEDescMore128char() throws ClassNotFoundException { - expMsg = "description:description=size must be between 0 and 128"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - String description = "test create preset20 test create preset20 test create " - + "preset20 test create preset20 test create preset20 test create preset20 129"; - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - - Video video = new Video(); - video.setCodec("h264"); - CodecOptions codecOptions = new CodecOptions(); - codecOptions.setProfile("main"); - video.setCodecOptions(codecOptions); - video.setBitRateInBps(102400); - video.setMaxFrameRate(29.97f); - - Encryption encryption = new Encryption(); - encryption.setStrategy("Fixed"); - encryption.setAesKey("ABCDabcd12345616"); - presetClient.createPreset(presetName, description, container, true, clip, audio, video, encryption); - } - - @Test - /** - * createPreset(CreatePresetRequest request) - */ - public void testCreatePresetNormal() { - CreatePresetRequest request = new CreatePresetRequest(); - presetName = convertName(prefix); - request.setPresetName(presetName); - request.setDescription("test create preset"); - request.setContainer("m4a"); - Clip clip = new Clip(); - clip.setStartTimeInSecond(10); - clip.setDurationInSecond(100); - request.setClip(clip); - - Audio audio = new Audio(); - audio.setBitRateInBps(2000); - audio.setSampleRateInHz(22050); - audio.setChannels(2); - request.setAudio(audio); - - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(64000); - video.setMaxFrameRate(50f); - video.setMaxWidthInPixel(4096); - video.setMaxHeightInPixel(3072); - video.setSizingPolicy("shrinkToFit"); - request.setVideo(video); - - presetClient.createPreset(request); - checkPresetExist(presetName, true); - } - - @Test - /** - * createPreset(CreatePresetRequest request) - * param: presetname, container, transmux - */ - public void testCreatePresetPCT() { - CreatePresetRequest request = new CreatePresetRequest(); - presetName = convertName(prefix); - request.setPresetName(presetName); - request.setContainer("m4a"); - request.setTransmux(true); - presetClient.createPreset(request); - checkPresetExist(presetName, true); - } -} diff --git a/src/test/java/com/baidubce/services/media/cases/CreateThumbNailJobTest.java b/src/test/java/com/baidubce/services/media/cases/CreateThumbNailJobTest.java deleted file mode 100755 index 9af8db15..00000000 --- a/src/test/java/com/baidubce/services/media/cases/CreateThumbNailJobTest.java +++ /dev/null @@ -1,1006 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.CreatePipelineRequest; -import com.baidubce.services.media.model.CreateThumbnailJobRequest; -import com.baidubce.services.media.model.GetThumbnailJobResponse; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.PipelineConfig; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.ThumbnailCapture; -import com.baidubce.services.media.model.ThumbnailSource; -import com.baidubce.services.media.model.ThumbnailTarget; - -public class CreateThumbNailJobTest extends AbstractMediaTest { - - public String pipelineForJob = null; - public String prefix = AbstractMediaTest.PRE_NAME + "createthumb"; - // the capacity is for the pipeline for job test - public int capacityNumber = 2; - - @Before - public void setUp() throws Exception { - super.setUp(); - pipelineForJob = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineForJob); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(capacityNumber); - request.setConfig(config); - pipelineClient.createPipeline(request); - checkPipelineExist(pipelineForJob, true); - } - - @After - public void tearDown() throws Exception { - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - while (true) { - try { - pipelineClient.deletePipeline(name); - break; - } catch (Exception e) { - if (e.getMessage().contains("pending/running")) { - Thread.sleep(5000); - } else { - break; - } - } - } - } - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * test create Thumbnail job successfully with function createThumbnailJob(String pipelineName, String sourceKey, ThumbnailTarget target, ThumbnailCapture capture) - */ - @Test - public void testCreateThumbNailJobNormal1() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job successfully with function createThumbnailJob(String pipelineName, String sourceKey) - */ - @Test - public void testCreateThumbNailJobNormal2() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job successfully with function createThumbnailJob(CreateThumbnailJobRequest request) - */ - @Test - public void testCreateThumbNailJobNormal3() { - - CreateThumbnailJobRequest request = new CreateThumbnailJobRequest(); - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - request.setPipelineName(pipelineName); - ThumbnailSource source = new ThumbnailSource(); - source.setKey(sourceKey); - request.setSource(source); - thumbNailJobId = mediaClient.createThumbnailJob(request).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - - /** - * test method of CreateThumbnailJobRequest - */ - @Test - public void testMethodOfCreateThumbnailJobRequest() { - - CreateThumbnailJobRequest request = new CreateThumbnailJobRequest(); - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - request.setPipelineName(pipelineName); - assertEquals(request.getPipelineName(), pipelineName); - ThumbnailSource source = new ThumbnailSource(); - source.setKey(sourceKey); - assertEquals(source.getKey(), sourceKey); - request.setSource(source); - ThumbnailTarget target = new ThumbnailTarget().withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(0).withEndTimeInSecond(10).withIntervalInSecond(5); - request.setTarget(target); - request.setCapture(capture); - assertEquals(request.getTarget().toString(), target.toString()); - assertEquals(request.getCapture().toString(), capture.toString()); - thumbNailJobId = mediaClient.createThumbnailJob(request).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - - /** - * test create Thumbnail job pipeline not exist - */ - @Test - public void testCreateThumbNailJobPipelineNotExist() { - pipelineName = convertName(prefix); - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipeline does not exist"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job pipeline deleted - */ - @Test - public void testCreateThumbNailJobPipelineDeleted() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - mediaClient.deletePipeline(pipelineName); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("pipeline has been deleted"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job pipeline null - */ - @Test - public void testCreateThumbNailJobPipelineNull() { - pipelineName = null; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("pipelineName should NOT be null or empty string"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job pipeline empty - */ - @Test - public void testCreateThumbNailJobPipelineEmpty() { - pipelineName = ""; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("pipelineName should NOT be null or empty string"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job sourceKey contains chinese char - */ - @Test - public void testCreateThumbNailJobSourceKeyContainsChineseChar() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY5; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job sourceKey contains special letter - */ - @Test - public void testCreateThumbNailJobSourceKeyContainsSpecialLetter() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY6; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job sourceKey long name - */ - @Test - public void testCreateThumbNailJobSourceKeyLongName() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY7; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job sourceKey under folder - */ - @Test - public void testCreateThumbNailJobSourceKeyUnderFolder() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY8; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job sourceKey not exist - */ - @Test - public void testCreateThumbNailJobSourceKeyNotExist() { - pipelineName = pipelineForJob; - sourceKey = "notexist.mp4"; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("bos object: notexist.mp4 does not exist"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - - /** - * test create Thumbnail job sourceKey null - */ - @Test - public void testCreateThumbNailJobSourceKeyNull() { - pipelineName = pipelineForJob; - sourceKey = null; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("source key should NOT be null or empty string"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job sourceKey ="" - */ - @Test - public void testCreateThumbNailJobSourceKeyEmpty() { - pipelineName = pipelineForJob; - sourceKey = ""; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("source key should NOT be null or empty string"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - - /** - * test create Thumbnail job source=null - */ - @Test - public void testCreateThumbNailJobSourceNull() { - - CreateThumbnailJobRequest request = new CreateThumbnailJobRequest(); - pipelineName = pipelineForJob; - request.setPipelineName(pipelineName); - ThumbnailSource source = null; - request.setSource(source); - bceEx.expect(IllegalArgumentException.class); - bceEx.expectMessage("source should NOT be null"); - thumbNailJobId = mediaClient.createThumbnailJob(request).getJobId(); - - } - - /** - * test create Thumbnail job with keyPrefix - */ - @Test - public void testCreateThumbNailJobKeyPrefix() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg") - .withSizingPolicy("keep").withKeyPrefix("testKeyPrefix"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job with keyPrefix underFolder - */ - @Test - public void testCreateThumbNailJobKeyPrefixUnderFolder() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg") - .withSizingPolicy("keep").withKeyPrefix("test/testKeyPrefix"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - /** - * test create Thumbnail job format jpg - */ - @Test - public void testCreateThumbNailJobFormatJpg() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job format png - */ - @Test - public void testCreateThumbNailJobFormatPng() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("png").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job format not support - */ - @Test - public void testCreateThumbNailJobFormatNotSupport() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("giff").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("target.Format from String value 'giff': value not one of declared Enum "); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job sizingPolicy:shrinkToFit - */ - @Test - public void testCreateThumbNailJobSizingPolicyShrinkToFit() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("shrinkToFit"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job sizingPolicy:stretch - */ - @Test - public void testCreateThumbNailJobSizingPolicyStretch() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("stretch"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job sizingPolicy:keep - */ - @Test - public void testCreateThumbNailJobSizingPolicyKeep() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job sizingPolicy:not set - */ - @Test - public void testCreateThumbNailJobSizingPolicyNotSet() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job sizingPolicy:not support - */ - @Test - public void testCreateThumbNailJobSizingPolicyNotSupported() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withSizingPolicy("test"); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("value not one of declared Enum instance names"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job WidthInPixel:10 - */ - @Test - public void testCreateThumbNailJobWidthInPixel10() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withWidthInPixel(10); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job WidthInPixel:9 - */ - @Test - public void testCreateThumbNailJobWidthInPixel9() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withWidthInPixel(9); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("widthInPixel=must be greater than or equal to 10"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job WidthInPixel:2000 - */ - @Test - public void testCreateThumbNailJobWidthInPixel2000() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withWidthInPixel(2000); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job WidthInPixel:2001 - */ - @Test - public void testCreateThumbNailJobWidthInPixel2001() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withWidthInPixel(2001); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("widthInPixel=must be less than or equal to 2000"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job WidthInPixel:1000 - */ - @Test - public void testCreateThumbNailJobWidthInPixel1000() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withWidthInPixel(1000); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job WidthInPixel:not set - */ - @Test - public void testCreateThumbNailJobWidthInPixelNotSet() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - GetThumbnailJobResponse response = mediaClient.getThumbnailJob(thumbNailJobId); - assertEquals(response.getTarget().getWidthInPixel().toString(), "600"); - } - - /** - * test create Thumbnail job heightInPixel:10 - */ - @Test - public void testCreateThumbNailJobHeightInPixel10() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withHeightInPixel(10); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job heightInPixel:9 - */ - @Test - public void testCreateThumbNailJobHeightInPixel9() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withHeightInPixel(9); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("heightInPixel=must be greater than or equal to 10"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job heightInPixel:2000 - */ - @Test - public void testCreateThumbNailJobHeightInPixel2000() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withHeightInPixel(2000); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job heightInPixel:2001 - */ - @Test - public void testCreateThumbNailJobHeightInPixel2001() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withHeightInPixel(2001); - ThumbnailCapture capture = new ThumbnailCapture(); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("heightInPixel=must be less than or equal to 2000"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, - sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job heightInPixel:1000 - */ - @Test - public void testCreateThumbNailJobHeightInPixel1000() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg").withHeightInPixel(1000); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job heightInPixel:not set - */ - @Test - public void testCreateThumbNailJobHeightInPixelNotSet() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withFormat("jpg"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - GetThumbnailJobResponse response = mediaClient.getThumbnailJob(thumbNailJobId); - assertEquals(response.getTarget().getHeightInPixel().toString(), "450"); - } - - /** - * test create Thumbnail job mode:auto - */ - @Test - public void testCreateThumbNailJobModeAuto() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("auto"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job mode:manual - */ - @Test - public void testCreateThumbNailJobModeMannul() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual").withStartTimeInSecond(10); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job mode:except auto manual - */ - @Test - public void testCreateThumbNailJobModeNotSupported() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("test"); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("value not one of declared Enum instance names: [auto, manual, split]"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job startTimeInSecond:0 - */ - @Test - public void testCreateThumbNailJobStartTimeInSecond0() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual").withStartTimeInSecond(0); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job startTimeInSecond:999999999 - */ - @Test - public void testCreateThumbNailJobStartTimeInSecond999999999() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual").withStartTimeInSecond(999999999); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job startTimeInSecond:1000000000 - */ - @Test - public void testCreateThumbNailJobStartTimeInSecond1000000000() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual").withStartTimeInSecond(1000000000); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job startTimeInSecond:-1 - */ - @Test - public void testCreateThumbNailJobStartTimeInSecond_1() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual").withStartTimeInSecond(-1); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("startTimeInSecond=must be greater than or equal to 0"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - } - /** - * test create Thumbnail job startTimeInSecond:auto - */ - @Test - public void testCreateThumbNailJobWithStartTimeInSecondInModeAuto() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("auto").withStartTimeInSecond(10); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("cannot specify start time, end time, interval or frame number in auto mode"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job startTimeInSecond:manual - */ - @Test - public void testCreateThumbNailJobWithoutStartTimeInSecondInModeManual() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job endTimeInSecond:0 - */ - @Test - public void testCreateThumbNailJobEndTimeInSecond0() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(0).withEndTimeInSecond(0).withIntervalInSecond(5); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job endTimeInSecond:999999999 - */ - @Test - public void testCreateThumbNailJobEndTimeInSecond999999999() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(999999998).withEndTimeInSecond(999999999).withIntervalInSecond(5); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job endTimeInSecond:1000000000 - */ - @Test - public void testCreateThumbNailJobEndTimeInSecond1000000000() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(999999998).withEndTimeInSecond(1000000000).withIntervalInSecond(5); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job endTimeInSecond:-1 - */ - @Test - public void testCreateThumbNailJobEndTimeInSecond_1() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(10).withEndTimeInSecond(-1).withIntervalInSecond(5); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("endTimeInSecond=must be greater than or equal to 0"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - } - - - /** - * test create Thumbnail job endTimeInSecond less than startTimeInSecond - */ - @Test - public void testCreateThumbNailJobEndTimeInSecondLessThanstartTimeInSecond() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(10).withEndTimeInSecond(5).withIntervalInSecond(5); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("start time cannot larger than end time"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job endTimeInSecond:auto - */ - @Test - public void testCreateThumbNailJobWithEndTimeInSecondInModeAuto() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("auto").withEndTimeInSecond(0); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("cannot specify start time, end time, interval or frame number in auto mode"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job set endTimeInSecond not set IntervalInSecond - */ - @Test - public void testCreateThumbNailJobWithEndTimeInSecondWithoutIntervalInSecond() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(0).withEndTimeInSecond(10); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - - /** - * test create Thumbnail job set IntervalInSecond but no startTimeInSecond - */ - @Test - public void testCreateThumbNailJobWithIntervalInSecondWithoutStartTimeInSecond() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withEndTimeInSecond(10).withIntervalInSecond(5); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job set IntervalInSecond but no endTimeInSecond - */ - @Test - public void testCreateThumbNailJobWithIntervalInSecondWithoutEndTimeInSecond() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(0).withIntervalInSecond(5); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - - /** - * test create Thumbnail job IntervalInSecond:0 - */ - @Test - public void testCreateThumbNailJobIntervalInSecond0() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(0).withEndTimeInSecond(10).withIntervalInSecond(0); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("intervalInSecond=must be greater than or equal to 1"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - } - - /** - * test create Thumbnail job IntervalInSecond:1 - */ - @Test - public void testCreateThumbNailJobIntervalInSecond1() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(9).withEndTimeInSecond(10).withIntervalInSecond(1); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job IntervalInSecond:999999999 - */ - @Test - public void testCreateThumbNailJobIntervalInSecond999999999() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(9).withEndTimeInSecond(10).withIntervalInSecond(999999999); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job IntervalInSecond:-1 - */ - @Test - public void testCreateThumbNailJobIntervalInSecond_1() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(9).withEndTimeInSecond(10).withIntervalInSecond(-1); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("intervalInSecond=must be greater than or equal to 1"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId();; - } - - /** - * test create Thumbnail job IntervalInSecond:1000000000 - */ - @Test - public void testCreateThumbNailJobIntervalInSecond1000000000() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("manual") - .withStartTimeInSecond(9).withEndTimeInSecond(10).withIntervalInSecond(1000000000); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - assertTrue("Invalid thumbnail job ID: " + thumbNailJobId, thumbNailJobId != null - && thumbNailJobId.trim().length() > 0); - } - - /** - * test create Thumbnail job IntervalInSecond:auto - */ - @Test - public void testCreateThumbNailJobWithIntervalInSecondInModeAuto() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget(); - ThumbnailCapture capture = new ThumbnailCapture().withMode("auto").withIntervalInSecond(5); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("cannot specify start time, end time, interval or frame number in auto mode"); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/CreateWaterMarkTest.java b/src/test/java/com/baidubce/services/media/cases/CreateWaterMarkTest.java deleted file mode 100755 index b72f5c26..00000000 --- a/src/test/java/com/baidubce/services/media/cases/CreateWaterMarkTest.java +++ /dev/null @@ -1,867 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertEquals; - -import org.junit.Rule; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.CreateWaterMarkRequest; -import com.baidubce.services.media.model.CreateWaterMarkResponse; -import com.baidubce.services.media.model.GetWaterMarkResponse; - - -public class CreateWaterMarkTest extends AbstractMediaTest { - String watermarkId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - if (watermarkId != null) { - mediaClient.deleteWaterMark(watermarkId); - watermarkId = null; - } - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * test create water mark normal with function CreateWaterMarkResponse createWaterMark(String bucket, String key, int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkNormal() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - CreateWaterMarkResponse res = new CreateWaterMarkResponse(); - res.setWatermarkId(watermarkId); - assertEquals(watermarkId, res.getWatermarkId()); - - } - - /** - * test method of CreateWaterMarkRequest - */ - @Test - public void testMethodOfCreateWaterMarkRequest() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - CreateWaterMarkRequest request = new CreateWaterMarkRequest(); - request.setBucket(bucket); - request.setKey(key); - request.setHorizontalOffsetInPixel(horizontalOffsetInPixel); - request.setVerticalOffsetInPixel(verticalOffsetInPixel); - request.setHorizontalAlignment(horizontalAlignment); - request.setVerticalAlignment(verticalAlignment); - assertEquals(request.getBucket(), bucket); - assertEquals(request.getKey(), key); - assertEquals(request.getVerticalOffsetInPixel().toString(), - Integer.toString(verticalOffsetInPixel)); - assertEquals(request.getHorizontalOffsetInPixel().toString(), - Integer.toString(horizontalOffsetInPixel)); - assertEquals(request.getVerticalAlignment(), verticalAlignment); - assertEquals(request.getHorizontalAlignment(), horizontalAlignment); - } - - /** - * test create water mark normal with function CreateWaterMarkResponse createWaterMark(String bucket, String key, int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkNormal1() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - String horizontalAlignment = "right"; - String verticalAlignment = "bottom"; - CreateWaterMarkRequest request = new CreateWaterMarkRequest(); - request.setBucket(bucket); - request.setKey(key); - request.setHorizontalOffsetInPixel(horizontalOffsetInPixel); - request.setVerticalOffsetInPixel(verticalOffsetInPixel); - request.setHorizontalAlignment(horizontalAlignment); - request.setVerticalAlignment(verticalAlignment); - CreateWaterMarkResponse response = mediaClient.createWaterMark(request); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("right", res.getHorizontalAlignment()); - assertEquals("bottom", res.getVerticalAlignment()); - } - - - /** - * test create water mark with bucket contains Chinese char - */ - @Test - public void testBucketContainsChineseChar() { - String bucket = "test测试bucket"; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("doesn't exist or isn't in bj region"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark with bucket not exist - */ - @Test - public void testBucketNotExist() { - String bucket = "bucketnotexist"; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("doesn't exist or isn't in bj region"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark with bucket ='' - */ - @Test - public void testBuckeEmpty() { - String bucket = ""; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(java.lang.IllegalArgumentException.class); - bceEx.expectMessage("bucket should NOT be null or empty string"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark with bucket= null - */ - @Test - public void testBucketNull() { - String bucket = null; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(java.lang.IllegalArgumentException.class); - bceEx.expectMessage("bucket should NOT be null"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark with bucket contais special char - */ - @Test - public void testBucketContainsSpecialChar() { - String bucket = "test#$@&*^test"; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("doesn't exist or isn't in bj region"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark for key( jpg png bmp PBM、GIF、TIF) . - */ - @Test - public void testKeySupportedJpg() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, key, - horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - - /** - * test create water mark for key( jpg png bmp PBM、GIF、TIF) . - */ - @Test - public void testKeySupportedPng() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO_PNG; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - - /** - * test create water mark for key( jpg png bmp PBM、GIF、TIF) . - */ - @Test - public void testKeySupportedBmp() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO_BMP; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - - /** - * test create water mark for key( jpg png bmp PBM、GIF、TIF) . - */ - @Test - public void testKeySupportedPbm() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO_PBM; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - - /** - * test create water mark for key( jpg png bmp PBM、GIF、TIF) . - */ - @Test - public void testKeySupportedGif() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO_Gif; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - - /** - * test create water mark for key( jpg png bmp PBM、GIF、TIF) . - */ - @Test - public void testKeySupportedTif() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO_TIF; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - - /** - * test create water mark for key not picture - */ - @Test - public void testKeyNotPicure() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_KEY; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("invalid watermark format"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark for key not jpg png bmp PBM、GIF、TIF - */ - @Test - public void testKeyPictureNotSupported() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO_PSD; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("invalid watermark format"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark for key not jpg png bmp PBM、GIF、TIF - */ - @Test - public void testKeyContainsChineseChar() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO1; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - /** - * test create water mark for key contains special char - */ - @Test - public void testKeyContainsSpecialChar() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO2; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - /** - * test create water mark for key under folder - */ - @Test - public void testKeyUnderFolder() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO3; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - - /** - * test create water mark for key not exist - */ - @Test - public void testKeyNotExist() { - String bucket = SOURCE_BUCKET; - String key = "notexist.jpg"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("notexist.jpg does not exist"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - /** - * test create water mark for key='' - */ - @Test - public void testKeyEmpty() { - String bucket = SOURCE_BUCKET; - String key = ""; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(java.lang.IllegalArgumentException.class); - bceEx.expectMessage("key should NOT be null or empty string"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - /** - * test create water mark for key='' - */ - @Test - public void testKeyNull() { - String bucket = SOURCE_BUCKET; - String key = null; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(java.lang.IllegalArgumentException.class); - bceEx.expectMessage("key should NOT be null"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark horizontalOffsetInPixel=0 - */ - @Test - public void testHorizontalOffsetInPixel0() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 0; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - /** - * test create water mark verticalOffsetInPixel=0 - */ - @Test - public void testVerticalOffsetInPixel0() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 0; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - } - - /** - * test create water mark horizontalOffsetInPixel=-1 - */ - @Test - public void testHorizontalOffsetInPixelNegative() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = -1; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("horizontalOffsetInPixel=must be greater than or equal to 0"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - /** - * test create water mark verticalOffsetInPixel=-1 - */ - @Test - public void testVerticalOffsetInPixelNegative() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = -1; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("verticalOffsetInPixel=must be greater than or equal to 0"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark HorizontalOffsetInPixel not set - */ - @Test - public void testHorizontalOffsetInPixelNull() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int verticalOffsetInPixel = 10; - CreateWaterMarkRequest request = new CreateWaterMarkRequest(); - request.setBucket(bucket); - request.setKey(key); - request.setVerticalOffsetInPixel(verticalOffsetInPixel); - CreateWaterMarkResponse response = mediaClient.createWaterMark(request); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("0", res.getHorizontalOffsetInPixel().toString()); - assertEquals("10", res.getVerticalOffsetInPixel().toString()); - } - /** - * test create water mark verticalOffsetInPixel not set - */ - @Test - public void testVerticalOffsetInPixelNull() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - CreateWaterMarkRequest request = new CreateWaterMarkRequest(); - request.setBucket(bucket); - request.setKey(key); - request.setHorizontalOffsetInPixel(horizontalOffsetInPixel); - CreateWaterMarkResponse response = mediaClient.createWaterMark(request); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("20", res.getHorizontalOffsetInPixel().toString()); - assertEquals("0", res.getVerticalOffsetInPixel().toString()); - } - - - /** - * test create water mark twice: it is ok, the response watermarkId is different - */ - @Test - public void testCreateWaterMarkTwice() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - assertNotEquals(response.getWatermarkId(), watermarkId); - mediaClient.deleteWaterMark(response.getWatermarkId()); - } - - /** - * test create water mark horizontalAlignmen and verticalAlignment : createWaterMark(String bucket, String key, String horizontalAlignment, String verticalAlignment) - */ - @Test - public void testCreateWaterMarkWithHorizontalAlignmentAndVerticalAlignment1() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("left", res.getHorizontalAlignment()); - assertEquals("top", res.getVerticalAlignment()); - } - - /** - * test create water mark horizontalAlignmen and verticalAlignment : createWaterMark(String bucket, String key, String horizontalAlignment, String verticalAlignment) - */ - @Test - public void testCreateWaterMarkWithHorizontalAlignmentAndVerticalAlignment2() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "center"; - String verticalAlignment = "center"; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("center", res.getHorizontalAlignment()); - assertEquals("center", res.getVerticalAlignment()); - } - /** - * test create water mark horizontalAlignmen and verticalAlignment : createWaterMark(String bucket, String key, String horizontalAlignment, String verticalAlignment) - */ - @Test - public void testCreateWaterMarkWithHorizontalAlignmentAndVerticalAlignment3() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "right"; - String verticalAlignment = "bottom"; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("right", res.getHorizontalAlignment()); - assertEquals("bottom", res.getVerticalAlignment()); - } - - /** - * test create water mark horizontalAlignmen null - */ - @Test - public void testCreateWaterMarkWithHorizontalAlignmentAndVerticalAlignmentNull() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = null; - String verticalAlignment = null; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("left", res.getHorizontalAlignment()); - assertEquals("top", res.getVerticalAlignment()); - assertEquals("0", res.getHorizontalOffsetInPixel().toString()); - assertEquals("0", res.getVerticalOffsetInPixel().toString()); - } - - /** - * test create water mark horizontalAlignmen empty - */ - @Test - public void testCreateWaterMarkWithHorizontalAlignmentAndVerticalAlignmentEmpty() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = ""; - String verticalAlignment = "top"; - int flag = 0; - try { - mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment); - } catch (Exception e) { - flag = 1; - } - assertEquals(1, flag); - flag = 0; - horizontalAlignment = "left"; - verticalAlignment = ""; - try { - mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment); - } catch (Exception e) { - flag = 1; - } - assertEquals(1, flag); - } - - /** - * test create water mark horizontalAlignmen illegal - */ - @Test - public void testCreateWaterMarkHorizontalAlignmentIllegal() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "test"; - String verticalAlignment = "top"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("value not one of declared Enum instance names: [left, center, right]"); - mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment); - } - - /** - * test create water mark horizontalAlignmen illegal - */ - @Test - public void testCreateWaterMarkVerticalAlignmentIllegal() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "left"; - String verticalAlignment = "test"; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("value not one of declared Enum instance names: [top, center, bottom]"); - mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment); - } - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkWithAlignmentAndOffset() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("left", res.getHorizontalAlignment()); - assertEquals("top", res.getVerticalAlignment()); - assertEquals("20", res.getHorizontalOffsetInPixel().toString()); - assertEquals("10", res.getVerticalOffsetInPixel().toString()); - } - - - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkWithAlignmentAndHorizontalOffsetInPixel4096() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - int horizontalOffsetInPixel = 4096; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("left", res.getHorizontalAlignment()); - assertEquals("top", res.getVerticalAlignment()); - assertEquals("4096", res.getHorizontalOffsetInPixel().toString()); - assertEquals("10", res.getVerticalOffsetInPixel().toString()); - } - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkWithAlignmentAndHorizontalOffsetInPixel4097() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - int horizontalOffsetInPixel = 4097; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("horizontalOffsetInPixel=must be less than or equal to 4096"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkWithAlignmentAndVerticalOffsetInPixel3072() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 3072; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("left", res.getHorizontalAlignment()); - assertEquals("top", res.getVerticalAlignment()); - assertEquals("20", res.getHorizontalOffsetInPixel().toString()); - assertEquals("3072", res.getVerticalOffsetInPixel().toString()); - } - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkWithAlignmentAndVerticalOffsetInPixel3073() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 3073; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("verticalOffsetInPixel=must be less than or equal to 3072"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkVerticalAlignmentCenterAndVerticalOffsetInPixe0() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "left"; - String verticalAlignment = "center"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 0; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("left", res.getHorizontalAlignment()); - assertEquals("center", res.getVerticalAlignment()); - assertEquals("20", res.getHorizontalOffsetInPixel().toString()); - assertEquals("0", res.getVerticalOffsetInPixel().toString()); - } - - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkVerticalAlignmentCenterAndVerticalOffsetInPixeNot0() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "left"; - String verticalAlignment = "center"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("VerticalOffsetInPixel is only valid when the value of VerticalAlignment is top or bottom"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkHorizontalAlignmentCenterAndHorizontalOffsetInPixel0() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "center"; - String verticalAlignment = "top"; - int horizontalOffsetInPixel = 0; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("center", res.getHorizontalAlignment()); - assertEquals("top", res.getVerticalAlignment()); - assertEquals("0", res.getHorizontalOffsetInPixel().toString()); - assertEquals("10", res.getVerticalOffsetInPixel().toString()); - } - - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkHorizontalAlignmentCenterAndHorizontalOffsetInPixelNot0() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "center"; - String verticalAlignment = "top"; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("only valid when the value of HorizontalAlignment is left or right"); - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - } - - /** - * test create water mark wiht function createWaterMark( - * String bucket, String key, String horizontalAlignment, String verticalAlignment, - * int horizontalOffsetInPixel, int verticalOffsetInPixel) - */ - @Test - public void testCreateWaterMarkAlignmentCenter() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - String horizontalAlignment = "center"; - String verticalAlignment = "center"; - int horizontalOffsetInPixel = 0; - int verticalOffsetInPixel = 0; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals("center", res.getHorizontalAlignment()); - assertEquals("center", res.getVerticalAlignment()); - assertEquals("0", res.getHorizontalOffsetInPixel().toString()); - assertEquals("0", res.getVerticalOffsetInPixel().toString()); - } - -} - diff --git a/src/test/java/com/baidubce/services/media/cases/DeletePipelineTest.java b/src/test/java/com/baidubce/services/media/cases/DeletePipelineTest.java deleted file mode 100755 index c627f42f..00000000 --- a/src/test/java/com/baidubce/services/media/cases/DeletePipelineTest.java +++ /dev/null @@ -1,121 +0,0 @@ -package com.baidubce.services.media.cases; - - -import org.junit.rules.ExpectedException; - -import static org.junit.Assert.*; - -import org.junit.Rule; -import org.junit.Ignore; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.media.model.DeletePipelineRequest; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.PipelineStatus; - -public class DeletePipelineTest extends AbstractMediaTest { - - public String prefix = AbstractMediaTest.PRE_NAME + "deletepipe"; - - @Before - public void setUp() throws Exception { - super.setUp(); - - } - - @After - public void tearDown() throws Exception { - // super.tearDown(); - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - pipelineClient.deletePipeline(name); - - } - } - - } - - @Rule - public ExpectedException BceEx = ExpectedException.none(); - - /** - * test pipelineName = "" with function deletePipeline(String pipelineName) - */ - @Test - public void testDeletePipelineEmpty(){ - pipelineName = ""; - BceEx.expect(IllegalArgumentException.class); - BceEx.expectMessage("pipelineName should NOT be null or empty string"); - pipelineClient.deletePipeline(pipelineName); - } - - /** - * test pipelineName = null with function deletePipeline(String pipelineName) - */ - @Test - public void testDeletePipelineNull(){ - pipelineName = null; - BceEx.expect(IllegalArgumentException.class); - BceEx.expectMessage("pipelineName should NOT be null or empty string"); - pipelineClient.deletePipeline(pipelineName); - } - - /** - * test pipelineName not exist with function deletePipeline(String pipelineName) - */ - @Test - public void testDeletePipelineNotExist(){ - pipelineName = convertName(prefix); - BceEx.expect(com.baidubce.BceServiceException.class); - BceEx.expectMessage("pipeline does not exist"); - pipelineClient.deletePipeline(pipelineName); - } - - - /** - * test delete pipelineName normal with function deletePipeline(String pipelineName) - */ - @Test - public void testDeletePipelineNormal(){ - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName, AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - pipelineClient.deletePipeline(pipelineName); - checkPipelineExist(pipelineName, false); - } - - /** - * test delete pipelineName normal with function deletePipeline(DeletePipelineRequest request) - */ - @Test - public void testDeletePipelineNormal1(){ - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName, AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - DeletePipelineRequest request = new DeletePipelineRequest(); - request.setPipelineName(pipelineName); - assertEquals(request.getPipelineName(),pipelineName); - pipelineClient.deletePipeline(request); - checkPipelineExist(pipelineName, false); - } - - /** - * test delete pipelineName twice with function deletePipeline(String pipelineName) - */ - @Test - public void testDeletePipelinetwice(){ - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName, AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET, 5); - checkPipelineExist(pipelineName, true); - pipelineClient.deletePipeline(pipelineName); - checkPipelineExist(pipelineName, false); - BceEx.expect(com.baidubce.BceServiceException.class); - BceEx.expectMessage("pipeline does not exist"); - pipelineClient.deletePipeline(pipelineName); - } -} diff --git a/src/test/java/com/baidubce/services/media/cases/DeletePresetTest.java b/src/test/java/com/baidubce/services/media/cases/DeletePresetTest.java deleted file mode 100755 index 5fd80499..00000000 --- a/src/test/java/com/baidubce/services/media/cases/DeletePresetTest.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.regex.*; - -import ch.qos.logback.classic.turbo.TurboFilter; - -import com.baidubce.services.media.model.Audio; -import com.baidubce.services.media.model.Clip; -import com.baidubce.services.media.model.CodecOptions; -import com.baidubce.services.media.model.CreatePresetRequest; -import com.baidubce.services.media.model.DeletePresetRequest; -import com.baidubce.services.media.model.Encryption; -import com.baidubce.services.media.model.GetPresetResponse; -import com.baidubce.services.media.model.ListPresetsResponse; -import com.baidubce.services.media.model.Video; -import com.baidubce.services.media.model.CodecOptions; -import com.baidubce.services.media.MediaClient; - -public class DeletePresetTest extends AbstractMediaTest { - - public String prefix = AbstractMediaTest.PRE_NAME + "deletepreset"; - @Rule - public ExpectedException myExp = ExpectedException.none(); - - @Before - public void setUp() throws Exception { - super.setUp(); - presetName = convertName(prefix); - String container = "hls"; - presetClient.createPreset(presetName, container); - checkPresetExist(presetName, true); - } - - @After - public void tearDown() throws Exception { - for (GetPresetResponse preset : presetClient.listPresets().getPresets()) { - GetPresetResponse resp = presetClient.getPreset(preset.getPresetName()); - System.out.println(resp); - assertTrue("Failed to get preset: " + preset.getPresetName(), resp - .getPresetName().equals(preset.getPresetName())); - presetName = preset.getPresetName(); - if (presetName.startsWith(prefix)) { - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - } - /* Pattern pattern = Pattern.compile("^bce."); - * Matcher m = pattern.matcher(presetName); - * boolean result = m.find(); - * if (!result) { - * System.out.println("delete preset " + presetName); - * presetClient.deletePreset(presetName); - * checkPresetExist(presetName, false); - * } - */ - } - } - - @Test - public void testDeletePresetExist(){ - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - } - - @Test - public void testDeletePresetRepeated() throws ClassNotFoundException{ - expMsg = "The requested preset does not exist"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - presetClient.deletePreset(presetName); - } - - @Test - public void testDeletePresetNotExist() throws ClassNotFoundException{ - expMsg = "The requested preset does not exist"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - presetClient.deletePreset(presetName); - } - - @Test - public void testDeletePresetNull() throws ClassNotFoundException{ - expMsg = "The parameter presetName should NOT be null or empty string"; - myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - - presetName = null; - presetClient.deletePreset(presetName); - } - - @Test - public void testDeletePresetEmpty() throws ClassNotFoundException{ - expMsg = "The parameter presetName should NOT be null or empty string"; - myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - - presetName = ""; - presetClient.deletePreset(presetName); - } - - @Test - /** - * deletePreset(DeletePresetRequest request) - */ - public void testDeletePresetNoraml(){ - DeletePresetRequest request = new DeletePresetRequest(); - request.setPresetName(presetName); - presetClient.deletePreset(request); - checkPresetExist(presetName, false); - } -} diff --git a/src/test/java/com/baidubce/services/media/cases/DeleteWaterMarkTest.java b/src/test/java/com/baidubce/services/media/cases/DeleteWaterMarkTest.java deleted file mode 100755 index 4fdbe0e3..00000000 --- a/src/test/java/com/baidubce/services/media/cases/DeleteWaterMarkTest.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.*; - -import org.junit.Rule; -import org.junit.Ignore; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.Audio; -import com.baidubce.services.media.model.Clip; -import com.baidubce.services.media.model.CreateJobResponse; -import com.baidubce.services.media.model.CreateWaterMarkResponse; -import com.baidubce.services.media.model.DeleteWaterMarkRequest; -import com.baidubce.services.media.model.Encryption; -import com.baidubce.services.media.model.GetJobResponse; -import com.baidubce.services.media.model.Video; - - -public class DeleteWaterMarkTest extends AbstractMediaTest { - String watermarkId = null; - public String prefix = AbstractMediaTest.PRE_NAME + "deletewm"; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - // super.tearDown(); - if (watermarkId != null) { - mediaClient.deleteWaterMark(watermarkId); - watermarkId = null; - } - } - - @Rule - public ExpectedException BceEx = ExpectedException.none(); - - /** - * test delete water mark normal with function deleteWaterMark(String watermarkId) - */ - @Test - public void testDeleteWaterMarkNormal() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId,true); - mediaClient.deleteWaterMark(watermarkId); - checkWaterMarkExist(watermarkId,false); - watermarkId = null; - } - - /** - * test delete water mark normal with function deleteWaterMark(DeleteWaterMarkRequest request) - */ - @Test - public void testDeleteWaterMarkNormal1() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId,true); - DeleteWaterMarkRequest request = new DeleteWaterMarkRequest(); - request.setWatermarkId(watermarkId); - assertEquals(request.getWatermarkId(),watermarkId); - mediaClient.deleteWaterMark(request); - checkWaterMarkExist(watermarkId,false); - watermarkId = null; - } - - /** - * test delete watermark used - */ - @Test - public void testDeleteWaterMarkUsed() { - - String bucket = AbstractMediaTest.SOURCE_BUCKET; - String key = AbstractMediaTest.SOURCE_LOGO; - int horizontalOffsetInPixel = 10; - int verticalOffsetInPixel = 20; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - presetName = convertName(prefix); - String container = "flv"; - Clip clip = new Clip(); - clip.setStartTimeInSecond(0); - Audio audio = new Audio(); - audio.setBitRateInBps(1600); - Video video = new Video(); - video.setCodec("h264"); - video.setBitRateInBps(102400); - video.setMaxFrameRate(50f); - video.setMaxHeightInPixel(1000); - video.setMaxWidthInPixel(1000); - Encryption encryption = null; - presetClient.createPreset(presetName, container, clip, audio, video, encryption,watermarkId); - checkPresetExist(presetName, true); - int flag = 0 ; - try{ - mediaClient.deleteWaterMark(watermarkId); - flag = 0 ; - }catch (Exception e){ - assertTrue(e.getMessage().contains("watermark is in use, please delete the relative presets first")); - flag = 1; - }finally{ - assertEquals(flag,1); - } - System.out.println(flag); - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - mediaClient.deleteWaterMark(watermarkId); - checkWaterMarkExist(watermarkId,false); - watermarkId = null; - } - - - /** - * test delete water mark not exist - */ - @Test - public void testDeleteWaterMarkNotExist() { - String tempId = "wmk-notlymani6y5r0ey"; - checkWaterMarkExist(tempId,false); - BceEx.expect(com.baidubce.BceServiceException.class); - BceEx.expectMessage("does not exist"); - mediaClient.deleteWaterMark(tempId); - } - - /** - * test delete water mark empty - */ - @Test - public void testDeleteWaterEmpty() { - String tempId = ""; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("watermarkId should NOT be null or empty string"); - mediaClient.deleteWaterMark(tempId); - } - - /** - * test delete water mark null - */ - @Test - public void testDeleteWaterNull() { - watermarkId = null; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("watermarkId should NOT be null"); - mediaClient.deleteWaterMark(watermarkId); - } - - /** - * test delete water mark twice - */ - @Test - public void testDeleteWaterMarkTwice() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId,true); - mediaClient.deleteWaterMark(watermarkId); - checkWaterMarkExist(watermarkId,false); - String tempId = watermarkId; - watermarkId = null; - BceEx.expect(com.baidubce.BceServiceException.class); - BceEx.expectMessage("does not exist"); - mediaClient.deleteWaterMark(tempId); - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/GetJobTest.java b/src/test/java/com/baidubce/services/media/cases/GetJobTest.java deleted file mode 100755 index 6fb3fbcb..00000000 --- a/src/test/java/com/baidubce/services/media/cases/GetJobTest.java +++ /dev/null @@ -1,174 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; -import org.junit.Ignore; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.CreatePipelineRequest; -import com.baidubce.services.media.model.GetJobRequest; -import com.baidubce.services.media.model.GetJobResponse; -import com.baidubce.services.media.model.CreateJobResponse; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.PipelineConfig; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.Target; - -public class GetJobTest extends AbstractMediaTest { - - public String pipelineForJob = null; - public int capacityNumber = 2; - public String presetNameSystem = "bce.audio_mp3_320kbps"; - public String prefix = AbstractMediaTest.PRE_NAME + "queryjob"; - - @Before - public void setUp() throws Exception { - super.setUp(); - pipelineForJob = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineForJob); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(capacityNumber); - request.setConfig(config); - pipelineClient.createPipeline(request); - checkPipelineExist(pipelineForJob, true); - } - - @After - public void tearDown() throws Exception { - // super.tearDown(); - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - while(true){ - try{ - pipelineClient.deletePipeline(name); - break; - }catch (Exception e){ - if (e.getMessage().contains("pending/running")){ - Thread.sleep(5000); - }else{ - break; - } - - } - } - - } - } - } - - @Rule - public ExpectedException BceEx = ExpectedException.none(); - - /** - * test get job successfully with function getJob(String jobId) - */ - @Test - public void testGetJobIDNormal() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - jobId = jobResp.getJobId(); - GetJobResponse resp = jobClient.getJob(jobId); - assertEquals(resp.getJobId(),jobId); - } - - /** - * test get job successfully with function getJob(GetJobRequest request) - */ - @Test - public void testGetJobIDNormal1() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - jobId = jobResp.getJobId(); - GetJobRequest request = new GetJobRequest(); - request.setJobId(jobId); - assertEquals(request.getJobId(),jobId); - GetJobResponse resp = jobClient.getJob(request); - assertEquals(resp.getJobId(),jobId); - } - - /** - * test method of GetJobResponse - */ - @Test - public void testMethodOfGetJobResponse() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - jobId = jobResp.getJobId(); - GetJobResponse resp0 = jobClient.getJob(jobId); - GetJobResponse resp = new GetJobResponse(); - resp.setJobId(resp0.getJobId()); - resp.setJobStatus(resp0.getJobStatus()); - resp.setPipelineName(resp0.getPipelineName()); - resp.setSource(resp0.getSource()); - resp.setTarget(resp0.getTarget()); - resp.setStartTime(resp0.getStartTime()); - resp.setEndTime(resp0.getEndTime()); - assertEquals(resp.getJobId(),jobId); - assertTrue(resp.getTarget().toString().contains(targetKey)); - assertTrue(resp.getSource().toString().contains(sourceKey)); - assertEquals(resp.getJobStatus(),resp0.getJobStatus()); - assertEquals(resp.getTarget().getPresetName(),presetName); - assertEquals(resp.getPipelineName(),pipelineName); - assertEquals(resp.getStartTime(),resp0.getStartTime()); - assertEquals(resp.getStartTime(),resp0.getStartTime()); - assertTrue(resp0.getMetadata().toString().contains("bceRequestId")); - assertTrue(resp0.toString().contains("class GetJobResponse")); - } - - /** - * test get job JobId = "" with function getJob(String jobId) - */ - @Test - public void testGetJobIDEmpty() { - jobId = ""; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("jobId should NOT be null or empty string"); - GetJobResponse resp = jobClient.getJob(jobId); - } - - /** - * test get job JobId = null with function getJob(String jobId) - */ - @Test - public void testGetJobIDNull() { - jobId = null; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("jobId should NOT be null or empty string"); - GetJobResponse resp = jobClient.getJob(jobId); - } - - /** - * test get job JobId not exist with function getJob(String jobId) - */ - @Test - public void testJobIDNotExist() { - jobId = "qatest"; - BceEx.expect(com.baidubce.BceServiceException.class); - BceEx.expectMessage("requested job does not exist"); - GetJobResponse resp = jobClient.getJob(jobId); - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/GetPipelineTest.java b/src/test/java/com/baidubce/services/media/cases/GetPipelineTest.java deleted file mode 100755 index 56aad9b2..00000000 --- a/src/test/java/com/baidubce/services/media/cases/GetPipelineTest.java +++ /dev/null @@ -1,183 +0,0 @@ -package com.baidubce.services.media.cases; - - -import org.junit.rules.ExpectedException; - -import static org.junit.Assert.*; - -import org.junit.Rule; -import org.junit.Ignore; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.media.model.GetPipelineRequest; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.GetPipelineResponse; -import com.baidubce.services.media.model.PipelineStatus; - -public class GetPipelineTest extends AbstractMediaTest { - - public String prefix = AbstractMediaTest.PRE_NAME + "querypipeline"; - - @Before - public void setUp() throws Exception { - super.setUp(); - - } - - @After - public void tearDown() throws Exception { - // super.tearDown(); - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - pipelineClient.deletePipeline(name); - - } - } - } - - - @Rule - public ExpectedException BceEx = ExpectedException.none(); - - /** - * test pipeline info with getPipeline(String pipelineName) - */ - - @Test - public void testGetPipeline(){ - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName,"test", AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName, true); - GetPipelineResponse pipelineResponse = new GetPipelineResponse(); - pipelineResponse = pipelineClient.getPipeline(pipelineName); - assertEquals(pipelineResponse.getState(),"ACTIVE"); - assertEquals(pipelineResponse.getPipelineName(),pipelineName); - assertEquals(pipelineResponse.getDescription(),"test"); - assertEquals(pipelineResponse.getSourceBucket(),AbstractMediaTest.SOURCE_BUCKET); - assertEquals(pipelineResponse.getTargetBucket(),AbstractMediaTest.TARGET_BUCKET); - assertTrue(pipelineResponse.getConfig().toString().contains("capacity: 5")); - assertTrue(pipelineResponse.getJobStatus().toString().contains("total")); - assertTrue(pipelineResponse.getClass().toString().contains("GetPipelineResponse")); - pipelineResponse.getLastUpdateTime();// can not be sure the assert. so not test this by now - assertTrue(pipelineResponse.getMetadata().toString().contains("bceRequestId")); - - } - - /** - * test pipeline info with getPipeline(GetPipelineRequest request) - */ - - @Test - public void testGetPipeline1(){ - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName,"test", AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName, true); - GetPipelineResponse pipelineResponse = new GetPipelineResponse(); - GetPipelineRequest request = new GetPipelineRequest(); - request.setPipelineName(pipelineName); - pipelineResponse = pipelineClient.getPipeline(request); - assertEquals(pipelineResponse.getState(),"ACTIVE"); - assertEquals(pipelineResponse.getPipelineName(),pipelineName); - assertEquals(pipelineResponse.getDescription(),"test"); - assertEquals(pipelineResponse.getSourceBucket(),AbstractMediaTest.SOURCE_BUCKET); - assertEquals(pipelineResponse.getTargetBucket(),AbstractMediaTest.TARGET_BUCKET); - assertTrue(pipelineResponse.getConfig().toString().contains("capacity: 5")); - assertTrue(pipelineResponse.getJobStatus().toString().contains("total")); - assertTrue(pipelineResponse.getClass().toString().contains("GetPipelineResponse")); - pipelineResponse.getLastUpdateTime();// can not be sure the assert. so not test this by now - assertTrue(pipelineResponse.getMetadata().toString().contains("bceRequestId")); - - } - - - /** - * test method of GetPipelineResponse - */ - @Test - public void testMethodOfGetPipelineResponse(){ - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName,"test", AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName, true); - GetPipelineResponse pipelineResponse = new GetPipelineResponse(); - GetPipelineResponse pipelineResponse1 = new GetPipelineResponse(); - pipelineResponse1 = pipelineClient.getPipeline(pipelineName); - pipelineResponse.setConfig(pipelineResponse1.getConfig()); - pipelineResponse.setDescription(pipelineResponse1.getDescription()); - pipelineResponse.setJobStatus(pipelineResponse1.getJobStatus()); - pipelineResponse.setLastUpdateTime(pipelineResponse1.getLastUpdateTime()); - pipelineResponse.setPipelineName(pipelineResponse1.getPipelineName()); - pipelineResponse.setSourceBucket(pipelineResponse1.getSourceBucket()); - pipelineResponse.setState(pipelineResponse1.getState()); - pipelineResponse.setTargetBucket(pipelineResponse1.getTargetBucket()); - assertEquals(pipelineResponse.getState(),"ACTIVE"); - assertEquals(pipelineResponse.getPipelineName(),pipelineName); - assertEquals(pipelineResponse.getDescription(),"test"); - pipelineResponse.getLastUpdateTime();// can not be sure the assert. so not test this by now - assertEquals(pipelineResponse.getSourceBucket(),AbstractMediaTest.SOURCE_BUCKET); - assertEquals(pipelineResponse.getTargetBucket(),AbstractMediaTest.TARGET_BUCKET); - assertTrue(pipelineResponse.getConfig().toString().contains("capacity: 5")); - assertTrue(pipelineResponse.getJobStatus().toString().contains("total")); - assertTrue(pipelineResponse.getMetadata().toString().contains("bceRequestId")); - } - - - /** - * test deleted pipeline with getPipeline(String pipelineName) - */ - - @Test - public void testGetPipelineDeleted(){ - pipelineName = convertName(prefix); - pipelineClient.createPipeline(pipelineName,"test", AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName, true); - pipelineClient.deletePipeline(pipelineName); - checkPipelineExist(pipelineName, false); - GetPipelineResponse pipelineResponse = new GetPipelineResponse(); - pipelineResponse = pipelineClient.getPipeline(pipelineName); - assertEquals(pipelineResponse.getState(),"INACTIVE"); - assertEquals(pipelineResponse.getPipelineName(),pipelineName); - assertEquals(pipelineResponse.getDescription(),"test"); - assertEquals(pipelineResponse.getSourceBucket(),AbstractMediaTest.SOURCE_BUCKET); - assertEquals(pipelineResponse.getTargetBucket(),AbstractMediaTest.TARGET_BUCKET); - assertTrue(pipelineResponse.getConfig().toString().contains("capacity: 5")); - assertTrue(pipelineResponse.getJobStatus().toString().contains("total")); - assertTrue(pipelineResponse.getClass().toString().contains("GetPipelineResponse")); - pipelineResponse.getLastUpdateTime();// can not be sure the assert. so not test this by now - assertTrue(pipelineResponse.getMetadata().toString().contains("bceRequestId")); - - } - - - /** - * test pipeline name not exist with getPipeline(String pipelineName) - */ - - @Test - public void testGetPipelineNotExist(){ - pipelineName = convertName(prefix); - checkPipelineExist(pipelineName, false); - GetPipelineResponse pipelineResponse = new GetPipelineResponse(); - BceEx.expect(com.baidubce.BceServiceException.class); - BceEx.expectMessage("pipeline does not exist"); - pipelineResponse = pipelineClient.getPipeline(pipelineName); - } - - /** - * test pipeline = '' with getPipeline(String pipelineName) - */ - - @Test - public void testGetPipelineEmpty(){ - pipelineName = ""; - GetPipelineResponse pipelineResponse = new GetPipelineResponse(); - BceEx.expect(IllegalArgumentException.class); - BceEx.expectMessage("pipelineName should NOT be null or empty string"); - pipelineResponse = pipelineClient.getPipeline(pipelineName); - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/GetThumbNailJobTest.java b/src/test/java/com/baidubce/services/media/cases/GetThumbNailJobTest.java deleted file mode 100755 index e9637642..00000000 --- a/src/test/java/com/baidubce/services/media/cases/GetThumbNailJobTest.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.Ignore; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.CreatePipelineRequest; -import com.baidubce.services.media.model.GetThumbnailJobRequest; -import com.baidubce.services.media.model.GetThumbnailJobResponse; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.PipelineConfig; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.ThumbnailCapture; -import com.baidubce.services.media.model.ThumbnailTarget; - -public class GetThumbNailJobTest extends AbstractMediaTest { - public String pipelineForJob = null; - public int capacityNumber = 2; - public String prefix = AbstractMediaTest.PRE_NAME + "querythumb"; - - @Before - public void setUp() throws Exception { - super.setUp(); - pipelineForJob = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineForJob); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(capacityNumber); - request.setConfig(config); - pipelineClient.createPipeline(request); - checkPipelineExist(pipelineForJob, true); - } - - @After - public void tearDown() throws Exception { - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - while(true){ - try{ - pipelineClient.deletePipeline(name); - break; - }catch (Exception e){ - if (e.getMessage().contains("pending/running")){ - Thread.sleep(5000); - }else{ - break; - } - - } - } - - } - } - } - - @Rule - public ExpectedException BceEx = ExpectedException.none(); - - /* - * test get job successfully with function getThumbnailJob(String jobId) - */ - @Test - public void testGetThumbNailJobNormal1(){ - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - GetThumbnailJobResponse response = mediaClient.getThumbnailJob(thumbNailJobId); - assertEquals(response.getJobId(),thumbNailJobId); - } - - /* - * test get job successfully with function getThumbnailJob(GetThumbnailJobRequest request) - */ - @Test - public void testGetThumbNailJobNormal2(){ - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - GetThumbnailJobRequest request = new GetThumbnailJobRequest(); - request.setJobId(thumbNailJobId); - GetThumbnailJobResponse response = mediaClient.getThumbnailJob(request); - assertEquals(response.getJobId(),thumbNailJobId); - } - - /* - * test method of GetThumbnailJobResponse - */ - @Test - public void testMethodOfGetThumbnailJobResponse(){ - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - thumbNailJobId = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture).getJobId(); - GetThumbnailJobResponse response = mediaClient.getThumbnailJob(thumbNailJobId); - - GetThumbnailJobResponse resp = new GetThumbnailJobResponse(); - resp.setJobId(response.getJobId()); - resp.setJobStatus(response.getJobStatus()); - resp.setPipelineName(response.getPipelineName()); - resp.setSource(response.getSource()); - resp.setTarget(response.getTarget()); - resp.setCapture(response.getCapture()); - assertEquals(resp.getJobId(),thumbNailJobId); - assertEquals(resp.getPipelineName(),pipelineName); - assertEquals(resp.getJobStatus(),response.getJobStatus()); - assertTrue(resp.getSource().toString().contains("ThumbnailSource")); - assertTrue(resp.getTarget().toString().contains("ThumbnailTargetStatus")); - assertTrue(resp.getCapture().toString().contains("ThumbnailCapture")); - } - - /* - * test thumbNailJobId =null - */ - @Test - public void testGetThumbNailJobThumbNailJobIdNull(){ - thumbNailJobId = null; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("jobId should NOT be null or empty string"); - GetThumbnailJobResponse response = mediaClient.getThumbnailJob(thumbNailJobId); - } - - /* - * test thumbNailJobId ="" - */ - @Test - public void testGetThumbNailJobThumbNailJobIdEmpty(){ - thumbNailJobId = ""; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("jobId should NOT be null or empty string"); - GetThumbnailJobResponse response = mediaClient.getThumbnailJob(thumbNailJobId); - } - - /* - * test thumbNailJobId not exist - */ - @Test - public void testGetThumbNailJobThumbNailJobIdNotExist(){ - thumbNailJobId = "job-notexist4qkmxpsw"; - BceEx.expect(com.baidubce.BceServiceException.class); - BceEx.expectMessage("The requested thumbnail does not exist"); - GetThumbnailJobResponse response = mediaClient.getThumbnailJob(thumbNailJobId); - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/GetWaterMarkTest.java b/src/test/java/com/baidubce/services/media/cases/GetWaterMarkTest.java deleted file mode 100755 index f87f3aed..00000000 --- a/src/test/java/com/baidubce/services/media/cases/GetWaterMarkTest.java +++ /dev/null @@ -1,165 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.assertEquals; - -import org.junit.Rule; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.CreateWaterMarkResponse; -import com.baidubce.services.media.model.GetWaterMarkRequest; -import com.baidubce.services.media.model.GetWaterMarkResponse; - -public class GetWaterMarkTest extends AbstractMediaTest { - String watermarkId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - if (watermarkId != null) { - mediaClient.deleteWaterMark(watermarkId); - watermarkId = null; - } - - } - - @Rule - public ExpectedException bceEx = ExpectedException.none(); - - /** - * test get water mark normal with GetWaterMarkResponse getWaterMark(String watermarkId) - */ - - @Test - public void testGetWaterMarkNormal() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - assertEquals(res.getWatermarkId(), watermarkId); - } - - /** - * test get water mark normal with GetWaterMarkResponse getWaterMark(GetWaterMarkRequest request) - */ - - @Test - public void testGetWaterMarkNormal1() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkRequest request = new GetWaterMarkRequest(); - request.setWatermarkId(watermarkId); - assertEquals(request.getWatermarkId(), watermarkId); - GetWaterMarkResponse res = mediaClient.getWaterMark(request); - assertEquals(res.getWatermarkId(), watermarkId); - } - - /** - * test method of GetWaterMarkResponse - */ - - @Test - public void testMethodOfGetWaterMarkResponse() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - String horizontalAlignment = "left"; - String verticalAlignment = "top"; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalAlignment, verticalAlignment, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId, true); - GetWaterMarkResponse res = mediaClient.getWaterMark(watermarkId); - GetWaterMarkResponse res1 = new GetWaterMarkResponse(); - res1.setWatermarkId(res.getWatermarkId()); - res1.setCreateTime(res.getCreateTime()); - res1.setBucket(res.getBucket()); - res1.setKey(res.getKey()); - res1.setVerticalOffsetInPixel(res.getVerticalOffsetInPixel()); - res1.setHorizontalOffsetInPixel(res.getHorizontalOffsetInPixel()); - res1.setHorizontalAlignment(res.getHorizontalAlignment()); - res1.setVerticalAlignment(res.getVerticalAlignment()); - assertEquals(res1.getWatermarkId(), watermarkId); - assertEquals(res1.getCreateTime(), res.getCreateTime()); - assertEquals(res1.getBucket(), bucket); - assertEquals(res1.getKey(), key); - assertEquals(res1.getVerticalOffsetInPixel().toString(), Integer.toString(verticalOffsetInPixel)); - assertEquals(res1.getHorizontalOffsetInPixel().toString(), Integer.toString(horizontalOffsetInPixel)); - assertEquals(res1.getVerticalAlignment(), verticalAlignment); - assertEquals(res1.getHorizontalAlignment(), horizontalAlignment); - } - - - /** - * test get water mark not exist - */ - @Test - public void testWaterMarkIdNotExist() { - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("does not exist"); - GetWaterMarkResponse response = mediaClient.getWaterMark("wmk-notlymani6y5r0ey"); - } - - /** - * test get water mark deleted - */ - @Test - public void testWaterMarkIdDeleted() { - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, - key, horizontalOffsetInPixel, verticalOffsetInPixel); - String tempId = response.getWatermarkId(); - checkWaterMarkExist(tempId, true); - mediaClient.deleteWaterMark(tempId); - checkWaterMarkExist(tempId, false); - bceEx.expect(com.baidubce.BceServiceException.class); - bceEx.expectMessage("does not exist"); - mediaClient.getWaterMark(tempId); - } - - - /** - * test get water mark empty - */ - @Test - public void testWaterMarkIdEmpty() { - bceEx.expect(java.lang.IllegalArgumentException.class); - bceEx.expectMessage("watermarkId should NOT be null or empty string"); - GetWaterMarkResponse response = mediaClient.getWaterMark(""); - } - - /** - * test get water mark null - */ - @Test - public void testWaterMarkIdNull() { - String tempId = null; - bceEx.expect(java.lang.IllegalArgumentException.class); - bceEx.expectMessage("watermarkId should NOT be null"); - GetWaterMarkResponse response = mediaClient.getWaterMark(tempId); - } -} diff --git a/src/test/java/com/baidubce/services/media/cases/ListJobTest.java b/src/test/java/com/baidubce/services/media/cases/ListJobTest.java deleted file mode 100755 index cd842e91..00000000 --- a/src/test/java/com/baidubce/services/media/cases/ListJobTest.java +++ /dev/null @@ -1,219 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import java.util.List; - -import org.junit.Before; -import org.junit.After; -import org.junit.Rule; -import org.junit.Test; -import org.junit.Ignore; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.GetJobResponse; -import com.baidubce.services.media.model.Job; -import com.baidubce.services.media.model.ListJobsRequest; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.ListJobsResponse; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.CreatePipelineRequest; -import com.baidubce.services.media.model.CreateJobResponse; -import com.baidubce.services.media.model.PipelineConfig; - -public class ListJobTest extends AbstractMediaTest { - - public String pipelineForJob = null; - public int capacityNumber = 2; - public String presetNameSystem = "bce.audio_mp3_320kbps"; - public String prefix = AbstractMediaTest.PRE_NAME + "listjob"; - - @Before - public void setUp() throws Exception { - super.setUp(); - pipelineForJob = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineForJob); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(capacityNumber); - request.setConfig(config); - pipelineClient.createPipeline(request); - checkPipelineExist(pipelineForJob, true); - } - - @After - public void tearDown() throws Exception { - // super.tearDown(); - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - while(true){ - try{ - pipelineClient.deletePipeline(name); - break; - }catch (Exception e){ - if (e.getMessage().contains("pending/running")){ - Thread.sleep(5000); - }else{ - break; - } - - } - } - - } - } - } - - @Rule - public ExpectedException BceEx = ExpectedException.none(); - - /** - * test list job successfully with function listJobs(String pipelineName) - */ - @Test - public void testListJobNormal() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - String jobId1 = jobResp.getJobId(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - String jobId2 = jobResp.getJobId(); - ListJobsResponse resp = jobClient.listJobs(pipelineName); - List jobs = resp.getJobs(); - int count = 0; - count = jobs.size(); - assertEquals(count,2);; - assertTrue(jobs.toString().contains(jobId1)); - assertTrue(jobs.toString().contains(jobId2)); - } - - /** - * test list job successfully with function listJobs(ListJobsRequest request) - */ - @Test - public void testListJobNormal1() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - String jobId1 = jobResp.getJobId(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - String jobId2 = jobResp.getJobId(); - ListJobsRequest request = new ListJobsRequest(); - request.setPipelineName(pipelineName); - assertEquals(request.getPipelineName(),pipelineName); - ListJobsResponse respponse = jobClient.listJobs(request); - ListJobsResponse resp = new ListJobsResponse(); - resp.setJobs(respponse.getJobs()); - List jobs = resp.getJobs(); - int count = 0; - count = jobs.size(); - assertEquals(count,2);; - assertTrue(jobs.toString().contains(jobId1)); - assertTrue(jobs.toString().contains(jobId2)); - } - - /** - * test list equal get with function listJobs(String pipelineName) - */ - @Test - public void testListJobIDEqualGetJobID() { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - String jobId = jobResp.getJobId(); - GetJobResponse resp = jobClient.getJob(jobId); - String jobId1 = resp.getJobId(); - ListJobsResponse resp1 = jobClient.listJobs(pipelineName); - List jobs = resp1.getJobs(); - String jobId2 = jobs.get(0).getJobId(); - assertEquals(jobId1,jobId2); - } - - - /** - * test pipeline not exist with function listJobs(String pipelineName) - */ - @Test - public void testListJobPipelineNotExist() { - pipelineName = convertName(prefix); - BceEx.expect(com.baidubce.BceServiceException.class); - BceEx.expectMessage("pipeline does not exist"); - ListJobsResponse resp = jobClient.listJobs(pipelineName); - } - - /** - * test pipeline = '' with function listJobs(String pipelineName) - */ - @Test - public void testListJobPipelineEmpty() { - pipelineName = ""; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("pipelineName should NOT be null or empty string"); - ListJobsResponse resp = jobClient.listJobs(pipelineName); - } - - /** - * test pipeline = null with function listJobs(String pipelineName) - */ - @Test - public void testListJobPipelineNull() { - pipelineName = null; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("pipelineName should NOT be null or empty string"); - ListJobsResponse resp = jobClient.listJobs(pipelineName); - } - - /** - * test list job pipeline deleted with function listJobs(String pipelineName) - */ - @Test - public void testListJobPipelineDeleted() throws InterruptedException { - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY; - targetKey = AbstractMediaTest.TARGET_KEY; - presetName = presetNameSystem; - CreateJobResponse jobResp = new CreateJobResponse(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - String jobId1 = jobResp.getJobId(); - jobResp = jobClient.createJob(pipelineName, sourceKey, targetKey,presetName); - String jobId2 = jobResp.getJobId(); - while(true){ - try{ - pipelineClient.deletePipeline(pipelineName); - break; - }catch (Exception e){ - - if (e.getMessage().contains("pending/running")){ - Thread.sleep(5000); - }else{ - break; - } - - } - } - - ListJobsResponse resp = jobClient.listJobs(pipelineName); - List jobs = resp.getJobs(); - int count = 0; - count = jobs.size(); - assertEquals(count,2);; - assertTrue(jobs.toString().contains(jobId1)); - assertTrue(jobs.toString().contains(jobId2)); - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/ListPipelineTest.java b/src/test/java/com/baidubce/services/media/cases/ListPipelineTest.java deleted file mode 100755 index 825ef5ff..00000000 --- a/src/test/java/com/baidubce/services/media/cases/ListPipelineTest.java +++ /dev/null @@ -1,163 +0,0 @@ -package com.baidubce.services.media.cases; - - -import org.junit.rules.ExpectedException; - -import static org.junit.Assert.*; - -import org.junit.Rule; -import org.junit.Ignore; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import java.util.List; - - -import com.baidubce.services.media.model.ListPipelinesRequest; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.PipelineStatus; - - -public class ListPipelineTest extends AbstractMediaTest { - - public String prefix = AbstractMediaTest.PRE_NAME + "listpipeline"; - - @Before - public void setUp() throws Exception { - super.setUp(); - - } - - @After - public void tearDown() throws Exception { - // super.tearDown(); - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - pipelineClient.deletePipeline(name); - - } - } - } - - - @Rule - public ExpectedException BceEx = ExpectedException.none(); - - - /** - * get pipeline list with function listPipelines() - */ - @Test - public void testListPipeline() { - int count0 = 0; - ListPipelinesResponse resp = pipelineClient.listPipelines(); - List pipelines = resp.getPipelines(); - count0 = pipelines.size(); - String pipelineName1 = convertName(prefix); - pipelineClient.createPipeline(pipelineName1,AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName1, true); - String pipelineName2 = convertName(prefix); - pipelineClient.createPipeline(pipelineName2,AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName2, true); - resp = pipelineClient.listPipelines(); - pipelines = resp.getPipelines(); - int count1 = -1; - count1 = pipelines.size(); - assertEquals(count0+2,count1); - String name; - int flag1 = 0; - int flag2 = 0; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.equals(pipelineName1) ){ - flag1 = 1; - - }else if(name.equals(pipelineName2)){ - flag2 = 1; - - } - } - - assertEquals(flag1,1); - assertEquals(flag2,1); - } - - - /** - * get pipeline list with function listPipelines(ListPipelinesRequest request) - */ - @Test - public void testListPipeline1() { - ListPipelinesRequest request = new ListPipelinesRequest(); - int count0 = 0; - ListPipelinesResponse resp = pipelineClient.listPipelines(request); - List pipelines = resp.getPipelines(); - count0 = pipelines.size(); - String pipelineName1 = convertName(prefix); - pipelineClient.createPipeline(pipelineName1,AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName1, true); - String pipelineName2 = convertName(prefix); - pipelineClient.createPipeline(pipelineName2,AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName2, true); - resp = pipelineClient.listPipelines(request); - pipelines = resp.getPipelines(); - int count1 = -1; - count1 = pipelines.size(); - assertEquals(count0+2,count1); - String name; - int flag1 = 0; - int flag2 = 0; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.equals(pipelineName1) ){ - flag1 = 1; - - }else if(name.equals(pipelineName2)){ - flag2 = 1; - - } - } - - assertEquals(flag1,1); - assertEquals(flag2,1); - } - - /** - * get pipeline list with function listPipelines() - */ - @Test - public void testMethodOfListPipelinesRequest() { - - String pipelineName1 = convertName(prefix); - pipelineClient.createPipeline(pipelineName1,AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName1, true); - String pipelineName2 = convertName(prefix); - pipelineClient.createPipeline(pipelineName2,AbstractMediaTest.SOURCE_BUCKET, AbstractMediaTest.TARGET_BUCKET,5); - checkPipelineExist(pipelineName2, true); - ListPipelinesResponse resp = pipelineClient.listPipelines(); - ListPipelinesResponse respTest = new ListPipelinesResponse(); - respTest.setPipelines(resp.getPipelines()); - assertEquals(respTest.getPipelines().size(),resp.getPipelines().size()); - String name; - int flag1 = 0; - int flag2 = 0; - for (PipelineStatus pipe : respTest.getPipelines()) { - name = pipe.getPipelineName(); - if (name.equals(pipelineName1) ){ - flag1 = 1; - - }else if(name.equals(pipelineName2)){ - flag2 = 1; - - } - } - - assertEquals(flag1,1); - assertEquals(flag2,1); - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/ListPresetTest.java b/src/test/java/com/baidubce/services/media/cases/ListPresetTest.java deleted file mode 100755 index 75067c02..00000000 --- a/src/test/java/com/baidubce/services/media/cases/ListPresetTest.java +++ /dev/null @@ -1,115 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.regex.*; - -import javax.naming.PartialResultException; - -import ch.qos.logback.classic.turbo.TurboFilter; - -import com.baidubce.services.media.model.Audio; -import com.baidubce.services.media.model.Clip; -import com.baidubce.services.media.model.CodecOptions; -import com.baidubce.services.media.model.CreatePresetRequest; -import com.baidubce.services.media.model.Encryption; -import com.baidubce.services.media.model.GetPresetResponse; -import com.baidubce.services.media.model.ListPresetsRequest; -import com.baidubce.services.media.model.ListPresetsResponse; -import com.baidubce.services.media.model.Video; -import com.baidubce.services.media.model.CodecOptions; -import com.baidubce.services.media.MediaClient; - -public class ListPresetTest extends AbstractMediaTest { - - public String prefix = AbstractMediaTest.PRE_NAME + "listpreset"; - - @Before - public void setUp() throws Exception { - super.setUp(); - presetName = convertName(prefix); - String container = "hls"; - presetClient.createPreset(presetName, container); - checkPresetExist(presetName, true); - } - - @After - public void tearDown() throws Exception { - for (GetPresetResponse preset : presetClient.listPresets().getPresets()) { - GetPresetResponse resp = presetClient.getPreset(preset.getPresetName()); - System.out.println(resp); - assertTrue("Failed to get preset: " + preset.getPresetName(), resp - .getPresetName().equals(preset.getPresetName())); - presetName = preset.getPresetName(); - if (presetName.startsWith(prefix)) { - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - } - /* Pattern pattern = Pattern.compile("^bce."); - * Matcher m = pattern.matcher(presetName); - * boolean result = m.find(); - * if (!result) { - * System.out.println("delete preset " + presetName); - * presetClient.deletePreset(presetName); - * checkPresetExist(presetName, false); - * } - */ - } - } - - @Test - public void testListPresetAddOne(){ - ListPresetsResponse resp = presetClient.listPresets(); - boolean exist = false; - for (GetPresetResponse preset : resp.getPresets()) { - if(preset.getPresetName().equals(presetName)){ - if(preset.getState().equals("ACTIVE")){ - exist = true; - } - break; - } - } - assertTrue("list presets error", exist); - } - - @Test - public void testListPresetDeleteOne(){ - ListPresetsResponse resp = presetClient.listPresets(); - boolean exist = false; - for (GetPresetResponse preset : resp.getPresets()) { - if(preset.getPresetName().equals(presetName)){ - if(preset.getState().equals("INACTIVE")){ - exist = true; - } - break; - } - } - assertFalse("list presets error", exist); - } - - @Test - /** - * ListPresetsResponse listPresets(ListPresetsRequest request) - */ - public void testListPresetsNormal(){ - ListPresetsRequest request = new ListPresetsRequest(); - ListPresetsResponse resp = presetClient.listPresets(request); - boolean exist = false; - for (GetPresetResponse preset : resp.getPresets()) { - if(preset.getPresetName().equals(presetName)){ - if(preset.getState().equals("INACTIVE")){ - exist = true; - } - break; - } - } - assertFalse("list presets error", exist); - } -} diff --git a/src/test/java/com/baidubce/services/media/cases/ListThumbNailJobTest.java b/src/test/java/com/baidubce/services/media/cases/ListThumbNailJobTest.java deleted file mode 100755 index 35bf929f..00000000 --- a/src/test/java/com/baidubce/services/media/cases/ListThumbNailJobTest.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.baidubce.services.media.cases; - -import java.util.List; - -import static org.junit.Assert.*; -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.Ignore; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.CreatePipelineRequest; -import com.baidubce.services.media.model.CreateThumbnailJobResponse; -import com.baidubce.services.media.model.GetThumbnailJobResponse; -import com.baidubce.services.media.model.ListPipelinesResponse; -import com.baidubce.services.media.model.ListThumbnailJobsRequest; -import com.baidubce.services.media.model.ListThumbnailJobsResponse; -import com.baidubce.services.media.model.PipelineConfig; -import com.baidubce.services.media.model.PipelineStatus; -import com.baidubce.services.media.model.ThumbnailCapture; -import com.baidubce.services.media.model.ThumbnailJobStatus; -import com.baidubce.services.media.model.ThumbnailTarget; - -public class ListThumbNailJobTest extends AbstractMediaTest { - - public String pipelineForJob = null; - public int capacityNumber = 2; - public String prefix = AbstractMediaTest.PRE_NAME + "listthumb"; - - @Before - public void setUp() throws Exception { - super.setUp(); - pipelineForJob = convertName(prefix); - CreatePipelineRequest request = new CreatePipelineRequest(); - request.setPipelineName(pipelineForJob); - request.setSourceBucket(AbstractMediaTest.SOURCE_BUCKET); - request.setTargetBucket(AbstractMediaTest.TARGET_BUCKET); - PipelineConfig config = new PipelineConfig(); - config.setCapacity(capacityNumber); - request.setConfig(config); - pipelineClient.createPipeline(request); - checkPipelineExist(pipelineForJob, true); - } - - @After - public void tearDown() throws Exception { - ListPipelinesResponse resp = pipelineClient.listPipelines(); - String name; - for (PipelineStatus pipe : resp.getPipelines()) { - name = pipe.getPipelineName(); - if (name.startsWith(prefix)) { - while(true){ - try{ - pipelineClient.deletePipeline(name); - break; - }catch (Exception e){ - if (e.getMessage().contains("pending/running")){ - Thread.sleep(5000); - }else{ - break; - } - - } - } - - } - } - } - - @Rule - public ExpectedException BceEx = ExpectedException.none(); - - - /** - * test list thumbnailjob with function listThumbnailJob(String pipelineName) - */ - @Test - public void testListThumbNailJobNormal1() { - - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - CreateThumbnailJobResponse jobResp = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture); - String jobId1 = jobResp.getJobId(); - jobResp = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture); - String jobId2 = jobResp.getJobId(); - ListThumbnailJobsResponse resp = mediaClient.listThumbnailJobs(pipelineName); - List jobs = resp.getThumbnails(); - int count = 0; - count = jobs.size(); - assertEquals(count,2); - assertTrue(jobs.toString().contains(jobId1)); - assertTrue(jobs.toString().contains(jobId2)); - } - - /** - * test list thumbnailjob with function listThumbnailJobs(ListThumbnailJobsRequest request) - */ - @Test - public void testListThumbNailJobNormal2() { - - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - CreateThumbnailJobResponse jobResp = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture); - String jobId1 = jobResp.getJobId(); - jobResp = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture); - String jobId2 = jobResp.getJobId(); - ListThumbnailJobsRequest request = new ListThumbnailJobsRequest(); - request.setPipeline(pipelineName); - ListThumbnailJobsResponse resp = mediaClient.listThumbnailJobs(request); - List jobs = resp.getThumbnails(); - int count = 0; - count = jobs.size(); - assertEquals(count,2); - assertTrue(jobs.toString().contains(jobId1)); - assertTrue(jobs.toString().contains(jobId2)); - } - - /** - * test list thumbnailjob pipelineName = null - */ - @Test - public void testListThumbNailJobPipelineNameNull() { - - pipelineName = null; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("pipelineName should NOT be null or empty string"); - ListThumbnailJobsResponse resp = mediaClient.listThumbnailJobs(pipelineName); - } - - /** - * test list thumbnailjob pipelineName = "" - */ - @Test - public void testListThumbNailJobPipelineNameEmpty() { - - pipelineName = ""; - BceEx.expect(java.lang.IllegalArgumentException.class); - BceEx.expectMessage("pipelineName should NOT be null or empty string"); - ListThumbnailJobsResponse resp = mediaClient.listThumbnailJobs(pipelineName); - } - - /** - * test list thumbnailjob pipelineName deleted - */ - @Test - public void testListThumbNailJobPipelineNameDeleted()throws InterruptedException { - - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - CreateThumbnailJobResponse jobResp = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture); - String jobId1 = jobResp.getJobId(); - jobResp = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture); - String jobId2 = jobResp.getJobId(); - while(true){ - try{ - pipelineClient.deletePipeline(pipelineName); - break; - }catch (Exception e){ - - if (e.getMessage().contains("pending/running")){ - Thread.sleep(5000); - }else{ - break; - } - - } - } - ListThumbnailJobsResponse resp = mediaClient.listThumbnailJobs(pipelineName); - List jobs = resp.getThumbnails(); - int count = 0; - count = jobs.size(); - assertEquals(count,2); - assertTrue(jobs.toString().contains(jobId1)); - assertTrue(jobs.toString().contains(jobId2)); - } - - /** - * test list thumbnailjob pipelineName not exist - */ - @Test - public void testListThumbNailJobPipelineNameNotExist() { - pipelineName = convertName(AbstractMediaTest.PRE_NAME); - BceEx.expect(com.baidubce.BceServiceException.class); - BceEx.expectMessage("pipeline does not exist"); - ListThumbnailJobsResponse resp = mediaClient.listThumbnailJobs(pipelineName); - } - - /** - * test list equal get - */ - @Test - public void testListThumbNailJobEqualGetJobID() { - - pipelineName = pipelineForJob; - sourceKey = AbstractMediaTest.SOURCE_KEY4; - ThumbnailTarget target = new ThumbnailTarget().withSizingPolicy("keep"); - ThumbnailCapture capture = new ThumbnailCapture(); - CreateThumbnailJobResponse jobResp = mediaClient.createThumbnailJob(pipelineName, sourceKey, target, capture); - String jobId = jobResp.getJobId(); - GetThumbnailJobResponse resp = mediaClient.getThumbnailJob(jobId); - String jobId1 = resp.getJobId(); - ListThumbnailJobsResponse resp1 = mediaClient.listThumbnailJobs(pipelineName); - List jobs = resp1.getThumbnails(); - String jobId2 = jobs.get(0).getJobId(); - assertEquals(jobId1,jobId2); - } - -} diff --git a/src/test/java/com/baidubce/services/media/cases/ListWaterMarkTest.java b/src/test/java/com/baidubce/services/media/cases/ListWaterMarkTest.java deleted file mode 100755 index d2b1e9fb..00000000 --- a/src/test/java/com/baidubce/services/media/cases/ListWaterMarkTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.baidubce.services.media.cases; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import static org.junit.Assert.*; - -import org.junit.Rule; -import org.junit.Ignore; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.services.media.model.CreateWaterMarkResponse; -import com.baidubce.services.media.model.ListWaterMarkRequest; -import com.baidubce.services.media.model.ListWaterMarkResponse; -import com.baidubce.services.media.model.WaterMark; - -public class ListWaterMarkTest extends AbstractMediaTest { - String watermarkId = null; - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - // super.tearDown(); - if (watermarkId != null) { - mediaClient.deleteWaterMark(watermarkId); - watermarkId = null; - } - } - - @Rule - public ExpectedException BceEx = ExpectedException.none(); - - /** - * test list water mark normal with listWaterMark() - */ - @Test - public void testListWaterMarkNormal() { - - int count = -1; - count = mediaClient.listWaterMark().getWatermarks().size(); - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel); - String tempWatermarkId1 = response.getWatermarkId(); - checkWaterMarkExist(tempWatermarkId1,true); - response = mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel); - String tempWatermarkId2 = response.getWatermarkId(); - checkWaterMarkExist(tempWatermarkId2,true); - - ListWaterMarkResponse resp = mediaClient.listWaterMark(); - List watermarks = resp.getWatermarks(); - assertEquals(count+2,watermarks.size()); - Set markId = new HashSet(); - for (WaterMark wm : watermarks) { - markId.add(wm.getWatermarkId()); - } - assertTrue(markId.contains(tempWatermarkId1)); - assertTrue(markId.contains(tempWatermarkId2)); - mediaClient.deleteWaterMark(tempWatermarkId1); - mediaClient.deleteWaterMark(tempWatermarkId2); - } - /** - * test list water mark normal with listWaterMark(ListWaterMarkRequest request) - */ - @Test - public void testListWaterMarkNormal1() { - - int count = -1; - ListWaterMarkRequest request = new ListWaterMarkRequest(); - count = mediaClient.listWaterMark(request).getWatermarks().size(); - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel); - String tempWatermarkId1 = response.getWatermarkId(); - checkWaterMarkExist(tempWatermarkId1,true); - response = mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel); - String tempWatermarkId2 = response.getWatermarkId(); - checkWaterMarkExist(tempWatermarkId2,true); - ListWaterMarkResponse resp = mediaClient.listWaterMark(request); - List watermarks = resp.getWatermarks(); - assertEquals(count+2,watermarks.size()); - Set markId = new HashSet(); - for (WaterMark wm : watermarks) { - markId.add(wm.getWatermarkId()); - } - assertTrue(markId.contains(tempWatermarkId1)); - assertTrue(markId.contains(tempWatermarkId2)); - mediaClient.deleteWaterMark(tempWatermarkId1); - mediaClient.deleteWaterMark(tempWatermarkId2); - } - /** - * test method of ListWaterMarkResponse - */ - @Test - public void testMethodOfListWaterMarkResponse() { - - String bucket = SOURCE_BUCKET; - String key = SOURCE_LOGO; - int horizontalOffsetInPixel = 20; - int verticalOffsetInPixel = 10; - CreateWaterMarkResponse response = mediaClient.createWaterMark(bucket, key, horizontalOffsetInPixel, verticalOffsetInPixel); - watermarkId = response.getWatermarkId(); - checkWaterMarkExist(watermarkId,true); - ListWaterMarkResponse resp = mediaClient.listWaterMark(); - ListWaterMarkResponse resp1 = new ListWaterMarkResponse(); - resp1.setWatermarks(resp.getWatermarks()); - - List watermarks = resp1.getWatermarks(); - Set markId = new HashSet(); - for (WaterMark wm : watermarks) { - markId.add(wm.getWatermarkId()); - } - assertTrue(markId.contains(watermarkId)); - } - - -} diff --git a/src/test/java/com/baidubce/services/media/cases/QueryMediaInfoTest.java b/src/test/java/com/baidubce/services/media/cases/QueryMediaInfoTest.java deleted file mode 100755 index 1108e9ef..00000000 --- a/src/test/java/com/baidubce/services/media/cases/QueryMediaInfoTest.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.baidubce.services.media.cases; - -import org.junit.After; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import com.baidubce.services.media.model.GetMediaInfoOfFileRequest; -import com.baidubce.services.media.model.GetMediaInfoOfFileResponse; - -public class QueryMediaInfoTest extends AbstractMediaTest { - - @Rule - public ExpectedException myExp = ExpectedException.none(); - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testQueryMediaInfoEnglishName() { - - String key = "mediainfotest.mp4"; - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(bucket, key); - System.out.println("\nkey = " + key + " returns: \n" + resp); - assertEquals(bucket, resp.getBucket()); - assertEquals(key, resp.getKey()); - } - - @Test - public void testQueryMediaInfoObjectContainFolder() { - - String key = "media/info/mediainfotest.mp4"; - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(bucket, key); - System.out.println("\nkey = " + key + " returns: \n" + resp); - assertEquals(bucket, resp.getBucket()); - assertEquals(key, resp.getKey()); - } - - @Test - public void testQueryMediaInfoObjectChineseName() { - - String key = "媒体信息测试.mp3"; - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(bucket, key); - System.out.println("\nkey = " + key + " returns: \n" + resp); - assertEquals(bucket, resp.getBucket()); - assertEquals(key, resp.getKey()); - } - - @Test - public void testQueryMediaInfoIncludeSpecialChars() { - - String key = "《媒体信息_测试》.mp3"; - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(bucket, key); - System.out.println("\nkey = " + key + " returns: \n" + resp); - assertEquals(bucket, resp.getBucket()); - assertEquals(key, resp.getKey()); - } - - @SuppressWarnings({ "unchecked", "unused" }) - @Test - public void testQueryMediaInfoObjectNotExist() throws ClassNotFoundException { - expMsg = "bos object: not_exist.mp3 does not exist"; - String key = "not_exist.mp3"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(bucket, key); - } - - @SuppressWarnings({ "unchecked", "unused" }) - @Test - public void testQueryMediaInfoBucketNotExist() throws ClassNotFoundException { - expMsg = "doesn't exist or isn't in bj region"; - bucket = "no-input"; - String key = "mediainfotest.mp4"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(bucket, key); - } - - @SuppressWarnings({ "unchecked", "unused" }) - @Test - public void testQueryMediaInfoBucketIsEmpty() throws ClassNotFoundException { - expMsg = "The parameter bucket should NOT be null or empty string"; - bucket = ""; - String key = "mediainfotest.mp4"; - myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(bucket, key); - } - - @SuppressWarnings({ "unchecked", "unused" }) - @Test - public void testQueryMediaInfoBucketIsNull() throws ClassNotFoundException { - expMsg = "The parameter bucket should NOT be null or empty string"; - bucket = null; - String key = "mediainfotest.mp4"; - myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(bucket, key); - } - - @Test - /** - * GetMediaInfoOfFileResponse getMediaInfoOfFile(GetMediaInfoOfFileRequest request) - */ - public void testQueryMediaInfoNormal() throws ClassNotFoundException { - String key = "mediainfotest.mp4"; - GetMediaInfoOfFileRequest request = new GetMediaInfoOfFileRequest(); - request.setBucket(bucket); - request.setKey(key); - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(request); - System.out.println("\nkey = " + key + " returns: \n" + resp); - assertEquals(bucket, resp.getBucket()); - assertEquals(key, resp.getKey()); - } - - @Test - /** - * GetMediaInfoOfFileResponse getMediaInfoOfFile(GetMediaInfoOfFileRequest request) - */ - public void testQueryMediaInfoDurationInSecondAndContainer() throws ClassNotFoundException { - String key = "mediainfotest.mp4"; - GetMediaInfoOfFileRequest request = new GetMediaInfoOfFileRequest(); - request.setBucket(bucket); - request.setKey(key); - GetMediaInfoOfFileResponse resp = mediaInfoClient.getMediaInfoOfFile(request); - System.out.println("\nkey = " + key + " returns: \n" + resp); - System.out.println(resp); - assertTrue(resp.getContainer().toString().contains("mp4")); - assertEquals(resp.getDurationInSecond().toString(), "220"); - System.out.println(resp.getDurationInSecond().toString()); - } -} - diff --git a/src/test/java/com/baidubce/services/media/cases/QueryPresetTest.java b/src/test/java/com/baidubce/services/media/cases/QueryPresetTest.java deleted file mode 100755 index 714c9a2b..00000000 --- a/src/test/java/com/baidubce/services/media/cases/QueryPresetTest.java +++ /dev/null @@ -1,119 +0,0 @@ -package com.baidubce.services.media.cases; - -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.regex.*; - -import ch.qos.logback.classic.turbo.TurboFilter; - -import com.baidubce.services.media.model.Audio; -import com.baidubce.services.media.model.Clip; -import com.baidubce.services.media.model.CodecOptions; -import com.baidubce.services.media.model.CreatePresetRequest; -import com.baidubce.services.media.model.Encryption; -import com.baidubce.services.media.model.GetPresetRequest; -import com.baidubce.services.media.model.GetPresetResponse; -import com.baidubce.services.media.model.ListPresetsResponse; -import com.baidubce.services.media.model.Video; -import com.baidubce.services.media.model.CodecOptions; -import com.baidubce.services.media.MediaClient; - -public class QueryPresetTest extends AbstractMediaTest { - - public String prefix = AbstractMediaTest.PRE_NAME + "querypreset"; - - @Rule - public ExpectedException myExp = ExpectedException.none(); - - @Before - public void setUp() throws Exception { - super.setUp(); - presetName = convertName(prefix); - String container = "hls"; - presetClient.createPreset(presetName, container); - checkPresetExist(presetName, true); - } - - @After - public void tearDown() throws Exception { - for (GetPresetResponse preset : presetClient.listPresets().getPresets()) { - GetPresetResponse resp = presetClient.getPreset(preset.getPresetName()); - System.out.println(resp); - assertTrue("Failed to get preset: " + preset.getPresetName(), resp - .getPresetName().equals(preset.getPresetName())); - presetName = preset.getPresetName(); - if (presetName.startsWith(prefix)) { - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - } - /* Pattern pattern = Pattern.compile("^bce."); - * Matcher m = pattern.matcher(presetName); - * boolean result = m.find(); - * if (!result) { - * System.out.println("delete preset " + presetName); - * presetClient.deletePreset(presetName); - * checkPresetExist(presetName, false); - * } - */ - } - } - - @Test - public void testQueryPresetExist(){ - checkPresetExist(presetName, true); - } - - @Test - public void testQueryPresetDelete(){ - presetClient.deletePreset(presetName); - checkPresetExist(presetName, false); - } - - @Test - public void testQueryPresetParamNull() throws ClassNotFoundException{ - expMsg = "The parameter presetName should NOT be null or empty string"; - myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - - presetName = null; - presetClient.getPreset(presetName); - } - - @Test - public void testQueryPresetParamEmpty() throws ClassNotFoundException{ - expMsg = "The parameter presetName should NOT be null or empty string"; - myExp.expect((Class) Class.forName(expParamException)); - myExp.expectMessage(expMsg); - - presetName = ""; - presetClient.getPreset(presetName); - } - - @Test - public void testQueryPresetNotExist() throws ClassNotFoundException{ - expMsg = "The requested preset does not exist"; - myExp.expect((Class) Class.forName(expServiceException)); - myExp.expectMessage(expMsg); - - presetName = convertName(prefix); - presetClient.getPreset(presetName); - } - - @Test - /** - * GetPresetResponse getPreset(GetPresetRequest request) - */ - public void testQueryPresetNormal(){ - GetPresetRequest request = new GetPresetRequest(); - request.setPresetName(presetName); - GetPresetResponse resp = pipelineClient.getPreset(request); - assertEquals(resp.getPresetName(), presetName); - } -} diff --git a/src/test/java/com/baidubce/services/moladb/model/TestAttributeDefinition.java b/src/test/java/com/baidubce/services/moladb/model/TestAttributeDefinition.java deleted file mode 100755 index 217f94a9..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestAttributeDefinition.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baidubce.services.moladb.model; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class TestAttributeDefinition { - @BeforeClass - public static void before() { - } - - @AfterClass - public static void after() { - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testAttribute() { - AttributeDefinition attr1 = new AttributeDefinition(); - attr1.withAttributeName("attr1"); - attr1.withAttributeType("N"); - Assert.assertEquals("attr1", attr1.getAttributeName()); - Assert.assertEquals("N", attr1.getAttributeType()); - } -} diff --git a/src/test/java/com/baidubce/services/moladb/model/TestAttributeValue.java b/src/test/java/com/baidubce/services/moladb/model/TestAttributeValue.java deleted file mode 100755 index 3606352f..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestAttributeValue.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.Map; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import com.baidubce.services.moladb.model.transform.AttributeValueUnmarshaller; -import com.baidubce.services.moladb.model.AttributeValue; -import com.baidubce.util.JsonUtils; -import com.fasterxml.jackson.databind.JsonNode; - -public class TestAttributeValue { - @BeforeClass - public static void before() { - } - - @AfterClass - public static void after() { - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testConstruction() { - AttributeValue attr1 = new AttributeValue("string1"); - Assert.assertEquals("string1", attr1.getAttributeValue()); - Assert.assertEquals(AttributeValue.ATTRIBUTE_TYPE_STRING, attr1.getAttributeType()); - - AttributeValue attr2 = new AttributeValue(); - attr2.withN("123"); - Assert.assertEquals(AttributeValue.ATTRIBUTE_TYPE_NUMBER, attr2.getAttributeType()); - - AttributeValue attr3 = new AttributeValue(); - attr3.withN("123"); - Assert.assertEquals(AttributeValue.ATTRIBUTE_TYPE_NUMBER, attr3.getAttributeType()); - - AttributeValue attr4 = new AttributeValue(123L); - Assert.assertEquals(AttributeValue.ATTRIBUTE_TYPE_NUMBER, attr4.getAttributeType()); - Assert.assertEquals(123L, attr4.getLong()); - - AttributeValue attr5 = new AttributeValue(123.3); - Assert.assertEquals(AttributeValue.ATTRIBUTE_TYPE_NUMBER, attr4.getAttributeType()); - int result = (int) (123.3 - attr5.getDouble()); - Assert.assertEquals(0, result); - - String bin = "binary"; - byte[] byte2 = bin.getBytes(); - AttributeValue attr6 = new AttributeValue(byte2); - Assert.assertEquals(AttributeValue.ATTRIBUTE_TYPE_BINARY, attr6.getAttributeType()); - String str3 = new String(attr6.getB()); - Assert.assertEquals(bin, str3); - } - - @Test - public void testSetB() { - String bin = "binary"; - AttributeValue value = new AttributeValue(); - value.withB(bin.getBytes()); - Assert.assertEquals(AttributeValue.ATTRIBUTE_TYPE_BINARY, value.getAttributeType()); - Assert.assertEquals("YmluYXJ5", value.getAttributeValue()); - - byte[] byte2 = bin.getBytes(); - value.withB(byte2); - String str3 = new String(value.getB()); - Assert.assertEquals(bin, str3); - } - - @Test - public void testToString() { - String bin = "binary"; - AttributeValue value = new AttributeValue(); - value.withB(bin.getBytes()); - String str = value.toString(); - Assert.assertEquals("{\"B\":\"YmluYXJ5\"}", str); - } - - @Test - public void testToJsonObj() { - String bin = "binary"; - AttributeValue value = new AttributeValue(); - value.withB(bin.getBytes()); - Map jsonObj = value.toJsonObj(); - Assert.assertEquals(1, jsonObj.size()); - Assert.assertEquals("YmluYXJ5", jsonObj.get("B")); - } - - @Test - public void testMarshallerAndUnmarshaller() { - AttributeValue value = new AttributeValue(); - value.withS("strValue"); - String jsonStr = JsonUtils.toJsonString(value.toJsonObj()); - AttributeValueUnmarshaller unmarshaller = new AttributeValueUnmarshaller(); - JsonNode jsonObj = JsonUtils.jsonNodeOf(jsonStr); - AttributeValue value1 = null; - try { - value1 = unmarshaller.unmarshall(jsonObj); - } catch (Exception e) { - e.printStackTrace(); - } - Assert.assertEquals(value.toString(), value1.toString()); - } -} diff --git a/src/test/java/com/baidubce/services/moladb/model/TestAttributeValueMap.java b/src/test/java/com/baidubce/services/moladb/model/TestAttributeValueMap.java deleted file mode 100755 index d20866b8..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestAttributeValueMap.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import com.baidubce.services.moladb.model.transform.AttributeValueMapUnmarshaller; -import com.baidubce.util.JsonUtils; -import com.fasterxml.jackson.databind.JsonNode; - -public class TestAttributeValueMap { - @Test - public void testToString() { - Map values = new HashMap(); - String attrName = "name1"; - AttributeValue value = new AttributeValue(); - value.withN("123"); - values.put(attrName, value); - String expect = "{name1={\"N\":\"123\"}}"; - Assert.assertEquals(expect, values.toString()); - } - - @Test - public void testMarshallerAndUnmarshaller() { - Map values = new HashMap(); - String attrName = "name1"; - AttributeValue value = new AttributeValue(); - value.withN("123"); - values.put(attrName, value); - Map obj = new HashMap(); - for (Map.Entry entry : values.entrySet()) { - obj.put(entry.getKey(), entry.getValue().toJsonObj()); - } - String jsonStr = JsonUtils.toJsonString(obj); - AttributeValueMapUnmarshaller unmarshaller = new AttributeValueMapUnmarshaller(); - JsonNode jsonObj = JsonUtils.jsonNodeOf(jsonStr); - Map value1 = null; - try { - value1 = unmarshaller.unmarshall(jsonObj); - } catch (Exception e) { - e.printStackTrace(); - } - Assert.assertEquals(values.toString(), value1.toString()); - boolean meetExcept = false; - try { - unmarshaller.unmarshall(null); - } catch (Exception e) { - meetExcept = true; - } - Assert.assertTrue(meetExcept); - - meetExcept = false; - try { - unmarshaller.unmarshall(JsonUtils.jsonNodeOf("[]")); - } catch (Exception e) { - meetExcept = true; - } - Assert.assertTrue(meetExcept); - } -} diff --git a/src/test/java/com/baidubce/services/moladb/model/TestAttributeValueUpdate.java b/src/test/java/com/baidubce/services/moladb/model/TestAttributeValueUpdate.java deleted file mode 100755 index 7c7b54cc..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestAttributeValueUpdate.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import com.baidubce.util.JsonUtils; - -public class TestAttributeValueUpdate { - @Test - public void testToJson() { - AttributeValueUpdate updateValue = new AttributeValueUpdate(); - AttributeValue value = new AttributeValue(); - value.withN("123"); - updateValue.withAction(AttributeValueUpdate.ACTION_PUT); - updateValue.withValue(value); - - Map jsonObj = updateValue.toJsonObj(); - String jsonStr = JsonUtils.toJsonString(jsonObj); - String expect = "{\"action\":\"Put\",\"value\":{\"N\":\"123\"}}"; - Assert.assertEquals(expect, jsonStr); - - updateValue.withAction(AttributeValueUpdate.ACTION_DELETE); - expect = "{\"action\":\"Delete\"}"; - jsonStr = JsonUtils.toJsonString(updateValue.toJsonObj()); - Assert.assertEquals(expect, jsonStr); - } -} diff --git a/src/test/java/com/baidubce/services/moladb/model/TestBatchGetItemRequest.java b/src/test/java/com/baidubce/services/moladb/model/TestBatchGetItemRequest.java deleted file mode 100755 index 0d1eaf46..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestBatchGetItemRequest.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import org.junit.Assert; -import org.junit.Test; - -public class TestBatchGetItemRequest { - - @Test - public void testLimitExceed() { - String tableName1 = "blog"; - String tableName2 = "userData"; - - HashMap requestItems = new HashMap(); - - ArrayList keys1 = new ArrayList(); - - Key table1key1 = new Key(); - table1key1.withAttribute("subject", new AttributeValue().withN("1101")); - table1key1.withAttribute("date", new AttributeValue().withS("2015/02/12")); - keys1.add(table1key1); - Key table1key2 = new Key(); - table1key2.withAttribute("subject", new AttributeValue().withN("111")); - table1key2.withAttribute("date", new AttributeValue().withS("2013/04/12")); - keys1.add(table1key2); - List attrs = new ArrayList(); - attrs.add("name"); - attrs.add("gender"); - attrs.add("address"); - - requestItems.put(tableName1, new KeysAndAttributes() - .withKeys(keys1) - .withAttributesToGet(attrs)); - - ArrayList keys2 = new ArrayList(); - - Key table2key1 = new Key(); - table2key1.withAttribute("city", new AttributeValue().withN("210")); - keys2.add(table2key1); - Key table2key2 = new Key(); - table2key2.withAttribute("city", new AttributeValue().withN("211")); - keys2.add(table2key2); - - Key table2key3 = new Key(); - table2key3.withAttribute("city", new AttributeValue().withN(212)); - keys2.add(table2key3); - - requestItems.put(tableName2, - new KeysAndAttributes().withKeys(keys2).withConsistentRead(true)); - - } - - @Test - public void testToJson() { - String tableName1 = "blog"; - String tableName2 = "userData"; - - HashMap requestItems = new HashMap(); - - ArrayList keys1 = new ArrayList(); - - Key table1key1 = new Key(); - table1key1.withAttribute("subject", new AttributeValue().withN(1101)); - table1key1.withAttribute("date", new AttributeValue().withS("2015/02/12")); - keys1.add(table1key1); - Key table1key2 = new Key(); - table1key2.withAttribute("subject", new AttributeValue().withN(111)); - table1key2.withAttribute("date", new AttributeValue().withS("2013/04/12")); - keys1.add(table1key2); - List attrs = new ArrayList(); - attrs.add("name"); - attrs.add("gender"); - attrs.add("address"); - - requestItems.put(tableName1, new KeysAndAttributes() - .withKeys(keys1).withAttributesToGet(attrs)); - - ArrayList keys2 = new ArrayList(); - - Key table2key1 = new Key(); - table2key1.withAttribute("city", new AttributeValue().withN(210)); - keys2.add(table2key1); - Key table2key2 = new Key(); - table2key2.withAttribute("city", new AttributeValue().withN(211)); - keys2.add(table2key2); - - Key table2key3 = new Key(); - table2key3.withAttribute("city", new AttributeValue().withN(212)); - keys2.add(table2key3); - - requestItems.put(tableName2, - new KeysAndAttributes().withKeys(keys2).withConsistentRead(true)); - - BatchGetItemRequest batchGetItemRequest = new BatchGetItemRequest().withRequestItems(requestItems); - String jsonStr = batchGetItemRequest.toString(); - System.out.println("jsonStr:" + jsonStr); - String expected = "{\"requestItems\":{\"userData\":{\"keys\":[{\"city\":{\"N\":\"210\"}}," - + "{\"city\":{\"N\":\"211\"}},{\"city\":{\"N\":\"212\"}}],\"consistentRead\":\"true\"}," - + "\"blog\":{\"keys\":[{\"date\":{\"S\":\"2015/02/12\"},\"subject\":{\"N\":\"1101\"}}," - + "{\"date\":{\"S\":\"2013/04/12\"},\"subject\":{\"N\":\"111\"}}]," - + "\"attributesToGet\":[\"name\",\"gender\",\"address\"]}}}"; - Assert.assertEquals(expected, jsonStr); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestBatchGetItemResult.java b/src/test/java/com/baidubce/services/moladb/model/TestBatchGetItemResult.java deleted file mode 100755 index f19250dc..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestBatchGetItemResult.java +++ /dev/null @@ -1,80 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.io.ByteArrayInputStream; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import com.baidubce.services.moladb.model.transform.BatchGetItemResponseUnmarshaller; - -public class TestBatchGetItemResult { - - @Test - public void testUnmarshallWithOutUnprocess() { - String table1 = "blog"; - String jsonStr = "{\"responses\":{\"blog\":[{\"item\":{\"body\":{\"B\":\"123==\"}," - + "\"auther\":{\"S\":\"moladb\"},\"subject\":{\"S\":\"howtousemoladb\"}," - + "\"date\":{\"S\":\"2015/02/12\"}}},{\"item\":{\"body\":{\"B\":\"123==\"}," - + "\"auther\":{\"S\":\"moladb\"},\"subject\":{\"S\":\"performanceofmoladb\"}," - + "\"date\":{\"S\":\"2015/02/12\"}}}]},\"status\":{\"blog\":[{\"key\":" - + "{\"subject\":{\"S\":\"performanceofbcc\"},\"date\":{\"S\":\"2013/04/02\"}}," - + "\"errorNo\":-404,\"errorMsg\":\"itemnotexist.\"},{\"key\":{\"subject\":" - + "{\"S\":\"performanceofmoladb\"},\"date\":{\"S\":\"2013/04/02\"}}," - + "\"errorNo\":0,\"errorMsg\":\"Succ.\"},{\"key\":{\"subject\":{\"S\":\"howtousemoladb\"}," - + "\"date\":{\"S\":\"2015/02/12\"}},\"errorNo\":0,\"errorMsg\":\"Succ.\"}]}}"; - BatchGetItemResponse result = new BatchGetItemResponse(); - BatchGetItemResponseUnmarshaller unmarshaller = new BatchGetItemResponseUnmarshaller( - result); - try { - ByteArrayInputStream in = new ByteArrayInputStream( - jsonStr.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - } - Map unprocess = result.getUnprocessedItems(); - Map>> resp = result.getResponses(); - Assert.assertEquals(null, unprocess); - Assert.assertEquals(2, resp.get(table1).size()); - } - - @Test - public void testUnmarshallWithUnprocess() { - String table3 = "userData"; - String jsonStr = "{\"responses\":{\"blog\":[{\"item\":{\"body\":{\"B\":\"123==\"}," - + "\"auther\":{\"S\":\"moladb\"},\"subject\":{\"S\":\"howtousemoladb\"}," - + "\"date\":{\"S\":\"2015/02/12\"}}},{\"item\":{\"body\":{\"B\":\"123==\"}," - + "\"auther\":{\"S\":\"moladb\"},\"subject\":{\"S\":\"performanceofmoladb\"}," - + "\"date\":{\"S\":\"2015/02/12\"}}}]},\"errors\":{\"blog\":[{\"key\":{\"subject\":" - + "{\"S\":\"performanceofbcc\"},\"date\":{\"S\":\"2013/04/02\"}},\"errorNo\":-404," - + "\"errorMsg\":\"itemnotexist.\"},{\"key\":{\"subject\":{\"S\":\"performanceofmoladb\"}," - + "\"date\":{\"S\":\"2013/04/02\"}},\"errorNo\":0,\"errorMsg\":\"Succ.\"}," - + "{\"key\":{\"subject\":{\"S\":\"howtousemoladb\"},\"date\":{\"S\":\"2015/02/12\"}}," - + "\"errorNo\":0,\"errorMsg\":\"Succ.\"}]},\"unprocessedItems\":{\"userData\":" - + "{\"attributesToGet\":[\"city\",\"name\"],\"consistentRead\":\"false\"," - + "\"keys\":[{\"city\":{\"S\":\"nanjing\"}},{\"city\":{\"S\":\"beijing\"}}]}}}"; - BatchGetItemResponse result = new BatchGetItemResponse(); - BatchGetItemResponseUnmarshaller unmarshaller = new BatchGetItemResponseUnmarshaller( - result); - try { - ByteArrayInputStream in = new ByteArrayInputStream( - jsonStr.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - } - Map unprocess = result.getUnprocessedItems(); - Map>> resp = result.getResponses(); - Assert.assertEquals(false, resp.isEmpty()); - Assert.assertEquals(2, unprocess.get(table3).getKeys().size()); - Assert.assertEquals(false, unprocess.get(table3).isConsistentRead()); - Assert.assertEquals(2, - unprocess.get(table3).getAttributesToGet().size()); - - BatchGetItemRequest req = new BatchGetItemRequest(); - req.withRequestItems(result.getUnprocessedItems()); - Assert.assertFalse(req.getRequestItems().get(table3).isConsistentRead()); - String resultStr = result.toString(); - System.out.println("result in str:" + resultStr); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestBatchWriteItemRequest.java b/src/test/java/com/baidubce/services/moladb/model/TestBatchWriteItemRequest.java deleted file mode 100755 index ff483bdd..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestBatchWriteItemRequest.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; - -public class TestBatchWriteItemRequest { - - @Test - public void testMarshall() { - String tableName1 = "table1"; - String tableName2 = "table2"; - - // Create a map for the requests in the batch - Map> requestItems = new HashMap>(); - - // Create a PutRequest for a new Forum item - Map item1 = new HashMap(); - item1.put("name", new AttributeValue().withS("BatchPutNewName")); - item1.put("age", new AttributeValue().withN(99)); - item1.put("subject", new AttributeValue().withN(400)); - - List actionOnTable1 = new ArrayList(); - actionOnTable1.add(new PutRequest().withItem(item1)); - requestItems.put(tableName1, actionOnTable1); - - // Create a PutRequest for a new Thread item - Map item2 = new HashMap(); - item2.put("value", new AttributeValue().withB("emhhbmdiaWFvDQpxaXlhbg".getBytes())); - item2.put("subject", new AttributeValue().withN(410)); - - Map item3 = new HashMap(); - item3.put("value", new AttributeValue().withB("emhhbmdiaWFvDQpxaXlhbg".getBytes())); - item3.put("subject", new AttributeValue().withN(410)); - - List actionOnTable2 = new ArrayList(); - actionOnTable2.add(new PutRequest().withItem(item2)); - actionOnTable2.add(new PutRequest().withItem(item3)); - - // Create a DeleteRequest for a Thread item - Key delKey = new Key(); - delKey.withAttribute("subject", new AttributeValue().withN(211)); - - actionOnTable2.add(new DeleteRequest().withKey(delKey)); - requestItems.put(tableName2, actionOnTable2); - - BatchWriteItemRequest batchWriteItemRequest = new BatchWriteItemRequest(); - batchWriteItemRequest.withRequestItems(requestItems); - String jsonStr = batchWriteItemRequest.toString(); - System.out.println("json str is: " + jsonStr); - String expect = "{\"requestItems\":{\"table2\":[{\"putRequest\":{\"item\":" - + "{\"subject\":{\"N\":\"410\"},\"value\":{\"B\":\"ZW1oaGJtZGlhV0Z2RFFweGFYbGhiZw==\"}}}}," - + "{\"putRequest\":{\"item\":{\"subject\":{\"N\":\"410\"},\"value\":" - + "{\"B\":\"ZW1oaGJtZGlhV0Z2RFFweGFYbGhiZw==\"}}}},{\"deleteRequest\":" - + "{\"key\":{\"subject\":{\"N\":\"211\"}}}}],\"table1\":[{\"putRequest\":" - + "{\"item\":{\"subject\":{\"N\":\"400\"},\"name\":{\"S\":\"BatchPutNewName\"}," - + "\"age\":{\"N\":\"99\"}}}}]}}"; - Assert.assertEquals(expect, jsonStr); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestBatchWriteItemResult.java b/src/test/java/com/baidubce/services/moladb/model/TestBatchWriteItemResult.java deleted file mode 100755 index 903c3657..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestBatchWriteItemResult.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.io.ByteArrayInputStream; -import java.util.List; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; -import com.baidubce.services.moladb.model.transform.BatchWriteItemResponseUnmarshaller; - -public class TestBatchWriteItemResult { - - @Test - public void testUnmarshall() { - String table1 = "blog"; - String table2 = "userData"; - String resp = "{\"errors\":{\"blog\":[{\"deleteRequest\":{\"key\":{\"subject\":" - + "{\"S\":\"howaboutbcc\"},\"date\":{\"S\":\"2015/01/01\"}},\"errorNo\":-404," - + "\"errorMsg\":\"itemnotexist.\"}},{\"putRequest\":{\"key\":{\"subject\":" - + "{\"S\":\"howtousemoladb\"},\"date\":{\"S\":\"2015/02/12\"}},\"errorNo\":0," - + "\"errorMsg\":\"Succ.\"}}]},\"unprocessedItems\":{\"userData\":[{\"deleteRequest\":" - + "{\"key\":{\"subject\":{\"S\":\"performanceofbos\"},\"date\":{\"S\":\"2013/04/12\"}}}}," - + "{\"putRequest\":{\"item\":{\"subject\":{\"S\":\"performanceofsms\"}," - + "\"date\":{\"S\":\"2013/04/12\"},\"body\":{\"B\":\"123==\"}}}}]}}"; - - BatchWriteItemResponse result = new BatchWriteItemResponse(); - BatchWriteItemResponseUnmarshaller unmarshaller = new BatchWriteItemResponseUnmarshaller( - result); - try { - ByteArrayInputStream in = new ByteArrayInputStream(resp.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - } - String str1 = result.toString(); - System.out.println("str1:" + str1); - Map> items = result.getUnprocessedItems(); - Assert.assertEquals(null, items.get(table1)); - DeleteRequest delReq = (DeleteRequest) items.get(table2).get(0); - PutRequest putReq = (PutRequest) items.get(table2).get(1); - Assert.assertTrue(null != delReq); - Assert.assertTrue(null != putReq); - Key keyToDel = delReq.getKey(); - Map itemToPut = putReq.getItem(); - Assert.assertEquals("performanceofbos", - keyToDel.getAttributes().get("subject").getS()); - Assert.assertEquals("performanceofbos", - keyToDel.getAttributes().get("subject").getAttributeValue()); - Assert.assertEquals(null, - itemToPut.get("columnName2")); - - BatchWriteItemRequest req = new BatchWriteItemRequest(); - req.withRequestItems(result.getUnprocessedItems()); - String reqStr = req.toString(); - System.out.println("req str:" + reqStr); - - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestCreateTableRequest.java b/src/test/java/com/baidubce/services/moladb/model/TestCreateTableRequest.java deleted file mode 100755 index b5396adb..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestCreateTableRequest.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.ArrayList; -import java.util.List; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -public class TestCreateTableRequest { - - @BeforeClass - public static void before() { - } - - @AfterClass - public static void after() { - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testArugmentNoCheck() { - CreateTableRequest req = new CreateTableRequest("table1"); - boolean meetExcept = false; - try { - List keySchema = new ArrayList(); - keySchema.add(new KeySchemaElement().withAttributeName("attr1") - .withKeyType(KeySchemaElement.HASH_KEY_TYPE)); - keySchema.add(new KeySchemaElement().withAttributeName("attr2").withKeyType("range")); - } catch (IllegalArgumentException e) { - meetExcept = true; - } - Assert.assertFalse(meetExcept); - meetExcept = false; - try { - List attrs = new ArrayList(); - attrs.add(new AttributeDefinition().withAttributeName("attr3").withAttributeType("b")); - req.withAttributeDefinitions(attrs); - } catch (IllegalArgumentException e) { - meetExcept = true; - } - Assert.assertFalse(meetExcept); - } - - @Test - public void testToJsonStr() { - CreateTableRequest req = new CreateTableRequest("table1"); - List attrs = new ArrayList(); - attrs.add(new AttributeDefinition().withAttributeName("attr1") - .withAttributeType(AttributeValue.ATTRIBUTE_TYPE_BINARY)); - attrs.add(new AttributeDefinition().withAttributeName("attr2") - .withAttributeType(AttributeValue.ATTRIBUTE_TYPE_STRING)); - attrs.add(new AttributeDefinition().withAttributeName("attr3") - .withAttributeType(AttributeValue.ATTRIBUTE_TYPE_BINARY)); - attrs.add(new AttributeDefinition().withAttributeName("attr4") - .withAttributeType(AttributeValue.ATTRIBUTE_TYPE_NUMBER)); - - req.withAttributeDefinitions(attrs); - List keySchema = new ArrayList(); - keySchema.add(new KeySchemaElement().withAttributeName("attr1").withKeyType(KeySchemaElement.HASH_KEY_TYPE)); - keySchema.add(new KeySchemaElement().withAttributeName("attr2").withKeyType(KeySchemaElement.RANGE_KEY_TYPE)); - req.withKeySchema(keySchema); - req.withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(100L) - .withWriteCapacityUnits(100L)); - - String jsonStr = req.toString(); - System.out.println("json str:" + jsonStr); - String expect = "{\"attributeDefinitions\":[{\"attributeType\":\"B\",\"attributeName\":\"attr1\"}," - + "{\"attributeType\":\"S\",\"attributeName\":\"attr2\"},{\"attributeType\":\"B\"," - + "\"attributeName\":\"attr3\"},{\"attributeType\":\"N\",\"attributeName\":\"attr4\"}]," - + "\"keySchema\":[{\"attributeName\":\"attr1\",\"keyType\":\"Hash\"},{\"attributeName\":" - + "\"attr2\",\"keyType\":\"Range\"}]," - + "\"provisionedThroughput\":{\"writeCapacityUnits\":100,\"readCapacityUnits\":100}," - + "\"tableName\":\"table1\"}"; - Assert.assertEquals(expect, jsonStr); - } -} diff --git a/src/test/java/com/baidubce/services/moladb/model/TestDeleteItemRequest.java b/src/test/java/com/baidubce/services/moladb/model/TestDeleteItemRequest.java deleted file mode 100755 index 4dec2507..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestDeleteItemRequest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.baidubce.services.moladb.model; - -import org.junit.Assert; -import org.junit.Test; - -public class TestDeleteItemRequest { - @Test - public void testMarshaller() { - DeleteItemRequest req = new DeleteItemRequest(); - Key keyToDel = new Key(); - AttributeValue value = new AttributeValue(); - value.withN(123); - keyToDel.withAttribute("key", value); - req.withKey(keyToDel).withTableName("table1"); - String jsonStr = req.toString(); - String expect = "{\"key\":{\"key\":{\"N\":\"123\"}},\"tableName\":\"table1\"}"; - Assert.assertEquals(expect, jsonStr); - - String reqInStr = req.toString(); - System.out.println("req in str:" + reqInStr); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestDescribeTableResult.java b/src/test/java/com/baidubce/services/moladb/model/TestDescribeTableResult.java deleted file mode 100755 index 3842afc7..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestDescribeTableResult.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.io.ByteArrayInputStream; -import org.junit.Assert; -import org.junit.Test; -import com.baidubce.services.moladb.model.transform.DescribeTableUnmarshaller; - -public class TestDescribeTableResult { - - @Test - public void testUnmarshaller() { - String jsonStr = "{\"attributeDefinitions\":[{\"attributeName\":\"subject\"," - + "\"attributeType\":\"S\"},{\"attributeName\":\"date\",\"attributeType\":\"S\"}," - + "{\"attributeName\":\"body\",\"attributeType\":\"B\"},{\"attributeName\":\"auther\"," - + "\"attributeType\":\"S\"},{\"attributeName\":\"count\",\"attributeType\":\"N\"}," - + "{\"attributeName\":\"desc\",\"attributeType\":\"S\"},{\"attributeName\":\"comments\"," - + "\"attributeType\":\"S\"},{\"attributeName\":\"tags\",\"attributeType\":\"S\"}]," - + "\"account\":\"fa6fe47154ef478cb5defa7267fd6482\",\"creationDateTime\":\"2013-06-01T23:00:10Z\"," - + "\"itemCount\":14,\"engineType\":\"atomdb\",\"keySchema\":[{\"attributeName\":\"subject\"," - + "\"keyType\":\"Hash\"},{\"attributeName\":\"date\",\"keyType\":\"Range\"}]," - + "\"provisionedThroughput\":{\"lastDecreaseDateTime\":\"2014-06-01T23:00:10Z\"," - + "\"lastIncreaseDateTime\":\"2014-06-01T23:00:10Z\",\"numberOfDecreasesToday\":0," - + "\"readCapacityUnits\":200,\"writeCapacityUnits\":400},\"tableName\":\"blog\"," - + "\"tableSizeInBytes\":897787877878," - + "\"tableStatus\":\"Active\"}"; - - GetTableResponse result = new GetTableResponse(); - DescribeTableUnmarshaller unmarshaller = new DescribeTableUnmarshaller( - result); - try { - ByteArrayInputStream in = new ByteArrayInputStream( - jsonStr.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - } - String resultStr = result.toString(); - System.out.println("describe table result:" + resultStr); - - Assert.assertEquals(14L, result.getItemCount().longValue()); - Assert.assertEquals("blog", result.getTableName()); - Assert.assertEquals(897787877878L, - result.getTableSizeInBytes().longValue()); - Assert.assertEquals("Active", result.getTableStatus()); - Assert.assertEquals(0, - result.getProvisionedThroughput().getNumberOfDecreasesToday().intValue()); - Assert.assertEquals(200, result.getProvisionedThroughput().getReadCapacityUnits()); - Assert.assertEquals(400, result.getProvisionedThroughput().getWriteCapacityUnits()); - Assert.assertEquals("subject", result.getKeySchema().get(0).getAttributeName()); - Assert.assertEquals("date", result.getKeySchema().get(1).getAttributeName()); - Assert.assertEquals(8, result.getAttributeDefinitions().size()); - } - - @Test - public void testInvalidKeySchema() { - String jsonStr = "{\"AttributeDefinitions\":[{\"AttributeName\":\"time\",\"AttributeType\":\"N\"}," - + "{\"AttributeName\":\"error\",\"AttributeType\":\"S\"},{\"AttributeName\":\"message\"," - + "\"AttributeType\":\"S\"}],\"CreationDateTime\":\"2014-06-01T23:00:10Z\",\"ItemCount\":\"1000\"," - + "\"KeySchema\":[{\"AttributeName\":\"attrName1\",\"KeyType\":\"HASH1\"}]," - + "\"ProvisionedThroughput\":{\"LastDecreaseDateTime\":\"2014-06-01T23:00:10Z\"," - + "\"LastIncreaseDateTime\":\"2014-06-01T23:00:10Z\",\"NumberOfDecreasesToday\":\"3\"," - + "\"ReadCapacityUnits\":\"1000\",\"WriteCapacityUnits\":\"100\"}," - + "\"TableName\":\"tableName1\",\"TableSizeInBytes\":\"897787877878\",\"token\":\"rwToken\"," - + "\"ReservedStorageCapacityInBytes\":10,\"TableStatus\":\"Active\"}"; - GetTableResponse result = new GetTableResponse(); - DescribeTableUnmarshaller unmarshaller = new DescribeTableUnmarshaller( - result); - boolean meetExcept = false; - try { - ByteArrayInputStream in = new ByteArrayInputStream( - jsonStr.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - meetExcept = true; - } - Assert.assertTrue(meetExcept); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestGetItemRequest.java b/src/test/java/com/baidubce/services/moladb/model/TestGetItemRequest.java deleted file mode 100755 index 632229c3..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestGetItemRequest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.ArrayList; -import java.util.List; -import org.junit.Assert; -import org.junit.Test; - -public class TestGetItemRequest { - - @Test - public void testMarshaller() { - String tableName = "table1"; - Key keyToGet = new Key(); - keyToGet.withAttribute("key", new AttributeValue().withN(104)); - List attrs = new ArrayList(); - attrs.add("name"); - attrs.add("articals"); - attrs.add("age"); - - GetItemRequest request = new GetItemRequest(tableName).withKey(keyToGet) - .withConsistentRead(true).withAttributesToGet(attrs); - String reqJson = request.toString(); - String expect = "{\"consistentRead\":\"true\"," - + "\"attributesToGet\":[\"name\",\"articals\",\"age\"]}"; - - Assert.assertEquals(expect, reqJson); - String toStr = request.toString(); - System.out.println("request in str:" + toStr); - - request = new GetItemRequest(); - request.withTableName("table2"); - request.withConsistentRead(false); - request.withKey(keyToGet); - reqJson = request.toString(); - System.out.println("json str:" + reqJson); - Assert.assertEquals("", reqJson); - - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestGetItemResult.java b/src/test/java/com/baidubce/services/moladb/model/TestGetItemResult.java deleted file mode 100755 index bffd5814..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestGetItemResult.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.io.ByteArrayInputStream; -import org.junit.Assert; -import org.junit.Test; -import com.baidubce.services.moladb.model.transform.GetItemResponseUnmarshaller; - -public class TestGetItemResult { - @Test - public void testUnmarshaller() { - - String resp = "{\"item\":{\"subject\":{\"S\":\"howtousemoladb?\"}," - + "\"date\":{\"S\":\"2015/01/02\"},\"body\":{\"B\":\"c28gZWFzeQ==\"}," - + "\"auther\":{\"S\":\"moladb\"}}}"; - - GetItemResponse result = new GetItemResponse(); - GetItemResponseUnmarshaller unmarshaller = new GetItemResponseUnmarshaller( - result); - try { - ByteArrayInputStream in = new ByteArrayInputStream(resp.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - } - String value1 = result.getItem().get("subject").getAttributeValue(); - Assert.assertEquals("howtousemoladb?", value1); - AttributeValue value2 = result.getItem().get("notExistAttr"); - System.out.println("not exist attr:" + value2); - Assert.assertEquals(null, value2); - String str = result.toString(); - System.out.println("result:" + str); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestItem.java b/src/test/java/com/baidubce/services/moladb/model/TestItem.java deleted file mode 100755 index b9530b73..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestItem.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.HashMap; -import java.util.Map; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import com.baidubce.services.moladb.model.AttributeValue; - -public class TestItem { - @BeforeClass - public static void before() { - } - - @AfterClass - public static void after() { - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testConstruction() { - Map item = new HashMap(); - item.put("attr1", new AttributeValue("binaryValue")); - item.put("attr2", new AttributeValue().withN("1234")); - item.put("attr3", new AttributeValue().withB("1234".getBytes())); - - Assert.assertEquals(1234, Integer.parseInt(item.get("attr2").getN())); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestListTablesResult.java b/src/test/java/com/baidubce/services/moladb/model/TestListTablesResult.java deleted file mode 100755 index 197f96fc..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestListTablesResult.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.io.ByteArrayInputStream; -import java.util.List; -import org.junit.Assert; -import org.junit.Test; -import com.baidubce.services.moladb.model.transform.ListTablesResponseUnmarshaller; - -public class TestListTablesResult { - - @Test - public void testUnmarshaller() { - - String resp = "{\"lastEvaluatedTableName\":\"tableName3\",\"tableNames\":[\"tableName1\"," - + "\"tableName2\",\"tableName3\"]}"; - - ListTablesResponse result = new ListTablesResponse(); - ListTablesResponseUnmarshaller unmarshaller = new ListTablesResponseUnmarshaller( - result); - try { - ByteArrayInputStream in = new ByteArrayInputStream(resp.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - } - - List names = result.getTableNames(); - - Assert.assertEquals(3, names.size()); - } - - @Test - public void testUnmarshallerLastEmpty() { - - String resp = "{\"tableNames\":[\"tableName1\",\"tableName2\",\"tableName3\"]}"; - - ListTablesResponse result = new ListTablesResponse(); - ListTablesResponseUnmarshaller unmarshaller = new ListTablesResponseUnmarshaller( - result); - try { - ByteArrayInputStream in = new ByteArrayInputStream(resp.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - } - - List names = result.getTableNames(); - Assert.assertEquals(3, names.size()); - } - - @Test - public void testUnmarshallerNoTable() { - - String resp = "{\"tableNames\":[]}"; - - ListTablesResponse result = new ListTablesResponse(); - ListTablesResponseUnmarshaller unmarshaller = new ListTablesResponseUnmarshaller( - result); - try { - ByteArrayInputStream in = new ByteArrayInputStream(resp.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - } - - List names = result.getTableNames(); - Assert.assertEquals(0, names.size()); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestPutItemRequest.java b/src/test/java/com/baidubce/services/moladb/model/TestPutItemRequest.java deleted file mode 100755 index 795d9c39..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestPutItemRequest.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.HashMap; -import java.util.Map; -import org.junit.Assert; -import org.junit.Test; - -public class TestPutItemRequest { - @Test - public void testMarshall() { - Map item = new HashMap(); - item.put("subject", new AttributeValue("howtousemoladb")); - item.put("count", new AttributeValue().withN("1234")); - - String tableName = "table1"; - PutItemRequest putItemRequest = new PutItemRequest(tableName); - putItemRequest.withTableName(tableName); - putItemRequest.withItem(item); - String jsonStr = putItemRequest.toString(); - System.out.println("jsonStr:" + jsonStr); - String expect = "{\"item\":{\"subject\":{\"S\":\"howtousemoladb\"}," - + "\"count\":{\"N\":\"1234\"}}}"; - - Assert.assertEquals(expect, jsonStr); - System.out.println("req in string:" + putItemRequest.toString()); - - PutItemRequest putItemRequest2 = new PutItemRequest(tableName); - Map attrs = new HashMap(); - attrs.put("attr1", new AttributeValue().withN(1)); - - putItemRequest2.withItem(attrs); - jsonStr = putItemRequest2.toString(); - System.out.println("jsonStr2:" + jsonStr); - - expect = "{\"item\":{\"attr1\":{\"N\":\"1\"}}}"; - Assert.assertEquals(expect, jsonStr); - - } - - @Test - public void testMarshallWithExpection() { - Map item = new HashMap(); - item.put("attr1", new AttributeValue("binaryValue")); - item.put("attr2", new AttributeValue().withN("1234")); - - String tableName = "table1"; - PutItemRequest putItemRequest = new PutItemRequest(tableName); - putItemRequest.withItem(item); - String jsonStr = putItemRequest.toString(); - System.out.println("jsonStr3:" + jsonStr); - String expect = "{\"item\":{\"attr2\":{\"N\":\"1234\"}," - + "\"attr1\":{\"S\":\"binaryValue\"}}}"; - - Assert.assertEquals(expect, jsonStr); - System.out.println("req in string:" + putItemRequest.toString()); - } - - @Test - public void testExpectNotExist() { - Map item = new HashMap(); - item.put("attr1", new AttributeValue("binaryValue")); - item.put("attr2", new AttributeValue().withN("1234")); - - String tableName = "table1"; - PutItemRequest putItemRequest = new PutItemRequest(tableName); - putItemRequest.withItem(item); - - String jsonStr = putItemRequest.toString(); - System.out.println("jsonStr4:" + jsonStr); - String expect = "{\"item\":{\"attr2\":" - + "{\"N\":\"1234\"},\"attr1\":{\"S\":\"binaryValue\"}}}"; - Assert.assertEquals(expect, jsonStr); - System.out.println("req in string:" + putItemRequest.toString()); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestQueryRequest.java b/src/test/java/com/baidubce/services/moladb/model/TestQueryRequest.java deleted file mode 100755 index 4dd2d493..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestQueryRequest.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import com.baidubce.services.moladb.MolaDbConstants; - -public class TestQueryRequest { - @BeforeClass - public static void before() { - } - - @AfterClass - public static void after() { - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testToJson() { - QueryRequest req = new QueryRequest("table1"); - Key key1 = new Key(); - key1.withAttribute("keyAttr1", new AttributeValue().withN(123)); - key1.withAttribute("keyAttr2", new AttributeValue().withN(456)); - req.withConsistentRead(true); - req.withExclusiveStartKey(key1); - req.withLimit(1000); - List attrs = new ArrayList(); - attrs.add("attr1"); - req.withAttributesToGet(attrs); - - String keyExpression = "hashKey" + " = " + MolaDbConstants.JSON_HASH_KEY_VALUE + " AND " - + "rangeKey" + " BETWEEN " + MolaDbConstants.JSON_LOW_BOUND - + " AND " + MolaDbConstants.JSON_UP_BOUND; - Map expressionAttributes = new HashMap(); - - expressionAttributes.put(MolaDbConstants.JSON_HASH_KEY_VALUE, new AttributeValue().withN(123)); - expressionAttributes.put(MolaDbConstants.JSON_LOW_BOUND, new AttributeValue().withN(456)); - expressionAttributes.put(MolaDbConstants.JSON_UP_BOUND, new AttributeValue().withS("789")); - - req.withKeyConditionExpression(keyExpression) - .withExpressionAttributeValues(expressionAttributes); - String json = null; - boolean meetExcept = false; - try { - json = req.toString(); - } catch (IllegalArgumentException e) { - meetExcept = true; - } - Assert.assertFalse(meetExcept); - Assert.assertEquals(1, req.getAttributesToGet().size()); - Assert.assertTrue(req.isConsistentRead()); - Assert.assertEquals(2, req.getExclusiveStartKey().getAttributes().size()); - Assert.assertEquals(1000, req.getLimit()); - Assert.assertEquals("table1", req.getTableName()); - String expect = "{\"keyConditionExpression\":\"hashKey = :HashKeyValue AND rangeKey BETWEEN " - + ":LowBound AND :UpBound\"," - + "\"expressionAttributeValues\":{\":HashKeyValue\":{\"N\":\"123\"}," - + "\":LowBound\":{\"N\":\"456\"},\":UpBound\":" - + "{\"S\":\"789\"}},\"exclusiveStartKey\":{\"keyAttr2\":{\"N\":\"456\"}," - + "\"keyAttr1\":{\"N\":\"123\"}}," - + "\"consistentRead\":\"true\",\"attributesToGet\":[\"attr1\"],\"limit\":\"1000\"," - + "\"tableName\":\"table1\",\"order\":\"Asc\"}"; - - Assert.assertEquals(expect, json); - req.orderByAsc(); - Assert.assertEquals(expect, req.toString()); - String expect2 = "{\"keyConditionExpression\":\"hashKey = :HashKeyValue " - + "AND rangeKey BETWEEN :LowBound AND :UpBound\"," - + "\"expressionAttributeValues\":{\":HashKeyValue\":{\"N\":\"123\"},\":LowBound\":{\"N\":\"456\"}," - + "\":UpBound\":{\"S\":\"789\"}},\"exclusiveStartKey\":{\"keyAttr2\":{\"N\":\"456\"}," - + "\"keyAttr1\":{\"N\":\"123\"}},\"consistentRead\":\"true\",\"attributesToGet\":[\"attr1\"]," - + "\"limit\":\"1000\",\"tableName\":\"table1\",\"order\":\"Desc\"}"; - req.orderByDesc(); - Assert.assertEquals(expect2, req.toString()); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestQueryResult.java b/src/test/java/com/baidubce/services/moladb/model/TestQueryResult.java deleted file mode 100755 index 6f98f485..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestQueryResult.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.io.ByteArrayInputStream; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import com.baidubce.services.moladb.model.transform.QueryResponseUnmarshaller; - -public class TestQueryResult { - @BeforeClass - public static void before() { - } - - @AfterClass - public static void after() { - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testInvalidRequest() { - String resp = "{}"; - - QueryResponse result = new QueryResponse(); - QueryResponseUnmarshaller unmarshaller = new QueryResponseUnmarshaller( - result); - boolean meetExcept = false; - try { - ByteArrayInputStream in = new ByteArrayInputStream( - resp.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - meetExcept = true; - } - Assert.assertTrue(meetExcept); - Assert.assertEquals(null, result.getLastEvaluatedKey()); - Assert.assertEquals(null, result.getItems()); - } - - @Test - public void testEmptyRequest() { - String resp = "{\"items\":[]}"; - - QueryResponse result = new QueryResponse(); - QueryResponseUnmarshaller unmarshaller = new QueryResponseUnmarshaller( - result); - boolean meetExcept = false; - try { - ByteArrayInputStream in = new ByteArrayInputStream( - resp.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - meetExcept = true; - } - Assert.assertFalse(meetExcept); - Assert.assertEquals(null, result.getLastEvaluatedKey()); - Assert.assertEquals(0, result.getItems().size()); - } - - @Test - public void testResponseNoLastEvaluatedKey() { - String resp = "{\"items\":[{\"item\":{\"body\":{\"B\":\"123==\"},\"auther\":{\"S\":\"moladb\"}}}]}"; - - QueryResponse result = new QueryResponse(); - QueryResponseUnmarshaller unmarshaller = new QueryResponseUnmarshaller( - result); - boolean meetExcept = false; - try { - ByteArrayInputStream in = new ByteArrayInputStream( - resp.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - meetExcept = true; - } - Assert.assertFalse(meetExcept); - Assert.assertEquals(null, result.getLastEvaluatedKey()); - Assert.assertEquals(1, result.getItems().size()); - } - - @Test - public void testResponseWithLastEvaluatedKey() { - String resp = "{\"items\":[{\"item\":{\"body\":{\"B\":\"123==\"},\"auther\":{\"S\":\"moladb\"}}}," - + "{\"item\":{\"body\":{\"B\":\"123==\"},\"auther\":{\"S\":\"moladb\"}}}]," - + "\"lastEvaluatedKey\":{\"subject\":{\"S\":\"performanceofsms\"},\"date\":{\"S\":\"2013/04/12\"}}}"; - - QueryResponse result = new QueryResponse(); - QueryResponseUnmarshaller unmarshaller = new QueryResponseUnmarshaller( - result); - boolean meetExcept = false; - try { - ByteArrayInputStream in = new ByteArrayInputStream( - resp.getBytes()); - result = unmarshaller.unmarshall(in); - } catch (Exception e) { - e.printStackTrace(); - meetExcept = true; - } - Assert.assertFalse(meetExcept); - Assert.assertEquals("performanceofsms", - result.getLastEvaluatedKey().getAttributes().get("subject").getAttributeValue()); - Assert.assertEquals(2, result.getItems().size()); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestUpdateItemRequest.java b/src/test/java/com/baidubce/services/moladb/model/TestUpdateItemRequest.java deleted file mode 100755 index cf376111..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestUpdateItemRequest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.baidubce.services.moladb.model; - -import java.io.IOException; -import java.util.HashMap; -import org.junit.Assert; -import org.junit.Test; - -public class TestUpdateItemRequest { - - @Test - public void testMarshall() throws IOException { - String tableName = "proxyserver_test_2columns"; - - HashMap updateItems = new HashMap(); - Key keyToUpdate = new Key(); - keyToUpdate.withAttribute("key", new AttributeValue().withN(104)); - - updateItems.put("name", new AttributeValueUpdate().withAction(AttributeValueUpdate.ACTION_PUT) - .withValue(new AttributeValue().withS("UpdateNewName"))); - updateItems.put("value", new AttributeValueUpdate().withAction(AttributeValueUpdate.ACTION_DELETE) - .withValue(new AttributeValue().withN(123))); - - UpdateItemRequest req = new UpdateItemRequest(); - req.withTableName(tableName); - req.withKey(keyToUpdate); - req.withAttributeUpdates(updateItems); - String jsonStr = req.toString(); - System.out.println("json str:" + jsonStr); - String expect = "{\"attributeUpdates\":{\"name\":{\"action\":\"Put\"," - + "\"value\":{\"S\":\"UpdateNewName\"}}," - + "\"value\":{\"action\":\"Delete\"}},\"key\":{\"key\":{\"N\":\"104\"}}}"; - - Assert.assertEquals(expect, jsonStr); - } - - @Test - public void testMarshallWithExpect() throws IOException { - String tableName = "blog"; - - HashMap updateItems = new HashMap(); - Key keyToUpdate = new Key(); - keyToUpdate.withAttribute("key", new AttributeValue().withN(104)); - - updateItems.put("name", new AttributeValueUpdate().withAction(AttributeValueUpdate.ACTION_PUT) - .withValue(new AttributeValue().withS("UpdateNewName"))); - updateItems.put("value", new AttributeValueUpdate().withAction(AttributeValueUpdate.ACTION_DELETE) - .withValue(new AttributeValue().withN(123))); - - UpdateItemRequest req = new UpdateItemRequest(); - req.withTableName(tableName); - req.withKey(keyToUpdate); - req.withAttributeUpdates(updateItems); - - String jsonStr = req.toString(); - System.out.println("json str with expect:" + jsonStr); - String expect = "{\"attributeUpdates\":{\"name\":" - + "{\"action\":\"Put\",\"value\":{\"S\":\"UpdateNewName\"}}," - + "\"value\":{\"action\":\"Delete\"}},\"key\":{\"key\":{\"N\":\"104\"}}}"; - Assert.assertEquals(expect, jsonStr); - } - - @Test - public void testExpectNotExist() throws IOException { - String tableName = "proxyserver_test_2columns"; - - HashMap updateItems = new HashMap(); - Key keyToUpdate = new Key(); - keyToUpdate.withAttribute("key", new AttributeValue().withN(104)); - - updateItems.put("name", new AttributeValueUpdate().withAction(AttributeValueUpdate.ACTION_PUT) - .withValue(new AttributeValue().withS("UpdateNewName"))); - updateItems.put("value", new AttributeValueUpdate().withAction(AttributeValueUpdate.ACTION_DELETE) - .withValue(new AttributeValue().withN(123))); - - UpdateItemRequest req = new UpdateItemRequest(); - req.withTableName(tableName); - req.withKey(keyToUpdate); - req.withAttributeUpdates(updateItems); - - String jsonStr = req.toString(); - System.out.println("json str with expect:" + jsonStr); - String expect = "{\"attributeUpdates\":" - + "{\"name\":{\"action\":\"Put\",\"value\":{\"S\":\"UpdateNewName\"}}," - + "\"value\":{\"action\":\"Delete\"}},\"key\":{\"key\":{\"N\":\"104\"}}}"; - Assert.assertEquals(expect, jsonStr); - } -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/moladb/model/TestUpdateTableRequest.java b/src/test/java/com/baidubce/services/moladb/model/TestUpdateTableRequest.java deleted file mode 100755 index 34ad01f5..00000000 --- a/src/test/java/com/baidubce/services/moladb/model/TestUpdateTableRequest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.baidubce.services.moladb.model; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.Assert; - -public class TestUpdateTableRequest { - - @BeforeClass - public static void before() { - } - - @AfterClass - public static void after() { - } - - @Before - public void setUp() throws Exception { - - } - - @After - public void tearDown() throws Exception { - - } - - @Test - public void testToJsonStrWithProvision() { - UpdateTableRequest req = new UpdateTableRequest("table1"); - req.withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(1000L)); - String jsonStr = req.toString(); - System.out.println("provision str:" + jsonStr); - String expect = "{\"provisionedThroughput\":{\"readCapacityUnits\":1000}}"; - Assert.assertEquals(expect, jsonStr); - } - - @Test - public void testToJsonStr() { - UpdateTableRequest req = new UpdateTableRequest("table1"); - req.withProvisionedThroughput(new ProvisionedThroughput().withReadCapacityUnits(1000L) - .withWriteCapacityUnits(10L)); - String jsonStr = req.toString(); - System.out.println("json str:" + jsonStr); - String expect = "{\"provisionedThroughput\":" - + "{\"writeCapacityUnits\":10,\"readCapacityUnits\":1000}}"; - Assert.assertEquals(expect, jsonStr); - } -} diff --git a/src/test/java/com/baidubce/services/ruleengine/RuleEngineClientTest.java b/src/test/java/com/baidubce/services/ruleengine/RuleEngineClientTest.java deleted file mode 100755 index 5ab91d29..00000000 --- a/src/test/java/com/baidubce/services/ruleengine/RuleEngineClientTest.java +++ /dev/null @@ -1,247 +0,0 @@ -package com.baidubce.services.ruleengine; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.ruleengine.model.CreateRuleRequest; -import com.baidubce.services.ruleengine.model.DeleteRulesRequest; -import com.baidubce.services.ruleengine.model.Destination; -import com.baidubce.services.ruleengine.model.DestinationKind; -import com.baidubce.services.ruleengine.model.ListRuleRequest; -import com.baidubce.services.ruleengine.model.ListRuleResponse; -import com.baidubce.services.ruleengine.model.Rule; -import com.baidubce.services.ruleengine.model.RuleState; -import com.baidubce.services.ruleengine.model.UpdateRuleRequest; -import org.junit.Before; -import org.junit.Test; - -import java.util.ArrayList; -import java.util.List; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.equalTo; - -/** - * Created by yuanyoujun on 2016/10/9. - */ -public class RuleEngineClientTest { - // qa-sandbox - private static final String TEST_ACCESSKEY = "2228f00dfcf64de494348e8486388da1"; - private static final String TEST_SECRETKEY = "40625acf5dcd4807ada78a24d876d87a"; - private static final String TEST_ENVIROMENT_ENDPOINT = "http://nmg01-hpc-w1134.nmg01.baidu.com:8009"; - - private static final String TEST_RULE_NAME = "test-rule-sdk"; - - private RuleEngineClient client; - - @Before - public void setUp() { - BceClientConfiguration config = new BceClientConfiguration() - .withCredentials(new DefaultBceCredentials(TEST_ACCESSKEY, TEST_SECRETKEY)) - .withEndpoint(TEST_ENVIROMENT_ENDPOINT); - client = new RuleEngineClient(config); - - // for production environment, just create the client like: - // client = new RuleengineClient(accessKey, secretKey); - } - - - @Test - public void testCreate() { - deleteRuleByName(TEST_RULE_NAME); - Rule rule = createRule(TEST_RULE_NAME); - - assertThat(rule.getName(), equalTo(TEST_RULE_NAME)); - } - - @Test - public void testDelete() { - deleteRuleByName(TEST_RULE_NAME); - Rule rule = createRule(TEST_RULE_NAME); - deleteRuleById(rule.getUuid()); - - String ruleId = findRuleIdByName(TEST_RULE_NAME); - assertThat(ruleId, equalTo(null)); - } - - @Test - public void testUpdate() { - deleteRuleByName(TEST_RULE_NAME); - Rule rule = createRule(TEST_RULE_NAME); - - UpdateRuleRequest updateReq = new UpdateRuleRequest(); - updateReq.setUuid(rule.getUuid()); - - final String newWhere = "a>b AND c < 100"; - updateReq.setWhere(newWhere); - - final String newSelect = "a,b,c,*"; - updateReq.setSelect(newSelect); - - final String newFrom = "topic/after/updating"; - updateReq.setFrom(newFrom); - - final String newDesc = "this is rule description after updating"; - updateReq.setDescription(newDesc); - - client.updateRule(updateReq); - - Rule newRule = client.getRule(rule.getUuid()); - - assertThat(newRule.getWhere(), equalTo(newWhere)); - assertThat(newRule.getFrom(), equalTo(newFrom)); - assertThat(newRule.getSelect(), equalTo(newSelect)); - assertThat(newRule.getDescription(), equalTo(newDesc)); - } - - @Test - public void testEnableDisable() { - deleteRuleByName(TEST_RULE_NAME); - Rule rule = createRule(TEST_RULE_NAME); - - assertThat(rule.getState(), equalTo(RuleState.ENABLED)); - - client.disableRule(rule.getUuid()); - rule = client.getRule(rule.getUuid()); - assertThat(rule.getState(), equalTo(RuleState.DISABLED)); - - client.enableRule(rule.getUuid()); - rule = client.getRule(rule.getUuid()); - assertThat(rule.getState(), equalTo(RuleState.ENABLED)); - } - - @Test - public void testGetRule() { - deleteRuleByName(TEST_RULE_NAME); - CreateRuleRequest request = new CreateRuleRequest(); - request.setName(TEST_RULE_NAME); - final String desc = "test rule is create from sdk, for testing"; - request.setDescription(desc); - final String endpoint = "sdk_test_endpoint"; - request.setEndpoint(endpoint); - final String topic = "topic/sensor01"; - request.setFrom(topic); - final String select = "temperature, name"; - request.setSelect(select); - final String where = "temperature > 90 AND name like '%sensor%'"; - request.setWhere(where); - List destinations = new ArrayList(); - Destination dest = new Destination(); - dest.setKind(DestinationKind.MQTT); - final String topicDest = "topic/sensor01_high_temp"; - dest.setValue(topicDest); - destinations.add(dest); - request.setDestinations(destinations); - Rule rule = client.createRule(request); - - Rule ruleOut = client.getRule(rule.getUuid()); - - assertThat(ruleOut.getState(), equalTo(RuleState.ENABLED)); - assertThat(ruleOut.getDescription(), equalTo(desc)); - assertThat(ruleOut.getName(), equalTo(TEST_RULE_NAME)); - assertThat(ruleOut.getSelect(), equalTo(select)); - assertThat(ruleOut.getFrom(), equalTo(topic)); - assertThat(ruleOut.getWhere(), equalTo(where)); - assertThat(ruleOut.getEndpoint(), equalTo(endpoint)); - - assertThat(ruleOut.getDestinations().size(), equalTo(1)); - assertThat(ruleOut.getDestinations().get(0).getKind(), equalTo(DestinationKind.MQTT)); - assertThat(ruleOut.getDestinations().get(0).getValue(), equalTo(topicDest)); - } - - @Test - public void testAddDestination() { - deleteRuleByName(TEST_RULE_NAME); - Rule rule = createRule(TEST_RULE_NAME); - - Destination request = new Destination(); - final String destination = "SOME_OTHER_TOPIC"; - request.setValue(destination); - request.setKind(DestinationKind.MQTT); - request.setRuleUuid(rule.getUuid()); - client.createDestination(request); - - Rule ruleOut = client.getRule(rule.getUuid()); - assertThat(ruleOut.getDestinations().size(), equalTo(2)); - boolean foundTheNewDestination = false; - for (Destination dest : ruleOut.getDestinations()) { - if (dest.getKind() == DestinationKind.MQTT - && dest.getValue().equals(destination)) { - foundTheNewDestination = true; - break; - } - } - - assertThat(foundTheNewDestination, equalTo(true)); - } - - @Test - public void testDeleteDestination() { - deleteRuleByName(TEST_RULE_NAME); - Rule rule = createRule(TEST_RULE_NAME); - - client.deleteDestination(rule.getDestinations().get(0).getUuid()); - - Rule ruleOut = client.getRule(rule.getUuid()); - assertThat(ruleOut.getDestinations().size(), equalTo(0)); - } - - - private void deleteRuleByName(String name) { - String ruleId = findRuleIdByName(name); - - if (ruleId != null) { - DeleteRulesRequest delRequest = new DeleteRulesRequest(); - List ruleIds = new ArrayList(); - ruleIds.add(ruleId); - delRequest.setRules(ruleIds); - client.deleteRule(delRequest); - } - } - - private void deleteRuleById(String ruleId) { - if (ruleId != null) { - DeleteRulesRequest delRequest = new DeleteRulesRequest(); - List ruleIds = new ArrayList(); - ruleIds.add(ruleId); - delRequest.setRules(ruleIds); - client.deleteRule(delRequest); - } - } - - private String findRuleIdByName(String name) { - int pageNo = 1; - String ruleId = null; - ListRuleResponse response = null; - do { - ListRuleRequest request = new ListRuleRequest(); - request.setPageNo(pageNo++); - response = client.listRules(request); - for (Rule rule : response.getResult()) { - if (rule.getName().equals(name)) { - ruleId = rule.getUuid(); - break; - } - } - } while (ruleId == null && response.getTotalCount() > response.getPageNo() * response.getPageSize()); - - return ruleId; - } - - private Rule createRule(String name) { - CreateRuleRequest request = new CreateRuleRequest(); - request.setName(name); - request.setDescription("test rule is create from sdk, for testing"); - request.setEndpoint("sdk_test_endpoint"); - request.setFrom("topic/sensor01"); - request.setSelect("temperature, name"); - request.setWhere("temperature > 90 AND name like '%sensor%'"); - List destinations = new ArrayList(); - Destination dest = new Destination(); - dest.setKind(DestinationKind.MQTT); - dest.setValue("topic/sensor01_high_temp"); - destinations.add(dest); - request.setDestinations(destinations); - Rule rule = client.createRule(request); - return rule; - } -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedDomainAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedDomainAbnorQaTest.java deleted file mode 100755 index b28fd498..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedDomainAbnorQaTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.DeleteVerifiedDomainRequest; - -@RunWith(Parameterized.class) -public class SesClientDeleteVerifiedDomainAbnorQaTest { - - private SesClient client; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inDomainName; - @Parameter(2) - public String expException; - @Parameter(3) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0,null, "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - { 1,"", "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - { 2," ", "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws InterruptedException, ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.deleteVerifiedDomain(inDomainName); - Thread.sleep(1000); - } - - @Test - public void testRequest() throws InterruptedException, - ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.deleteVerifiedDomain(new DeleteVerifiedDomainRequest() - .withDomainName(inDomainName)); - Thread.sleep(1000); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedDomainNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedDomainNorQaTest.java deleted file mode 100755 index 9f1fef96..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedDomainNorQaTest.java +++ /dev/null @@ -1,138 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.BceServiceException; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.DeleteVerifiedDomainRequest; -import com.baidubce.services.ses.model.GetVerifiedDomainResponse; - -@RunWith(Parameterized.class) -public class SesClientDeleteVerifiedDomainNorQaTest { - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inDomainName; - @Parameter(2) - public String inStatus; - @Parameter(3) - public int inStatusCode; - @Parameter(4) - public String inMailDomainCert; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, "tom0.com", "success:none", 0, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD==" }, - { 1, "tom1.com", "failed:none", 1, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD==" }, - { 2, "tom2.com", "temporaryfailure:none", 2, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD==" }, - { 3, "tom3.com", "pending:none", 3, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD==" }, - { 4, "tom4.com", "notstarted:none", 4, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD=="}, - { 5, "tom5.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD==" }, - { 6, "notExist.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD=="}, - }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - switch (tag) { - case 6: { - jedis.hdel(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName, inMailDomainCert); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inDomainName); - break; - } - default: { - jedis.hset(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName, inMailDomainCert); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inDomainName, inStatus); - } - } - Thread.sleep(100); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inDomainName); - this.jedis.quit(); - } - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void test() throws InterruptedException { - switch(tag){ - case 6:{ - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("input identity not verified"); - this.client.deleteVerifiedDomain(inDomainName); - Thread.sleep(1000); - } - default:{ - this.client.deleteVerifiedDomain(inDomainName); - Thread.sleep(1000); - - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("domain not verified"); - GetVerifiedDomainResponse gResponse = this.client - .getVerifiedDomain(inDomainName); - Thread.sleep(1000); - } - } - } - - @Test - public void testRequest() throws InterruptedException { - switch(tag){ - case 6:{ - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("input identity not verified"); - this.client.deleteVerifiedDomain(new DeleteVerifiedDomainRequest() - .withDomainName(inDomainName)); - Thread.sleep(1000); - } - default:{ - this.client.deleteVerifiedDomain(new DeleteVerifiedDomainRequest() - .withDomainName(inDomainName)); - Thread.sleep(1000); - - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("domain not verified"); - GetVerifiedDomainResponse gResponse = this.client - .getVerifiedDomain(inDomainName); - Thread.sleep(1000); - } - - } - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedEmailAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedEmailAbnorQaTest.java deleted file mode 100755 index d98eb5c6..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedEmailAbnorQaTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.DeleteVerifiedEmailRequest; - -@RunWith(Parameterized.class) -public class SesClientDeleteVerifiedEmailAbnorQaTest { - - private SesClient client; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inEmailAddr; - @Parameter(2) - public String expException; - @Parameter(3) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, null, "java.lang.IllegalArgumentException", - "object emailAddress should not be null or empty" }, - { 1, "", "java.lang.IllegalArgumentException", - "object emailAddress should not be null or empty" }, - { 2, " ", "java.lang.IllegalArgumentException", - "object emailAddress should not be null or empty" }, - { 3, "abc", "java.lang.IllegalArgumentException", "illegal email" }, }); - } - - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws InterruptedException, ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.deleteVerifiedEmail(inEmailAddr); - Thread.sleep(1000); - } - - @Test - public void testRequest() throws InterruptedException, - ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.deleteVerifiedEmail(new DeleteVerifiedEmailRequest() - .withEmailAddress(inEmailAddr)); - Thread.sleep(1000); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedEmailNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedEmailNorQaTest.java deleted file mode 100755 index abb4e793..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientDeleteVerifiedEmailNorQaTest.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.BceServiceException; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.DeleteVerifiedEmailRequest; -import com.baidubce.services.ses.model.GetVerifiedEmailResponse; - -@RunWith(Parameterized.class) -public class SesClientDeleteVerifiedEmailNorQaTest { - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inEmailAddr; - @Parameter(2) - public String inStatus; - @Parameter(3) - public int inStatusCode; - @Parameter(4) - public String inMailAddrCert; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, "wanglinqing01@baidu.com", "success:none", 0, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 1, "wanglinqing01@baidu.com", "failed:none", 1, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 2, "wanglinqing01@baidu.com", "temporaryfailure:none", 2, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 3, "wanglinqing01@baidu.com", "pending:none", 3, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 4, "wanglinqing01@baidu.com", "notstarted:none", 4, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 5, "wanglinqing01@baidu.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 6, "wanglinqingNotExist@baidu.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - - }); - } - - - @Before - public void setUp() throws InterruptedException { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - switch(tag){ - case 6:{ - jedis.hdel(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr); - break; - } - default:{ - jedis.hset(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr, inMailAddrCert); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr, inStatus); - } - } - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr); - this.jedis.quit(); - } - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void test() throws InterruptedException { - switch(tag){ - case 6:{ - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("input identity not verified"); - this.client.deleteVerifiedEmail(inEmailAddr); - Thread.sleep(1000); - } - default:{ - this.client.deleteVerifiedEmail(inEmailAddr); - Thread.sleep(1000); - - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("mail addr not verified"); - GetVerifiedEmailResponse gResponse = this.client - .getVerifiedEmail(inEmailAddr); - Thread.sleep(1000); - } - } - } - @Test - public void testRequest() throws InterruptedException { - switch(tag){ - case 6:{ - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("input identity not verified"); - this.client.deleteVerifiedEmail(new DeleteVerifiedEmailRequest().withEmailAddress(inEmailAddr)); - Thread.sleep(1000); - } - default:{ - this.client.deleteVerifiedEmail(new DeleteVerifiedEmailRequest().withEmailAddress(inEmailAddr)); - Thread.sleep(1000); - - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("mail addr not verified"); - GetVerifiedEmailResponse gResponse = this.client - .getVerifiedEmail(inEmailAddr); - Thread.sleep(1000); - } - } - } -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedDomainAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedDomainAbnorQaTest.java deleted file mode 100755 index 074ad37e..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedDomainAbnorQaTest.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.GetVerifiedDomainRequest; - -@RunWith(Parameterized.class) -public class SesClientGetVerifiedDomainAbnorQaTest { - - private SesClient client; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inDomainName; - @Parameter(2) - public String expException; - @Parameter(3) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - { 0,null, "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - { 1,"", "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - { 2," ", "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws ClassNotFoundException, InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.getVerifiedDomain(inDomainName); - Thread.sleep(1000); - } - - @Test - public void testRequest() throws ClassNotFoundException, InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.getVerifiedDomain(new GetVerifiedDomainRequest().withDomainName(inDomainName)); - Thread.sleep(1000); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedDomainNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedDomainNorQaTest.java deleted file mode 100755 index 4feaffe2..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedDomainNorQaTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.GetVerifiedDomainRequest; -import com.baidubce.services.ses.model.GetVerifiedDomainResponse; - -@RunWith(Parameterized.class) -public class SesClientGetVerifiedDomainNorQaTest { - - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inDomainName; - @Parameter(2) - public String inStatus; - @Parameter(3) - public int inStatusCode; - @Parameter(4) - public String inMailDomainCert; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, "tom0.com", "success:none", 0, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 1, "tom1.com", "failed:none", 1, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 2, "tom2.com", "temporaryfailure:none", 2, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 3, "tom3.com", "pending:none", 3, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 4, "tom4.com", "notstarted:none", 4, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 5, "tom5.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 6, "notExist.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - } - ); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - jedis.hset(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName, inMailDomainCert); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inDomainName, inStatus); - Thread.sleep(1000); - } - - @After - public void tearDown() throws InterruptedException { - this.client.shutdown(); - jedis.hdel(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inDomainName); - this.jedis.quit(); - Thread.sleep(1000); - } - - @Test - public void test() throws InterruptedException { - GetVerifiedDomainResponse gResponse = this.client - .getVerifiedDomain(inDomainName); - Thread.sleep(1000); - Assert.assertEquals(inStatusCode, gResponse.getDetail().getDomainAttr() - .getStatus().intValue()); - } - - @Test - public void testRequest() throws InterruptedException { - GetVerifiedDomainResponse gResponse = this.client - .getVerifiedDomain(new GetVerifiedDomainRequest() - .withDomainName(inDomainName)); - Thread.sleep(1000); - Assert.assertEquals(inStatusCode, gResponse.getDetail().getDomainAttr() - .getStatus().intValue()); - } -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedEmailAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedEmailAbnorQaTest.java deleted file mode 100755 index f0c182ab..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedEmailAbnorQaTest.java +++ /dev/null @@ -1,88 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.GetVerifiedEmailRequest; -import com.baidubce.services.ses.model.GetVerifiedEmailResponse; - -@RunWith(Parameterized.class) -public class SesClientGetVerifiedEmailAbnorQaTest { - private SesClient client; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inEmailAddr; - @Parameter(2) - public String expException; - @Parameter(3) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, null, "java.lang.IllegalArgumentException", - "object emailAddress should not be null or empty" }, - { 1, "", "java.lang.IllegalArgumentException", - "object emailAddress should not be null or empty" }, - { 2, " ", "java.lang.IllegalArgumentException", - "object emailAddress should not be null or empty" }, - { 3, "abc", "java.lang.IllegalArgumentException", "illegal email" }, }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws ClassNotFoundException, InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - GetVerifiedEmailResponse gResponse = this.client - .getVerifiedEmail(inEmailAddr); - Thread.sleep(1000); - } - - @Test - public void testRequest() throws ClassNotFoundException, - InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.getVerifiedEmail(new GetVerifiedEmailRequest() - .withEmailAddress(inEmailAddr)); - Thread.sleep(1000); - - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedEmailNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedEmailNorQaTest.java deleted file mode 100755 index b8187dbb..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientGetVerifiedEmailNorQaTest.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.Rule; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.GetVerifiedEmailRequest; -import com.baidubce.services.ses.model.GetVerifiedEmailResponse; - -@RunWith(Parameterized.class) -public class SesClientGetVerifiedEmailNorQaTest { - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inEmailAddr; - @Parameter(2) - public String inStatus; - @Parameter(3) - public int inStatusCode; - @Parameter(4) - public String inMailAddrCert; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, "wanglinqing01@baidu.com", "success:none", 0, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 1, "wanglinqing01@baidu.com", "failed:none", 1, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 2, "wanglinqing01@baidu.com", "temporaryfailure:none", 2, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 3, "wanglinqing01@baidu.com", "pending:none", 3, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 4, "wanglinqing01@baidu.com", "notstarted:none", 4, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 5, "wanglinqing01@baidu.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 6, "wanglinqingNotExist@baidu.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - jedis.hset(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr, inMailAddrCert); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr, inStatus); - - Thread.sleep(1000); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr); - this.jedis.quit(); - } - - @Test - public void test() throws InterruptedException { - GetVerifiedEmailResponse gResponse = this.client - .getVerifiedEmail(inEmailAddr); - Thread.sleep(1000); - Assert.assertEquals(inStatusCode, gResponse.getDetail().getStatus().intValue()); - } - - @Test - public void testRequest() throws InterruptedException { - GetVerifiedEmailResponse gResponse = this.client - .getVerifiedEmail(new GetVerifiedEmailRequest() - .withEmailAddress(inEmailAddr)); - Thread.sleep(1000); - Assert.assertEquals(inStatusCode, gResponse.getDetail().getStatus().intValue()); -} - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientListRecipientBlacklistNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientListRecipientBlacklistNorQaTest.java deleted file mode 100755 index b3ca737e..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientListRecipientBlacklistNorQaTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.baidubce.services.ses; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SesRequest; -import com.baidubce.services.ses.model.ListRecipientBlacklistResponse; - -public class SesClientListRecipientBlacklistNorQaTest { - private SesClient client; - private Jedis jedis; - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() { - ListRecipientBlacklistResponse lResponse = this.client - .listRecipientBlacklist(); - Assert.assertEquals(jedis.hlen(SesConf.RECP_BLACKLIST_KEY).intValue(),lResponse.getRecpt().size()); - } - - @Test - public void testRequest() { - ListRecipientBlacklistResponse lResponse = this.client - .listRecipientBlacklist(new SesRequest()); - Assert.assertEquals(jedis.hlen(SesConf.RECP_BLACKLIST_KEY).intValue(),lResponse.getRecpt().size()); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientListVerifiedDomainNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientListVerifiedDomainNorQaTest.java deleted file mode 100755 index bf10aff2..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientListVerifiedDomainNorQaTest.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SesRequest; -import com.baidubce.services.ses.model.DomainDetailModel; -import com.baidubce.services.ses.model.ListVerifiedDomainResponse; - -@RunWith(Parameterized.class) -public class SesClientListVerifiedDomainNorQaTest { - - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inDomainName; - @Parameter(2) - public String inStatus; - @Parameter(3) - public int inStatusCode; - @Parameter(4) - public String inMailDomainCert; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, "tom.com", "success:none", 0, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 1, "tom.com", "failed:none", 1, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 2, "tom.com", "temporaryfailure:none", 2, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 3, "tom.com", "pending:none", 3, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 4, "tom.com", "notstarted:none", 4, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 5, "tom.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - jedis.hset(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName, inMailDomainCert); - jedis.hset(SesConf.MAIL_CERT_INFO_KEY, inDomainName, inMailDomainCert); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inDomainName, inStatus); - Thread.sleep(1000); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName); - jedis.hdel(SesConf.DKIM_CERT_INFO_KEY, inDomainName); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inDomainName); - this.jedis.quit(); - } - - @Test - public void test() throws InterruptedException { - ListVerifiedDomainResponse lResponse = this.client.listVerifiedDomain(); - Thread.sleep(1000); - - executeAssert(lResponse); - } - - @Test - public void testRequest() throws InterruptedException { - ListVerifiedDomainResponse lResponse = this.client - .listVerifiedDomain(new SesRequest()); - Thread.sleep(1000); - - executeAssert(lResponse); - } - - private void executeAssert(ListVerifiedDomainResponse lResponse) { - int validDomainCount = 0; - Iterator rIterator = jedis.hgetAll(SesConf.MAIL_CERT_STATUS_KEY) - .keySet().iterator(); - while (rIterator.hasNext()) { - if (!rIterator.next().contains("@")) { - validDomainCount++; - } - - } - Assert.assertEquals(validDomainCount, lResponse.getDetails().size()); - - Iterator eIterator = lResponse.getDetails() - .iterator(); - while (eIterator.hasNext()) { - DomainDetailModel domainDetail = eIterator.next(); - if (domainDetail.getDomain().equals(inDomainName)) { - Assert.assertEquals(inStatusCode, domainDetail.getDomainAttr() - .getStatus().intValue()); - } - } - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientListVerifiedEmailNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientListVerifiedEmailNorQaTest.java deleted file mode 100755 index 1a9aa9fb..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientListVerifiedEmailNorQaTest.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SesRequest; -import com.baidubce.services.ses.model.EmailDetailModel; -import com.baidubce.services.ses.model.ListVerifiedEmailResponse; - -@RunWith(Parameterized.class) -public class SesClientListVerifiedEmailNorQaTest { - - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inEmailAddr; - @Parameter(2) - public String inStatus; - @Parameter(3) - public int inStatusCode; - @Parameter(4) - public String inMailAddrCert; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, "wanglinqing01@baidu.com", "none:none", 5, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 1, "wanglinqing01@baidu.com", "pending:none", 3, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 2, "wanglinqing01@baidu.com", "success:none", 0, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 3, "wanglinqing01@baidu.com", "failed:none", 1, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 4, "wanglinqing01@baidu.com", "temporaryfailure:none", 2, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 5, "wanglinqing01@baidu.com", "notstarted:none", 4, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - - }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - jedis.hset(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr, inMailAddrCert); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr, inStatus); - Thread.sleep(1000); - } - - @After - public void tearDown() throws InterruptedException { - this.client.shutdown(); - jedis.hdel(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr); - this.jedis.quit(); - Thread.sleep(1000); - } - - @Test - public void test() throws InterruptedException { - ListVerifiedEmailResponse lResponse = this.client.listVerifiedEmail(); - Thread.sleep(1000); - - executeAssert(lResponse); - } - - @Test - public void testRequest() throws InterruptedException { - ListVerifiedEmailResponse lResponse = this.client - .listVerifiedEmail(new SesRequest()); - Thread.sleep(1000); - executeAssert(lResponse); - } - - private void executeAssert(ListVerifiedEmailResponse lResponse){ - int validAddrCount = 0; - Iterator rIterator = jedis.hgetAll(SesConf.MAIL_CERT_STATUS_KEY) - .keySet().iterator(); - while (rIterator.hasNext()) { - if (rIterator.next().contains("@")) { - validAddrCount++; - } - - } - Assert.assertEquals(validAddrCount, lResponse.getDetails().size()); - - Iterator eIterator = lResponse.getDetails() - .iterator(); - while (eIterator.hasNext()) { - EmailDetailModel emailDetail = eIterator.next(); - if (emailDetail.getAddress().equals(inEmailAddr)) { - Assert.assertEquals(inStatusCode, emailDetail.getStatus() - .intValue()); - } - } - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientSendMailSimpleAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientSendMailSimpleAbnorQaTest.java deleted file mode 100755 index 1f150980..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientSendMailSimpleAbnorQaTest.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.baidubce.services.ses; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SendEmailResponse; - -@RunWith(Parameterized.class) -public class SesClientSendMailSimpleAbnorQaTest { - private SesClient client; - private Jedis jedis; - private String domainName = null; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inFrom; - @Parameter(2) - public String[] inToAddr; - @Parameter(3) - public String inSubject; - @Parameter(4) - public String inBody; - @Parameter(5) - public String[] inAttachName; - @Parameter(6) - public String expException; - @Parameter(7) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - // from为null - { 0, null, new String[] { "wanglinqing01@baidu.com", }, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "from should not be null or empty" }, - // from为"" - { 1, "", new String[] { "wanglinqing01@baidu.com", }, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "from should not be null or empty" }, - // from为" " - { 2, " ", new String[] { "wanglinqing01@baidu.com", }, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "from should not be null or empty" }, - // from不符合格式"xxx@yyy" - { 3, "abc", new String[] { "wanglinqing01@baidu.com", }, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "illegal email" }, - // toAddr为null - { 4, "wanglinqing01@baidu.com", null, "testSubject", - "testBody", new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "toAddr should not be null or empty" }, - // toAddr全部为"" - { 5, "wanglinqing01@baidu.com", new String[] { "", }, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "illegal email" }, - // toAddr全部为" " - { 6, "wanglinqing01@baidu.com", new String[] { " ", }, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "illegal email" }, - // toAddr全部不符合格式"xxx@yyy" - { 7, "wanglinqing01@baidu.com", new String[] { "abc", }, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "illegal email" }, - // subject为null - { 8, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, null, - "testBody", new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "subject should not be null or empty" }, - // subject为"" - { 9, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, "", - "testBody", new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "subject should not be null or empty" }, - // subject为" " - { 10, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, " ", - "testBody", new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "subject should not be null or empty" }, - // body为null - { 11, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject", null, - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "body should not be null or empty" }, - // body为"" - { 12, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject", "", - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "body should not be null or empty" }, - // body为" " - { 13, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject", " ", - new String[] { "/attachment-test1.txt" }, - "java.lang.IllegalArgumentException", "body should not be null or empty" }, - - // from未经验证 - { 14, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - "com.baidubce.BceServiceException", - "sender address is not verified" }, - // from验证fail - { 15, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - "com.baidubce.BceServiceException", - "sender address is not verified" }, - - }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - - if (inFrom != null && !inFrom.trim().isEmpty()) { - if (inFrom.contains("@")) { - domainName = inFrom.split("@")[1]; - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, domainName); - } - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - - switch (tag) { - case 14: { - break; - } - case 15: { - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inFrom, "fail:none"); - break; - } - default: - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inFrom, "success:none"); - } - } - } - - @After - public void tearDown() { - this.client.shutdown(); - if (inFrom != null && !inFrom.isEmpty()) { - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - } - jedis.quit(); - } - - @Test - public void test() throws URISyntaxException, ClassNotFoundException, - InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - File[] attachFile = new File[inAttachName.length]; - int i = 0; - for (String attachName : inAttachName) { - attachFile[i] = new File(SesClientSendMailSimpleNorQaTest.class - .getResource(attachName).toURI()); - i++; - } - - SendEmailResponse sResponse = this.client.sendEmail(inFrom, inToAddr, - inSubject, inBody, attachFile); - Thread.sleep(1000); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientSendMailSimpleNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientSendMailSimpleNorQaTest.java deleted file mode 100755 index b6f3802e..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientSendMailSimpleNorQaTest.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.baidubce.services.ses; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SendEmailResponse; - -@RunWith(Parameterized.class) -public class SesClientSendMailSimpleNorQaTest { - private SesClient client; - private Jedis jedis; - private String domainName = null; - private String verifyTarget = null; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inFrom; - @Parameter(2) - public String[] inToAddr; - @Parameter(3) - public String inSubject; - @Parameter(4) - public String inBody; - @Parameter(5) - public String[] inAttachName; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - // toAddr含1个 - { - 0, - "wanglinqing01@baidu.com", - new String[] { "wanglinqing-01@baidu.com", }, - "testSubject-1个toAddr-中文主题", "testBody中文内容", - new String[] { "/attachment-test1.txt" } }, - // toAddr含2个 - { - 1, - "wanglinqing01@baidu.com", - new String[] { "wanglinqing2010@126.com", - "zinier@tom.com" }, - "testSubject-2个toAddr", "testBody", - new String[] { "/attachment-test1.txt" } }, - // attachment含2个 - { - 2, - "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject-2个attachment", - "testBody", - new String[] { "/attachment-test1.txt", - "/attachment-test2.md" } }, - // attachment含0个 - { - 3, - "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject-0个attachment", "testBody", - new String[] {} }, - // domainVerified - { - 4, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject-domainVerified", "testBody", - new String[] { "/attachment-test1.txt" } }, - // domainVerifiedFail,emailVerifiedSuccess - { - 5, - "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject-domainVerifiedFail-emailVerifiedSuccess", - "testBody", - new String[] { "/attachment-test1.txt" } }, - //domainVerifiedSuccess,emailVerifiedFail - { - 6, - "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject-domainVerifiedSuccess-emailVerifiedFail", - "testBody", - new String[] { "/attachment-test1.txt" } }, - // attachmentFiles为null - { - 7, - "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-attachmentNull", "testBody中文内容", - null}, - }); - } - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - domainName = inFrom.split("@")[1]; - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, domainName); - - switch (tag) { - case 4: { - verifyTarget = domainName; - break; - } - case 5: { - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, domainName, "fail:none"); - verifyTarget = inFrom; - break; - } - case 6:{ - jedis.hset(SesConf.DOMAIN_CERT_INFO_KEY, domainName, "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD"); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, domainName, "success:none"); - verifyTarget = domainName; - break; - } - default: - verifyTarget = inFrom; - } - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, verifyTarget, "success:none"); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, domainName); - jedis.hdel(SesConf.DOMAIN_CERT_INFO_KEY, domainName); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, verifyTarget); - jedis.quit(); - } - - @Test - public void test() throws URISyntaxException, InterruptedException { - File[] attachFile = null; - switch(tag){ - case 7:break; - default:{ - attachFile = new File[inAttachName.length]; - int i = 0; - for (String attachName : inAttachName) { - attachFile[i] = new File(SesClientSendMailSimpleNorQaTest.class - .getResource(attachName).toURI()); - i++; - } - - } - } - - SendEmailResponse sResponse = this.client.sendEmail(inFrom, inToAddr, - inSubject, inBody, attachFile); - Thread.sleep(1000); - Assert.assertNotNull(sResponse.getMessageId()); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientSendMailSimpleWithNameNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientSendMailSimpleWithNameNorQaTest.java deleted file mode 100755 index 00b10092..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientSendMailSimpleWithNameNorQaTest.java +++ /dev/null @@ -1,153 +0,0 @@ -package com.baidubce.services.ses; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SendEmailResponse; - -@RunWith(Parameterized.class) -public class SesClientSendMailSimpleWithNameNorQaTest { - private SesClient client; - private Jedis jedis; - private String domainName = null; - private String verifyTarget = null; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inFrom; - @Parameter(2) - public String inName; - @Parameter(3) - public String[] inToAddr; - @Parameter(4) - public String inSubject; - @Parameter(5) - public String inBody; - @Parameter(6) - public String[] inAttachName; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - // toAddr含1个 - { - 0, - "wanglinqing01@baidu.com", - "王林庆01", - new String[] { "675686650@qq.com", }, - "testSubject-1个toAddr-中文主题-自定义名称", "testBody中文内容", - new String[] { "/attachment-test1.txt" } }, - // toAddr含2个 - { - 1, - "wanglinqing01@baidu.com", - "测试人员abc", - new String[] { "wanglinqing01@baidu.com", - "wanglinqing2010@126.com" }, - "testSubject-2个toAddr-自定义名称", "testBody", - new String[] { "/attachment-test1.txt" } }, - // attachment含2个 - { - 2, - "wanglinqing01@baidu.com", - "自定义名称!@#¥%……&*()——+", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject-2个attachment-自定义名称", - "testBody", - new String[] { "/attachment-test1.txt", - "/attachment-test2.md" } }, - // attachment含0个 - { - 3, - "wanglinqing01@baidu.com", - "自定义名称sdfghjdfghjksdgfhjsdfghjsdfadghghjjklklkyytyyuiuoiuoioioioiooioioioigfgfhjkjllk,,m,mxxzxzsdsdsds", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject-0个attachment-自定义名称", "testBody", - new String[] {} }, - // domainVerified - { - 4, "wanglinqing01@baidu.com", - "域名被验证", - new String[] { "wanglinqing01@baidu.com" }, - "testSubject-domainVerified-自定义名称", "testBody", - new String[] { "/attachment-test1.txt" } }, - }); - } - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - domainName = inFrom.split("@")[1]; - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, domainName); - - switch (tag) { - case 4: { - verifyTarget = domainName; - break; - } - default: - verifyTarget = inFrom; - } - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, verifyTarget, "success:none"); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, domainName); - jedis.hdel(SesConf.DOMAIN_CERT_INFO_KEY, domainName); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, verifyTarget); - jedis.quit(); - } - - @Test - public void test() throws URISyntaxException, InterruptedException { - File[] attachFile = null; - switch(tag){ - case 7:break; - default:{ - attachFile = new File[inAttachName.length]; - int i = 0; - for (String attachName : inAttachName) { - attachFile[i] = new File(SesClientSendMailSimpleWithNameNorQaTest.class - .getResource(attachName).toURI()); - i++; - } - - } - } - - SendEmailResponse sResponse = this.client.sendEmail(inFrom, inName, - inToAddr, inSubject, inBody, attachFile); - Thread.sleep(1000); - Assert.assertNotNull(sResponse.getMessageId()); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientSendMailWithCcAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientSendMailWithCcAbnorQaTest.java deleted file mode 100755 index 0fdcff07..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientSendMailWithCcAbnorQaTest.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.baidubce.services.ses; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SendEmailResponse; - -@RunWith(Parameterized.class) -public class SesClientSendMailWithCcAbnorQaTest { - private SesClient client; - private Jedis jedis; - private String domainName = null; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inFrom; - @Parameter(2) - public String[] inToAddr; - @Parameter(3) - public String inSubject; - @Parameter(4) - public String inBody; - @Parameter(5) - public String[] inAttachName; - @Parameter(6) - public String[] inCcAddr; - @Parameter(7) - public String[] inBccAddr; - @Parameter(8) - public String expException; - @Parameter(9) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - // 0个toAddr-0个ccAddr-0个bccAddr - { 0, "wanglinqing01@baidu.com", new String[] {}, - "testSubject", "testBody", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, - "java.lang.IllegalArgumentException", "toAddr should not be null or empty" }, - // toAddrNull-ccAddrNull-bccAddrNull - { 1, "wanglinqing01@baidu.com", null, "testSubject", - "testBody", - new String[] { "/attachment-test1.txt" }, null, - null, "java.lang.IllegalArgumentException", - "toAddr should not be null or empty" }, }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - domainName = inFrom.split("@")[1]; - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, domainName); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inFrom, "success:none"); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.quit(); - } - - @Test - public void test() throws URISyntaxException, InterruptedException, - ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - File[] attachFile = new File[inAttachName.length]; - int i = 0; - for (String attachName : inAttachName) { - attachFile[i] = new File(SesClientSendMailSimpleNorQaTest.class - .getResource(attachName).toURI()); - i++; - } - - SendEmailResponse sResponse = - this.client.sendEmail(inFrom, null, inToAddr, inCcAddr, inBccAddr, inSubject, inBody, attachFile); - Thread.sleep(1000); - Assert.assertNotNull(sResponse.getMessageId()); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientSendMailWithCcNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientSendMailWithCcNorQaTest.java deleted file mode 100755 index 726028d1..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientSendMailWithCcNorQaTest.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.baidubce.services.ses; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SendEmailResponse; - -@RunWith(Parameterized.class) -public class SesClientSendMailWithCcNorQaTest { - private SesClient client; - private Jedis jedis; - private String domainName = null; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inFrom; - @Parameter(2) - public String[] inToAddr; - @Parameter(3) - public String inSubject; - @Parameter(4) - public String inBody; - @Parameter(5) - public String[] inAttachName; - @Parameter(6) - public String[] inCcAddr; - @Parameter(7) - public String[] inBccAddr; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - // 1个toAddr-1个ccAddr-1个bccAddr - { 0, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-1个toAddr-1个ccAddr-1个bccAddr", "testBody", - new String[] { "/attachment-test1.txt" }, - new String[] { "zinier@tom.com" }, - new String[] { "wanglinqing_1984@126.com" } }, - // 2个toAddr-0个ccAddr-0个bccAddr - { - 1, - "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", - "zinier@tom.com" }, - "testSubject-2个toAddr-0个ccAddr-0个bccAddr", "testBody", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {} }, - // 1个toAddr-2个ccAddr-0个bccAddr - { - 2, - "wanglinqing01@baidu.com", - new String[] {"wanglinqing01@baidu.com"}, - "testSubject-1个toAddr-2个ccAddr-0个bccAddr", - "testBody", - new String[] { "/attachment-test1.txt" }, - new String[] { "zini-er@tom.com","wanglinqing_1984@126.com" }, new String[] {} }, - // 1个toAddr-0个ccAddr-2个bccAddr - { - 3, - "wanglinqing01@baidu.com", - new String[] {"wanglinqing01@baidu.com"}, - "testSubject-1个toAddr-0个ccAddr-2个bccAddr", - "testBody", - new String[] { "/attachment-test1.txt" }, - new String[] {}, - new String[] { "zinier@tom.com","wanglinqing-01@126.com" } }, }); - } - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - domainName = inFrom.split("@")[1]; - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, domainName); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inFrom, "success:none"); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.quit(); - } - - @Test - public void test() throws URISyntaxException, InterruptedException { - File[] attachFile = new File[inAttachName.length]; - int i = 0; - for (String attachName : inAttachName) { - attachFile[i] = new File(SesClientSendMailSimpleNorQaTest.class - .getResource(attachName).toURI()); - i++; - } - - SendEmailResponse sResponse = - this.client.sendEmail(inFrom, null, inToAddr, inCcAddr, inBccAddr, inSubject, inBody, attachFile); - Thread.sleep(1000); - Assert.assertNotNull(sResponse.getMessageId()); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientSendMailWithPriorityAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientSendMailWithPriorityAbnorQaTest.java deleted file mode 100755 index ec407572..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientSendMailWithPriorityAbnorQaTest.java +++ /dev/null @@ -1,202 +0,0 @@ -package com.baidubce.services.ses; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SendEmailRequest; -import com.baidubce.services.ses.model.SendEmailResponse; -import com.baidubce.services.ses.model.SendEmailRequest.Mail; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Destination; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Message; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Source; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Subject; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Destination.Addr; - -@RunWith(Parameterized.class) -public class SesClientSendMailWithPriorityAbnorQaTest { - private SesClient client; - private Jedis jedis; - private String domainName = null; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inFrom; - @Parameter(2) - public String[] inToAddr; - @Parameter(3) - public String inSubject; - @Parameter(4) - public String inBody; - @Parameter(5) - public String[] inAttachName; - @Parameter(6) - public String[] inCcAddr; - @Parameter(7) - public String[] inBccAddr; - @Parameter(8) - public int inPriority; - @Parameter(9) - public int inCharset; - @Parameter(10) - public String inReturnPath; - @Parameter(11) - public String inReplyTo; - @Parameter(12) - public String expException; - @Parameter(13) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - // Priority=-1 - { 0, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-Priority0-charset0-中文标题", - "testBody-中文内容", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, -1, 0, null, - null, "java.lang.IllegalArgumentException", - "illegal priority" }, - // Priority=100 - { 1, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-Priority0-charset0-中文标题", - "testBody-中文内容", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, 100, 0, null, - null, "java.lang.IllegalArgumentException", - "illegal priority" }, - // charset=-1 - { 2, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-Priority0-charset0-中文标题", - "testBody-中文内容", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, 0, -1, null, - null, "java.lang.IllegalArgumentException", - "illegal charset" }, - // charset=5 - { 3, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-Priority0-charset0-中文标题", - "testBody-中文内容", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, 0, 5, null, - null, "java.lang.IllegalArgumentException", - "illegal charset" }, }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - domainName = inFrom.split("@")[1]; - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, domainName); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inFrom, "success:none"); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.quit(); - } - - @Test - public void test() throws URISyntaxException, InterruptedException, ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - File[] attachFile = new File[inAttachName.length]; - int i = 0; - for (String attachName : inAttachName) { - attachFile[i] = new File(SesClientSendMailSimpleNorQaTest.class - .getResource(attachName).toURI()); - i++; - } - SendEmailResponse sResponse = - this.client.sendEmail(inFrom, null, inReturnPath, inReplyTo, inToAddr, inCcAddr, inBccAddr, inSubject, - inBody, inPriority, inCharset, attachFile); - Assert.assertNotNull(sResponse.getMessageId()); - Thread.sleep(1000); - } - - @Test - public void testRequest() throws URISyntaxException, InterruptedException, ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - Source source = new Source(); - source.setFrom(inFrom); - source.setReturnPath(inReturnPath); - source.setReplyTo(inReplyTo); - - Destination dest = new Destination(); - dest.setToAddr(Addr.asAddrList(inToAddr)); - dest.setCcAddr(Addr.asAddrList(inCcAddr)); - dest.setBccAddr(Addr.asAddrList(inBccAddr)); - - Subject subject = new Subject(); - subject.setData(inSubject); - subject.setCharset(new Integer(inCharset)); - - Message message = new Message(); - Subject bodySubject = new Subject(); - bodySubject.setData(inBody); - bodySubject.setCharset(new Integer(inCharset)); - message.setHtml(bodySubject); - - Mail mail = new Mail(); - mail.setSource(source); - mail.setDestination(dest); - mail.setSubject(subject); - mail.setMessage(message); - mail.setPriority(new Integer(inPriority)); - - SendEmailRequest sRequest = new SendEmailRequest(); - sRequest.setMail(mail); - - File[] attachFile = new File[inAttachName.length]; - int i = 0; - for (String attachName : inAttachName) { - attachFile[i] = new File(SesClientSendMailSimpleNorQaTest.class - .getResource(attachName).toURI()); - i++; - } - - SendEmailResponse sResponse = this.client.sendEmail(sRequest); - Thread.sleep(1000); - Assert.assertNotNull(sResponse.getMessageId()); - } -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientSendMailWithPriorityNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientSendMailWithPriorityNorQaTest.java deleted file mode 100755 index 4d964b6b..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientSendMailWithPriorityNorQaTest.java +++ /dev/null @@ -1,199 +0,0 @@ -package com.baidubce.services.ses; - -import java.io.File; -import java.net.URISyntaxException; -import java.nio.charset.Charset; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.apache.commons.codec.binary.Base64; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SendEmailRequest; -import com.baidubce.services.ses.model.SendEmailResponse; -import com.baidubce.services.ses.model.SendEmailRequest.Mail; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Attachment; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Destination; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Message; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Source; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Subject; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Destination.Addr; - -@RunWith(Parameterized.class) -public class SesClientSendMailWithPriorityNorQaTest { - private SesClient client; - private Jedis jedis; - private String domainName = null; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inFrom; - @Parameter(2) - public String[] inToAddr; - @Parameter(3) - public String inSubject; - @Parameter(4) - public String inBody; - @Parameter(5) - public String[] inAttachName; - @Parameter(6) - public String[] inCcAddr; - @Parameter(7) - public String[] inBccAddr; - @Parameter(8) - public int inPriority; - @Parameter(9) - public int inCharset; - @Parameter(10) - public String inReturnPath; - @Parameter(11) - public String inReplyTo; - @Parameter(12) - public String[][] inAttachData; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - // Priority=0,charset=0 - { 0, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-Priority0-charset0-中文标题", - "testBody-中文内容", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, 0, 0, null, - null,new String[][]{{"attach1.file","附件内容1"},{"attach2.file","附件内容2"}} }, - // Priority=99,charset=1 - { 1, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-Priority99-charset1-中文标题", - "testBody-中文内容", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, 99, 1, null, - null ,new String[][]{{"attach1.file","附件内容1"},{"attach2.file","附件内容2"}} }, - // Priority=0,charset=2 - { 2, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-Priority0-charset2-中文标题", - "testBody-中文内容", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, 0, 2, null, - null ,new String[][]{{"attach1.file","附件内容1"},{"attach2.file","附件内容2"}} }, - // Priority=0,charset=3 - { 3, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-Priority0-charset3-中文标题", - "testBody-中文内容", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, 0, 3, null, - null ,new String[][]{{"attach1.file","附件内容1"},{"attach2.file","附件内容2"}} }, - // Priority=0,charset=4 - { 4, "wanglinqing01@baidu.com", - new String[] { "wanglinqing01@baidu.com", }, - "testSubject-Priority0-charset4-中文标题", - "testBody-中文内容", - new String[] { "/attachment-test1.txt" }, - new String[] {}, new String[] {}, 0, 4, null, - null ,new String[][]{{"attach1.file","附件内容1"},{"attach2.file","附件内容2"}} }, - }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - domainName = inFrom.split("@")[1]; - Thread.sleep(1000); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, domainName); - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inFrom, "success:none"); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inFrom); - jedis.quit(); - } - - @Test - public void test() throws URISyntaxException, InterruptedException { - File[] attachFile = new File[inAttachName.length]; - int i = 0; - for (String attachName : inAttachName) { - attachFile[i] = new File(SesClientSendMailSimpleNorQaTest.class - .getResource(attachName).toURI()); - i++; - } - SendEmailResponse sResponse = - this.client.sendEmail(inFrom, null, inReturnPath, inReplyTo, inToAddr, inCcAddr, inBccAddr, inSubject, - inBody, inPriority, inCharset, attachFile); - Assert.assertNotNull(sResponse.getMessageId()); - Thread.sleep(1000); - } - - @Test - public void testRequest() throws URISyntaxException, InterruptedException { - Source source = new Source(); - source.setFrom(inFrom); - source.setReturnPath(inReturnPath); - source.setReplyTo(inReplyTo); - - Destination dest = new Destination(); - dest.setToAddr(Addr.asAddrList(inToAddr)); - dest.setCcAddr(Addr.asAddrList(inCcAddr)); - dest.setBccAddr(Addr.asAddrList(inBccAddr)); - - Subject subject = new Subject(); - subject.setData(inSubject); - subject.setCharset(new Integer(inCharset)); - - Message message = new Message(); - Subject bodySubject = new Subject(); - bodySubject.setData(inBody); - bodySubject.setCharset(new Integer(inCharset)); - message.setHtml(bodySubject); - - - Mail mail = new Mail(); - mail.setSource(source); - mail.setDestination(dest); - mail.setSubject(subject); - mail.setMessage(message); - mail.setPriority(new Integer(inPriority)); - - List attachList=new ArrayList(); - for(String[] attach:inAttachData){ - attachList.add(new Attachment(attach[0],Base64.encodeBase64String(attach[1].getBytes(Charset.forName("UTF-8"))))); - } - mail.setAttachments(attachList); - - SendEmailRequest sRequest = new SendEmailRequest(); - sRequest.setMail(mail); - - SendEmailResponse sResponse = this.client.sendEmail(sRequest); - Thread.sleep(1000); - Assert.assertNotNull(sResponse.getMessageId()); - } -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientSetGetFeedbackNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientSetGetFeedbackNorQaTest.java deleted file mode 100755 index 9e125264..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientSetGetFeedbackNorQaTest.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SesRequest; -import com.baidubce.services.ses.model.GetFeedbackResponse; -import com.baidubce.services.ses.model.SetFeedbackRequest; - -@RunWith(Parameterized.class) -public class SesClientSetGetFeedbackNorQaTest { - private SesClient client; - - @Parameter(0) - public int tag; - @Parameter(1) - public int inType; - @Parameter(2) - public boolean inEnabled; - @Parameter(3) - public String inEmailAddr; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, 1, false, "wanglinqing01@baidu.com" }, - { 1, 2, true, "wanglinqing01@baidu.com" }, - { 2, 3, true, "wanglinqing01@baidu.com" }, - // 不传入任何参数,则设置为默认值 - { 3, 1, false, "wanglinqing01@baidu.com" }, }); - } - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws InterruptedException { - - SetFeedbackRequest sRequest = new SetFeedbackRequest(); - switch (tag) { - case 3: - break; - default: { - sRequest.setType(inType); - sRequest.setEnabled(inEnabled); - sRequest.setEmail(inEmailAddr); - } - } - this.client.setFeedback(sRequest); - Thread.sleep(1000); - GetFeedbackResponse gResponse = this.client.getFeedback(); - Thread.sleep(1000); - - Assert.assertEquals(inType, gResponse.getType().intValue()); - Assert.assertEquals(inEnabled, gResponse.isEnabled()); - Assert.assertEquals(inEmailAddr, gResponse.getEmail()); - } - - @Test - public void testRequest() throws InterruptedException { - - SetFeedbackRequest sRequest = new SetFeedbackRequest(); - switch (tag) { - case 3: - break; - default: { - sRequest.setType(inType); - sRequest.setEnabled(inEnabled); - sRequest.setEmail(inEmailAddr); - } - } - this.client.setFeedback(sRequest); - Thread.sleep(1000); - GetFeedbackResponse gResponse = this.client.getFeedback(new SesRequest()); - Thread.sleep(1000); - - Assert.assertEquals(inType, gResponse.getType().intValue()); - Assert.assertEquals(inEnabled, gResponse.isEnabled()); - Assert.assertEquals(inEmailAddr, gResponse.getEmail()); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientSetGetQuotaNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientSetGetQuotaNorQaTest.java deleted file mode 100755 index 1e6c6098..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientSetGetQuotaNorQaTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.SesRequest; -import com.baidubce.services.ses.model.GetQuotaResponse; - -//@RunWith(Parameterized.class) -public class SesClientSetGetQuotaNorQaTest { - - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public int inMaxPerDay; - @Parameter(2) - public int inMaxPerSecond; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { -// { 0, 100, 10 }, - // 不传入任何参数,则设置为默认值 -// { 1, 100, 10 }, - }); - } - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - this.jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws InterruptedException { -// SetQuotaRequest sRequest = new SetQuotaRequest(); -// switch (tag) { -// case 1: -// break; -// default: { -// sRequest.setMaxPerDay(inMaxPerDay); -// sRequest.setMaxPerSecond(inMaxPerSecond); -// } -// } -// this.client.setQuota(sRequest); -// Thread.sleep(1000); - - GetQuotaResponse gResponse = this.client.getQuota(); - Thread.sleep(1000); - - Assert.assertEquals(jedis.get(SesConf.MAIL_QUOTA_KEY), gResponse.getMaxPerDay().toString()); - Assert.assertEquals(jedis.get(SesConf.MAIL_RATE_LIMIT_KEY), gResponse.getMaxPerSecond().toString()); - Assert.assertEquals(jedis.get(SesConf.MAIL_SEND_COUNT_KEY), gResponse - .getUsedToday().toString()); - } - - @Test - public void testRequest() throws InterruptedException { - - GetQuotaResponse gResponse = this.client.getQuota(new SesRequest()); - Thread.sleep(1000); - - Assert.assertEquals(jedis.get(SesConf.MAIL_QUOTA_KEY), gResponse.getMaxPerDay().toString()); - Assert.assertEquals(jedis.get(SesConf.MAIL_RATE_LIMIT_KEY), gResponse.getMaxPerSecond().toString()); - Assert.assertEquals(jedis.get(SesConf.MAIL_SEND_COUNT_KEY), gResponse - .getUsedToday().toString()); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientTest.java b/src/test/java/com/baidubce/services/ses/SesClientTest.java deleted file mode 100755 index 63fd9b24..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientTest.java +++ /dev/null @@ -1,303 +0,0 @@ -package com.baidubce.services.ses; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.hamcrest.CustomMatcher; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; - -import com.baidubce.BceServiceException; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.GetFailedReasonResponse; -import com.baidubce.services.ses.model.GetFeedbackResponse; -import com.baidubce.services.ses.model.GetQuotaResponse; -import com.baidubce.services.ses.model.GetVerifiedDomainResponse; -import com.baidubce.services.ses.model.GetVerifiedEmailResponse; -import com.baidubce.services.ses.model.IsInRecipientBlacklistResponse; -import com.baidubce.services.ses.model.ListRecipientBlacklistResponse; -import com.baidubce.services.ses.model.ListVerifiedDomainResponse; -import com.baidubce.services.ses.model.ListVerifiedEmailResponse; -import com.baidubce.services.ses.model.SendEmailRequest; -import com.baidubce.services.ses.model.SendEmailResponse; -import com.baidubce.services.ses.model.SetFeedbackRequest; -import com.baidubce.services.ses.model.SetQuotaRequest; -import com.baidubce.services.ses.model.VerifyDKIMResponse; -import com.baidubce.services.ses.model.VerifyDomainResponse; -import com.baidubce.services.ses.model.SendEmailRequest.Mail; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Destination; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Message; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Source; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Subject; -import com.baidubce.services.ses.model.SendEmailRequest.Mail.Destination.Addr; -import com.google.common.base.Objects; - -@RunWith(Enclosed.class) -public class SesClientTest { - - @Ignore - public static class Base { - protected static final String ENDPOINT = "http://nmg02-bce-test9.nmg02.baidu.com:8886"; - protected static final String ACCESSKEY_ID = "46bd9968a6194b4bbdf0341f2286ccce"; - protected static final String SECRET_KEY = "ec7f4e0174254f6f9020f9680fb1da9f"; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - protected SesClient client; - - @Before - public void setUp() { - this.client = new SesClient(new SesClientConfiguration().withCredentials( - new DefaultBceCredentials(ACCESSKEY_ID, SECRET_KEY)) - .withEndpoint(ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - protected void expectBceServiceException(final int statusCode, final String errorCode) { - this.thrown.expect(new CustomMatcher( - "BceServiceException [ statusCode=" + statusCode + ", errorCode=" - + errorCode + "]") { - @Override - public boolean matches(Object item) { - return (item instanceof BceServiceException) - && ((BceServiceException) item).getStatusCode() == statusCode - && Objects.equal(((BceServiceException) item).getErrorCode(), - errorCode); - } - }); - } - } - -// public static class VerifiedEmailTest extends Base { -// @Test -// public void testVerifyEmail() { -// this.client.verifyEmail("h.h_07@163.com"); -// } -// -// @Test -// public void testListVerifiedEmail() { -// testVerifyEmail(); -// -// ListVerifiedEmailResponse response = this.client.listVerifiedEmail(); -// -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// Assert.assertTrue(response.getDetails().size() >= 1); -// } -// -// @Test -// public void testGetEmailAddress() { -// testVerifyEmail(); -// -// GetVerifiedEmailResponse response = this.client.getVerifiedEmail("h.h_07@163.com"); -// -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// Assert.assertTrue(response.getDetail().getAddress().equals("h.h_07@163.com")); -// } -// -// @Test -// public void testDeleteEmailAddress() { -// testVerifyEmail(); -// -// this.client.deleteVerifiedEmail("h.h_07@163.com"); -// } -// -// } -// -// public static class VerifiedDomainTest extends Base { -// @Test -// public void testVerifyDomain() { -// VerifyDomainResponse response = this.client.verifyDomain("163.com"); -// Assert.assertTrue(response != null && response.getToken() != null -// && !response.getToken().isEmpty()); -// } -// -// @Test -// public void testListVerifiedDomain() { -// testVerifyDomain(); -// -// ListVerifiedDomainResponse response = this.client.listVerifiedDomain(); -// -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// Assert.assertTrue(response.getDetails().size() >= 1); -// } -// -// @Test -// public void testGetVerifiedDomain() { -// testVerifyDomain(); -// -// GetVerifiedDomainResponse response = this.client.getVerifiedDomain("163.com"); -// -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// Assert.assertTrue(response.getDetail().getDomain().equals("163.com")); -// } -// -// @Test -// public void testDeletedDomain() { -// testVerifyDomain(); -// -// this.client.deleteVerifiedDomain("163.com"); -// } -// -// @Test -// public void testVerifyDKIM() { -// VerifyDKIMResponse response = this.client.verifyDKIM("163.com"); -// -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// Assert.assertTrue(response.getToken().getKeys().size() >= 1); -// } -// -// @Test -// public void testEnableDKIM() { -// this.client.enableDKIM("163.com"); -// } -// } -// -// public static class EmailSendTest extends Base { -// @Ignore -// public void testSimpleSendEmail() throws URISyntaxException { -// // build attachment files -// File attachment1 = new File(EmailSendTest.class.getResource( -// "/attachment-test1.txt").toURI()); -// File attachment2 = new File(EmailSendTest.class -// .getResource("/attachment-test2.md").toURI()); -// File[] attachments = new File[] { attachment1, attachment2 }; -// -// // send email -// SendEmailResponse response = this.client.sendEmail("zhangzheyuan@qq.com", -// new String[] { "harlen1017@163.com" }, "test", "TEST", attachments); -// -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// } -// -// @Ignore -// public void testSendEmail() { -// // build source object -// Source source = new Source("zhangzheyuan@qq.com", "zhangzheyuan@qq.com", -// "zhangzheyuan@qq.com"); -// -// // build destination object -// List toAddr = new ArrayList(); -// toAddr.add(new Addr().withAddr("h.h_07@163.com")); -// Destination destination = new Destination(toAddr, toAddr, toAddr); -// -// // build subject object -// Subject subject = new Subject(); -// subject.setData("test"); -// subject.setCharset(1); -// -// // build message object -// Message message = new Message(); -// message.setHtml(subject); -// -// // build mail object -// Mail mail = new Mail(source, destination, subject, 1, message); -// -// // build request object -// SendEmailRequest request = new SendEmailRequest(); -// request.setMail(mail); -// -// // send email -// SendEmailResponse response = this.client.sendEmail(request); -// -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// } -// } -// -// public static class FeedbackTest extends Base { -// @Test -// public void testSetFeedback() { -// SetFeedbackRequest request = new SetFeedbackRequest(); -// request.setType(2); -// request.setEmail("h.h_07@163.com"); -// request.setEnabled(true); -// -// this.client.setFeedback(request); -// } -// -// @Test -// public void testGetFeedback() { -// testSetFeedback(); -// -// GetFeedbackResponse response = this.client.getFeedback(); -// -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// Assert.assertTrue(response.getEmail().equals("h.h_07@163.com") -// && response.isEnabled() == true); -// } -// } -// -// public static class QuotaTest extends Base { -// @Test -// public void testSetQuota() { -// SetQuotaRequest request = new SetQuotaRequest(); -// request.setMaxPerDay("100000"); -// request.setMaxPerSecond("200"); -// -// this.client.setQuota(request); -// } -// -// @Test -// public void testGetQuota() { -// testSetQuota(); -// -// GetQuotaResponse response = this.client.getQuota(); -// -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// Assert.assertTrue(response.getMaxPerDay() == 100000 -// && response.getMaxPerSecond() == 200); -// } -// } -// -// public static class BlacklistTest extends Base { -// @Test -// public void testListRecipientBlacklist() { -// ListRecipientBlacklistResponse response = this.client.listRecipientBlacklist(); -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// } -// -// @Test -// public void testIsInRecipientBlacklist() { -// IsInRecipientBlacklistResponse response = this.client -// .isInRecipientBlacklist(String.format("%s.com", UUID.randomUUID() -// .toString())); -// Assert.assertTrue(!response.isExist()); -// } -// } -// -// -// public static class StatTest extends Base { -// @Test -// public void testGetFailedReason() { -// GetFailedReasonResponse response = this.client.getFailedReason(); -// Assert.assertTrue(response.getMetadata().getBceRequestId() != null -// && response.getMetadata().getBceRequestId().length() > 0); -// } -// } -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientVerifyDKIMAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientVerifyDKIMAbnorQaTest.java deleted file mode 100755 index 6ebd7c18..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientVerifyDKIMAbnorQaTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.VerifyDKIMRequest; - -@RunWith(Parameterized.class) -public class SesClientVerifyDKIMAbnorQaTest { - - private SesClient client; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inDomainName; - @Parameter(2) - public String expException; - @Parameter(3) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, null, "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - { 1, "", "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - { 2, " ", "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - - }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws ClassNotFoundException, InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.verifyDKIM(inDomainName); - Thread.sleep(1000); - } - - @Test - public void testRequest() throws ClassNotFoundException, InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.verifyDKIM(new VerifyDKIMRequest() - .withDomainName(inDomainName)); - Thread.sleep(1000); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientVerifyDKIMNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientVerifyDKIMNorQaTest.java deleted file mode 100755 index 87aba5c0..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientVerifyDKIMNorQaTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.VerifyDKIMRequest; -import com.baidubce.services.ses.model.VerifyDKIMResponse; - -@RunWith(Parameterized.class) -public class SesClientVerifyDKIMNorQaTest { - - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inDomainName; - @Parameter(2) - public String inStatus; - @Parameter(3) - public String expStatus; - @Parameter(4) - public String inMailDomainCert; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, "tom.com", null, "none:notstarted", "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 1, "tom.com", "none:none", "none:notstarted", "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 2, "tom.com", "none:pending", "none:notstarted", "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 3, "tom.com", "none:success", "none:notstarted", "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 4, "tom.com", "none:failed", "none:notstarted", "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 5, "tom.com", "none:temporaryfailure", "none:notstarted", "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - { 6, "tom.com", "none:notstarted", "none:notstarted", "ZDUyYzAyMGE2OGM1MmY5NGEyZGM4OD" }, - } - ); - } - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - jedis.hset(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName, inMailDomainCert); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inDomainName); - jedis.hdel(SesConf.DKIM_CERT_INFO_KEY, inDomainName); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inDomainName); - jedis.hdel(SesConf.DKIM_CERT_INFO_KEY, inDomainName); - jedis.quit(); - } - - @Test - public void test() throws InterruptedException { - switch (tag) { - case 0: { - break; - } - default: { - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inDomainName, inStatus); - } - } - - VerifyDKIMResponse vResponse = this.client.verifyDKIM(inDomainName); - Thread.sleep(1000); - - Assert.assertTrue(vResponse.getToken().getKeys().size() > 0); - - Assert.assertTrue(jedis.hexists(SesConf.MAIL_CERT_STATUS_KEY, - inDomainName)); - Assert.assertTrue(jedis - .hexists(SesConf.DKIM_CERT_INFO_KEY, inDomainName)); - Assert.assertEquals(expStatus, - jedis.hget(SesConf.MAIL_CERT_STATUS_KEY, inDomainName)); - } - - @Test - public void testRequest() throws InterruptedException { - switch (tag) { - case 0: { - break; - } - default: { - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inDomainName, inStatus); - } - } - - VerifyDKIMResponse vResponse = this.client - .verifyDKIM(new VerifyDKIMRequest() - .withDomainName(inDomainName)); - Thread.sleep(1000); - - Assert.assertTrue(vResponse.getToken().getKeys().size() > 0); - - Assert.assertTrue(jedis.hexists(SesConf.MAIL_CERT_STATUS_KEY, - inDomainName)); - Assert.assertTrue(jedis - .hexists(SesConf.DKIM_CERT_INFO_KEY, inDomainName)); - Assert.assertEquals(expStatus, - jedis.hget(SesConf.MAIL_CERT_STATUS_KEY, inDomainName)); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientVerifyDomainAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientVerifyDomainAbnorQaTest.java deleted file mode 100755 index 9410395b..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientVerifyDomainAbnorQaTest.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.VerifyDomainRequest; - -@RunWith(Parameterized.class) -public class SesClientVerifyDomainAbnorQaTest { - - private SesClient client; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inDomainName; - @Parameter(2) - public String expException; - @Parameter(3) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, null, "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - { 1, "", "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, - { 2, " ", "java.lang.IllegalArgumentException", - "object domainName should not be null or empty" }, }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws ClassNotFoundException, InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.verifyDomain(inDomainName); - Thread.sleep(1000); - - } - - @Test - public void testRequest() throws ClassNotFoundException, - InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.verifyDomain(new VerifyDomainRequest() - .withDomainName(inDomainName)); - Thread.sleep(1000); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientVerifyDomainNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientVerifyDomainNorQaTest.java deleted file mode 100755 index 4578fb8a..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientVerifyDomainNorQaTest.java +++ /dev/null @@ -1,124 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.VerifyDomainRequest; -import com.baidubce.services.ses.model.VerifyDomainResponse; - -@RunWith(Parameterized.class) -public class SesClientVerifyDomainNorQaTest { - - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inDomainName; - @Parameter(2) - public String inStatus; - @Parameter(3) - public String expStatus; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { 0, "tom.com", null, "notstarted:none" }, - { 1, "tom.com", "none:none", "notstarted:none" }, - { 2, "tom.com", "pending:none", "notstarted:none" }, - { 3, "tom.com", "success:none", "notstarted:none" }, - { 4, "tom.com", "failed:none", "notstarted:none" }, - { 5, "tom.com", "temporaryfailure:none", "notstarted:none" }, - { 6, "tom.com", "notstarted:none", "notstarted:none" }, }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); -// jedis.hdel(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inDomainName); - Thread.sleep(1000); - } - - @After - public void tearDown() { - this.client.shutdown(); - jedis.hdel(SesConf.DOMAIN_CERT_INFO_KEY, inDomainName); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inDomainName); - jedis.quit(); - } - - @Test - public void test() throws InterruptedException { - switch (tag) { - case 0: { - break; - } - default: { - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inDomainName, inStatus); - } - } - - VerifyDomainResponse vResponse = this.client.verifyDomain(inDomainName); - Thread.sleep(1000); - - Assert.assertTrue(vResponse.getToken().length()>0); - - Assert.assertTrue(jedis.hexists(SesConf.DOMAIN_CERT_INFO_KEY, - inDomainName)); - Assert.assertTrue(jedis.hexists(SesConf.MAIL_CERT_STATUS_KEY, - inDomainName)); - Assert.assertEquals( - jedis.hget(SesConf.MAIL_CERT_STATUS_KEY, inDomainName), - expStatus); - } - - @Test - public void testRequest() throws InterruptedException { - switch (tag) { - case 0: { - break; - } - default: { - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inDomainName, inStatus); - } - } - VerifyDomainResponse vResponse = this.client - .verifyDomain(new VerifyDomainRequest() - .withDomainName(inDomainName)); - Thread.sleep(1000); - - Assert.assertTrue(vResponse.getToken().length()>0); - - Assert.assertTrue(jedis.hexists(SesConf.DOMAIN_CERT_INFO_KEY, - inDomainName)); - Assert.assertTrue(jedis.hexists(SesConf.MAIL_CERT_STATUS_KEY, - inDomainName)); - Assert.assertEquals( - jedis.hget(SesConf.MAIL_CERT_STATUS_KEY, inDomainName), - expStatus); - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientVerifyEmailAbnorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientVerifyEmailAbnorQaTest.java deleted file mode 100755 index d6a8f1cb..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientVerifyEmailAbnorQaTest.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.VerifyEmailRequest; - -@RunWith(Parameterized.class) -public class SesClientVerifyEmailAbnorQaTest { - private SesClient client; - - @Parameter(0) - public String inEmailAddr; - @Parameter(1) - public String expException; - @Parameter(2) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - { null, "java.lang.IllegalArgumentException", - "object emailAddress should not be null or empty" }, - { "", "java.lang.IllegalArgumentException", - "object emailAddress should not be null or empty" }, - { " ", "java.lang.IllegalArgumentException", - "object emailAddress should not be null or empty" }, - { "abc", "com.baidubce.BceServiceException", - "user id or mail addr empty or format error (Status Code: 500; Error Code: 3" }, - }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws ClassNotFoundException, InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.verifyEmail(inEmailAddr); - Thread.sleep(1000); - } - - @Test - public void testRequest() throws ClassNotFoundException, - InterruptedException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - this.client.verifyEmail(new VerifyEmailRequest() - .withEmailAddress(inEmailAddr)); - Thread.sleep(1000); - - } - -} diff --git a/src/test/java/com/baidubce/services/ses/SesClientVerifyEmailNorQaTest.java b/src/test/java/com/baidubce/services/ses/SesClientVerifyEmailNorQaTest.java deleted file mode 100755 index a52af62f..00000000 --- a/src/test/java/com/baidubce/services/ses/SesClientVerifyEmailNorQaTest.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.baidubce.services.ses; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import redis.clients.jedis.Jedis; - -import com.baidubce.BceServiceException; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SesConf; -import com.baidubce.services.ses.SesClient; -import com.baidubce.services.ses.SesClientConfiguration; -import com.baidubce.services.ses.model.VerifyEmailRequest; - -@RunWith(Parameterized.class) -public class SesClientVerifyEmailNorQaTest { - private SesClient client; - private Jedis jedis; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inEmailAddr; - @Parameter(2) - public String inStatus; - @Parameter(3) - public String expStatus; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - { 0, "wanglinqing01@baidu.com", null, "pending:none" }, - { 1, "wanglinqing01@baidu.com", "none:none", - "pending:none" }, - { 2, "wanglinqing01@baidu.com", "pending:none", - "pending:none" }, - { 3, "wanglinqing01@baidu.com", "success:none", - "pending:none" }, - { 4, "wanglinqing01@baidu.com", "failed:none", - "pending:none" }, - { 5, "wanglinqing01@baidu.com", - "temporaryfailure:none", "pending:none" }, - { 6, "wanglinqing01@baidu.com", "notstarted:none", - "pending:none" }, - { 7, "wanglinqingNotExist@baidu.com", null, - "pending:none" }, - - }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SesClient( - new SesClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SesConf.SES_AK, - SesConf.SES_SK)).withEndpoint( - SesConf.SES_ENDPOINT)); - jedis = new Jedis(SesConf.SES_REDIS_HOST, SesConf.SES_REDIS_PORT); - // jedis.hdel(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr); - Thread.sleep(1000); - } - - @After - public void tearDown() throws InterruptedException { - this.client.shutdown(); - // jedis.hdel(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr); - jedis.hdel(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr); - jedis.quit(); - Thread.sleep(1000); - } - - @Rule - public ExpectedException expectedException = ExpectedException.none(); - - @Test - public void test() throws InterruptedException { - if (tag == 3){ - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr, inStatus); - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("mail addr [" + inEmailAddr + "] already verified, please not re-verify"); - this.client.verifyEmail(new VerifyEmailRequest() - .withEmailAddress(inEmailAddr)); - Thread.sleep(1000); - } - else{ - switch (tag) { - case 0:{ - break; - } - case 7:{ - break; - } - default: { - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr, inStatus); - } - } - - this.client.verifyEmail(inEmailAddr); - Thread.sleep(1000); - - Assert.assertTrue(jedis.hexists(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr)); - Assert.assertTrue(jedis.hexists(SesConf.MAIL_CERT_STATUS_KEY, - inEmailAddr)); - Assert.assertEquals(expStatus, - jedis.hget(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr)); - - } - } - - @Test - public void testRequest() throws InterruptedException { - if (tag == 3){ - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr, inStatus); - expectedException.expect(BceServiceException.class); - expectedException.expectMessage("mail addr [" + inEmailAddr + "] already verified, please not re-verify"); - this.client.verifyEmail(new VerifyEmailRequest() - .withEmailAddress(inEmailAddr)); - Thread.sleep(1000); - } - else{ - switch (tag) { - case 0: { - break; - } - case 7:{ - break; - } - default: { - jedis.hset(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr, inStatus); - } - } - - this.client.verifyEmail(new VerifyEmailRequest() - .withEmailAddress(inEmailAddr)); - Thread.sleep(1000); - - Assert.assertTrue(jedis.hexists(SesConf.MAIL_CERT_INFO_KEY, inEmailAddr)); - Assert.assertTrue(jedis.hexists(SesConf.MAIL_CERT_STATUS_KEY, - inEmailAddr)); - Assert.assertEquals(expStatus, - jedis.hget(SesConf.MAIL_CERT_STATUS_KEY, inEmailAddr)); - } - } -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientCreateTemplateAbnorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientCreateTemplateAbnorQaTest.java deleted file mode 100755 index aa5207f9..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientCreateTemplateAbnorQaTest.java +++ /dev/null @@ -1,187 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.BceServiceException; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.SmsRequest; - -@RunWith(Parameterized.class) -public class SmsClientCreateTemplateAbnorQaTest { - private SmsClient client; - private List templateIdList = new ArrayList(); - - @Parameter(0) - public int tag; - @Parameter(1) - public String inName; - @Parameter(2) - public String inContent; - @Parameter(3) - public String expMessage; - @Parameter(4) - public String expException; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - { - 1, - null, - "y", - "string name of request object should not be null or empty", - "java.lang.IllegalArgumentException" - }, - { - 2, - "", - "y", - "string name of request object should not be null or empty", - "java.lang.IllegalArgumentException" - }, - { - 3, - " ", - "y", - "string name of request object should not be null or empty", - "java.lang.IllegalArgumentException" - }, - { - 4, - "x123456789x123456789x123456789x12", - "y", - "the length of smsTplName=x123456789x123456789x123456789x12 is longer than 32", - "com.baidubce.BceServiceException"}, - { - 5, - "x", - null, - "string content of request object should not be null or empty", - "java.lang.IllegalArgumentException"}, - { - 6, - "x", - "", - "string content of request object should not be null or empty", - "java.lang.IllegalArgumentException"}, - { - 7, - "x", - " ", - "string content of request object should not be null or empty", - "java.lang.IllegalArgumentException"}, - { - 8, - "x", - "x123456789x123456789x123456789x123456789x123456789x123456789x123456789x", - "the length of " - + "smsTplContent=x123456789x123456789x12345678" - + "9x123456789x123456789x123456789x123456789x is longer than 70", - "com.baidubce.BceServiceException"}, - { - 9, - "duplicateName", - "y1", - "template name exists", - "com.baidubce.BceServiceException" - }, - { - 10, - "duplicateNameCaseInsensitive", - "y1", - "template name exists", - "com.baidubce.BceServiceException" - }}); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration().withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, SmsConf.SMS_SK)) - .withEndpoint(SmsConf.SMS_ENDPOINT)); - ListTemplateResponse lResponse = this.client - .listTemplate(new SmsRequest()); - List templateList = lResponse - .getTemplateList(); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - Thread.sleep(1000); - } - - @After - public void tearDown() { - for (String templateId : templateIdList) { - DeleteTemplateRequest request = new DeleteTemplateRequest(); - request.setTemplateId(templateId); - System.out.println(templateId); - this.client.deleteTemplate(request); - } - this.client.shutdown(); - } - - @Test - public void test() throws BceServiceException, ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - String name = null; - - switch (tag) { - case 9: { - CreateTemplateResponse response = this.client - .createTemplate(new CreateTemplateRequest().withName("x") - .withContent("y")); - Assert.assertNotNull(response.getData().getTemplateId()); - templateIdList.add(response.getData().getTemplateId()); - name = "x"; - break; - - } - case 10: { - CreateTemplateResponse response = this.client - .createTemplate(new CreateTemplateRequest().withName("X") - .withContent("y")); - Assert.assertNotNull(response.getData().getTemplateId()); - templateIdList.add(response.getData().getTemplateId()); - name = "x"; - break; - } - default: - name = inName; - } - - CreateTemplateResponse response = this.client - .createTemplate(new CreateTemplateRequest().withName(name) - .withContent(inContent)); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientCreateTemplateNorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientCreateTemplateNorQaTest.java deleted file mode 100755 index ae3f7683..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientCreateTemplateNorQaTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.SmsRequest; - -@RunWith(Parameterized.class) -public class SmsClientCreateTemplateNorQaTest { - private SmsClient client; - private List templateIdList = new ArrayList(); - - @Parameter(0) - public String inName; - @Parameter(1) - public String inContent; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - {"x", "y"}, - {"x1", "y1"}, - { - "x123456789x123456789x123456789x1", - "x123456789x123456789x123456789x123456789x123456789x123456789x123456789" - }, - {"模板名", "模板内容"}, {"x", "y${yk1}y${yk2}"}, - {"x*", "y*"}}); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - ListTemplateResponse lResponse = this.client - .listTemplate(new SmsRequest()); - List templateList = lResponse - .getTemplateList(); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - Thread.sleep(1000); - } - - @After - public void tearDown() { - for (String templateId : templateIdList) { - DeleteTemplateRequest request = new DeleteTemplateRequest(); - request.setTemplateId(templateId); - this.client.deleteTemplate(request); - } - this.client.shutdown(); - } - - @Test - public void test() { - CreateTemplateResponse response = this.client - .createTemplate(new CreateTemplateRequest().withName(inName) - .withContent(inContent)); - Assert.assertNotNull(response.getData().getTemplateId()); - templateIdList.add(response.getData().getTemplateId()); - GetTemplateDetailResponse gResponse = this.client - .getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(response.getData().getTemplateId())); - Assert.assertEquals(inName, gResponse.getName()); - Assert.assertEquals(inContent, gResponse.getContent()); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientDeleteTemplateAbnorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientDeleteTemplateAbnorQaTest.java deleted file mode 100755 index 3476a0ef..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientDeleteTemplateAbnorQaTest.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.BceServiceException; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.SmsRequest; - -@RunWith(Parameterized.class) -public class SmsClientDeleteTemplateAbnorQaTest { - private SmsClient client; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inTemplateId; - @Parameter(2) - public String expMessage; - @Parameter(3) - public String expException; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - {1, null, "object templateId should not be null or empty.", "java.lang.IllegalArgumentException"}, - {2, "", "object templateId should not be null or empty.", "java.lang.IllegalArgumentException"}, - {3, " ", "object templateId should not be null or empty.", "java.lang.IllegalArgumentException"}, - {4, "smsTpl:notExistId944df8a9833153babc5930", "template does not exist", - "com.baidubce.BceServiceException"}, - {5, "deletedId", "template does not exist", "com.baidubce.BceServiceException"}}); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - ListTemplateResponse lResponse = this.client - .listTemplate(new SmsRequest()); - List templateList = lResponse - .getTemplateList(); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - Thread.sleep(1000); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws BceServiceException, ClassNotFoundException { - String templateId = null; - String tmpTemplateId = null; - - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - switch (tag) { - case 5: { - try { - // 创建模板 - CreateTemplateResponse cResponse = this.client - .createTemplate(new CreateTemplateRequest().withName( - "x") - .withContent("y")); - tmpTemplateId = cResponse.getData().getTemplateId(); - // 确认模板创建成功 - GetTemplateDetailResponse gResponse = this.client - .getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(tmpTemplateId)); - Assert.assertEquals(tmpTemplateId, gResponse.getTemplateId()); - // 删除模板 - DeleteTemplateRequest dRequest = new DeleteTemplateRequest(); - dRequest.setTemplateId(tmpTemplateId); - this.client.deleteTemplate(dRequest); - // 确认模板已删除(无法获取已删除模板的详情) - this.client.getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(tmpTemplateId)); - } catch (BceServiceException e) { - Assert.assertTrue("Case data prepare fail", e.getMessage() - .contains("no records in database")); - } - templateId = tmpTemplateId; - break; - } - default: - templateId = inTemplateId; - } - DeleteTemplateRequest dRequest2 = new DeleteTemplateRequest(); - dRequest2.setTemplateId(templateId); - this.client.deleteTemplate(dRequest2); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientDeleteTemplateNorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientDeleteTemplateNorQaTest.java deleted file mode 100755 index 6c1d2b9f..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientDeleteTemplateNorQaTest.java +++ /dev/null @@ -1,164 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.List; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import com.baidubce.BceServiceException; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.SmsRequest; -import com.baidubce.services.sms.model.UpdateTemplateRequest; -import com.baidubce.services.sms.model.UpdateTemplateResponse; - -public class SmsClientDeleteTemplateNorQaTest { - private SmsClient client; - private SmsInternalClient internalClient; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - this.internalClient = new SmsInternalClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - ListTemplateResponse lResponse = this.client - .listTemplate(new SmsRequest()); - Thread.sleep(1000); - List templateList = lResponse - .getTemplateList(); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - } - - @After - public void tearDown() { - this.client.shutdown(); - this.internalClient.shutdown(); - } - - @Test - public void testDeleteProcessingTemplate() throws BceServiceException { - thrown.expect(BceServiceException.class); - thrown.expectMessage("no records in database"); - String templateId = null; - - try { - // 创建模板 - CreateTemplateResponse cResponse = this.client - .createTemplate(new CreateTemplateRequest().withName("x") - .withContent("y")); - templateId = cResponse.getData().getTemplateId(); - // 确认模板创建成功 - GetTemplateDetailResponse gResponse = this.client - .getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(templateId)); - Assert.assertEquals(templateId, gResponse.getTemplateId()); - // 删除模板 - DeleteTemplateRequest dRequest = new DeleteTemplateRequest(); - dRequest.setTemplateId(templateId); - this.client.deleteTemplate(dRequest); - } catch (BceServiceException e) { - Assert.assertTrue("Case data prepare fail", false); - } - // 确认模板已删除(无法获取已删除模板的详情) - this.client.getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(templateId)); - } - - @Test - public void testDeleteValidTemplate() throws BceServiceException { - thrown.expect(BceServiceException.class); - thrown.expectMessage("no records in database"); - String templateId = null; - - try { - // 创建模板 - CreateTemplateResponse cResponse = this.client - .createTemplate(new CreateTemplateRequest().withName("x") - .withContent("y")); - templateId = cResponse.getData().getTemplateId(); - // 更新模板 - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("VALID"); - UpdateTemplateResponse uResponse = this.internalClient - .updateTemplate(uRequest); - - // 确认模板状态为VALID - GetTemplateDetailResponse gResponse = this.client - .getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(templateId)); - Assert.assertEquals("VALID", gResponse.getStatus()); - // 删除模板 - DeleteTemplateRequest dRequest = new DeleteTemplateRequest(); - dRequest.setTemplateId(templateId); - this.client.deleteTemplate(dRequest); - } catch (BceServiceException e) { - Assert.assertTrue("Case data prepare fail", false); - } - // 确认模板已删除(无法获取已删除模板的详情) - this.client.getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(templateId)); - } - - @Test - public void testDeleteInvalidTemplate() throws BceServiceException { - thrown.expect(BceServiceException.class); - thrown.expectMessage("no records in database"); - String templateId = null; - - try { - // 创建模板 - CreateTemplateResponse cResponse = this.client - .createTemplate(new CreateTemplateRequest().withName("x") - .withContent("y")); - templateId = cResponse.getData().getTemplateId(); - // 更新模板 - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("INVALID"); - UpdateTemplateResponse uResponse = this.internalClient - .updateTemplate(uRequest); - - // 确认模板状态为VALID - GetTemplateDetailResponse gResponse = this.client - .getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(templateId)); - Assert.assertEquals("INVALID", gResponse.getStatus()); - // 删除模板 - DeleteTemplateRequest dRequest = new DeleteTemplateRequest(); - dRequest.setTemplateId(templateId); - this.client.deleteTemplate(dRequest); - } catch (BceServiceException e) { - Assert.assertTrue("Case data prepare fail", false); - } - // 确认模板已删除(无法获取已删除模板的详情) - this.client.getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(templateId)); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientGetTemplateDetailAbnorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientGetTemplateDetailAbnorQaTest.java deleted file mode 100755 index 32474d13..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientGetTemplateDetailAbnorQaTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.UUID; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.BceServiceException; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.SmsRequest; - -@RunWith(Parameterized.class) -public class SmsClientGetTemplateDetailAbnorQaTest { - private SmsClient client; - - @Parameter(0) - public int tag; - @Parameter(1) - public String inTemplateId; - @Parameter(2) - public String expMessage; - @Parameter(3) - public String expException; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - {1, null, "object templateId should not be null or empty.", "java.lang.IllegalArgumentException"}, - {2, "", "object templateId should not be null or empty.", "java.lang.IllegalArgumentException"}, - {3, " ", "object templateId should not be null or empty.", "java.lang.IllegalArgumentException"}, - { - 4, - "smsTpl:notExistId944df8a9833153babc5930", - "no records in database", - "com.baidubce.BceServiceException" - }, - {5, "deletedId", "no records in database", "com.baidubce.BceServiceException"}}); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - ListTemplateResponse lResponse = this.client - .listTemplate(new SmsRequest()); - List templateList = lResponse - .getTemplateList(); - Thread.sleep(1000); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws ClassNotFoundException { - String templateId = null; - String tmpTemplateId = null; - - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - switch (tag) { - case 5: { - try { - // 创建模板 - CreateTemplateResponse cResponse = this.client - .createTemplate(new CreateTemplateRequest().withName( - UUID.randomUUID().toString().substring(0, 32)) - .withContent("test{KEY}")); - tmpTemplateId = cResponse.getData().getTemplateId(); - // 确认模板创建成功 - GetTemplateDetailResponse gResponse = this.client - .getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(tmpTemplateId)); - Assert.assertEquals(tmpTemplateId, gResponse.getTemplateId()); - // 删除模板 - DeleteTemplateRequest dRequest = new DeleteTemplateRequest(); - dRequest.setTemplateId(tmpTemplateId); - this.client.deleteTemplate(dRequest); - // 确认模板已删除(无法获取已删除模板的详情) - this.client.getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(tmpTemplateId)); - } catch (BceServiceException e) { - Assert.assertTrue("Case data prepare fail", e.getMessage() - .contains("no records in database")); - } - templateId = tmpTemplateId; - break; - } - default: - templateId = inTemplateId; - } - - this.client.getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(templateId)); - } -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientGetTemplateDetailNorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientGetTemplateDetailNorQaTest.java deleted file mode 100755 index 6b692585..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientGetTemplateDetailNorQaTest.java +++ /dev/null @@ -1,131 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.List; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.SmsRequest; -import com.baidubce.services.sms.model.UpdateTemplateRequest; - -@RunWith(Parameterized.class) -public class SmsClientGetTemplateDetailNorQaTest { - private SmsClient client; - private List templateIdList = new ArrayList(); - - @Parameter(0) - public int tag; - @Parameter(1) - public String description; - @Parameter(2) - public String inName; - @Parameter(3) - public String inContent; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][]{ - {1, "namecontent", "x", "y"}, - {2, "namecontent", "x123456789x123456789x123456789x1", "y"}, - {3, "namecontent", "x1", "x123456789x123456789x123456789x123456789x123456789"}, - {4, "namecontent", "x2", "y${yk1}y${yk2}"}, - {5, "namecontent", "x3", "y*"}, - {6, "VALID", "x4", "y"}, - {7, "INVALID", "x5", "y"}, - {8, "time", "x6", "y"} - }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - ListTemplateResponse lResponse = this.client - .listTemplate(new SmsRequest()); - List templateList = lResponse - .getTemplateList(); - Thread.sleep(1000); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - } - @After - public void tearDown() { - for (String templateId : templateIdList) { - DeleteTemplateRequest request = new DeleteTemplateRequest(); - request.setTemplateId(templateId); - this.client.deleteTemplate(request); - } - this.client.shutdown(); - } - @Test - public void test() throws InterruptedException { - String status = "PROCESSING"; - Date createTime = new Date(); - Date updateTime = createTime; - - CreateTemplateResponse cResponse = this.client - .createTemplate(new CreateTemplateRequest().withName(inName) - .withContent(inContent)); - Assert.assertNotNull(cResponse.getData().getTemplateId()); - String templateId = cResponse.getData().getTemplateId(); - templateIdList.add(templateId); - - switch (tag) { - case 6: - case 7: { - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus(description); - break; - } - case 8: { - Thread.sleep(3000); - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("PROCESSING"); - updateTime = new Date(); - break; - } - default: - } - - GetTemplateDetailResponse gResponse = this.client - .getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(templateId)); - - Assert.assertEquals(inName, gResponse.getName()); - Assert.assertEquals(inContent, gResponse.getContent()); - Assert.assertEquals(status, gResponse.getStatus()); - Assert.assertTrue((gResponse.getCreateTime().getTime() - createTime - .getTime()) / 1000 < 3); - Assert.assertTrue((gResponse.getUpdateTime().getTime() - updateTime - .getTime()) / 1000 < 3); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientListTemplateNorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientListTemplateNorQaTest.java deleted file mode 100755 index 5df637a9..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientListTemplateNorQaTest.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.SmsRequest; -import com.baidubce.services.sms.model.UpdateTemplateRequest; - -@RunWith(Parameterized.class) -public class SmsClientListTemplateNorQaTest { - private SmsClient client; - private SmsInternalClient internalClient; - private List templateIdList = new ArrayList(); - - @Parameter(0) - public int tag; - @Parameter(1) - public String description; - @Parameter(2) - public String inName; - @Parameter(3) - public String inContent; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - {1, "namecontent", "x", "y"}, - { - 2, - "namecontent", - "x123456789x123456789x123456789x1", - "x123456789x123456789x123456789x123456789x123456789x123456789x123456789" - }, - {3, "namecontent", "x", "y${yk1}y${yk2}"}, - {4, "namecontent", "x*", "y*"}, - {5, "VALID", "x", "y"}, {6, "INVALID", "x", "y"}, - {7, "time", "x", "y"}, {8, "deletedId", "x", "y"}}); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - this.internalClient = - new SmsInternalClient(new SmsClientConfiguration().withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - List templateList = this.client - .listTemplate(new SmsRequest()).getTemplateList(); - Thread.sleep(1000); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x") || template.getName().equals("x2")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - } - - @After - public void tearDown() { - for (String templateId : templateIdList) { - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("VALID"); - this.internalClient.updateTemplate(uRequest); - - DeleteTemplateRequest request = new DeleteTemplateRequest(); - request.setTemplateId(templateId); - this.client.deleteTemplate(request); - } - this.client.shutdown(); - this.internalClient.shutdown(); - } - - @Test - public void test() { - int beforeSize = 0; - int afterSize = 0; - int targetOffset = 0; - beforeSize = this.client.listTemplate(new SmsRequest()) - .getTemplateList().size(); - - CreateTemplateResponse cResponse = this.client - .createTemplate(new CreateTemplateRequest().withName("x") - .withContent("y")); - String templateId = cResponse.getData().getTemplateId(); - templateIdList.add(templateId); - - switch (tag) { - case 5: - case 6: { - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus(description); - break; - } - case 7: { - CreateTemplateResponse cResponse2 = this.client - .createTemplate(new CreateTemplateRequest().withName("x2") - .withContent("y2")); - String templateId2 = cResponse2.getData().getTemplateId(); - templateIdList.add(templateId2); - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("PROCESSING"); - targetOffset++; - break; - } - case 8: { - CreateTemplateResponse cResponse2 = this.client - .createTemplate(new CreateTemplateRequest().withName("x2") - .withContent("y2")); - String templateId2 = cResponse2.getData().getTemplateId(); - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(templateId2)); - break; - } - default: - } - - List templateList = this.client - .listTemplate(new SmsRequest()).getTemplateList(); - afterSize = afterSize + templateList.size(); - Assert.assertEquals(beforeSize, afterSize - 1 - targetOffset); - Assert.assertEquals("x", templateList.get(afterSize - 1 - targetOffset) - .getName()); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientQueryMessageDetailAbnorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientQueryMessageDetailAbnorQaTest.java deleted file mode 100755 index daafcce8..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientQueryMessageDetailAbnorQaTest.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.SmsClient; -import com.baidubce.services.sms.SmsClientConfiguration; -import com.baidubce.services.sms.model.QueryMessageDetailRequest; -import com.baidubce.services.sms.model.QueryMessageDetailResponse; - -@RunWith(Parameterized.class) -public class SmsClientQueryMessageDetailAbnorQaTest { - private SmsClient client; - - @Parameter(0) - public String inMessageId; - @Parameter(1) - public String expException; - @Parameter(2) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - { null, "java.lang.IllegalArgumentException", - "object messageId should not be null or empty" }, - { "", "java.lang.IllegalArgumentException", - "object messageId should not be null or empty" }, - { " ", "java.lang.IllegalArgumentException", - "object messageId should not be null or empty" }, - { "notExistIdxxxx", "com.baidubce.BceServiceException", - "no record found" }, }); - - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint( - SmsConf.SMS_ENDPOINT)); - Thread.sleep(1000); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - // 查询短信详情 - QueryMessageDetailResponse qResponse = this.client - .queryMessageDetail(new QueryMessageDetailRequest() - .withMessageId(inMessageId)); - } -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientQueryMessageDetailNorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientQueryMessageDetailNorQaTest.java deleted file mode 100755 index 7be0ac57..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientQueryMessageDetailNorQaTest.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.UUID; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.QueryMessageDetailRequest; -import com.baidubce.services.sms.model.QueryMessageDetailResponse; -import com.baidubce.services.sms.model.SendMessageRequest; -import com.baidubce.services.sms.model.SmsRequest; -import com.baidubce.services.sms.model.UpdateTemplateRequest; - -@RunWith(Parameterized.class) -public class SmsClientQueryMessageDetailNorQaTest { - private SmsClient client; - private SmsInternalClient internalClient; - private List templateIdList = new ArrayList(); - - @Parameter(0) - public List inReceiver; - @Parameter(1) - public String inContentVar; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { - // content含中文字符 - {Arrays.asList("18811086572"), "{\"var1\":\"张三\"}"}, - // 短信整体长达达到最大 - { - Arrays.asList("18811086572"), - "{\"var1\":\"" + UUID.randomUUID().toString() - + UUID.randomUUID().toString() - + UUID.randomUUID().toString() - + UUID.randomUUID().toString() - + UUID.randomUUID().toString() - + UUID.randomUUID().toString().substring(0, 20) - + "\"}" - }, - // 2个receiver - {Arrays.asList("18811086572", "13716953216"), "{\"var1\":\"张三两遍\"}"}}); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - this.internalClient = new SmsInternalClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - ListTemplateResponse lResponse = this.client - .listTemplate(new SmsRequest()); - List templateList = lResponse - .getTemplateList(); - Thread.sleep(1000); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - } - - @After - public void tearDown() { - for (String templateId : templateIdList) { - DeleteTemplateRequest request = new DeleteTemplateRequest(); - request.setTemplateId(templateId); - this.client.deleteTemplate(request); - } - this.client.shutdown(); - this.internalClient.shutdown(); - } - - @Test - public void test() { - // 创建模板 - CreateTemplateResponse cResponse = this.client - .createTemplate(new CreateTemplateRequest().withName("x") - .withContent("${var1},查询短信详情Nor")); - String templateId = cResponse.getData().getTemplateId(); - templateIdList.add(templateId); - - // 将模板更新为valid状态 - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("VALID"); - this.internalClient.updateTemplate(uRequest); - - // 发送短信 - Date expTime = new Date(); - SendMessageRequest sRequest = new SendMessageRequest(); - sRequest.setTemplateId(templateId); - sRequest.setReceiver(inReceiver); - sRequest.setContentVar(inContentVar); - String messageId = this.client.sendMessage(sRequest).getMessageId(); - // 查询短信详情 - QueryMessageDetailResponse qResponse = this.client - .queryMessageDetail(new QueryMessageDetailRequest() - .withMessageId(messageId)); - - // 验证信息 - Assert.assertEquals( - inContentVar.split(",")[0].split(":")[1].split("\\\"")[1] - + ",查询短信详情Nor", qResponse.getContent()); - Assert.assertEquals(inReceiver, qResponse.getReceiver()); - Assert.assertTrue((qResponse.getSendTime().getTime() - expTime - .getTime()) / 1000 < 3); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientQueryQuotaNorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientQueryQuotaNorQaTest.java deleted file mode 100755 index b79521db..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientQueryQuotaNorQaTest.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.SmsClient; -import com.baidubce.services.sms.SmsClientConfiguration; -import com.baidubce.services.sms.model.SmsRequest; -import com.baidubce.services.sms.model.QueryQuotaResponse; -import com.baidubce.services.sms.model.UpdateQuotaRequest; - -@RunWith(Parameterized.class) -public class SmsClientQueryQuotaNorQaTest { - - private SmsClient client; - private SmsInternalClient internalClient; - - @Parameter(0) - public int inMaxSend; - @Parameter(1) - public int inMaxReceive; - - @Parameters - public static Collection data() { - return Arrays.asList(new Object[][] { { 0, 0 }, { 1, 2 }, - {1111111111,222222222}, - - }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint( - SmsConf.SMS_ENDPOINT)); - this.internalClient = new SmsInternalClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint( - SmsConf.SMS_ENDPOINT)); - Thread.sleep(1000); - } - - @After - public void tearDown() { - this.client.shutdown(); - this.internalClient.shutdown(); - } - - @Test - public void test() { - int beforeMaxSend, beforeMaxReceive; - int afterMaxSend, afterMaxReceive; - UpdateQuotaRequest uRequest = new UpdateQuotaRequest(); - QueryQuotaResponse qResponse = null; - - //获取当前配额值,便于测试后恢复环境 - qResponse = this.client.queryQuota(new SmsRequest()); - beforeMaxSend = qResponse.getMaxSendPerDay(); - beforeMaxReceive = qResponse.getMaxReceivePerPhoneNumberDay(); - - //将配额更新为预期值 - uRequest.setMaxSendPerDay(inMaxSend); - uRequest.setMaxReceivePerPhoneNumberDay(inMaxReceive); - this.internalClient.updateQuota(uRequest); - //获取更新后的配额值 - qResponse = this.client.queryQuota(new SmsRequest()); - afterMaxSend = qResponse.getMaxSendPerDay(); - afterMaxReceive = qResponse.getMaxReceivePerPhoneNumberDay(); - - //将配额恢复为测试开始前的值 - uRequest.setMaxSendPerDay(beforeMaxSend); - uRequest.setMaxReceivePerPhoneNumberDay(beforeMaxReceive); - this.internalClient.updateQuota(uRequest); - - //比较预期值与更新后实际获取到的配额值 - Assert.assertEquals(inMaxSend, afterMaxSend); - Assert.assertEquals(inMaxReceive, afterMaxReceive); - } -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientSendMessageAbnorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientSendMessageAbnorQaTest.java deleted file mode 100755 index 83a8f94d..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientSendMessageAbnorQaTest.java +++ /dev/null @@ -1,278 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.UUID; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.SendMessageRequest; -import com.baidubce.services.sms.model.SendMessageResponse; -import com.baidubce.services.sms.model.SmsRequest; -import com.baidubce.services.sms.model.UpdateTemplateRequest; - -@RunWith(Parameterized.class) -public class SmsClientSendMessageAbnorQaTest { - private SmsClient client; - private SmsInternalClient internalClient; - private List templateIdList = new ArrayList(); - - // 0:无参数模板,1:1个参数的模板,2:2个参数的模板,3:不用创建模板 - // 10:审批中的模板,20:审批失败的模板,30:已删除的模板 - @Parameter(0) - public int tag; - @Parameter(1) - public String inTemplateId; - @Parameter(2) - public List inReceiver; - @Parameter(3) - public String inContentVar; - @Parameter(4) - public String expException; - @Parameter(5) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - // templateId参数非法 - // templateId为null - {3, null, Arrays.asList("18811086572"), "{}", - "java.lang.IllegalArgumentException", - "string templateId of request should not be null or empty"}, - // templateId为空串 - {3, "", Arrays.asList("18811086572"), "{}", - "java.lang.IllegalArgumentException", - "string templateId of request should not be null or empty"}, - // templateId仅包含空白符 - {3, " ", Arrays.asList("18811086572"), "{}", - "java.lang.IllegalArgumentException", - "string templateId of request should not be null or empty"}, - // templateId不存在 - {3, "smsTpl:notExistId944df8a9833153babc5930", - Arrays.asList("18811086572"), "{}", - "com.baidubce.BceServiceException", - "no records in database"}, - // templateId状态为processing - {10, "", Arrays.asList("18811086572"), "{}", - "com.baidubce.BceServiceException", - "template is not in valid state"}, - // templateId状态为invalid - {20, "", Arrays.asList("18811086572"), "{}", - "com.baidubce.BceServiceException", - "template is not in valid state"}, - // templateId已删除 - {30, "", Arrays.asList("18811086572"), "{}", - "com.baidubce.BceServiceException", - "no records in database"}, - - // receiver参数非法 - // receiver为null - {0, "", null, "{}", - "java.lang.IllegalArgumentException", - "list receiver of request should not be null or empty"}, - // receiver为空串 - {0, "", Arrays.asList(""), "{}", - "java.lang.IllegalArgumentException", - "receiver should not be null or empty"}, - // receiver仅包含空白串 - {0, "", Arrays.asList(" "), "{}", - "java.lang.IllegalArgumentException", - "receiver should not be null or empty"}, - // receiver包含非数字字符 - {0, "", Arrays.asList("1381193940a"), "{}", - "com.baidubce.BceServiceException", - "receiver=1381193940a is not a valid phone number"}, - // receiver位数不足11位 - {0, "", Arrays.asList("1"), "{}", - "com.baidubce.BceServiceException", - "receiver=1 is not a valid phone number"}, - // 部分receiver位数不足11位 - {0, "", Arrays.asList("18811086572", "1"), "{}", - "com.baidubce.BceServiceException", - "receiver=1 is not a valid phone number"}, - - // contentVar参数非法 - // contentVar为null - {0, "", Arrays.asList("18811086572"), null, - "java.lang.IllegalArgumentException", - "contentVar should not be null or empty"}, - // contentVar为空串 - {0, "", Arrays.asList("18811086572"), "", - "java.lang.IllegalArgumentException", - "contentVar should not be null or empty"}, - // contentVar仅包含空白符 - {0, "", Arrays.asList("18811086572"), " ", - "java.lang.IllegalArgumentException", - "contentVar should not be null or empty"}, - // contentVar不符合json格式 - {0, "", Arrays.asList("18811086572"), "{zzz}", - "com.baidubce.BceServiceException", - "contentVar={zzz} is not a valid json string"}, - // 模板含1个变量,contentVar无变量值 - {1, "", Arrays.asList("18811086572"), "{}", - "com.baidubce.BceServiceException", - "var map not match template"}, - // 模板含2个变量,contentVar仅提供1个变量值 - {2, "", Arrays.asList("18811086572"), - "{\"var1\":\"张三\"}", - "com.baidubce.BceServiceException", - "var map not match template"}, - // 模板含1个变量,contentVar提供的变量对未加引号 - {1, "", Arrays.asList("18811086572"), "{var1:张三}", - "com.baidubce.BceServiceException", - "contentVar={var1:张三} is not a valid json string"}, - // 模板含1个变量,contentVar长度超限 - { - 1, - "", - Arrays.asList("18811086572"), - "{\"var1\":\"" - + UUID.randomUUID().toString() - + UUID.randomUUID().toString() - + UUID.randomUUID().toString() - + UUID.randomUUID().toString() - + UUID.randomUUID().toString() - + UUID.randomUUID().toString() - .substring(0, 23) + "x\"}", - "com.baidubce.BceServiceException", - "message's content is too large, not allow to > 210 chars"}, - }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - this.internalClient = new SmsInternalClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - ListTemplateResponse lResponse = this.client - .listTemplate(new SmsRequest()); - List templateList = lResponse - .getTemplateList(); - Thread.sleep(1000); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - } - - @After - public void tearDown() { - for (String templateId : templateIdList) { - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("VALID"); - this.internalClient.updateTemplate(uRequest); - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(templateId)); - } - this.client.shutdown(); - this.internalClient.shutdown(); - } - - @Test - public void test() throws ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - String templateId = null; - CreateTemplateResponse cResponse = null; - - switch (tag) { - case 1: { - cResponse = this.client.createTemplate(new CreateTemplateRequest() - .withName("x").withContent("${var1},你妈喊你回家")); - templateId = cResponse.getData().getTemplateId(); - prepareTemplate(templateId); - break; - } - case 2: { - cResponse = this.client.createTemplate(new CreateTemplateRequest() - .withName("x").withContent("${var1},你妈喊你回家${var2}")); - templateId = cResponse.getData().getTemplateId(); - prepareTemplate(templateId); - break; - } - case 0: { - cResponse = this.client.createTemplate(new CreateTemplateRequest() - .withName("x").withContent("你妈喊你回家")); - templateId = cResponse.getData().getTemplateId(); - prepareTemplate(templateId); - break; - } - case 10: { - cResponse = this.client.createTemplate(new CreateTemplateRequest() - .withName("x").withContent("你妈喊你回家")); - templateId = cResponse.getData().getTemplateId(); - templateIdList.add(templateId); - break; - } - case 20: { - cResponse = this.client.createTemplate(new CreateTemplateRequest() - .withName("x").withContent("你妈喊你回家")); - templateId = cResponse.getData().getTemplateId(); - templateIdList.add(templateId); - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("INVALID"); - this.internalClient.updateTemplate(uRequest); - break; - } - case 30: { - cResponse = this.client.createTemplate(new CreateTemplateRequest() - .withName("x").withContent("你妈喊你回家")); - templateId = cResponse.getData().getTemplateId(); - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(templateId)); - break; - } - default: - templateId = inTemplateId; - } - - SendMessageRequest sRequest = new SendMessageRequest(); - sRequest.setTemplateId(templateId); - sRequest.setReceiver(inReceiver); - sRequest.setContentVar(inContentVar); - SendMessageResponse sResponse = this.client.sendMessage(sRequest); - } - - private void prepareTemplate(String templateId) { - templateIdList.add(templateId); - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("VALID"); - this.internalClient.updateTemplate(uRequest); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientSendMessageNorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientSendMessageNorQaTest.java deleted file mode 100755 index dd24ffe4..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientSendMessageNorQaTest.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.SendMessageRequest; -import com.baidubce.services.sms.model.SendMessageResponse; -import com.baidubce.services.sms.model.SmsRequest; -import com.baidubce.services.sms.model.UpdateTemplateRequest; - -@RunWith(Parameterized.class) -public class SmsClientSendMessageNorQaTest { - private SmsClient client; - private SmsInternalClient internalClient; - private List templateIdList = new ArrayList(); - - @Parameter(0) - public int tag; - @Parameter(1) - public int inSendCount; - @Parameter(2) - public List inReceiver; - @Parameter(3) - public String inContentVar; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - // 带1个参数的模板 - {1, 1, Arrays.asList("18811086572"), "{\"var1\":\"张三\"}"}, - // 带2个参数的模板 - {2, 1, Arrays.asList("18811086572"), "{\"var1\":\"张三\",\"var2\":\"吃饭\"}"}, - // 1个receiver - {0, 1, Arrays.asList("18811086572"), "{}"}, - // 2个receiver - {0, 2, Arrays.asList("18811086572", "13716953216"), "{}"}, - // contentVar中含空白符 - {0, 1, Arrays.asList("18811086572"), "{ }"}, - // 模板不含变量,contentVar提供多余变量值 - {0, 1, Arrays.asList("18811086572"), "{\"var1\":\"张三\"}"} - // contentVar最大长度 该case是长短信,实际按4条计费,暂时注释掉 - // { - // 1, - // 1, - // Arrays.asList("18811086572"), - // "{\"var1\":\"" + UUID.randomUUID().toString() - // + UUID.randomUUID().toString() - // + UUID.randomUUID().toString() - // + UUID.randomUUID().toString() - // + UUID.randomUUID().toString() - // + UUID.randomUUID().toString().substring(0,23) + - // "\"}" }, - - }); - - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - this.internalClient = new SmsInternalClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint(SmsConf.SMS_ENDPOINT)); - ListTemplateResponse lResponse = this.client - .listTemplate(new SmsRequest()); - Thread.sleep(1000); - List templateList = lResponse - .getTemplateList(); - for (GetTemplateDetailResponse template : templateList) { - if (template.getName().equals("x")) { - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(template.getTemplateId())); - } - } - } - - @After - public void tearDown() { - for (String templateId : templateIdList) { - DeleteTemplateRequest request = new DeleteTemplateRequest(); - request.setTemplateId(templateId); - this.client.deleteTemplate(request); - } - this.client.shutdown(); - this.internalClient.shutdown(); - } - - @Test - public void test() { - String templateId = null; - CreateTemplateResponse cResponse = null; - - switch (tag) { - case 1: { - cResponse = this.client.createTemplate(new CreateTemplateRequest() - .withName("x").withContent("${var1},你妈喊你回家")); - break; - } - case 2: { - cResponse = this.client.createTemplate(new CreateTemplateRequest() - .withName("x").withContent("${var1},你妈喊你回家${var2}")); - break; - } - default: { - cResponse = this.client.createTemplate(new CreateTemplateRequest() - .withName("x").withContent("你妈喊你回家")); - } - } - templateId = cResponse.getData().getTemplateId(); - templateIdList.add(templateId); - UpdateTemplateRequest uRequest = new UpdateTemplateRequest() - .withTemplateId(templateId); - uRequest.setStatus("VALID"); - this.internalClient.updateTemplate(uRequest); - SendMessageRequest sRequest = new SendMessageRequest(); - sRequest.setTemplateId(templateId); - sRequest.setReceiver(inReceiver); - sRequest.setContentVar(inContentVar); - SendMessageResponse sResponse = this.client.sendMessage(sRequest); - Assert.assertNotNull(sResponse.getMessageId()); - Assert.assertEquals(inSendCount, sResponse.getSendStat().getSendCount()); - Assert.assertEquals(inSendCount, sResponse.getSendStat() - .getSuccessCount()); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientStatReceiverAbnorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientStatReceiverAbnorQaTest.java deleted file mode 100755 index 2ccf3f57..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientStatReceiverAbnorQaTest.java +++ /dev/null @@ -1,83 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Before; -import org.junit.Rule; -import org.junit.Test; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.SmsClient; -import com.baidubce.services.sms.SmsClientConfiguration; -import com.baidubce.services.sms.model.StatReceiverRequest; - -@RunWith(Parameterized.class) -public class SmsClientStatReceiverAbnorQaTest { - private SmsClient client; - - @Parameter(0) - public String inPhoneNumber; - @Parameter(1) - public String expException; - @Parameter(2) - public String expMessage; - - @Parameters - public static Collection data() { - return Arrays - .asList(new Object[][] { - { null, "java.lang.IllegalArgumentException", - "object phoneNumber should not be null or empty" }, - { "", "java.lang.IllegalArgumentException", - "object phoneNumber should not be null or empty" }, - { " ", "java.lang.IllegalArgumentException", - "object phoneNumber should not be null or empty" }, - { "1", "com.baidubce.BceServiceException", - "parameter validator error: phoneNumber=1 is not a valid phone number" }, - { - "1381193940a", - "com.baidubce.BceServiceException", - "parameter validator error: phoneNumber=1381193940a is not a valid phone number" }, - { - "11111111111,13811939406", - "com.baidubce.BceServiceException", - "parameter validator error: phoneNumber=11111111111,13811939406 is not a valid phone number" }, }); - } - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint( - SmsConf.SMS_ENDPOINT)); - Thread.sleep(1000); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() throws ClassNotFoundException { - thrown.expect((Class) Class.forName(expException)); - thrown.expectMessage(expMessage); - - client.statReceiver(new StatReceiverRequest() - .withPhoneNumber(inPhoneNumber)); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientStatReceiverNorQaTest.java b/src/test/java/com/baidubce/services/sms/SmsClientStatReceiverNorQaTest.java deleted file mode 100755 index e534a3ce..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientStatReceiverNorQaTest.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.Arrays; -import java.util.Collection; - -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.conf.SmsConf; -import com.baidubce.services.sms.SmsClient; -import com.baidubce.services.sms.SmsClientConfiguration; -import com.baidubce.services.sms.model.StatReceiverRequest; -import com.baidubce.services.sms.model.StatReceiverResponse; - -@RunWith(Parameterized.class) -public class SmsClientStatReceiverNorQaTest { - private SmsClient client; - - @Parameter(0) - public String inPhoneNumber; - @Parameter(1) - public int expReceivedCount; - - @Parameters - public static Collection data(){ - return Arrays.asList(new Object[][]{ - {"13811112222",0}, -// {"14113705021",1}, - }); - } - - @Before - public void setUp() throws InterruptedException { - this.client = new SmsClient( - new SmsClientConfiguration() - .withCredentials( - new DefaultBceCredentials(SmsConf.SMS_AK, - SmsConf.SMS_SK)).withEndpoint( - SmsConf.SMS_ENDPOINT)); - Thread.sleep(1000); - } - - @After - public void tearDown() { - this.client.shutdown(); - } - - @Test - public void test() { - StatReceiverResponse sResponse=client.statReceiver(new StatReceiverRequest().withPhoneNumber(inPhoneNumber)); - Assert.assertEquals(expReceivedCount, sResponse.getReceivedToday().intValue()); - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsClientTest.java b/src/test/java/com/baidubce/services/sms/SmsClientTest.java deleted file mode 100755 index 43dcdaf8..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsClientTest.java +++ /dev/null @@ -1,230 +0,0 @@ -package com.baidubce.services.sms; - -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import org.hamcrest.CustomMatcher; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; - -import com.baidubce.BceServiceException; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.sms.model.CreateTemplateRequest; -import com.baidubce.services.sms.model.CreateTemplateResponse; -import com.baidubce.services.sms.model.DeleteTemplateRequest; -import com.baidubce.services.sms.model.GetTemplateDetailRequest; -import com.baidubce.services.sms.model.GetTemplateDetailResponse; -import com.baidubce.services.sms.model.ListTemplateResponse; -import com.baidubce.services.sms.model.QueryMessageDetailRequest; -import com.baidubce.services.sms.model.QueryMessageDetailResponse; -import com.baidubce.services.sms.model.QueryQuotaResponse; -import com.baidubce.services.sms.model.SendMessageRequest; -import com.baidubce.services.sms.model.SendMessageResponse; -import com.baidubce.services.sms.model.SmsRequest; -import com.baidubce.services.sms.model.StatReceiverRequest; -import com.baidubce.services.sms.model.StatReceiverResponse; -import com.baidubce.services.sms.model.TemplateStatus; -import com.baidubce.services.sms.model.UpdateQuotaRequest; -import com.baidubce.services.sms.model.UpdateTemplateRequest; -import com.google.common.base.Objects; - -@RunWith(Enclosed.class) -public class SmsClientTest { - - @Ignore - public static class Base { - protected static final String ENDPOINT = "http://nmg02-bce-test8.nmg02.baidu.com:8887"; - protected static final String ACCESSKEY_ID = "11f9634810b743ad9255266b064ddba1"; - protected static final String SERCERT_KEY = "d5b8dd75acca40f8bb6cd75269305a1c"; - - @Rule - public ExpectedException thrown = ExpectedException.none(); - - protected SmsClient client; - protected SmsInternalClient internalClient; - - @Before - public void setUp() { - this.client = new SmsClient(new SmsClientConfiguration().withCredentials( - new DefaultBceCredentials(ACCESSKEY_ID, SERCERT_KEY)).withEndpoint(ENDPOINT)); - this.internalClient = - new SmsInternalClient(new SmsClientConfiguration().withCredentials( - new DefaultBceCredentials(ACCESSKEY_ID, SERCERT_KEY)).withEndpoint(ENDPOINT)); - } - - @After - public void tearDown() { - this.client.shutdown(); - this.internalClient.shutdown(); - } - - protected void expectBceServiceException(final int statusCode, final String errorCode) { - this.thrown.expect(new CustomMatcher( - "BceServiceException [ statusCode=" + statusCode + ", errorCode=" - + errorCode + "]") { - @Override - public boolean matches(Object item) { - return (item instanceof BceServiceException) - && ((BceServiceException) item).getStatusCode() == statusCode - && Objects.equal(((BceServiceException) item).getErrorCode(), errorCode); - } - }); - } - } - - public static class MessageTest extends Base { - private static ThreadLocal localMessageId = new ThreadLocal(); - - @Test - public void testSendMessage() { - // create template - CreateTemplateResponse createResponse = this.client - .createTemplate(new CreateTemplateRequest().withName( - UUID.randomUUID().toString().substring(0, 32)).withContent("test${KEY}")); - // update - UpdateTemplateRequest updateRequest = new UpdateTemplateRequest() - .withTemplateId(createResponse.getData().getTemplateId()); - updateRequest.setName(UUID.randomUUID().toString().substring(0, 32)); - updateRequest.setContent("test${KEY}"); - updateRequest.setStatus(TemplateStatus.VALID.getValue()); - this.internalClient.updateTemplate(updateRequest); - // send message - System.out.println("--------->" + createResponse.getData().getTemplateId()); - SendMessageRequest request = new SendMessageRequest(); - request.setTemplateId(createResponse.getData().getTemplateId()); - request.setContentVar("{\"KEY\" : \"val1\"}"); - List receivers = new ArrayList(); - receivers.add("13589878678"); - request.setReceiver(receivers); - SendMessageResponse sendResponse = this.client.sendMessage(request); - localMessageId.set(sendResponse.getMessageId()); - Assert.assertTrue(sendResponse.getMessageId() != null - && sendResponse.getMessageId().length() > 0); - } - - @Test - public void testQueryMessageDetail() { - testSendMessage(); - - QueryMessageDetailResponse querResponse = this.client - .queryMessageDetail(new QueryMessageDetailRequest() - .withMessageId(localMessageId.get())); - - Assert.assertTrue(querResponse.getMessageId().equals(localMessageId.get())); - } - } - - public static class TemplateTest extends Base { - private static ThreadLocal localTemplateId = new ThreadLocal(); - - @Test - public void testCreateTemplate() { - CreateTemplateResponse response = this.client - .createTemplate(new CreateTemplateRequest().withName( - UUID.randomUUID().toString().substring(0, 32)).withContent("test${KEY}")); - - System.out.println(localTemplateId.get()); - localTemplateId.set(response.getData().getTemplateId()); - - Assert.assertTrue(response.getData() != null - && response.getData().getTemplateId().length() > 0); - } - - @Test - public void testUpdateTemplate() { - testCreateTemplate(); - - String randomTemplateName = UUID.randomUUID().toString().substring(0, 32); - - // update - UpdateTemplateRequest updateRequest = new UpdateTemplateRequest() - .withTemplateId(localTemplateId.get()); - updateRequest.setName(randomTemplateName); - updateRequest.setContent("test${KEY}"); - updateRequest.setStatus(TemplateStatus.VALID.getValue()); - this.internalClient.updateTemplate(updateRequest); - - // get - GetTemplateDetailResponse getResponse = this.client - .getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(localTemplateId.get())); - - Assert.assertTrue(getResponse.getName().equals(randomTemplateName)); - } - - @Ignore - public void testDeleteTemplate() { - expectBceServiceException(400, "ParamError"); - // first to create a template - testCreateTemplate(); - // second to delete it - this.client.deleteTemplate(new DeleteTemplateRequest() - .withTemplateId(localTemplateId.get())); - // last to get it then throw no records in database exception - this.client.getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(localTemplateId.get())); - } - - @Test - public void testGetTemplateDetail() { - // first to create a template - testCreateTemplate(); - // second to get detail of the template - GetTemplateDetailResponse response = this.client - .getTemplateDetail(new GetTemplateDetailRequest() - .withTemplateId(localTemplateId.get())); - - Assert.assertTrue(response.getTemplateId().equals(localTemplateId.get())); - } - - @Test - public void testListTemplate() { - // first to create a template - testCreateTemplate(); - // second to list - ListTemplateResponse response = this.client.listTemplate(new SmsRequest()); - - Assert.assertTrue(response.getTemplateList().size() > 0); - } - } - - public static class QuotaTest extends Base { - @Test - public void testUpdateQuota() { - // first to update - this.internalClient.updateQuota(new UpdateQuotaRequest(1000, 100)); - - // second to query - QueryQuotaResponse response = this.client.queryQuota(new SmsRequest()); - Assert.assertTrue(response.getMaxReceivePerPhoneNumberDay() == 100); - } - - @Test - public void testQueryQuota() { - // first to update - testUpdateQuota(); - - // second to query - QueryQuotaResponse response = this.client.queryQuota(new SmsRequest()); - Assert.assertTrue(response.getMaxSendPerDay() == 1000); - } - } - - public static class StatTest extends Base { - @Test - public void testStatReceiver() { - StatReceiverResponse response = this.client.statReceiver(new StatReceiverRequest() - .withPhoneNumber("13000000000")); - Assert.assertTrue(response.getMaxReceivePerPhoneNumberDay() == 100); - } - } - -} diff --git a/src/test/java/com/baidubce/services/sms/SmsInternalClient.java b/src/test/java/com/baidubce/services/sms/SmsInternalClient.java deleted file mode 100755 index c19d0ff8..00000000 --- a/src/test/java/com/baidubce/services/sms/SmsInternalClient.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.services.sms; - -import static com.google.common.base.Preconditions.checkNotNull; - -import com.baidubce.http.HttpMethodName; -import com.baidubce.internal.InternalRequest; -import com.baidubce.services.sms.model.SmsResponse; -import com.baidubce.services.sms.model.UpdateQuotaRequest; -import com.baidubce.services.sms.model.UpdateTemplateRequest; -import com.baidubce.services.sms.model.UpdateTemplateResponse; -import com.baidubce.util.JsonUtils; - -/** - * The entrance class for all client access to the API of SMS(Baidu message Service). - *

- * All of the API method of SMS is included in this class. - *

- */ -public class SmsInternalClient extends SmsClientSupport { - /** - * Constructs a new SmsClient instance with default settings. - */ - public SmsInternalClient() { - this(new SmsClientConfiguration()); - } - - /** - * Constructs a new SmsClient instance with the specified configuration. - * - * @param config the specified configuration, default inherit super class - * com.baidubce.BceClientConfiguration - * - * @see com.baidubce.services.sms.SmsClientConfiguration - */ - public SmsInternalClient(SmsClientConfiguration config) { - super(config, SMS_HANDLERS); - } - - /** - * Update message template - * - * @param request The request object which includes the name, content and status of template which is ready to be - * updated - * @return The response object which is empty - * - * @see com.baidubce.services.sms.model.UpdateTemplateRequest - * @see com.baidubce.services.sms.model.UpdateTemplateResponse - */ - public UpdateTemplateResponse updateTemplate(UpdateTemplateRequest request) { - checkNotNull(request, "object request should not be null."); - assertStringNotNullOrEmpty(request.getTemplateId(), "object templateId should not be null or empty."); - - InternalRequest internalRequest = - this.createRequest("template", request, HttpMethodName.PUT, request.getTemplateId()); - - // fill in the request payload - internalRequest = fillRequestPayload(internalRequest, JsonUtils.toJsonString(request)); - - return this.invokeHttpClient(internalRequest, UpdateTemplateResponse.class); - } - - /** - * Set the sending quota - * - * @param request The request object which includes the detail of sending quota which is ready to be set - * - * @see com.baidubce.services.sms.model.UpdateQuotaRequest - */ - public void updateQuota(UpdateQuotaRequest request) { - checkNotNull(request, "object request should not be null."); - - InternalRequest internalRequest = this.createRequest("quota", request, HttpMethodName.PUT); - - // fill in the request payload - internalRequest = fillRequestPayload(internalRequest, JsonUtils.toJsonString(request)); - - this.invokeHttpClient(internalRequest, SmsResponse.class); - } - -} \ No newline at end of file diff --git a/src/test/java/com/baidubce/services/sms/model/UpdateQuotaRequest.java b/src/test/java/com/baidubce/services/sms/model/UpdateQuotaRequest.java deleted file mode 100755 index 7dd94ae2..00000000 --- a/src/test/java/com/baidubce/services/sms/model/UpdateQuotaRequest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.services.sms.model; - -public class UpdateQuotaRequest extends SmsRequest { - /** - * The max count of sending message a day - */ - private Integer maxSendPerDay; - /** - * The max count of receiving message a day - */ - private Integer maxReceivePerPhoneNumberDay; - - public UpdateQuotaRequest() { - } - - public UpdateQuotaRequest(Integer maxSendPerDay, Integer maxReceivePerPhoneNumberDay) { - this.maxSendPerDay = maxSendPerDay; - this.maxReceivePerPhoneNumberDay = maxReceivePerPhoneNumberDay; - } - - public Integer getMaxSendPerDay() { - return maxSendPerDay; - } - - public void setMaxSendPerDay(Integer maxSendPerDay) { - this.maxSendPerDay = maxSendPerDay; - } - - public Integer getMaxReceivePerPhoneNumberDay() { - return maxReceivePerPhoneNumberDay; - } - - public void setMaxReceivePerPhoneNumberDay(Integer maxReceivePerPhoneNumberDay) { - this.maxReceivePerPhoneNumberDay = maxReceivePerPhoneNumberDay; - } - - @Override - public String toString() { - return "UpdateQuotaRequest [maxSendPerDay=" + maxSendPerDay + ", maxReceivePerPhoneNumberDay=" - + maxReceivePerPhoneNumberDay + "]"; - } - -} diff --git a/src/test/java/com/baidubce/services/sms/model/UpdateTemplateRequest.java b/src/test/java/com/baidubce/services/sms/model/UpdateTemplateRequest.java deleted file mode 100755 index ec327936..00000000 --- a/src/test/java/com/baidubce/services/sms/model/UpdateTemplateRequest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.services.sms.model; - -import com.baidubce.services.ses.model.SesRequest; - -public class UpdateTemplateRequest extends SesRequest { - /** - * The URL parameter.
- * The id of message template, it is unique in whole situation.
- * For example:smsTpl:6nHdNumZ4ZtGaKO.
- * It must do URLencode before using it. - */ - private String templateId; - - /** - * The name of message template
- * It is unique, and it's max length is 32 chars. - */ - private String name; - - /** - * The content of message template.
- * It's max length is 70 chars, and it's pattern is similar to ${KEY}, which key is the name of variable
- * You can make a definition as you need, but it should be brief as possible as you can. - */ - private String content; - - /** - * The status of message template.
- * It is a ENUM, and it's optional value is - *

    - * processing - *
- *
    - * valid - *
- *
    - * unvalid - *
- * - * @see com.baidubce.services.sms.model.TemplateStatus - */ - private String status; - - public UpdateTemplateRequest withTemplateId(String templateId) { - setTemplateId(templateId); - return this; - } - - public UpdateTemplateRequest withName(String name) { - this.setName(name); - return this; - } - - public String getTemplateId() { - return templateId; - } - - public void setTemplateId(String templateId) { - this.templateId = templateId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getContent() { - return content; - } - - public void setContent(String content) { - this.content = content; - } - - public String getStatus() { - return status; - } - - public void setStatus(String status) { - this.status = status; - } - - @Override - public String toString() { - return "EditTemplateRequest [templateId=" + templateId + ", name=" + name + ", content=" + content - + ", status=" + status + "]"; - } - -} diff --git a/src/test/java/com/baidubce/services/sts/StsClientTest.java b/src/test/java/com/baidubce/services/sts/StsClientTest.java deleted file mode 100755 index c0690339..00000000 --- a/src/test/java/com/baidubce/services/sts/StsClientTest.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2014 Baidu.com, Inc. All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ -package com.baidubce.services.sts; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.BceServiceException; -import com.baidubce.TestUtils; -import com.baidubce.auth.BceCredentials; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.auth.DefaultBceSessionCredentials; -import com.baidubce.services.sts.model.GetSessionTokenRequest; -import com.baidubce.services.sts.model.GetSessionTokenResponse; -import com.google.common.base.Objects; -import org.hamcrest.CustomMatcher; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.experimental.runners.Enclosed; -import org.junit.rules.ExpectedException; -import org.junit.runner.RunWith; - -import java.util.Date; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.hasProperty; - -@RunWith(Enclosed.class) -public class StsClientTest { - - @Ignore - public static class Base { - @Rule - public ExpectedException thrown = ExpectedException.none(); - - protected static String ENDPOINT = "http://10.107.37.40:8586"; - - protected StsClient client; - protected BceClientConfiguration config; - - @Before - public void setUp() { - this.config = new BceClientConfiguration(); - this.config.setCredentials(new DefaultBceCredentials("d154df3e2ac44e53b566db53ec644a7e", - "2e8445d62bc84011991b4306b91f19f8")); - this.config.setEndpoint(ENDPOINT); - this.client = new StsClient(this.config); - } - - protected void expectBceServiceException(final int statusCode, final String errorCode) { - this.expectBceServiceException(statusCode, errorCode, null); - } - - protected void expectBceServiceException( - final int statusCode, final String errorCode, final String errorMessage) { - this.thrown.expect(new CustomMatcher( - "BceServiceException [ statusCode=" + statusCode + ", errorCode=" + errorCode + "]") { - @Override - public boolean matches(Object item) { - if (!(item instanceof BceServiceException)) { - return false; - } - BceServiceException bceServiceException = (BceServiceException) item; - return bceServiceException.getStatusCode() == statusCode - && Objects.equal(bceServiceException.getErrorCode(), errorCode) - && (errorMessage == null || errorMessage.equals(bceServiceException.getErrorMessage())); - } - }); - } - } - - public static class GetSessionTokenTest extends Base { - @Test - public void testOrdinary() { - GetSessionTokenResponse response = this.client.getSessionToken(); - assertThat(response, hasProperty("accessKeyId")); - assertThat(response, hasProperty("secretAccessKey")); - assertThat(response, hasProperty("sessionToken")); - assertThat(response, hasProperty("expiration", TestUtils.timeGapInSecondsGreaterThan(new Date(), 1500))); - } - - @Test - public void testDurationSeconds() { - GetSessionTokenResponse response = - this.client.getSessionToken(new GetSessionTokenRequest().withDurationSeconds(10)); - assertThat(response, hasProperty("accessKeyId")); - assertThat(response, hasProperty("secretAccessKey")); - assertThat(response, hasProperty("sessionToken")); - assertThat(response, hasProperty("expiration", TestUtils.timeGapInSecondsLessThan(new Date(), 30))); - } - - @Test - public void testAcl() { - GetSessionTokenResponse response = - this.client.getSessionToken(new GetSessionTokenRequest().withAcl("" - + "{" - + " \"id\": \"test\"," - + " \"accessControlList\": [" - + " {" - + " \"eid\": \"e0\"," - + " \"service\": \"bce:bos\"," - + " \"region\": \"bj\"," - + " \"effect\": \"Allow\"," - + " \"resource\": [\"test-bucket/*\"]," - + " \"permission\": [\"READ\"]" - + " }" - + " ]" - + "}")); - assertThat(response, hasProperty("accessKeyId")); - assertThat(response, hasProperty("secretAccessKey")); - assertThat(response, hasProperty("sessionToken")); - assertThat(response, hasProperty("expiration")); - } - - @Test - public void testEmptyAcl() { - this.expectBceServiceException(400, "InvalidRequest"); - this.client.getSessionToken(new GetSessionTokenRequest().withAcl("{}")); - } - - @Test - public void testInvalidAcl() { - this.expectBceServiceException(400, "InvalidRequestBody"); - this.client.getSessionToken(new GetSessionTokenRequest().withAcl("{")); - } - - @Test - public void testTemporaryCredential() { - GetSessionTokenResponse response = this.client.getSessionToken(); - BceCredentials tempCredentials = new DefaultBceSessionCredentials( - response.getAccessKeyId(), - response.getSecretAccessKey(), - response.getSessionToken()); - this.expectBceServiceException(400, "InvalidRequest", "not support temporal credential"); - this.client.getSessionToken(new GetSessionTokenRequest().withRequestCredentials(tempCredentials)); - } - } -} diff --git a/src/test/java/com/baidubce/services/tsdb/TsdbClientTest.java b/src/test/java/com/baidubce/services/tsdb/TsdbClientTest.java deleted file mode 100755 index 73405ddc..00000000 --- a/src/test/java/com/baidubce/services/tsdb/TsdbClientTest.java +++ /dev/null @@ -1,607 +0,0 @@ -package com.baidubce.services.tsdb; - -import static org.hamcrest.MatcherAssert.assertThat; -import static org.hamcrest.Matchers.closeTo; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.equalTo; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.hamcrest.Matchers.hasItem; -import static org.hamcrest.Matchers.hasProperty; -import static org.hamcrest.Matchers.hasSize; -import static org.hamcrest.Matchers.is; -import static org.hamcrest.Matchers.notNullValue; - -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; -import java.util.Arrays; -import java.util.List; - -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.tsdb.model.Aggregator; -import com.baidubce.services.tsdb.model.Datapoint; -import com.baidubce.services.tsdb.model.Filters; -import com.baidubce.services.tsdb.model.GetMetricsResponse; -import com.baidubce.services.tsdb.model.GetTagsResponse; -import com.baidubce.services.tsdb.model.Group; -import com.baidubce.services.tsdb.model.GroupBy; -import com.baidubce.services.tsdb.model.Query; -import com.baidubce.services.tsdb.model.QueryDatapointsResponse; -import com.baidubce.services.tsdb.model.ValueFilter; -import com.baidubce.services.tsdb.model.WriteDatapointsRequest; -import com.baidubce.util.JsonUtils; - -public class TsdbClientTest { - // qa-sandbox - private static final String AK = "7b852806a751453caa6babd00bbcfaa5"; - private static final String SK = "146f895ad3c54552bf2a51721f7304b8"; - private static final String ENDPOINT = "http://testoutersdk.tsdb.iot.gz.baidubce.com:8011"; - private static final String METRIC = "test_java_sdk"; - private static final String TAG_KEY = "tag1"; - private static final String TAG_VALUE = "value1"; - private static final byte[] BYTE_VALUE_1 = new byte[] {0x01, 0x02, 0x00, 0x03}; - private static final byte[] BYTE_VALUE_2 = new byte[] {0x11, 0x12, 0x00, 0x13}; - private static final double DOUBLE_VALUE_1 = 1.1; - private static final double DOUBLE_VALUE_2 = 1.2; - private static final double DOUBLE_VALUE_3 = 1.3; - private static final long LONG_VALUE_1 = 11; - private static final long LONG_VALUE_2 = 12; - private static final long LONG_VALUE_3 = 13; - private static final String STRING_VALUE_1 = "str1"; - private static final String STRING_VALUE_2 = "str2"; - - private TsdbClient tsdbClient; - - @Before - public void setUp() { - BceClientConfiguration config = new BceClientConfiguration() - .withCredentials(new DefaultBceCredentials(AK, SK)) - .withEndpoint(ENDPOINT); - tsdbClient = new TsdbClient(config); - } - - private void writeDoubleDatapointsTest(long baseTimestamp) { - List datapoints = Arrays.asList(new Datapoint() - .withMetric(METRIC) - .addTag(TAG_KEY, TAG_VALUE) - .addDoubleValue(baseTimestamp, DOUBLE_VALUE_1) - .addDoubleValue(baseTimestamp + 1, DOUBLE_VALUE_2)); - - tsdbClient.writeDatapoints(new WriteDatapointsRequest().withDatapoints(datapoints), false); - } - - private void writeDoubleDatapointsTest(long baseTimestamp, Double... values) { - List datapoints = Arrays.asList(new Datapoint() - .withMetric(METRIC) - .addTag(TAG_KEY, TAG_VALUE)); - for (Double value : values) { - datapoints.get(0).addDoubleValue(baseTimestamp++, value); - } - - tsdbClient.writeDatapoints(new WriteDatapointsRequest().withDatapoints(datapoints), false); - } - - private void writeBytesDatapointsTest(long baseTimestamp) { - List datapoints = Arrays.asList(new Datapoint() - .withMetric(METRIC) - .addTag(TAG_KEY, TAG_VALUE) - .addBytesValue(baseTimestamp, BYTE_VALUE_1) - .addBytesValue(baseTimestamp + 1, BYTE_VALUE_2)); - - tsdbClient.writeDatapoints(new WriteDatapointsRequest().withDatapoints(datapoints), false); - } - - @Test - public void getMetricsTest() throws Exception { - writeDoubleDatapointsTest(System.currentTimeMillis()); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - GetMetricsResponse response = tsdbClient.getMetrics(); - - assertThat(response, hasProperty("metrics")); - assertThat(response.getMetrics(), is(notNullValue())); - assertThat(response.getMetrics(), hasItem(METRIC)); - } - - @Test - public void getTagsTest() throws Exception { - writeDoubleDatapointsTest(System.currentTimeMillis()); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - GetTagsResponse response = tsdbClient.getTags(METRIC); - - assertThat(response, hasProperty("tags")); - assertThat(response.getTags(), is(notNullValue())); - assertThat(response.getTags().get(TAG_KEY), is(notNullValue())); - assertThat(response.getTags().get(TAG_KEY), hasItem(TAG_VALUE)); - } - - @Test - public void queryDatapointsTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeDoubleDatapointsTest(baseTimestamp); - writeDoubleDatapointsTest(baseTimestamp + 2); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueries(baseTimestamp, baseTimestamp + 4); - - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), greaterThanOrEqualTo(1)); - } - - @Test - public void queryDatapointsWithDoubleValueFilterEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeDoubleDatapointsTest(baseTimestamp, DOUBLE_VALUE_1, DOUBLE_VALUE_2, DOUBLE_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.EQUAL, DOUBLE_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(1)); - assertThat(values.get(0).getDoubleValue(), closeTo(DOUBLE_VALUE_1, 0.001)); - } - - @SuppressWarnings("unchecked") - @Test - public void queryDatapointsWithDoubleValueFilterNotEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeDoubleDatapointsTest(baseTimestamp, DOUBLE_VALUE_1, DOUBLE_VALUE_2, DOUBLE_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.NOT_EQUAL, DOUBLE_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(2)); - List doubleValues = Arrays.asList(values.get(0).getDoubleValue(), values.get(1).getDoubleValue()); - assertThat(doubleValues, containsInAnyOrder(closeTo(DOUBLE_VALUE_2, 0.001), closeTo(DOUBLE_VALUE_3, 0.001))); - } - - @Test - public void queryDatapointsWithDoubleValueFilterLessTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeDoubleDatapointsTest(baseTimestamp, DOUBLE_VALUE_1, DOUBLE_VALUE_2, DOUBLE_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.LESS, DOUBLE_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(0L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - assertThat(response.getResults().get(0).getGroups().get(0).getTimeAndValueList().size(), equalTo(0)); - } - - @Test - public void queryDatapointsWithDoubleValueFilterLessOrEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeDoubleDatapointsTest(baseTimestamp, DOUBLE_VALUE_1, DOUBLE_VALUE_2, DOUBLE_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.LESS_OR_EQUAL, DOUBLE_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(1)); - assertThat(values.get(0).getDoubleValue(), closeTo(DOUBLE_VALUE_1, 0.001)); - } - - @Test - public void queryDatapointsWithDoubleValueFilterGreaterTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeDoubleDatapointsTest(baseTimestamp, DOUBLE_VALUE_1, DOUBLE_VALUE_2, DOUBLE_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.GREATER, DOUBLE_VALUE_2)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(1)); - assertThat(values.get(0).getDoubleValue(), closeTo(DOUBLE_VALUE_3, 0.001)); - } - - @SuppressWarnings("unchecked") - @Test - public void queryDatapointsWithDoubleValueFilterGreaterOrEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeDoubleDatapointsTest(baseTimestamp, DOUBLE_VALUE_1, DOUBLE_VALUE_2, DOUBLE_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.GREATER_OR_EQUAL, DOUBLE_VALUE_2)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(2L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(2)); - List doubleValues = Arrays.asList(values.get(0).getDoubleValue(), values.get(1).getDoubleValue()); - assertThat(doubleValues, containsInAnyOrder(closeTo(DOUBLE_VALUE_2, 0.001), closeTo(DOUBLE_VALUE_3, 0.001))); - } - - private void writeLongDatapointsTest(long baseTimestamp, Long... values) { - List datapoints = Arrays.asList(new Datapoint() - .withMetric(METRIC) - .addTag(TAG_KEY, TAG_VALUE)); - for (Long value : values) { - datapoints.get(0).addLongValue(baseTimestamp++, value); - } - - tsdbClient.writeDatapoints(new WriteDatapointsRequest().withDatapoints(datapoints), false); - } - - @Test - public void queryDatapointsWithLongValueFilterEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeLongDatapointsTest(baseTimestamp, LONG_VALUE_1, LONG_VALUE_2, LONG_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.EQUAL, LONG_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(1)); - assertThat(values.get(0).getLongValue(), equalTo(LONG_VALUE_1)); - } - - @SuppressWarnings("unchecked") - @Test - public void queryDatapointsWithLongValueFilterNotEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeLongDatapointsTest(baseTimestamp, LONG_VALUE_1, LONG_VALUE_2, LONG_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.NOT_EQUAL, LONG_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(2)); - List longValues = Arrays.asList(values.get(0).getLongValue(), values.get(1).getLongValue()); - assertThat(longValues, containsInAnyOrder(equalTo(LONG_VALUE_2), equalTo(LONG_VALUE_3))); - } - - @Test - public void queryDatapointsWithLongValueFilterLessTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeLongDatapointsTest(baseTimestamp, LONG_VALUE_1, LONG_VALUE_2, LONG_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.LESS, LONG_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(0L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - assertThat(response.getResults().get(0).getGroups().get(0).getTimeAndValueList().size(), equalTo(0)); - } - - @Test - public void queryDatapointsWithDoubleLongFilterLessOrEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeLongDatapointsTest(baseTimestamp, LONG_VALUE_1, LONG_VALUE_2, LONG_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.LESS_OR_EQUAL, LONG_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(1)); - assertThat(values.get(0).getLongValue(), equalTo(LONG_VALUE_1)); - } - - @Test - public void queryDatapointsWithLongValueFilterGreaterTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeLongDatapointsTest(baseTimestamp, LONG_VALUE_1, LONG_VALUE_2, LONG_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.GREATER, LONG_VALUE_2)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(1)); - assertThat(values.get(0).getLongValue(), equalTo(LONG_VALUE_3)); - } - - @SuppressWarnings("unchecked") - @Test - public void queryDatapointsWithLongValueFilterGreaterOrEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeLongDatapointsTest(baseTimestamp, LONG_VALUE_1, LONG_VALUE_2, LONG_VALUE_3); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 3, - ValueFilter.createValueFilter(ValueFilter.GREATER_OR_EQUAL, LONG_VALUE_2)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(2L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Number")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(2)); - List longValues = Arrays.asList(values.get(0).getLongValue(), values.get(1).getLongValue()); - assertThat(longValues, containsInAnyOrder(equalTo(LONG_VALUE_2), equalTo(LONG_VALUE_3))); - } - - private void writeStringDatapointsTest(long baseTimestamp, String... values) { - List datapoints = Arrays.asList(new Datapoint().withMetric(METRIC).addTag(TAG_KEY, TAG_VALUE)); - for (String value : values) { - datapoints.get(0).addStringValue(baseTimestamp++, value); - } - - tsdbClient.writeDatapoints(new WriteDatapointsRequest().withDatapoints(datapoints), false); - } - - @Test - public void queryDatapointsWithStringValueFilterEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeStringDatapointsTest(baseTimestamp, STRING_VALUE_1, STRING_VALUE_2); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 2, - ValueFilter.createValueFilter(ValueFilter.EQUAL, STRING_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("String")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(1)); - assertThat(values.get(0).getStringValue(), equalTo(STRING_VALUE_1)); - } - - @Test - public void queryDatapointsWithStringValueFilterNotEqualTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeStringDatapointsTest(baseTimestamp, STRING_VALUE_1, STRING_VALUE_2); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueriesWithValueFilter(baseTimestamp, baseTimestamp + 2, - ValueFilter.createValueFilter(ValueFilter.NOT_EQUAL, STRING_VALUE_1)); - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(1)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("String")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(1)); - assertThat(values.get(0).getStringValue(), equalTo(STRING_VALUE_2)); - } - - @Test - public void queryBytesDatapointsTest() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeBytesDatapointsTest(baseTimestamp); - writeDoubleDatapointsTest(baseTimestamp + 2); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = Arrays.asList(new Query() - .withMetric(METRIC) - .withFilters(new Filters() - .withAbsoluteStart(baseTimestamp) - .withAbsoluteEnd(baseTimestamp + 4))); - - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), equalTo(4L)); - assertThat(response.getResults().get(0).getGroups().size(), equalTo(2)); - - assertThat(response.getResults().get(0).getGroups().get(0).getGroupInfos().get(0).getType(), equalTo("Bytes")); - List values = response.getResults().get(0).getGroups().get(0).getTimeAndValueList(); - assertThat(values.size(), equalTo(2)); - assertThat(values.get(0).isBytes(), equalTo(true)); - assertThat(values.get(0).getBytesValue(), equalTo(BYTE_VALUE_1)); - assertThat(values.get(1).isBytes(), equalTo(true)); - assertThat(values.get(1).getBytesValue(), equalTo(BYTE_VALUE_2)); - - assertThat(response.getResults().get(0).getGroups().get(1).getGroupInfos().get(0).getType(), equalTo("Number")); - values = response.getResults().get(0).getGroups().get(1).getTimeAndValueList(); - assertThat(values.size(), equalTo(2)); - assertThat(values.get(0).isDouble(), equalTo(true)); - assertThat(values.get(0).getDoubleValue(), equalTo(DOUBLE_VALUE_1)); - assertThat(values.get(1).isDouble(), equalTo(true)); - assertThat(values.get(1).getDoubleValue(), equalTo(DOUBLE_VALUE_2)); - } - - @Test - public void testGeneratePresignedUrlForQueryDatapoints() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - writeDoubleDatapointsTest(baseTimestamp); - writeDoubleDatapointsTest(baseTimestamp + 2); - Thread.sleep(1000); - - List queries = createQueries(baseTimestamp, baseTimestamp + 4); - URL url = tsdbClient.generatePresignedUrlForQueryDatapoints(queries); - - HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection(); - urlConnection.setRequestMethod("GET"); - - InputStream inputStream = null; - try { - inputStream = urlConnection.getInputStream(); - QueryDatapointsResponse response = JsonUtils.loadFrom(inputStream, - QueryDatapointsResponse.class); - - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), greaterThanOrEqualTo(1)); - } finally { - if (inputStream != null) { - inputStream.close(); - } - } - } - - @Test - public void testWriteGzip() throws Exception { - long baseTimestamp = System.currentTimeMillis(); - List datapoints = Arrays.asList(new Datapoint() - .withMetric(METRIC) - .addTag(TAG_KEY, TAG_VALUE) - .addDoubleValue(baseTimestamp, 1.1) - .addDoubleValue(baseTimestamp + 1, 1.2)); - - tsdbClient.writeDatapoints(datapoints); - // Sleep 1 second to ensure that the datapoints are writed into Tsdb. - Thread.sleep(1000); - - List queries = createQueries(baseTimestamp, baseTimestamp + 2); - - QueryDatapointsResponse response = tsdbClient.queryDatapoints(queries); - - assertThat(response, hasProperty("results")); - assertThat(response.getResults(), hasSize(1)); - assertThat(response.getResults().get(0).getMetric(), equalTo(METRIC)); - assertThat(response.getResults().get(0).getRawCount(), greaterThanOrEqualTo(1L)); - assertThat(response.getResults().get(0).getGroups().size(), greaterThanOrEqualTo(1)); - } - - private List createQueries(long startTimestamp, long endTimestamp) { - return Arrays.asList(new Query() - .withMetric(METRIC) - .withFilters(new Filters() - .withAbsoluteStart(startTimestamp) - .withAbsoluteEnd(endTimestamp) - .addTag(TAG_KEY, TAG_VALUE)) - .addGroupBy(new GroupBy() - .withName(TsdbConstants.GROUP_BY_NAME_TIME) - .withTimeRangeSize("1 second") - .withGroupCount(1)) - .withLimit(100) - .addAggregator(new Aggregator() - .withName(TsdbConstants.AGGREGATOR_NAME_SUM) - .withSampling("1 second"))); - } - - private List createQueriesWithValueFilter(long startTimestamp, long endTimestamp, ValueFilter valueFilter) { - return Arrays.asList(new Query() - .withMetric(METRIC) - .withFilters(new Filters() - .withAbsoluteStart(startTimestamp) - .withAbsoluteEnd(endTimestamp) - .addTag(TAG_KEY, TAG_VALUE) - .withValue(valueFilter))); - } -} diff --git a/src/test/java/com/baidubce/services/vod/AbstractVodTest.java b/src/test/java/com/baidubce/services/vod/AbstractVodTest.java deleted file mode 100755 index a2079fe4..00000000 --- a/src/test/java/com/baidubce/services/vod/AbstractVodTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.baidubce.services.vod; - -import java.io.File; -import java.io.FileNotFoundException; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.bos.BosClientConfiguration; -import com.baidubce.services.vod.VodClient; -import com.baidubce.services.vod.model.CreateMediaResourceResponse; - -public abstract class AbstractVodTest { - -// static final String VOD_END_POINT = "http://vod.bce-testinternal.baidu.com"; - static final String VOD_END_POINT = "http://vod.bce-testinternal.baidu.com"; - static final String BOS_END_POINT = "http://10.105.97.15"; - - // Linqing's account - static String AK = "27add1b94dd5485d916cc866190be704"; - static String SK = "49ce4909b87441e794c24dd673a6fa17"; - - protected VodClient vodClient; - - protected String mediaId; - - public void setUp() throws Exception { - DefaultBceCredentials cred = new DefaultBceCredentials(AK, SK); - - BceClientConfiguration vodConfig = - new BceClientConfiguration().withCredentials(cred).withEndpoint(VOD_END_POINT); - - BosClientConfiguration bosConfig = - new BosClientConfiguration().withCredentials(cred).withEndpoint(BOS_END_POINT); - - vodClient = new VodClient(vodConfig, bosConfig); - - } - - protected void createSampleMedia() throws FileNotFoundException, InterruptedException { - File file = new File("/Users/hdp/Movies/short.mp4"); - String title = "short mp4"; - String description = "490KB"; - CreateMediaResourceResponse response = vodClient.createMediaResource(title, description, file); - mediaId = response.getMediaId(); - String status; - do { - Thread.sleep(2000); - status = vodClient.getMediaResource(mediaId).getStatus(); - } while (!status.equals("PUBLISHED")); - } -} diff --git a/src/test/java/com/baidubce/services/vod/ut/CreateMediaResourceTest.java b/src/test/java/com/baidubce/services/vod/ut/CreateMediaResourceTest.java deleted file mode 100755 index cdc02bc2..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/CreateMediaResourceTest.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baidubce.services.vod.ut; - -import java.io.File; -import java.io.FileNotFoundException; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.CreateMediaResourceResponse; - -public class CreateMediaResourceTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void uploadSmallFileTest() throws FileNotFoundException { - File file = new File("/Users/baidu/Downloads/a.mov"); - String title = "Gail Sophicha"; - String description = "Back To December"; - CreateMediaResourceResponse response = vodClient.createMediaResource(title, description, file); - String mediaId = response.getMediaId(); - System.out.println("meidaId = " + mediaId); - } - - @Test - public void uploadLargeFileTest() throws FileNotFoundException { - File file = new File("/Volumes/sd/video/Martian.mp4"); - String title = "Gail Sophicha"; - String description = "Back To December"; - CreateMediaResourceResponse response = vodClient.createMediaResource(title, description, file); - String mediaId = response.getMediaId(); - System.out.println("meidaId = " + mediaId); - } - -} diff --git a/src/test/java/com/baidubce/services/vod/ut/DeleteMediaResourceTest.java b/src/test/java/com/baidubce/services/vod/ut/DeleteMediaResourceTest.java deleted file mode 100755 index cb859439..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/DeleteMediaResourceTest.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.baidubce.services.vod.ut; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GetMediaResourceResponse; - -public class DeleteMediaResourceTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - createSampleMedia(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testDeleteMediaResource() { - - assertEquals("PUBLISHED", vodClient.getMediaResource(mediaId).getStatus()); - vodClient.deleteMediaResource(mediaId); - try { - GetMediaResourceResponse response = vodClient.getMediaResource(mediaId); - System.out.println(response); - fail("Failed to delete resource " + mediaId); - } catch (Exception e) { - // Should throw out exception here - - } - } - -} diff --git a/src/test/java/com/baidubce/services/vod/ut/ExternalTest.java b/src/test/java/com/baidubce/services/vod/ut/ExternalTest.java deleted file mode 100755 index e7a68248..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/ExternalTest.java +++ /dev/null @@ -1,139 +0,0 @@ -package com.baidubce.services.vod.ut; - -import static org.junit.Assert.*; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.baidubce.BceClientConfiguration; -import com.baidubce.auth.DefaultBceCredentials; -import com.baidubce.services.vod.VodClient; -import com.baidubce.services.vod.model.CreateMediaResourceResponse; -import com.baidubce.services.vod.model.PlayableUrl; -import com.baidubce.services.vod.model.PlaybackCode; - -public class ExternalTest { - private static Logger logger = LoggerFactory.getLogger(ExternalTest.class); - - @Before - public void setUp() throws Exception { - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testRegion() throws FileNotFoundException, InterruptedException { - // external account - String AK = "9ea040b91e974376a28367f23721e6fb"; - String SK = "0b555564eefa453bbc5b2305db047c23"; - - DefaultBceCredentials cred = new DefaultBceCredentials(AK, SK); - BceClientConfiguration vodConfig = new BceClientConfiguration().withCredentials(cred); - VodClient vodClient = new VodClient(vodConfig); - - logger.info(vodClient.getEndpoint().toString()); - - } - - @Test - @Ignore - public void testSample() throws FileNotFoundException, InterruptedException { - // external account - String AK = "9ea040b91e974376a28367f23721e6fb"; - String SK = "0b555564eefa453bbc5b2305db047c23"; - - DefaultBceCredentials cred = new DefaultBceCredentials(AK, SK); - BceClientConfiguration vodConfig = new BceClientConfiguration().withCredentials(cred); - VodClient vodClient = new VodClient(vodConfig); - - // create a media ID - File file = new File("/Users/hdp/Movies/GailSophicha.mp4"); - String title = "Gail Sophicha"; - String description = "Back To December"; - String mediaId = vodClient.createMediaResource(title, description, file).getMediaId(); - logger.info("[meidaId] = " + mediaId); - - // get its attribute - String status; - do { - Thread.sleep(2000); - status = vodClient.getMediaResource(mediaId).getStatus(); - logger.info("[status] = " + status); - } while (!status.equals("PUBLISHED")); - logger.info("[mediaId] = " + vodClient.getMediaResource(mediaId)); - - // get playable URL and web player code - PlayableUrl result = vodClient.getPlayableUrl(mediaId).getResult(); - logger.info("[url] = " + result.getFile() + ", [cover] = " + result.getCover()); - - List codes = vodClient.getPlayerCode(mediaId, 250, 160, true).getCodes(); - for (int i = 0; i < codes.size(); i++) { - logger.info("[codeType] = " + codes.get(i).getCodeType() + ", [source] = " + codes.get(i).getSourceCode()); - } - - String newTitle = "New Title"; - String newDesc = "New Description"; - vodClient.updateMediaResource(mediaId, newTitle, newDesc); - logger.info("After update attributes: " + vodClient.getMediaResource(mediaId)); - - vodClient.updateMediaResource(mediaId, title, description); - - // disable and publish again - vodClient.stopMediaResource(mediaId); - assertEquals("DISABLED", vodClient.getMediaResource(mediaId).getStatus()); - - vodClient.publishMediaResource(mediaId); - assertEquals("PUBLISHED", vodClient.getMediaResource(mediaId).getStatus()); - - vodClient.deleteMediaResource(mediaId); - try { - status = vodClient.getMediaResource(mediaId).getStatus(); - logger.info("[status] = " + status); - fail("Failed to delete resource " + mediaId); - } catch (Exception e) { - // Should throw out exception here - - } - } - - @Test - @Ignore - public void testCreatMediaResource() throws InterruptedException { - String sourceBucket = "bce-media-sdk"; - String sourceKey = "GailSophicha.mp4"; - - // external account - final String AK = "9ea040b91e974376a28367f23721e6fb"; - final String SK = "0b555564eefa453bbc5b2305db047c23"; - - DefaultBceCredentials cred = new DefaultBceCredentials(AK, SK); - BceClientConfiguration vodConfig = new BceClientConfiguration().withCredentials(cred); - VodClient vodClient = new VodClient(vodConfig); - - String title = "GailSophicha"; - String description = ""; - CreateMediaResourceResponse response = - vodClient.createMediaResource(sourceBucket, sourceKey, title, description); - String mediaId = response.getMediaId(); - - // make sure it is published - String status; - do { - Thread.sleep(2000); - status = vodClient.getMediaResource(mediaId).getStatus(); - logger.info("[status] = " + status); - } while (!status.equals("PUBLISHED")); - logger.info("[mediaId] = " + vodClient.getMediaResource(mediaId)); - - } -} diff --git a/src/test/java/com/baidubce/services/vod/ut/GenerateMediaDeliveryInfoTest.java b/src/test/java/com/baidubce/services/vod/ut/GenerateMediaDeliveryInfoTest.java deleted file mode 100755 index 013a6951..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/GenerateMediaDeliveryInfoTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.baidubce.services.vod.ut; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GenerateMediaDeliveryInfoResponse; -import com.baidubce.services.vod.model.GetPlayerCodeResponse; -import com.baidubce.services.vod.model.PlaybackCode; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.fail; - -public class GenerateMediaDeliveryInfoTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gfxj1qfuis44avyt"; - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testGenerateMediaDeliveryInfo() { - GenerateMediaDeliveryInfoResponse response = vodClient.generateMediaDeliveryInfo(mediaId); - System.out.println(response); -// String htmlCode = null; -// String flashCode = null; -// String standalonePage = null; -// for (PlaybackCode code : response.getCodes()) { -// if (code.getCodeType().equals("html")) { -// htmlCode = code.getSourceCode(); -// } else if (code.getCodeType().equals("flash")) { -// flashCode = code.getSourceCode(); -// -// } else if (code.getCodeType().equals("url")) { -// standalonePage = code.getSourceCode(); -// } else { -// fail("Unexpected code = " + code); -// } -// } - } -} diff --git a/src/test/java/com/baidubce/services/vod/ut/GenerateMediaPlayerCodeTest.java b/src/test/java/com/baidubce/services/vod/ut/GenerateMediaPlayerCodeTest.java deleted file mode 100755 index 6e19cbd2..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/GenerateMediaPlayerCodeTest.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baidubce.services.vod.ut; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GenerateMediaPlayerCodeResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - - -public class GenerateMediaPlayerCodeTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gfxj1qfuis44avyt"; - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testGenerateMediaPlayerCode() { - GenerateMediaPlayerCodeResponse response = vodClient.generateMediaPlayerCode(mediaId, 160, 90, true); - System.out.println(response); - - } -} diff --git a/src/test/java/com/baidubce/services/vod/ut/GetMediaDownloadTest.java b/src/test/java/com/baidubce/services/vod/ut/GetMediaDownloadTest.java deleted file mode 100755 index 9a5dc7f9..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/GetMediaDownloadTest.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.baidubce.services.vod.ut; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GetMediaSourceDownloadResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - - -public class GetMediaDownloadTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gaqi5dznriez85n3"; - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testGetMediaDownload() { - GetMediaSourceDownloadResponse response = vodClient.getMediaSourceDownload(mediaId, -1); - System.out.println(response.getSourceUrl()); - } -} diff --git a/src/test/java/com/baidubce/services/vod/ut/GetMediaResourceTest.java b/src/test/java/com/baidubce/services/vod/ut/GetMediaResourceTest.java deleted file mode 100755 index c33f5f4b..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/GetMediaResourceTest.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baidubce.services.vod.ut; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GetMediaResourceResponse; - -public class GetMediaResourceTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gbbdvcve3e3238k1"; - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testGetMediaSource() { - GetMediaResourceResponse response = vodClient.getMediaResource(mediaId); - System.out.println(response); - assertEquals("PUBLISHED", response.getStatus()); - assertEquals("Gail Sophicha", response.getAttributes().getTitle()); - assertEquals("Back To December", response.getAttributes().getDescription()); - assertTrue(61767567 == response.getMeta().getSizeInBytes()); - assertTrue(286 == response.getMeta().getDurationInSeconds()); - } - -} diff --git a/src/test/java/com/baidubce/services/vod/ut/GetMediaStatisticTest.java b/src/test/java/com/baidubce/services/vod/ut/GetMediaStatisticTest.java deleted file mode 100755 index 9901dc24..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/GetMediaStatisticTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baidubce.services.vod.ut; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GetMediaStatisticResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - - -public class GetMediaStatisticTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gfxj1qfuis44avyt"; - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testGetMediaStatisticWithAggregate() { - GetMediaStatisticResponse response = vodClient.getMediaStatistic(mediaId, null, null, true); - System.out.println(response); - } - @Test - public void testGetMediaStatisticWithoutAggregate() { - GetMediaStatisticResponse response = vodClient.getMediaStatistic(mediaId, null, null, false); - System.out.println(response); - } -} diff --git a/src/test/java/com/baidubce/services/vod/ut/GetPlayableUrlTest.java b/src/test/java/com/baidubce/services/vod/ut/GetPlayableUrlTest.java deleted file mode 100755 index 9509db0c..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/GetPlayableUrlTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baidubce.services.vod.ut; - - -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GetPlayableUrlResponse; - -public class GetPlayableUrlTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gaqi5dznriez85n3"; - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testGetPlayableUrl() { - GetPlayableUrlResponse response = vodClient.getPlayableUrl(mediaId); - assertTrue(response.getSuccess()); - System.out.println(response); - } - -} diff --git a/src/test/java/com/baidubce/services/vod/ut/GetPlayerCodeTest.java b/src/test/java/com/baidubce/services/vod/ut/GetPlayerCodeTest.java deleted file mode 100755 index 945bd019..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/GetPlayerCodeTest.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.baidubce.services.vod.ut; - -import static org.junit.Assert.fail; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GetPlayerCodeResponse; -import com.baidubce.services.vod.model.PlaybackCode; - -public class GetPlayerCodeTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gaqi5dznriez85n3"; - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testGetPlayerCode() { - GetPlayerCodeResponse response = vodClient.getPlayerCode(mediaId, 160, 90, true); - System.out.println(response); - String htmlCode = null; - String flashCode = null; - String standalonePage = null; - for (PlaybackCode code : response.getCodes()) { - if (code.getCodeType().equals("html")) { - htmlCode = code.getSourceCode(); - } else if (code.getCodeType().equals("flash")) { - flashCode = code.getSourceCode(); - - } else if (code.getCodeType().equals("url")) { - standalonePage = code.getSourceCode(); - } else { - fail("Unexpected code = " + code); - } - } - } -} diff --git a/src/test/java/com/baidubce/services/vod/ut/ListMediaResourceTest.java b/src/test/java/com/baidubce/services/vod/ut/ListMediaResourceTest.java deleted file mode 100755 index 42fe5e8c..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/ListMediaResourceTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.baidubce.services.vod.ut; - -import com.baidubce.util.DateUtils; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import java.util.Date; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.ListMediaResourceResponse; -import com.baidubce.services.vod.model.MediaResource; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - -public class ListMediaResourceTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testListMediaResources() { - ListMediaResourceResponse responce = vodClient.listMediaResources(); - - for (MediaResource mediaResource : responce.getMedia()) { - String mediaId = mediaResource.getMediaId(); - String status = mediaResource.getStatus(); - String createTime = mediaResource.getCreateTime(); - String publishTime = mediaResource.getPublishTime(); - String title = mediaResource.getAttributes().getTitle(); - String description = mediaResource.getAttributes().getDescription(); - long duration = mediaResource.getMeta().getDurationInSeconds(); - long size = mediaResource.getMeta().getSizeInBytes(); - System.out.println(mediaResource); - } - } - - @Test - public void testListMediaResourcesWithPage() { - ListMediaResourceResponse responce = vodClient.listMediaResources(1, 2, null, null, null, null); - assertEquals(responce.getMedia().size(), 2); - for (MediaResource mediaResource : responce.getMedia()) { - String mediaId = mediaResource.getMediaId(); - String status = mediaResource.getStatus(); - String createTime = mediaResource.getCreateTime(); - String publishTime = mediaResource.getPublishTime(); - String title = mediaResource.getAttributes().getTitle(); - String description = mediaResource.getAttributes().getDescription(); - long duration = mediaResource.getMeta().getDurationInSeconds(); - long size = mediaResource.getMeta().getSizeInBytes(); - System.out.println(mediaResource); - } - } - - @Test - public void testListMediaResourcesWithPageBeginEnd() { - Date begin = DateUtils.parseAlternateIso8601Date("2016-01-15T08:46:56Z"); - Date end = DateUtils.parseAlternateIso8601Date("2016-01-18T08:46:56Z"); - ListMediaResourceResponse responce = vodClient.listMediaResources(1, 20, null, begin, end, null); - assertTrue(responce.getMedia().size() > 0); - for (MediaResource mediaResource : responce.getMedia()) { - String mediaId = mediaResource.getMediaId(); - String status = mediaResource.getStatus(); - String createTime = mediaResource.getCreateTime(); - String publishTime = mediaResource.getPublishTime(); - String title = mediaResource.getAttributes().getTitle(); - String description = mediaResource.getAttributes().getDescription(); - long duration = mediaResource.getMeta().getDurationInSeconds(); - long size = mediaResource.getMeta().getSizeInBytes(); - System.out.println(mediaResource); - } - } -} diff --git a/src/test/java/com/baidubce/services/vod/ut/PublishMediaResourceTest.java b/src/test/java/com/baidubce/services/vod/ut/PublishMediaResourceTest.java deleted file mode 100755 index f2d76b80..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/PublishMediaResourceTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baidubce.services.vod.ut; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.vod.AbstractVodTest; - -public class PublishMediaResourceTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gaqi5dznriez85n3"; - vodClient.stopMediaResource(mediaId); - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testPublishMediaResource() { - assertNotEquals(vodClient.getMediaResource(mediaId).getStatus(), "PUBLISHED"); - vodClient.publishMediaResource(mediaId); - assertEquals(vodClient.getMediaResource(mediaId).getStatus(), "PUBLISHED"); - } - -} diff --git a/src/test/java/com/baidubce/services/vod/ut/ReTranscodeTest.java b/src/test/java/com/baidubce/services/vod/ut/ReTranscodeTest.java deleted file mode 100755 index 93f3f8b3..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/ReTranscodeTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baidubce.services.vod.ut; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GetMediaResourceResponse; -import com.baidubce.services.vod.model.ReTranscodeResponse; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import static org.junit.Assert.assertEquals; - -public class ReTranscodeTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gaqi5dznriez85n3"; - } - - @After - public void tearDown() throws Exception { - } - - @Test - public void testReTranscode() { - GetMediaResourceResponse r1 = vodClient.getMediaResource(mediaId); - assertEquals(r1.getStatus(), "PUBLISHED"); - ReTranscodeResponse response = vodClient.reTranscode(mediaId); - GetMediaResourceResponse r2 = vodClient.getMediaResource(mediaId); - assertEquals(r2.getStatus(), "RUNNING"); - } -} diff --git a/src/test/java/com/baidubce/services/vod/ut/StopMediaResourceTest.java b/src/test/java/com/baidubce/services/vod/ut/StopMediaResourceTest.java deleted file mode 100755 index 20f2f155..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/StopMediaResourceTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.baidubce.services.vod.ut; - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.vod.AbstractVodTest; - -public class StopMediaResourceTest extends AbstractVodTest { - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gaqi5dznriez85n3"; - } - - @After - public void tearDown() throws Exception { - vodClient.publishMediaResource(mediaId); - } - - @Test - public void testStopMediaResource() { - assertEquals(vodClient.getMediaResource(mediaId).getStatus(), "PUBLISHED"); - vodClient.stopMediaResource(mediaId); - assertEquals(vodClient.getMediaResource(mediaId).getStatus(), "DISABLED"); - - } - -} diff --git a/src/test/java/com/baidubce/services/vod/ut/UpdateMediaResourceTest.java b/src/test/java/com/baidubce/services/vod/ut/UpdateMediaResourceTest.java deleted file mode 100755 index d428a5af..00000000 --- a/src/test/java/com/baidubce/services/vod/ut/UpdateMediaResourceTest.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.baidubce.services.vod.ut; - - -import static org.junit.Assert.assertEquals; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -import com.baidubce.services.vod.AbstractVodTest; -import com.baidubce.services.vod.model.GetMediaResourceResponse; - -public class UpdateMediaResourceTest extends AbstractVodTest { - String oldTitle; - String oldDescription; - - @Before - public void setUp() throws Exception { - super.setUp(); - mediaId = "mda-gaqi5dznriez85n3"; - GetMediaResourceResponse response = vodClient.getMediaResource(mediaId); - oldTitle = response.getAttributes().getTitle(); - oldDescription = response.getAttributes().getDescription(); - System.out.println("[titel] = " + oldTitle + ", [description] = " + oldDescription); - } - - @After - public void tearDown() throws Exception { - vodClient.updateMediaResource(mediaId, oldTitle, oldDescription); - } - - @Test - public void testUpdateMediaResource() { - String title = "new Title"; - String description = "new description"; - vodClient.updateMediaResource(mediaId, title, description); - GetMediaResourceResponse response = vodClient.getMediaResource(mediaId); - assertEquals(title, response.getAttributes().getTitle()); - assertEquals(description, response.getAttributes().getDescription()); - } - -} diff --git a/src/test/resources/attachment-test1.txt b/src/test/resources/attachment-test1.txt deleted file mode 100755 index 8e63c459..00000000 --- a/src/test/resources/attachment-test1.txt +++ /dev/null @@ -1 +0,0 @@ -中国 \ No newline at end of file diff --git a/src/test/resources/attachment-test2.md b/src/test/resources/attachment-test2.md deleted file mode 100755 index 30d74d25..00000000 --- a/src/test/resources/attachment-test2.md +++ /dev/null @@ -1 +0,0 @@ -test \ No newline at end of file diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml deleted file mode 100755 index a316a95d..00000000 --- a/src/test/resources/logback.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - ${LOG_HOME}/BosUnitTest.%d{yyyy-MM-dd}.log - 30 - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n - - - 10MB - - - - - - - - \ No newline at end of file