From 7476493080d6c7dc895f1eeda7d4781c8295b03f Mon Sep 17 00:00:00 2001 From: "tian.ming@huawei.com" Date: Sat, 10 Sep 2016 12:41:16 +0800 Subject: Modify license information. JIRA:https://jira.open-o.org/browse/OCS-46 Change-Id: Iff62c4f5a9f29e20ab6f54772f60b1ab7ea65b1a Signed-off-by: tian.ming@huawei.com fix the build error. Change-Id: Iecab881eaad2442d48da9a162f2207f742e6982c Signed-off-by: tian.ming@huawei.com fix the build error. Change-Id: Iecab881eaad2442d48da9a162f2207f742e6982c Signed-off-by: tian.ming@huawei.com --- .../remoteservice/exception/ExceptionArgs.java | 10 +- .../remoteservice/exception/ServiceException.java | 32 +-- .../openo/baseservice/roa/util/ReaderHelper.java | 10 +- .../openo/baseservice/roa/util/ServiceUtil.java | 177 -------------- .../baseservice/roa/util/clientsdk/HttpUtil.java | 169 ------------- .../baseservice/roa/util/clientsdk/JsonUtil.java | 99 -------- .../roa/util/clientsdk/RestClientUtil.java | 133 ----------- .../roa/util/restclient/DefaultAsyncCallback.java | 6 +- .../roa/util/restclient/HttpBaseRest.java | 28 +-- .../baseservice/roa/util/restclient/HttpRest.java | 8 +- .../util/restclient/RestHttpContentExchange.java | 14 +- .../baseservice/roa/util/restclient/Restful.java | 50 ++-- .../roa/util/restclient/RestfulAsyncCallback.java | 10 +- .../roa/util/restclient/RestfulClientConst.java | 8 +- .../roa/util/restclient/RestfulConfigure.java | 10 +- .../roa/util/restclient/RestfulFactory.java | 8 +- .../roa/util/restclient/RestfulOptions.java | 52 +--- .../roa/util/restclient/RestfulParametes.java | 28 +-- .../roa/util/restclient/RestfulResponse.java | 24 +- .../baseservice/roa/util/ReaderHelperTest.java | 12 +- .../baseservice/roa/util/TestServiceUtil.java | 16 +- .../roa/util/clientsdk/TestHttpUtil.java | 266 --------------------- .../roa/util/clientsdk/TestJsonUtil.java | 184 -------------- .../roa/util/clientsdk/TestRestClientUtil.java | 210 ---------------- .../roa/util/clientsdk/demo/JsonTestClass.java | 88 ------- .../roa/util/restclient/TestHttpRest.java | 188 +++------------ .../restclient/TestRestHttpContentExchange.java | 44 ++-- .../roa/util/restclient/TestRestfulConfigure.java | 37 ++- .../roa/util/restclient/TestRestfulFactory.java | 17 +- .../roa/util/restclient/TestRestfulOptions.java | 59 ++--- .../roa/util/restclient/TestRestfulParametes.java | 34 +-- .../roa/util/restclient/TestRestfulResponse.java | 30 +-- 32 files changed, 274 insertions(+), 1787 deletions(-) delete mode 100644 rest-client/src/main/java/org/openo/baseservice/roa/util/ServiceUtil.java delete mode 100644 rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/HttpUtil.java delete mode 100644 rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/JsonUtil.java delete mode 100644 rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/RestClientUtil.java delete mode 100644 rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestHttpUtil.java delete mode 100644 rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestJsonUtil.java delete mode 100644 rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestRestClientUtil.java delete mode 100644 rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/demo/JsonTestClass.java (limited to 'rest-client/src') diff --git a/rest-client/src/main/java/org/openo/baseservice/remoteservice/exception/ExceptionArgs.java b/rest-client/src/main/java/org/openo/baseservice/remoteservice/exception/ExceptionArgs.java index 40dd2b1..6c92f23 100644 --- a/rest-client/src/main/java/org/openo/baseservice/remoteservice/exception/ExceptionArgs.java +++ b/rest-client/src/main/java/org/openo/baseservice/remoteservice/exception/ExceptionArgs.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -22,7 +22,7 @@ package org.openo.baseservice.remoteservice.exception; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public class ExceptionArgs { @@ -51,7 +51,7 @@ public class ExceptionArgs { *

*

* - * @since SDNO 0.5 + * @since */ public ExceptionArgs() { // default constructor. @@ -62,7 +62,7 @@ public class ExceptionArgs { *

*

* - * @since SDNO 0.5 + * @since * @param descArgs: descriptions. * @param reasonArgs: reasons. * @param detailArgs: details. diff --git a/rest-client/src/main/java/org/openo/baseservice/remoteservice/exception/ServiceException.java b/rest-client/src/main/java/org/openo/baseservice/remoteservice/exception/ServiceException.java index e64d914..91f6acf 100644 --- a/rest-client/src/main/java/org/openo/baseservice/remoteservice/exception/ServiceException.java +++ b/rest-client/src/main/java/org/openo/baseservice/remoteservice/exception/ServiceException.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -23,7 +23,7 @@ import java.text.MessageFormat; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public class ServiceException extends Exception { @@ -54,7 +54,7 @@ public class ServiceException extends Exception { * This method is only used as deserialized, in other cases, use parameterized constructor. *

* - * @since SDNO 0.5 + * @since */ public ServiceException() { super(""); @@ -65,7 +65,7 @@ public class ServiceException extends Exception { *

*

* - * @since SDNO 0.5 + * @since * @param id: details. * @param cause: reason. */ @@ -79,7 +79,7 @@ public class ServiceException extends Exception { *

*

* - * @since SDNO 0.5 + * @since * @param message: details. */ public ServiceException(final String message) { @@ -91,7 +91,7 @@ public class ServiceException extends Exception { *

*

* - * @since SDNO 0.5 + * @since * @param id: exception id. * @param message: details. */ @@ -105,7 +105,7 @@ public class ServiceException extends Exception { *

*

* - * @since SDNO 0.5 + * @since * @param id: exception id. * @param httpCode: http status code. */ @@ -120,7 +120,7 @@ public class ServiceException extends Exception { *

*

* - * @since SDNO 0.5 + * @since * @param id: exception id. * @param httpCode: http code. * @param exceptionArgs: Exception handling frame parameters. @@ -138,7 +138,7 @@ public class ServiceException extends Exception { * Have a placeholder exception, use args formatted message. *

* - * @since SDNO 0.5 + * @since * @param id: exception id. * @param message: details. * @param args: Placeholders for parameters @@ -155,7 +155,7 @@ public class ServiceException extends Exception { * Have a placeholder exception, use args formatted message *

* - * @since SDNO 0.5 + * @since * @param id: exception id. * @param message: details. * @param cause: reason. @@ -172,7 +172,7 @@ public class ServiceException extends Exception { *

*

* - * @since SDNO 0.5 + * @since * @param id: exception id. * @param message: details. * @param cause: reason. @@ -187,7 +187,7 @@ public class ServiceException extends Exception { *

*

* - * @since SDNO 0.5 + * @since * @param cause: reason. */ public ServiceException(final Throwable cause) { @@ -198,7 +198,7 @@ public class ServiceException extends Exception { * Get exceptoin id.
* * @return - * @since SDNO 0.5 + * @since */ public String getId() { if(id == null || id.isEmpty()) { @@ -223,7 +223,7 @@ public class ServiceException extends Exception { * Obtain the ROA exception handling framework parameters
* * @return exception args. - * @since SDNO 0.5 + * @since */ public ExceptionArgs getExceptionArgs() { return exceptionArgs; @@ -237,7 +237,7 @@ public class ServiceException extends Exception { * Gets the parameter information
* * @return parameter list. - * @since SDNO 0.5 + * @since */ protected Object[] getArgs() { if(args == null || args.length == 0 || DEFAULT_ID.equals(getId())) { diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/ReaderHelper.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/ReaderHelper.java index 86124cf..85e4f56 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/ReaderHelper.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/ReaderHelper.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -25,7 +25,7 @@ import java.io.Reader; *

* * @author - * @version SDNO 0.5 31-May-2016 + * @version 31-May-2016 */ public class ReaderHelper { @@ -36,7 +36,7 @@ public class ReaderHelper { *

*

* - * @since SDNO 0.5 + * @since * @param reader */ public ReaderHelper(final Reader reader) { @@ -50,7 +50,7 @@ public class ReaderHelper { * Gets the next line.
* * @return line if present else null. - * @since SDNO 0.5 + * @since */ public String getLine() { if(ite != null && ite.hasNext()) { diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/ServiceUtil.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/ServiceUtil.java deleted file mode 100644 index aca60c0..0000000 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/ServiceUtil.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.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 org.openo.baseservice.roa.util; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.io.InputStream; -import java.util.Enumeration; -import java.util.Properties; - -/** - * Service connection configuration util.
- *

- * Get host and port from the Client Configure the connection environment and service Configure - * profile - *

- * - * @author - * @version SDNO 0.5 28-May-2016 - */ -public class ServiceUtil { - - private static final Logger LOG = LoggerFactory.getLogger(ServiceUtil.class); - - private final Properties allConfigure = new Properties(); - - private final Properties serviceConfigure; - - private String serviceStage; - - private String serviceName; - - /** - * Constructor
- *

- * Load profile information. - *

- * - * @since SDNO 0.5 - * @param serviceName user-specified service name. - * @param url invoked service url. - */ - public ServiceUtil(final String serviceName, final String url) { - final String fomattedUrl = formatUrl(url); - serviceConfigure = loadProperties("service-configure.properties"); - if(null == serviceName || serviceName.isEmpty()) { - this.serviceName = getServiceNameWhitUrl(fomattedUrl); - } else { - this.serviceName = serviceName; - } - loadPropertyFile(); - } - - /** - * Get the service user-specified host. - *
- * - * @return host - * @since SDNO 0.5 - */ - public String getServiceHost() { - final String host = allConfigure.getProperty(serviceName + "." + serviceStage + ".host"); - if(null == host) { - return ""; - } - return host; - } - - /** - * Get the service user-specified port. - *
- * - * @return port - * @since SDNO 0.5 - */ - public int getServicePort() { - final String portStr = allConfigure.getProperty(serviceName + "." + serviceStage + ".port"); - if(null == portStr) { - return -1; - } - return Integer.parseInt(portStr); - } - - private String getServiceNameWhitUrl(final String url) { - final Enumeration keys = serviceConfigure.propertyNames(); - while(keys.hasMoreElements()) { - final String key = (String)keys.nextElement(); - if(key.endsWith("urls")) { - final String urls = serviceConfigure.getProperty(key); - for(String tempUrl : urls.split(",")) { - tempUrl = formatUrl(tempUrl); - if(url.startsWith(tempUrl)) { - return key.split("\\.")[0]; - } - } - - } - } - return ""; - } - - private static String formatUrl(final String url) { - String outUrl = url; - if(outUrl.contains("?")) { - outUrl = outUrl.split("\\?")[0]; - } - outUrl = outUrl.replace("\\", "/"); - outUrl = outUrl.replaceAll("[/]{2,}", "/"); - outUrl = outUrl.endsWith("/") ? outUrl.substring(0, outUrl.length() - 1) : outUrl; - outUrl = outUrl.endsWith("/*") ? outUrl.substring(0, outUrl.length() - 2) : outUrl; - return outUrl; - } - - /** - * Loads the client and service configuration files. - *
- * - * @since SDNO 0.5 - */ - private void loadPropertyFile() { - final Properties clientConfigure = loadProperties(serviceName + "-client-configure.properties"); - allConfigure.putAll(clientConfigure); - allConfigure.putAll(serviceConfigure); - serviceStage = allConfigure.getProperty(serviceName + ".stage"); - } - - /** - * Loads the client and service configuration files. - *
- * - * @param classProperties: service profile file name. - * @return Service configuration. - * @since SDNO 0.5 - */ - private Properties loadProperties(final String classProperties) { - final Properties properties = new Properties(); - InputStream inputStream = null; - ClassLoader classloader = null; - try { - classloader = this.getClass().getClassLoader(); - if(classloader != null) { - inputStream = classloader.getResourceAsStream(classProperties); - } - if(inputStream != null) { - properties.load(inputStream); - inputStream.close(); - } - } catch(final IOException e) { - LOG.error("load file error: ", e); - } finally { - if(inputStream != null) { - try { - inputStream.close(); - } catch(final IOException ee) { - LOG.error("close inputStream error: ", ee); - } - inputStream = null; - } - } - return properties; - } -} diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/HttpUtil.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/HttpUtil.java deleted file mode 100644 index 3c6493c..0000000 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/HttpUtil.java +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.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 org.openo.baseservice.roa.util.clientsdk; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.Collection; -import java.util.Date; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Http utilities. - *
- *

- *

- * - * @author - * @version SDNO 0.5 28-May-2016 - */ -public class HttpUtil { - - /** - * - */ - private static final String APPLICATION_JSON = "application/json"; - - private static final Logger LOGGER = LoggerFactory.getLogger(HttpUtil.class); - - private HttpUtil() { - - } - - /** - * Check if the given array contains the given value (with case-insensitive comparison). - *
- * - * @param array The array - * @param value The value to search - * @return true if the array contains the value - * @since SDNO 0.5 - */ - public static boolean containsIgnoreCase(final String[] array, final String value) { - for(final String str : array) { - if(value == null && str == null) { - return true; - } - if(value != null && value.equalsIgnoreCase(str)) { - return true; - } - } - return false; - } - - /** - * Join an array of strings with the given separator. - *
- * - * @param array The array of strings - * @param separator The separator - * @return the resulting string - * @since SDNO 0.5 - */ - public static String join(final String[] array, final String separator) { - final int len = array.length; - if(len == 0) { - return ""; - } - final StringBuilder out = new StringBuilder(); - out.append(array[0]); - for(int i = 1; i < len; i++) { - out.append(separator).append(array[i]); - } - return out.toString(); - } - - /** - * Format the given parameter object into string. - *
- * - * @param param param input - * @return query param string - * @since SDNO 0.5 - */ - public static String parameterToString(final Object param) { - if(param == null) { - return ""; - } else if(param instanceof Date) { - return Long.toString(((Date)param).getTime()); - } else if(param instanceof Collection) { - final StringBuilder b = new StringBuilder(); - for(final Object o : (Collection)param) { - if(b.length() > 0) { - b.append(','); - } - b.append(String.valueOf(o)); - } - return b.toString(); - } else { - return String.valueOf(param); - } - } - - /** - * get accept header - *
- * - * @param accepts accepts accept types - * @return the accepts string - * @since SDNO 0.5 - */ - public static String selectHeaderAccept(final String[] accepts) { - if(accepts.length == 0) { - return null; - } - if(HttpUtil.containsIgnoreCase(accepts, APPLICATION_JSON)) { - return APPLICATION_JSON; - } - return HttpUtil.join(accepts, ","); - } - - /** - * select head content type - *
- * - * @param contentTypes contentTypes content types - * @return the json string or the first content type - * @since SDNO 0.5 - */ - public static String selectHeaderContentType(final String[] contentTypes) { - if(contentTypes.length == 0) { - return APPLICATION_JSON; - } - if(HttpUtil.containsIgnoreCase(contentTypes, APPLICATION_JSON)) { - return APPLICATION_JSON; - } - return contentTypes[0]; - } - - /** - * Escape the given string to be used as URL query value.
- * - * @param str str param str - * @return escape string - * @since SDNO 0.5 - */ - public static String escapeString(final String str) { - try { - return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); - } catch(final UnsupportedEncodingException e) { - LOGGER.info("UTF8 is not supported", e); - return str; - } - } -} diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/JsonUtil.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/JsonUtil.java deleted file mode 100644 index 2234e19..0000000 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/JsonUtil.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.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 org.openo.baseservice.roa.util.clientsdk; - -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; - -import net.sf.json.JSON; - -import java.io.IOException; - -/** - * JSON parse utilities. - *
- *

- *

- * - * @author - * @version SDNO 0.5 28-May-2016 - */ -public final class JsonUtil { - - private static final ObjectMapper MAPPER = new ObjectMapper(); - - static { - MAPPER.setDeserializationConfig(MAPPER.getDeserializationConfig() - .without(org.codehaus.jackson.map.DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES)); - } - - private JsonUtil() { - } - - /** - * Parse JSON formated string.
- * - * @param jsonstr: JSON formated string. - * @param type: result type. - * @return parsed object. - * @throws IOException incase error. - * @since SDNO 0.5 - */ - public static T unMarshal(final String jsonstr, final Class type) throws IOException { - return MAPPER.readValue(jsonstr, type); - } - - /** - * Parse JSON formatted string (for a generic target type). - *
- * - * @param jsonstr request data. - * @param type target type. - * @return result object. - * @throws IOException incase error. - * @since SDNO 0.5 - */ - public static T unMarshal(final String jsonstr, final TypeReference type) throws IOException { - return MAPPER.readValue(jsonstr, type); - } - - /** - * Convert object to JSON format string. - *
- * - * @param srcObj source object. - * @return JSON format string. - * @throws IOException incase of error. - * @since SDNO 0.5 - */ - public static String marshal(final Object srcObj) throws IOException { - if(srcObj instanceof JSON) { - return srcObj.toString(); - } - return MAPPER.writeValueAsString(srcObj); - } - - /** - * Get parsing mapper - *
- * - * @return parsing mapper - * @since SDNO 0.5 - */ - public static ObjectMapper getMapper() { - return MAPPER; - } -} diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/RestClientUtil.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/RestClientUtil.java deleted file mode 100644 index b769f0a..0000000 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/clientsdk/RestClientUtil.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.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 org.openo.baseservice.roa.util.clientsdk; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.Restful; -import org.openo.baseservice.roa.util.restclient.RestfulAsyncCallback; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; - -import java.util.HashSet; -import java.util.Set; - -/** - * Rest Client Tools. - *
- *

- *

- * - * @author - * @version SDNO 0.5 28-May-2016 - */ -public class RestClientUtil { - - private static Set> ret = new HashSet<>(); - - static { - ret.add(Boolean.class); - ret.add(Character.class); - ret.add(Byte.class); - ret.add(Short.class); - ret.add(Integer.class); - ret.add(Long.class); - ret.add(Float.class); - ret.add(Double.class); - ret.add(Void.class); - ret.add(String.class); - } - - private RestClientUtil() { - - } - - /** - * Processing HTTP requests. - *
- * - * @param method method name. - * @param path request path. - * @param parameters parameters. - * @param restFull ReST request instance - * @return The ReST response. - * @throws ServiceException Exception information. - * @since SDNO 0.5 - */ - public static RestfulResponse invokeMethod(final String method, final String path, - final RestfulParametes parameters, final Restful restFull) throws ServiceException { - RestfulResponse response; - if("get".equalsIgnoreCase(method)) { - response = restFull.get(path, parameters); - } else if("put".equalsIgnoreCase(method)) { - response = restFull.put(path, parameters); - } else if("post".equalsIgnoreCase(method)) { - response = restFull.post(path, parameters); - } else if("delete".equalsIgnoreCase(method)) { - response = restFull.delete(path, parameters); - } else if("patch".equalsIgnoreCase(method)) { - response = restFull.patch(path, parameters); - } else { - throw new ServiceException("NotSuppertMethod", 400); - } - return response; - } - - /** - * An asynchronous HTTP request. - *
- * - * @param method http method. - * @param path request path. - * @param parameters request parameters. - * @param restFull restFull instance. - * @param callback callback function. - * @throws ServiceException in case error. - * @since SDNO 0.5 - */ - public static void invokeAsyncMethod(final String method, final String path, final RestfulParametes parameters, - final Restful restFull, final RestfulAsyncCallback callback) throws ServiceException { - if("get".equalsIgnoreCase(method)) { - restFull.asyncGet(path, parameters, callback); - } else if("put".equalsIgnoreCase(method)) { - restFull.asyncPut(path, parameters, callback); - } else if("post".equalsIgnoreCase(method)) { - restFull.asyncPost(path, parameters, callback); - } else if("delete".equalsIgnoreCase(method)) { - restFull.asyncDelete(path, parameters, callback); - } else if("patch".equalsIgnoreCase(method)) { - restFull.asyncPatch(path, parameters, callback); - } else { - throw new ServiceException("NotSuppertMethod", 400); - } - } - - /** - * Determine whether a class is a native.
- * - * @param clazz: class type. - * @return whether primitive or not. - * @since SDNO 0.5 - */ - public static boolean isPrimitive(final Class clazz) { - if(clazz.isPrimitive()) { - return true; - } - if(ret.contains(clazz)) { - return true; - } - return false; - } -} diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/DefaultAsyncCallback.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/DefaultAsyncCallback.java index 8195b0d..81adeb6 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/DefaultAsyncCallback.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/DefaultAsyncCallback.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -21,7 +21,7 @@ package org.openo.baseservice.roa.util.restclient; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public class DefaultAsyncCallback implements RestfulAsyncCallback { diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/HttpBaseRest.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/HttpBaseRest.java index 4f58778..3e64937 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/HttpBaseRest.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/HttpBaseRest.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -31,7 +31,6 @@ import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpExchange; import org.eclipse.jetty.http.HttpMethods; import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.ServiceUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,7 +40,7 @@ import org.slf4j.LoggerFactory; *

* * @author - * @version SDNO 0.5 Aug 9, 2016 + * @version Aug 9, 2016 */ public abstract class HttpBaseRest implements Restful { @@ -68,7 +67,7 @@ public abstract class HttpBaseRest implements Restful { *

*

* - * @since SDNO 0.5 + * @since */ public HttpBaseRest() { super(); @@ -145,7 +144,7 @@ public abstract class HttpBaseRest implements Restful { * @param callback * @return * @throws ServiceException - * @since SDNO 0.5 + * @since */ protected RestfulResponse sendHttpRequest(final String method, final String servicePath, final RestfulParametes restParametes, final RestfulOptions options, final RestfulAsyncCallback callback) @@ -193,23 +192,6 @@ public abstract class HttpBaseRest implements Restful { } else { String host = defaultIP; int iPort = defaultPort; - String calledServiceName = null; - if(options != null) { - calledServiceName = options.getCalledServicName(); - } - final ServiceUtil serviceUtil = new ServiceUtil(calledServiceName, url.toString()); - final String configHost = serviceUtil.getServiceHost(); - final int configPort = serviceUtil.getServicePort(); - if(!configHost.isEmpty() && configPort > 0) { - if(options != null) { - options.setHost(configHost); - options.setPort(configPort); - } else { - host = configHost; - - iPort = configPort; - } - } if(options != null) { host = options.getHost(); if(host.isEmpty()) { diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/HttpRest.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/HttpRest.java index 50a3538..047f20e 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/HttpRest.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/HttpRest.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -29,7 +29,7 @@ import org.slf4j.LoggerFactory; *

* * @author - * @version SDNO 0.5 Aug 9, 2016 + * @version Aug 9, 2016 */ public class HttpRest extends HttpBaseRest { @@ -40,7 +40,7 @@ public class HttpRest extends HttpBaseRest { * * @param options: rest options. * @throws ServiceException - * @since SDNO 0.5 + * @since */ public void initHttpRest(final RestfulOptions option) throws ServiceException { if(option == null) { diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestHttpContentExchange.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestHttpContentExchange.java index 85118ce..99328a7 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestHttpContentExchange.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestHttpContentExchange.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -43,7 +43,7 @@ import java.util.zip.GZIPInputStream; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public class RestHttpContentExchange extends ContentExchange { @@ -58,7 +58,7 @@ public class RestHttpContentExchange extends ContentExchange { *

*

* - * @since SDNO 0.5 + * @since * @param cacheFields whether to cache response header. * @param asyncCallback callback method. */ @@ -74,7 +74,7 @@ public class RestHttpContentExchange extends ContentExchange { * @param data GZipped data. * @return Uncompressed data. * @throws IOException - * @since SDNO 0.5 + * @since */ public String decompressGzipToStr(final byte[] data) throws IOException { if(data == null) { @@ -125,7 +125,7 @@ public class RestHttpContentExchange extends ContentExchange { * @param name buffer * @param value value * @throws IOException - * @since SDNO 0.5 + * @since */ @Override protected synchronized void onResponseHeader(final Buffer name, final Buffer value) throws IOException { @@ -203,7 +203,7 @@ public class RestHttpContentExchange extends ContentExchange { * * @return response object. * @throws IOException - * @since SDNO 0.5 + * @since */ public RestfulResponse getResponse() throws IOException { final RestfulResponse rsp = new RestfulResponse(); diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/Restful.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/Restful.java index 7a7c11e..8527e68 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/Restful.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/Restful.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -23,7 +23,7 @@ import org.openo.baseservice.remoteservice.exception.ServiceException; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public interface Restful { @@ -34,7 +34,7 @@ public interface Restful { * @param restParametes: query parameters. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse get(String servicePath, RestfulParametes restParametes) throws ServiceException; @@ -46,7 +46,7 @@ public interface Restful { * @param options: request options. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse head(String servicePath, RestfulParametes restParametes, RestfulOptions options) throws ServiceException; @@ -58,7 +58,7 @@ public interface Restful { * @param restParametes: request parameters. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse head(String servicePath, RestfulParametes restParametes) throws ServiceException; @@ -70,7 +70,7 @@ public interface Restful { * @param options: request options. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse get(String servicePath, RestfulParametes restParametes, RestfulOptions options) throws ServiceException; @@ -82,7 +82,7 @@ public interface Restful { * @param restParametes: request parameters. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncGet(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) throws ServiceException; @@ -95,7 +95,7 @@ public interface Restful { * @param options: request options. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncGet(String servicePath, RestfulParametes restParametes, RestfulOptions options, RestfulAsyncCallback callback) throws ServiceException; @@ -107,7 +107,7 @@ public interface Restful { * @param restParametes: request parameters. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse put(String servicePath, RestfulParametes restParametes) throws ServiceException; @@ -119,7 +119,7 @@ public interface Restful { * @param options: request options. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse put(String servicePath, RestfulParametes restParametes, RestfulOptions options) throws ServiceException; @@ -131,7 +131,7 @@ public interface Restful { * @param restParametes: request parameters. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncPut(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) throws ServiceException; @@ -144,7 +144,7 @@ public interface Restful { * @param options: request options. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncPut(String servicePath, RestfulParametes restParametes, RestfulOptions options, RestfulAsyncCallback callback) throws ServiceException; @@ -156,7 +156,7 @@ public interface Restful { * @param restParametes: request parameters. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse post(String servicePath, RestfulParametes restParametes) throws ServiceException; @@ -168,7 +168,7 @@ public interface Restful { * @param options: request options. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse post(String servicePath, RestfulParametes restParametes, RestfulOptions options) throws ServiceException; @@ -180,7 +180,7 @@ public interface Restful { * @param restParametes: request parameters. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncPost(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) throws ServiceException; @@ -193,7 +193,7 @@ public interface Restful { * @param options: request options. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncPost(String servicePath, RestfulParametes restParametes, RestfulOptions options, RestfulAsyncCallback callback) throws ServiceException; @@ -205,7 +205,7 @@ public interface Restful { * @param restParametes: request parameters. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse delete(String servicePath, RestfulParametes restParametes) throws ServiceException; @@ -217,7 +217,7 @@ public interface Restful { * @param options: request options. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse delete(String servicePath, RestfulParametes restParametes, RestfulOptions options) throws ServiceException; @@ -229,7 +229,7 @@ public interface Restful { * @param restParametes: request parameters. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncDelete(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) throws ServiceException; @@ -242,7 +242,7 @@ public interface Restful { * @param options: request options. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncDelete(String servicePath, RestfulParametes restParametes, RestfulOptions options, RestfulAsyncCallback callback) throws ServiceException; @@ -254,7 +254,7 @@ public interface Restful { * @param restParametes: request parameters. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse patch(String servicePath, RestfulParametes restParametes) throws ServiceException; @@ -266,7 +266,7 @@ public interface Restful { * @param options: request options. * @return response. * @throws ServiceException - * @since SDNO 0.5 + * @since */ RestfulResponse patch(String servicePath, RestfulParametes restParametes, RestfulOptions options) throws ServiceException; @@ -278,7 +278,7 @@ public interface Restful { * @param restParametes: request parameters. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncPatch(String servicePath, RestfulParametes restParametes, RestfulAsyncCallback callback) throws ServiceException; @@ -291,7 +291,7 @@ public interface Restful { * @param options: request options. * @param callback: response callback method. * @throws ServiceException - * @since SDNO 0.5 + * @since */ void asyncPatch(String servicePath, RestfulParametes restParametes, RestfulOptions options, RestfulAsyncCallback callback) throws ServiceException; diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulAsyncCallback.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulAsyncCallback.java index bf11c16..bf461c9 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulAsyncCallback.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulAsyncCallback.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -21,7 +21,7 @@ package org.openo.baseservice.roa.util.restclient; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public interface RestfulAsyncCallback { @@ -29,7 +29,7 @@ public interface RestfulAsyncCallback { * Response callback.
* * @param response: response of ReST call. - * @since SDNO 0.5 + * @since */ void callback(RestfulResponse response); @@ -37,7 +37,7 @@ public interface RestfulAsyncCallback { * Exceptoin callback.
* * @param e: ReST call exception. - * @since SDNO 0.5 + * @since */ void handleExcepion(Throwable e); } diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulClientConst.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulClientConst.java index ef02b7d..a3b6581 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulClientConst.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulClientConst.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -21,7 +21,7 @@ package org.openo.baseservice.roa.util.restclient; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public class RestfulClientConst { @@ -37,8 +37,6 @@ public class RestfulClientConst { public static final String SERVER_KEY_NAME = "defaulServer"; - public static final String CALLED_SERVICE_NAME = "serviceName"; - public static final String HOST_KEY_NAME = "host"; public static final String PORT_KEY_NAME = "port"; diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulConfigure.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulConfigure.java index 3d0a0ff..3ce6859 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulConfigure.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulConfigure.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -33,7 +33,7 @@ import net.sf.json.JSONObject; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public class RestfulConfigure { @@ -47,7 +47,7 @@ public class RestfulConfigure { * Use the default path initialization http Rest options. *

* - * @since SDNO 0.5 + * @since */ public RestfulConfigure() { final String config = "/etc/conf/restclient.json"; @@ -72,7 +72,7 @@ public class RestfulConfigure { * Use the specified file to initialize http Rest options. *

* - * @since SDNO 0.5 + * @since * @param configfile */ public RestfulConfigure(final String configfile) { diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulFactory.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulFactory.java index e53bab1..5b94374 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulFactory.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulFactory.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -29,7 +29,7 @@ import java.util.Map; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public class RestfulFactory { @@ -57,7 +57,7 @@ public class RestfulFactory { * * @param protocol protocol. currently only support 'http'. * @return restful instance. - * @since SDNO 0.5 + * @since */ public static synchronized Restful getRestInstance(final String protocol) { Restful rest = INSTANCES.get(protocol); diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulOptions.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulOptions.java index 912abf5..6e5812f 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulOptions.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulOptions.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -24,7 +24,7 @@ import java.util.Map; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public class RestfulOptions { @@ -34,37 +34,11 @@ public class RestfulOptions { private final Map optionsMap = new HashMap<>(); - /** - * Set called service name.
- * - * @param serviceName service name. - * @return true. - * @since SDNO 0.5 - */ - public boolean setCalledServiceName(final String serviceName) { - this.setOption(RestfulClientConst.CALLED_SERVICE_NAME, serviceName); - return true; - } - - /** - * Get called service name.
- * - * @return - * @since SDNO 0.5 - */ - public String getCalledServicName() { - final Object obj = this.getOption(RestfulClientConst.CALLED_SERVICE_NAME); - if(null == obj) { - return ""; - } - return (String)obj; - } - /** * Get port.
* * @return port. - * @since SDNO 0.5 + * @since */ public int getPort() { final Object obj = this.getOption(RestfulClientConst.PORT_KEY_NAME); @@ -79,7 +53,7 @@ public class RestfulOptions { * * @param port port to set. * @return - * @since SDNO 0.5 + * @since */ public boolean setPort(final int port) { this.setOption(RestfulClientConst.PORT_KEY_NAME, port); @@ -90,7 +64,7 @@ public class RestfulOptions { * Get host.
* * @return the host. - * @since SDNO 0.5 + * @since */ public String getHost() { final Object obj = this.getOption(RestfulClientConst.HOST_KEY_NAME); @@ -105,7 +79,7 @@ public class RestfulOptions { * * @param host host to set. * @return - * @since SDNO 0.5 + * @since */ public boolean setHost(final String host) { this.setOption(RestfulClientConst.HOST_KEY_NAME, host); @@ -117,7 +91,7 @@ public class RestfulOptions { * * @param timeout time-out to set in seconds. * @return - * @since SDNO 0.5 + * @since */ public boolean setRestTimeout(final int timeout) { if(0 < timeout && REST_OPTIONS_TIMEOUT_MAXTIMEOUT >= timeout) { @@ -131,7 +105,7 @@ public class RestfulOptions { * Get time-out.
* * @return time-out in seconds. - * @since SDNO 0.5 + * @since */ public int getRestTimeout() { final Object obj = this.getOption(REST_OPTIONS_NAME_TIMEOUT); @@ -146,7 +120,7 @@ public class RestfulOptions { * * @param optionName option name. * @return option - * @since SDNO 0.5 + * @since */ public Object getOption(final String optionName) { return optionsMap.get(optionName); @@ -157,7 +131,7 @@ public class RestfulOptions { * * @param optionName option name. * @return option value as int. - * @since SDNO 0.5 + * @since */ public int getIntOption(final String optionName) { final Object obj = this.getOption(optionName); @@ -172,7 +146,7 @@ public class RestfulOptions { * * @param optionName option name. * @return option value as string. - * @since SDNO 0.5 + * @since */ public String getStringOption(final String optionName) { final Object obj = this.getOption(optionName); @@ -188,7 +162,7 @@ public class RestfulOptions { * @param option option name. * @param optionsValue option value. * @return - * @since SDNO 0.5 + * @since */ public Object setOption(final String option, final Object optionsValue) { return optionsMap.put(option, optionsValue); diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulParametes.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulParametes.java index c6c5933..aea8753 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulParametes.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulParametes.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -25,7 +25,7 @@ import java.util.Map; *

* * @author - * @version SDNO 0.5 Aug 9, 2016 + * @version Aug 9, 2016 */ public class RestfulParametes { @@ -40,7 +40,7 @@ public class RestfulParametes { * * @param key * @return - * @since SDNO 0.5 + * @since */ public String get(final String key) { return paramMap.get(key); @@ -50,7 +50,7 @@ public class RestfulParametes { *
* * @param data - * @since SDNO 0.5 + * @since */ public void setRawData(final String data) { this.rawData = data; @@ -60,7 +60,7 @@ public class RestfulParametes { *
* * @return - * @since SDNO 0.5 + * @since */ public String getRawData() { return this.rawData; @@ -72,7 +72,7 @@ public class RestfulParametes { * @param key * @param value * @return - * @since SDNO 0.5 + * @since */ public String put(final String key, final String value) { return paramMap.put(key, value); @@ -84,7 +84,7 @@ public class RestfulParametes { * @param key * @param value * @return - * @since SDNO 0.5 + * @since */ public String putHttpContextHeader(final String key, final String value) { return headerMap.put(key, value); @@ -96,7 +96,7 @@ public class RestfulParametes { * @param key * @param value * @return - * @since SDNO 0.5 + * @since */ public String putHttpContextHeader(final String key, final int value) { return this.putHttpContextHeader(key, String.valueOf(value)); @@ -107,7 +107,7 @@ public class RestfulParametes { * * @param key * @return - * @since SDNO 0.5 + * @since */ public String getHttpContextHeader(final String key) { return headerMap.get(key); @@ -117,7 +117,7 @@ public class RestfulParametes { *
* * @return - * @since SDNO 0.5 + * @since */ public Map getParamMap() { return paramMap; @@ -127,7 +127,7 @@ public class RestfulParametes { *
* * @param paramMap - * @since SDNO 0.5 + * @since */ public void setParamMap(final Map paramMap) { this.paramMap = paramMap; @@ -137,7 +137,7 @@ public class RestfulParametes { *
* * @return - * @since SDNO 0.5 + * @since */ public Map getHeaderMap() { return this.headerMap; @@ -147,7 +147,7 @@ public class RestfulParametes { *
* * @param headerMap - * @since SDNO 0.5 + * @since */ public void setHeaderMap(final Map headerMap) { this.headerMap = headerMap; diff --git a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulResponse.java b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulResponse.java index 28a0c6d..25105b7 100644 --- a/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulResponse.java +++ b/rest-client/src/main/java/org/openo/baseservice/roa/util/restclient/RestfulResponse.java @@ -1,11 +1,11 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.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 + * 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, @@ -24,7 +24,7 @@ import java.util.Map; *

* * @author - * @version SDNO 0.5 28-May-2016 + * @version 28-May-2016 */ public class RestfulResponse { @@ -38,7 +38,7 @@ public class RestfulResponse { *
* * @return - * @since SDNO 0.5 + * @since */ public int getStatus() { return status; @@ -48,7 +48,7 @@ public class RestfulResponse { *
* * @param status - * @since SDNO 0.5 + * @since */ public void setStatus(final int status) { this.status = status; @@ -58,7 +58,7 @@ public class RestfulResponse { *
* * @return - * @since SDNO 0.5 + * @since */ public Map getRespHeaderMap() { return respHeaderMap; @@ -68,7 +68,7 @@ public class RestfulResponse { *
* * @param header - * @since SDNO 0.5 + * @since */ public void setRespHeaderMap(final Map header) { this.respHeaderMap = header; @@ -79,7 +79,7 @@ public class RestfulResponse { * * @param key header param name. * @return header param value as integer. (-1 if error) - * @since SDNO 0.5 + * @since */ public int getRespHeaderInt(final String key) { if(respHeaderMap != null) { @@ -96,7 +96,7 @@ public class RestfulResponse { * * @param key header param name. * @return value as long. -1 if no value. - * @since SDNO 0.5 + * @since */ public long getRespHeaderLong(final String key) { if(respHeaderMap != null) { @@ -113,7 +113,7 @@ public class RestfulResponse { * * @param key header name. * @return header value. - * @since SDNO 0.5 + * @since */ public String getRespHeaderStr(final String key) { if(respHeaderMap != null) { @@ -126,7 +126,7 @@ public class RestfulResponse { *
* * @return - * @since SDNO 0.5 + * @since */ public String getResponseContent() { return responseContent; @@ -136,7 +136,7 @@ public class RestfulResponse { *
* * @param responseString - * @since SDNO 0.5 + * @since */ public void setResponseJson(final String responseString) { this.responseContent = responseString; diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/ReaderHelperTest.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/ReaderHelperTest.java index 78f08da..9922476 100644 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/ReaderHelperTest.java +++ b/rest-client/src/test/java/org/openo/baseservice/roa/util/ReaderHelperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,7 +32,7 @@ import junit.framework.Assert; *

* * @author - * @version SDNO 0.5 12-Jun-2016 + * @version 12-Jun-2016 */ public class ReaderHelperTest { @@ -40,7 +40,7 @@ public class ReaderHelperTest { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -50,7 +50,7 @@ public class ReaderHelperTest { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @AfterClass public static void tearDownAfterClass() throws Exception { @@ -60,7 +60,7 @@ public class ReaderHelperTest { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @Before public void setUp() throws Exception { @@ -70,7 +70,7 @@ public class ReaderHelperTest { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @After public void tearDown() throws Exception { diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/TestServiceUtil.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/TestServiceUtil.java index f4f93e4..d99d562 100644 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/TestServiceUtil.java +++ b/rest-client/src/test/java/org/openo/baseservice/roa/util/TestServiceUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,7 +28,7 @@ import org.junit.Test; *

* * @author - * @version SDNO 0.5 13-Jun-2016 + * @version 13-Jun-2016 */ public class TestServiceUtil { @@ -36,7 +36,7 @@ public class TestServiceUtil { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -46,7 +46,7 @@ public class TestServiceUtil { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @AfterClass public static void tearDownAfterClass() throws Exception { @@ -56,7 +56,7 @@ public class TestServiceUtil { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @Before public void setUp() throws Exception { @@ -66,7 +66,7 @@ public class TestServiceUtil { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @After public void tearDown() throws Exception { @@ -75,7 +75,7 @@ public class TestServiceUtil { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetServiceHost() { @@ -84,7 +84,7 @@ public class TestServiceUtil { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetServicePort() { diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestHttpUtil.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestHttpUtil.java deleted file mode 100644 index 419d4d0..0000000 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestHttpUtil.java +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.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 org.openo.baseservice.roa.util.clientsdk; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.Arrays; -import java.util.Date; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -import mockit.Mocked; -import mockit.NonStrictExpectations; - -/** - *
- *

- *

- * - * @author - * @version SDNO 0.5 13-Jun-2016 - */ -public class TestHttpUtil { - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @Before - public void setUp() throws Exception { - } - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @After - public void tearDown() throws Exception { - } - - /** - *
- * - * @since SDNO 0.5 - */ - @Test - public void testContainsIgnoreCase() { - final String[] array = {"hello", "how", "are", "you", "?"}; - final String toFind = "Hello"; - Assert.assertTrue(HttpUtil.containsIgnoreCase(array, toFind)); - } - - /** - *
- * - * @since SDNO 0.5 - */ - @Test - public void testContainsIgnoreCaseNull() { - final String[] array = {"hello", "how", "are", "you", "?"}; - final String toFind = "Hello"; - Assert.assertFalse(HttpUtil.containsIgnoreCase(array, null)); - - array[0] = null; - Assert.assertFalse(HttpUtil.containsIgnoreCase(array, toFind)); - - Assert.assertTrue(HttpUtil.containsIgnoreCase(array, null)); - array[0] = "hello"; - array[array.length - 1] = null; - Assert.assertTrue(HttpUtil.containsIgnoreCase(array, null)); - } - - /** - *
- * - * @since SDNO 0.5 - */ - @Test - public void testJoin() { - final String[] array = {"hello", "how", "are", "you", "?"}; - String actual = HttpUtil.join(array, ","); - String expected = "hello,how,are,you,?"; - Assert.assertEquals(actual, expected); - - actual = HttpUtil.join(array, "#"); - expected = expected.replaceAll(",", "#"); - Assert.assertEquals(actual, expected); - actual = HttpUtil.join(new String[] {}, ","); - Assert.assertEquals(actual, ""); - } - - /** - *
- * - * @since SDNO 0.5 - */ - @Test - public void testParameterToString() { - // with param string. - Object param = new String("String Param"); - String actual = HttpUtil.parameterToString(param); - String expected = "String Param"; - Assert.assertEquals(expected, actual); - - // with param date. - final Date date = new Date(); - param = date; - expected = "" + date.getTime(); - actual = HttpUtil.parameterToString(param); - Assert.assertEquals(expected, actual); - - // with param collection. - final String[] array = {"hello", "how", "are", "you", "?"}; - param = Arrays.asList(array); - expected = HttpUtil.join(array, ","); - actual = HttpUtil.parameterToString(param); - Assert.assertEquals(expected, actual); - - // with param any - param = new Object() { - - @Override - public String toString() { - return "test object"; - } - }; - expected = "test object"; - actual = HttpUtil.parameterToString(param); - Assert.assertEquals(expected, actual); - - // with param null. - expected = ""; - actual = HttpUtil.parameterToString(null); - Assert.assertEquals(expected, actual); - - } - - /** - *
- * - * @since SDNO 0.5 - */ - @Test - public void testSelectHeaderAccept() { - final String[] accepts = {"application/json", "text/plain", "application/xml"}; - String expected = "application/json"; - String actual = HttpUtil.selectHeaderAccept(accepts); - Assert.assertEquals(expected, actual); - - accepts[0] = "application/x-www-form-urlencoded"; - expected = HttpUtil.join(accepts, ","); - actual = HttpUtil.selectHeaderAccept(accepts); - Assert.assertEquals(expected, actual); - - expected = null; - actual = HttpUtil.selectHeaderAccept(new String[] {}); - Assert.assertEquals(expected, actual); - - } - - /** - *
- * - * @since SDNO 0.5 - */ - @Test - public void testSelectHeaderContentType() { - final String[] accepts = {"application/json", "text/plain", "application/xml"}; - String expected = "application/json"; - String actual = HttpUtil.selectHeaderContentType(accepts); - Assert.assertEquals(expected, actual); - - accepts[0] = "application/x-www-form-urlencoded"; - expected = "application/x-www-form-urlencoded"; - actual = HttpUtil.selectHeaderContentType(accepts); - Assert.assertEquals(expected, actual); - - expected = "application/json"; - actual = HttpUtil.selectHeaderContentType(new String[] {}); - Assert.assertEquals(expected, actual); - } - - /** - *
- * - * @throws Exception - * @since SDNO 0.5 - */ - @Test - public void testEscapeString() throws Exception { - final String str = "/this/url/to be encoded"; - final String actual = HttpUtil.escapeString(str); - final String expected = "%2Fthis%2Furl%2Fto%20be%20encoded"; - Assert.assertEquals(expected, actual); - } - - /** - *
- * - * @throws Exception - * @since SDNO 0.5 - */ - @Ignore - @Test - public void testEscapeStringException() throws Exception { - - final String str = "/this/url/to be encoded"; - new NonStrictExpectations() { - - @Mocked - URLEncoder encoder; - - { - URLEncoder.encode(str, "utf8"); - result = new UnsupportedEncodingException(); - } - }; - - final String actual = HttpUtil.escapeString(str); - Assert.assertEquals(str, actual); - } -} diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestJsonUtil.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestJsonUtil.java deleted file mode 100644 index d532b94..0000000 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestJsonUtil.java +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.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 org.openo.baseservice.roa.util.clientsdk; - -import org.openo.baseservice.roa.util.clientsdk.demo.JsonTestClass; - -import org.codehaus.jackson.JsonParseException; -import org.codehaus.jackson.map.JsonMappingException; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; - -import net.sf.json.JSONObject; - -import junit.framework.Assert; - -/** - *
- *

- *

- * - * @author - * @version SDNO 0.5 13-Jun-2016 - */ -public class TestJsonUtil { - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @Before - public void setUp() throws Exception { - } - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @After - public void tearDown() throws Exception { - } - - /** - *
- * - * @throws Exception - * @since SDNO 0.5 - */ - @Test - public void testUnMarshalStringClassOfT() throws Exception { - final String name = "myname"; - final int id = 25; - final String jsonstr = "{\"name\": \"" + name + "\", \"id\": " + id + "}"; - - final JsonTestClass jsonObj = JsonUtil.unMarshal(jsonstr, JsonTestClass.class); - - Assert.assertNotNull(jsonObj); - Assert.assertEquals(name, jsonObj.getName()); - Assert.assertEquals(id, jsonObj.getId()); - - } - - /** - *
- * - * @throws Exception - * @since SDNO 0.5 - */ - @Test - public void testUnMarshalStringTypeReferenceOfT() throws Exception { - final String name = "myname"; - final int id = 25; - final String jsonstr = "{\"name\": \"" + name + "\", \"id\": " + id + "}"; - - final JsonTestClass jsonObj = JsonUtil.unMarshal(jsonstr, new TypeReference() {}); - - Assert.assertNotNull(jsonObj); - Assert.assertEquals(name, jsonObj.getName()); - Assert.assertEquals(id, jsonObj.getId()); - } - - /** - *
- * - * @throws Exception - * @since SDNO 0.5 - */ - @Test - public void testMarshal() throws Exception { - final JsonTestClass jsonObj = new JsonTestClass(); - jsonObj.setId(1); - jsonObj.setName("somename"); - final String str = JsonUtil.marshal(jsonObj); - final JSONObject json = JSONObject.fromObject(str); - Assert.assertNotNull(json); - Assert.assertEquals(json.getString("name"), jsonObj.getName()); - Assert.assertEquals(json.getInt("id"), jsonObj.getId()); - - } - - /** - *
- * - * @throws Exception - * @since SDNO 0.5 - */ - @Test - public void testMarshalJsonObj() throws Exception { - final JSONObject jsonObj = new JSONObject(); - jsonObj.put("id", 10); - jsonObj.put("name", "some-name"); - final String str = JsonUtil.marshal(jsonObj); - final JSONObject json = JSONObject.fromObject(str); - Assert.assertNotNull(json); - Assert.assertEquals(json.getString("name"), "some-name"); - Assert.assertEquals(json.getInt("id"), 10); - - } - - /** - *
- * - * @throws JsonParseException - * @throws JsonMappingException - * @throws Exception - * @since SDNO 0.5 - */ - @Test - public void testGetMapper() throws JsonParseException, JsonMappingException, Exception { - final String name = "myname"; - final int id = 25; - final ObjectMapper mapper = JsonUtil.getMapper(); - Assert.assertNotNull(mapper); - final JSONObject json = new JSONObject(); - json.put("name", name); - json.put("id", id); - final JsonTestClass jsonObj = mapper.readValue(json.toString(), JsonTestClass.class); - Assert.assertNotNull(jsonObj); - Assert.assertEquals(name, jsonObj.getName()); - Assert.assertEquals(id, jsonObj.getId()); - } -} diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestRestClientUtil.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestRestClientUtil.java deleted file mode 100644 index 0fcaf40..0000000 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/TestRestClientUtil.java +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.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 org.openo.baseservice.roa.util.clientsdk; - -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.restclient.Restful; -import org.openo.baseservice.roa.util.restclient.RestfulAsyncCallback; -import org.openo.baseservice.roa.util.restclient.RestfulParametes; -import org.openo.baseservice.roa.util.restclient.RestfulResponse; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; -import org.junit.rules.ExpectedException; - -import java.util.Arrays; -import java.util.Date; - -import junit.framework.Assert; -import mockit.Expectations; -import mockit.Mocked; - -/** - *
- *

- *

- * - * @author - * @version SDNO 0.5 13-Jun-2016 - */ -public class TestRestClientUtil { - - @Mocked - Restful restFullMock; - - ExpectedException thrown = ExpectedException.none();; - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception { - } - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @AfterClass - public static void tearDownAfterClass() throws Exception { - } - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @Before - public void setUp() throws Exception { - } - - /** - *
- * - * @throws java.lang.Exception - * @since SDNO 0.5 - */ - @After - public void tearDown() throws Exception { - } - - /** - *
- * - * @throws ServiceException - * @since SDNO 0.5 - */ - @Ignore - @Test - public void testInvokeMethod() throws ServiceException { - final String path = "test/path"; - final RestfulParametes parameters = null; - final RestfulResponse expected = new RestfulResponse(); - expected.setStatus(200); - - new Expectations() { - - { - restFullMock.get(path, parameters); - returns(expected); - - restFullMock.post(path, parameters); - returns(expected); - - restFullMock.patch(path, parameters); - returns(expected); - - restFullMock.delete(path, parameters); - returns(expected); - - restFullMock.put(path, parameters); - returns(expected); - } - }; - RestfulResponse actual = RestClientUtil.invokeMethod("GET", path, parameters, restFullMock); - Assert.assertEquals(200, actual.getStatus()); - - actual = RestClientUtil.invokeMethod("POST", path, parameters, restFullMock); - Assert.assertEquals(200, actual.getStatus()); - - actual = RestClientUtil.invokeMethod("PATCH", path, parameters, restFullMock); - Assert.assertEquals(200, actual.getStatus()); - - actual = RestClientUtil.invokeMethod("DELETE", path, parameters, restFullMock); - Assert.assertEquals(200, actual.getStatus()); - - actual = RestClientUtil.invokeMethod("PUT", path, parameters, restFullMock); - Assert.assertEquals(200, actual.getStatus()); - } - - @Ignore - @Test(expected = ServiceException.class) - public void testInvokeMethodException() throws ServiceException { - RestClientUtil.invokeMethod("UNKNOWN-METHOD", "some/path", null, restFullMock); - } - - /** - *
- * - * @throws ServiceException - * @since SDNO 0.5 - */ - @Ignore - @Test(expected = ServiceException.class) - public void testInvokeAsyncMethod() throws ServiceException { - final String path = "test/path"; - final RestfulParametes parameters = null; - final RestfulAsyncCallback callback = null; - - RestClientUtil.invokeAsyncMethod("GET", path, parameters, restFullMock, callback); - - RestClientUtil.invokeAsyncMethod("POST", path, parameters, restFullMock, callback); - - RestClientUtil.invokeAsyncMethod("PATCH", path, parameters, restFullMock, callback); - - RestClientUtil.invokeAsyncMethod("DELETE", path, parameters, restFullMock, callback); - - RestClientUtil.invokeAsyncMethod("PUT", path, parameters, restFullMock, callback); - - RestClientUtil.invokeAsyncMethod("UNKNOWN", path, parameters, restFullMock, callback); - } - - /** - *
- * - * @since SDNO 0.5 - */ - @Ignore - @Test - public void testIsPrimitive() { - - Assert.assertTrue(RestClientUtil.isPrimitive(Integer.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(Long.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(Double.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(Void.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(String.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(Boolean.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(Byte.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(Character.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(Short.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(Float.class)); - - Assert.assertTrue(RestClientUtil.isPrimitive(int.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(long.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(double.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(void.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(boolean.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(byte.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(char.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(short.class)); - Assert.assertTrue(RestClientUtil.isPrimitive(float.class)); - - Assert.assertFalse(RestClientUtil.isPrimitive(Object.class)); - Assert.assertFalse(RestClientUtil.isPrimitive(Date.class)); - Assert.assertFalse(RestClientUtil.isPrimitive(Arrays.class)); - } -} diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/demo/JsonTestClass.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/demo/JsonTestClass.java deleted file mode 100644 index 5833bca..0000000 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/clientsdk/demo/JsonTestClass.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. - * - * Licensed under the Apache License, Version 2.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 org.openo.baseservice.roa.util.clientsdk.demo; - -/** - *
- *

- *

- * - * @author - * @version SDNO 0.5 13-Jun-2016 - */ -public class JsonTestClass { - - /** - * - */ - private String name; - - /** - * - */ - private int id; - - /** - * Constructor
- *

- *

- * - * @since SDNO 0.5 - */ - public JsonTestClass() { - } - - /** - *
- * - * @return - * @since SDNO 0.5 - */ - public String getName() { - return name; - } - - /** - *
- * - * @param name - * @since SDNO 0.5 - */ - public void setName(String name) { - this.name = name; - } - - /** - *
- * - * @return - * @since SDNO 0.5 - */ - public int getId() { - return id; - } - - /** - *
- * - * @param id - * @since SDNO 0.5 - */ - public void setId(int id) { - this.id = id; - } -} diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestHttpRest.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestHttpRest.java index ac8b4a8..47d4ac8 100644 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestHttpRest.java +++ b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestHttpRest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,8 +19,10 @@ package org.openo.baseservice.roa.util.restclient; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; -import org.openo.baseservice.remoteservice.exception.ServiceException; -import org.openo.baseservice.roa.util.ServiceUtil; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Field; +import java.net.URLEncoder; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpExchange; @@ -29,18 +31,12 @@ import org.junit.AfterClass; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.runner.RunWith; +import org.openo.baseservice.remoteservice.exception.ServiceException; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.Field; -import java.net.URLEncoder; - -import mockit.Expectations; import mockit.Mock; import mockit.MockUp; import mockit.Mocked; @@ -53,7 +49,7 @@ import mockit.integration.junit4.JMockit; *

* * @author - * @version SDNO 0.5 13-Jun-2016 + * @version 13-Jun-2016 */ @RunWith(JMockit.class) public class TestHttpRest { @@ -65,7 +61,7 @@ public class TestHttpRest { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -75,7 +71,7 @@ public class TestHttpRest { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @AfterClass public static void tearDownAfterClass() throws Exception { @@ -85,7 +81,7 @@ public class TestHttpRest { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @Before public void setUp() throws Exception { @@ -95,7 +91,7 @@ public class TestHttpRest { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @After public void tearDown() throws Exception { @@ -105,7 +101,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testInitHttpRest() throws Exception { @@ -128,7 +124,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testInitHttpRestExcpetion() throws Exception { @@ -154,7 +150,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testInitHttpRestNull() throws Exception { @@ -169,7 +165,7 @@ public class TestHttpRest { * * @throws NoSuchFieldException * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testCreateRestHttpContentExchange() throws NoSuchFieldException, Exception { @@ -197,7 +193,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testGetStringRestfulParametes() throws Exception { @@ -235,7 +231,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testGetStringRestfulParametesRestfulOptions() throws Exception { @@ -266,9 +262,8 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ - @Ignore @Test public void testGetStringRestfulParametesEncodeError() throws Exception { final RestfulOptions options = new RestfulOptions(); @@ -321,7 +316,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testHeadStringRestfulParametes() throws Exception { @@ -358,9 +353,8 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ - @Ignore @Test public void testHeadStringRestfulParametesRestfulOptions() throws Exception { final RestfulOptions options = new RestfulOptions(); @@ -388,20 +382,6 @@ public class TestHttpRest { parametes.put("address", null); parametes.putHttpContextHeader("Content-Type", ""); parametes.putHttpContextHeader("Accept-Encoding", ""); - new Expectations() { - - ServiceUtil serviceUtil; - - { - serviceUtil = new ServiceUtil(anyString, anyString); - serviceUtil.getServiceHost(); - returns("127.0.0.1"); - - serviceUtil.getServicePort(); - returns(10); - } - - }; final RestfulResponse response = httpRest.head("path/to/service", parametes, options); assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus()); } @@ -412,7 +392,7 @@ public class TestHttpRest { * @param options * @return * @throws ServiceException - * @since SDNO 0.5 + * @since */ private HttpRest getHttpRest(final RestfulOptions options) throws ServiceException { final HttpRest httpRest = new HttpRest(); @@ -439,7 +419,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testAsyncGetStringRestfulParametesRestfulAsyncCallback() throws Exception { @@ -486,7 +466,7 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ @Test public void testAsyncGetStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws ServiceException { @@ -533,9 +513,8 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ - @Ignore @Test public void testPutStringRestfulParametes() throws ServiceException { final RestfulOptions options = new RestfulOptions(); @@ -563,20 +542,6 @@ public class TestHttpRest { parametes.put("address", null); parametes.putHttpContextHeader("Content-Type", ""); parametes.putHttpContextHeader("Accept-Encoding", ""); - new Expectations() { - - ServiceUtil serviceUtil; - - { - serviceUtil = new ServiceUtil(anyString, anyString); - serviceUtil.getServiceHost(); - returns("127.0.0.1"); - - serviceUtil.getServicePort(); - returns(-1); - } - - }; final RestfulResponse response = httpRest.put("path/to/service", parametes); assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus()); } @@ -585,9 +550,8 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ - @Ignore @Test public void testPutStringRestfulParametesRestfulOptions() throws ServiceException { @@ -616,20 +580,6 @@ public class TestHttpRest { parametes.put("address", null); parametes.putHttpContextHeader("Content-Type", ""); parametes.putHttpContextHeader("Accept-Encoding", ""); - new Expectations() { - - ServiceUtil serviceUtil; - - { - serviceUtil = new ServiceUtil(anyString, anyString); - serviceUtil.getServiceHost(); - returns("127.0.0.1"); - - serviceUtil.getServicePort(); - returns(10); - } - - }; final RestfulResponse response = httpRest.put("path/to/service", parametes, null); assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus()); } @@ -638,7 +588,7 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ @Test public void testAsyncPutStringRestfulParametesRestfulAsyncCallback() throws ServiceException { @@ -685,7 +635,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testAsyncPutStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws Exception { @@ -732,7 +682,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testPostStringRestfulParametes() throws Exception { @@ -772,9 +722,8 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ - @Ignore @Test public void testPostStringRestfulParametesRestfulOptions() throws ServiceException { final RestfulOptions options = new RestfulOptions(); @@ -803,20 +752,6 @@ public class TestHttpRest { parameters.setRawData("{ \"data\"=\"sample JSON data\""); parameters.putHttpContextHeader("Content-Type", ""); parameters.putHttpContextHeader("Accept-Encoding", ""); - new Expectations() { - - ServiceUtil serviceUtil; - - { - serviceUtil = new ServiceUtil(anyString, anyString); - serviceUtil.getServiceHost(); - returns("127.0.0.1"); - - serviceUtil.getServicePort(); - returns(10); - } - - }; thrown.expect(ServiceException.class); thrown.expectMessage("request is exception"); final RestfulResponse response = httpRest.post("path/to/service", parameters, null); @@ -827,7 +762,7 @@ public class TestHttpRest { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testAsyncPostStringRestfulParametesRestfulAsyncCallback() throws Exception { @@ -875,7 +810,7 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ @Test public void testAsyncPostStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws ServiceException { @@ -923,7 +858,7 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ @Test public void testDeleteStringRestfulParametes() throws ServiceException { @@ -939,9 +874,8 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ - @Ignore @Test public void testDeleteStringRestfulParametesRestfulOptions() throws ServiceException { final RestfulOptions options = new RestfulOptions(); @@ -970,20 +904,6 @@ public class TestHttpRest { parameters.setRawData("{ \"data\"=\"sample JSON data\""); parameters.putHttpContextHeader("Content-Type", ""); parameters.putHttpContextHeader("Accept-Encoding", ""); - new Expectations() { - - ServiceUtil serviceUtil; - - { - serviceUtil = new ServiceUtil(anyString, anyString); - serviceUtil.getServiceHost(); - returns("127.0.0.1"); - - serviceUtil.getServicePort(); - returns(10); - } - - }; final RestfulResponse response = httpRest.delete("path/to/service", parameters, options); assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus()); } @@ -992,7 +912,7 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ @Test public void testAsyncDeleteStringRestfulParametesRestfulAsyncCallback() throws ServiceException { @@ -1040,7 +960,7 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ @Test public void testAsyncDeleteStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws ServiceException { @@ -1088,9 +1008,8 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ - @Ignore @Test public void testPatchStringRestfulParametes() throws ServiceException { final RestfulOptions options = new RestfulOptions(); @@ -1119,20 +1038,6 @@ public class TestHttpRest { parameters.setRawData("{ \"data\"=\"sample JSON data\""); parameters.putHttpContextHeader("Content-Type", ""); parameters.putHttpContextHeader("Accept-Encoding", ""); - new Expectations() { - - ServiceUtil serviceUtil; - - { - serviceUtil = new ServiceUtil(anyString, anyString); - serviceUtil.getServiceHost(); - returns("127.0.0.1"); - - serviceUtil.getServicePort(); - returns(10); - } - - }; final RestfulResponse response = httpRest.patch("path/to/service", parameters); assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus()); } @@ -1141,9 +1046,8 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ - @Ignore @Test public void testPatchStringRestfulParametesRestfulOptions() throws ServiceException { final RestfulOptions options = new RestfulOptions(); @@ -1172,20 +1076,6 @@ public class TestHttpRest { parameters.setRawData("{ \"data\"=\"sample JSON data\""); parameters.putHttpContextHeader("Content-Type", ""); parameters.putHttpContextHeader("Accept-Encoding", ""); - new Expectations() { - - ServiceUtil serviceUtil; - - { - serviceUtil = new ServiceUtil(anyString, anyString); - serviceUtil.getServiceHost(); - returns("127.0.0.1"); - - serviceUtil.getServicePort(); - returns(10); - } - - }; final RestfulResponse response = httpRest.patch("path/to/service", parameters, options); assertEquals(HttpExchange.STATUS_COMPLETED, response.getStatus()); } @@ -1194,7 +1084,7 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ @Test public void testAsyncPatchStringRestfulParametesRestfulAsyncCallback() throws ServiceException { @@ -1242,7 +1132,7 @@ public class TestHttpRest { *
* * @throws ServiceException - * @since SDNO 0.5 + * @since */ @Test public void testAsyncPatchStringRestfulParametesRestfulOptionsRestfulAsyncCallback() throws ServiceException { diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestHttpContentExchange.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestHttpContentExchange.java index 094e43d..8575e0c 100644 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestHttpContentExchange.java +++ b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestHttpContentExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -63,7 +63,7 @@ import mockit.integration.junit4.JMockit; *

* * @author - * @version SDNO 0.5 20-Jun-2016 + * @version 20-Jun-2016 */ @RunWith(JMockit.class) public class TestRestHttpContentExchange { @@ -78,7 +78,7 @@ public class TestRestHttpContentExchange { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -88,7 +88,7 @@ public class TestRestHttpContentExchange { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @AfterClass public static void tearDownAfterClass() throws Exception { @@ -98,7 +98,7 @@ public class TestRestHttpContentExchange { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @Before public void setUp() throws Exception { @@ -108,7 +108,7 @@ public class TestRestHttpContentExchange { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @After public void tearDown() throws Exception { @@ -119,7 +119,7 @@ public class TestRestHttpContentExchange { *
* * @throws IOException - * @since SDNO 0.5 + * @since */ @Test public void testOnRequestCommitted() throws IOException { @@ -137,7 +137,7 @@ public class TestRestHttpContentExchange { *
* * @throws IOException - * @since SDNO 0.5 + * @since */ @Test public void testOnRequestComplete() throws IOException { @@ -155,7 +155,7 @@ public class TestRestHttpContentExchange { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testOnResponseComplete() throws Exception { @@ -199,7 +199,7 @@ public class TestRestHttpContentExchange { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testDecompressGzipToStr() throws Exception { @@ -242,7 +242,7 @@ public class TestRestHttpContentExchange { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testDecompressGzipToStrException() throws Exception { @@ -294,7 +294,7 @@ public class TestRestHttpContentExchange { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testDecompressGzipToStrNull() throws Exception { @@ -314,7 +314,7 @@ public class TestRestHttpContentExchange { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testOnResponseHeaderBufferBuffer() throws Exception { @@ -352,7 +352,7 @@ public class TestRestHttpContentExchange { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testOnExceptionThrowable() { @@ -366,7 +366,7 @@ public class TestRestHttpContentExchange { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testOnExceptionThrowableWithCallback() { @@ -397,7 +397,7 @@ public class TestRestHttpContentExchange { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testOnConnectionFailedThrowable() { @@ -411,7 +411,7 @@ public class TestRestHttpContentExchange { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testOnConnectionFailedThrowableException() { @@ -442,7 +442,7 @@ public class TestRestHttpContentExchange { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testExpireHttpDestination() { @@ -457,7 +457,7 @@ public class TestRestHttpContentExchange { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testExpireHttpDestinationException() throws Exception { @@ -494,7 +494,7 @@ public class TestRestHttpContentExchange { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testIsGzip() throws Exception { @@ -533,7 +533,7 @@ public class TestRestHttpContentExchange { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testGetResponse() throws Exception { @@ -565,7 +565,7 @@ public class TestRestHttpContentExchange { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ @Test public void testGetResponseGzip() throws Exception { diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulConfigure.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulConfigure.java index 30b5620..7cc7b1e 100644 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulConfigure.java +++ b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulConfigure.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,8 +24,8 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; -import org.junit.Ignore; import org.junit.Test; +import org.junit.runner.RunWith; import net.sf.json.JSONObject; @@ -35,6 +35,7 @@ import java.net.URL; import mockit.Mock; import mockit.MockUp; +import mockit.integration.junit4.JMockit; /** *
@@ -42,15 +43,16 @@ import mockit.MockUp; *

* * @author - * @version SDNO 0.5 20-Jun-2016 + * @version 20-Jun-2016 */ +@RunWith(JMockit.class) public class TestRestfulConfigure { /** *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -61,7 +63,7 @@ public class TestRestfulConfigure { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @AfterClass public static void tearDownAfterClass() throws Exception { @@ -71,7 +73,7 @@ public class TestRestfulConfigure { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @Before public void setUp() throws Exception { @@ -81,7 +83,7 @@ public class TestRestfulConfigure { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @After public void tearDown() throws Exception { @@ -106,11 +108,9 @@ public class TestRestfulConfigure { /** *
- * * @throws Exception - * @since SDNO 0.5 + * @since */ - @Ignore @Test public final void testRestfulConfigure() throws Exception { final RestfulConfigure configure = new RestfulConfigure(); @@ -126,11 +126,9 @@ public class TestRestfulConfigure { /** *
- * * @throws Exception - * @since SDNO 0.5 + * @since */ - @Ignore @Test public final void testRestfulConfigureAppRootNull() throws Exception { new MockUp() { @@ -157,9 +155,8 @@ public class TestRestfulConfigure { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ - @Ignore @Test public final void testRestfulConfigureDefault() throws Exception { @@ -188,9 +185,8 @@ public class TestRestfulConfigure { *
* * @throws Exception - * @since SDNO 0.5 + * @since */ - @Ignore @Test public final void testRestfulConfigureException() throws Exception { @@ -214,11 +210,9 @@ public class TestRestfulConfigure { } /** - *
* - * @since SDNO 0.5 + * @since */ - @Ignore @Test public final void testRestfulConfigureString() { final String configFile = "rest-client-test.json"; @@ -236,9 +230,8 @@ public class TestRestfulConfigure { /** *
* - * @since SDNO 0.5 + * @since */ - @Ignore @Test public final void testGetOptions() { } diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulFactory.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulFactory.java index 70c7dea..5678732 100644 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulFactory.java +++ b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,9 +26,11 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; +import org.junit.runner.RunWith; import mockit.Mock; import mockit.MockUp; +import mockit.integration.junit4.JMockit; /** *
@@ -36,15 +38,16 @@ import mockit.MockUp; *

* * @author - * @version SDNO 0.5 21-Jun-2016 + * @version 21-Jun-2016 */ +@RunWith(JMockit.class) public class TestRestfulFactory { /** *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -54,7 +57,7 @@ public class TestRestfulFactory { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @AfterClass public static void tearDownAfterClass() throws Exception { @@ -64,7 +67,7 @@ public class TestRestfulFactory { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @Before public void setUp() throws Exception { @@ -74,7 +77,7 @@ public class TestRestfulFactory { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @After public void tearDown() throws Exception { @@ -83,7 +86,7 @@ public class TestRestfulFactory { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetRestInstance() { diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulOptions.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulOptions.java index 624f54c..b91bbef 100644 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulOptions.java +++ b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ import mockit.integration.junit4.JMockit; *

* * @author - * @version SDNO 0.5 20-Jun-2016 + * @version 20-Jun-2016 */ @RunWith(JMockit.class) public class TestRestfulOptions { @@ -55,7 +55,7 @@ public class TestRestfulOptions { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -65,7 +65,7 @@ public class TestRestfulOptions { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @AfterClass public static void tearDownAfterClass() throws Exception { @@ -75,7 +75,7 @@ public class TestRestfulOptions { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @Before public void setUp() throws Exception { @@ -85,7 +85,7 @@ public class TestRestfulOptions { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @After public void tearDown() throws Exception { @@ -94,34 +94,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 - */ - @Test - public void testSetCalledServiceName() { - final RestfulOptions options = new RestfulOptions(); - final String serviceName = "sample-service"; - assertTrue(options.setCalledServiceName(serviceName)); - assertEquals(serviceName, options.getCalledServicName()); - } - - /** - *
- * - * @since SDNO 0.5 - */ - @Test - public void testGetCalledServicName() { - final RestfulOptions options = new RestfulOptions(); - final String serviceName = "sample-service"; - assertEquals("", options.getCalledServicName()); - options.setCalledServiceName(serviceName); - assertEquals(serviceName, options.getCalledServicName()); - } - - /** - *
- * - * @since SDNO 0.5 + * @since */ @Test public void testGetPort() { @@ -135,7 +108,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetPort() { @@ -148,7 +121,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetHost() { @@ -162,7 +135,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetHost() { @@ -175,7 +148,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetRestTimeout() { @@ -207,7 +180,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetRestTimeout() { @@ -223,7 +196,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetOption() { @@ -248,7 +221,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetIntOption() { @@ -270,7 +243,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetStringOption() { @@ -291,7 +264,7 @@ public class TestRestfulOptions { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetOption() { diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulParametes.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulParametes.java index fd6fd9f..fbe9430 100644 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulParametes.java +++ b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulParametes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ import java.util.Map; *

* * @author - * @version SDNO 0.5 21-Jun-2016 + * @version 21-Jun-2016 */ public class TestRestfulParametes { @@ -42,7 +42,7 @@ public class TestRestfulParametes { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -52,7 +52,7 @@ public class TestRestfulParametes { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @AfterClass public static void tearDownAfterClass() throws Exception { @@ -62,7 +62,7 @@ public class TestRestfulParametes { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @Before public void setUp() throws Exception { @@ -72,7 +72,7 @@ public class TestRestfulParametes { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @After public void tearDown() throws Exception { @@ -81,7 +81,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGet() { @@ -96,7 +96,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetRawData() { @@ -109,7 +109,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetRawData() { @@ -123,7 +123,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testPut() { @@ -137,7 +137,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testPutHttpContextHeaderStringString() { @@ -149,7 +149,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testPutHttpContextHeaderStringInt() { @@ -161,7 +161,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetHttpContextHeader() { @@ -175,7 +175,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetParamMap() { @@ -188,7 +188,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetParamMap() { @@ -203,7 +203,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetHeaderMap() { @@ -216,7 +216,7 @@ public class TestRestfulParametes { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetHeaderMap() { diff --git a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulResponse.java b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulResponse.java index c837aec..19fc7d5 100644 --- a/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulResponse.java +++ b/rest-client/src/test/java/org/openo/baseservice/roa/util/restclient/TestRestfulResponse.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Huawei Technologies Co., Ltd. + * Copyright 2016 Huawei Technologies Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ import java.util.Map; *

* * @author - * @version SDNO 0.5 20-Jun-2016 + * @version 20-Jun-2016 */ public class TestRestfulResponse { @@ -50,7 +50,7 @@ public class TestRestfulResponse { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -60,7 +60,7 @@ public class TestRestfulResponse { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @AfterClass public static void tearDownAfterClass() throws Exception { @@ -70,7 +70,7 @@ public class TestRestfulResponse { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @Before public void setUp() throws Exception { @@ -80,7 +80,7 @@ public class TestRestfulResponse { *
* * @throws java.lang.Exception - * @since SDNO 0.5 + * @since */ @After public void tearDown() throws Exception { @@ -89,7 +89,7 @@ public class TestRestfulResponse { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetStatus() { @@ -107,7 +107,7 @@ public class TestRestfulResponse { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetStatus() { @@ -121,7 +121,7 @@ public class TestRestfulResponse { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetRespHeaderMap() { @@ -140,7 +140,7 @@ public class TestRestfulResponse { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetRespHeaderMap() { @@ -159,7 +159,7 @@ public class TestRestfulResponse { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetRespHeaderInt() { @@ -186,7 +186,7 @@ public class TestRestfulResponse { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetRespHeaderLong() { @@ -220,7 +220,7 @@ public class TestRestfulResponse { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetRespHeaderStr() { @@ -244,7 +244,7 @@ public class TestRestfulResponse { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testGetResponseContent() { @@ -259,7 +259,7 @@ public class TestRestfulResponse { /** *
* - * @since SDNO 0.5 + * @since */ @Test public void testSetResponseJson() { -- cgit 1.2.3-korg