Commit 0d8514fa by Adi Amir

add test function

parent 382727dc
......@@ -8,6 +8,7 @@ version = '1.0.1' + gitLog()
sourceCompatibility = 1.8
repositories {
mavenLocal()
maven { url "http://mandubian-mvn.googlecode.com/svn/trunk/mandubian-mvn/repository" }
maven { url "http://172.16.1.132:8081/repository/internal" }
}
......@@ -15,7 +16,7 @@ repositories {
dependencies {
// compile 'com.flipkart.zjsonpatch:zjsonpatch:0.2.1'
// compile group:'com.ipgallery.common', name:'microservice', version:'1.2.0'
compile group:'com.ipgallery.common', name:'microservice', version:'1.3.2'
compile group:'com.ipgallery.common', name:'microservice', version:'1.4.0-local'
compile group:'com.ipgallery.common', name:'itc', version:'1.0.0'
// compile 'com.ipgallery.common:utils:1.1.0'
compile 'io.swagger:swagger-annotations:1.5.7'
......
......@@ -36,12 +36,25 @@ response:
{
"success": true,
"error": null,
"objectNode": {"link": "../repo/public-safety/san-diego/media/camera/CAMERA-STG-HYP1052-CAM-L/latest-image/CAMERA-STG-HYP1052-CAM-L_1487807853000_0_IMAGE.JPG"}
"objectNode": {"link": "../repo/public-safety/san-diego/media/camera/CAMERA-STG-HYP1052-CAM-L/latest_image.jpg"}
}
volume:
/mcx/config/repo/public-safety
MDE ==> GET 172.16.1.72:50005/mde/api/v2/ge/media/camera/CAMERA-STG-HYP1017-CAM-L/latestImage
response:
{
"success": true,
"error": null,
"objectNode": {
"timestamp": 1488444220553,
"data": "XXXXXXXXXXXXXXXXXXXXXXXXXX"
}
}
response:
{IMAGE CONTENT}
......
......@@ -9,9 +9,23 @@ import http.simpleHttpClient.SimpleHttpRequest;
import http.simpleHttpClient.SimpleHttpResponse;
import microservice.RequestContext;
import microservice.types.BaseRestResponse;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.CookieStore;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Deque;
import java.util.Map;
......@@ -48,6 +62,7 @@ public class GEManager {
break;
case "camera":
brr = getCamera(serviceId,apiIdAsParams,requestContext,content,isMaintenanceRequest);
//brr = testGetImage(requestContext, apiIdAsParams);
break;
default:
}
......@@ -259,4 +274,42 @@ public class GEManager {
}
return newArray;
}
private BaseRestResponse testGetImage(RequestContext requestContext, String[] apiIds) {
try {
// init http client
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.Jdk14Logger");
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
registry.register(new Scheme("https", 443, SSLSocketFactory.getSocketFactory()));
ThreadSafeClientConnManager connManager = new ThreadSafeClientConnManager(registry);
connManager.setDefaultMaxPerRoute(100);
connManager.setMaxTotal(100);
DefaultHttpClient defaulthttpClient = new DefaultHttpClient(connManager);
CookieStore cookieStore = defaulthttpClient.getCookieStore();
String uri = "https://ie-cities-media.run.asv-pr-pub.ice.predix.io/v2/file/CAMERA-STG-HYP1052-CAM-L_1487807853000_0_IMAGE.JPG";
HttpGet getRequest = new HttpGet(uri);
getRequest.addHeader("Authorization", "Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6ImxlZ2FjeS10b2tlbi1rZXkiLCJ0eXAiOiJKV1QifQ.eyJqdGkiOiI4MDdlMzQxMTk5MzY0MDVlOTkyNTk1YTA5ZjhhMTExYyIsInN1YiI6ImlwZ2FsbGVyeSIsInNjb3BlIjpbImllLWN1cnJlbnQuaWNzLUlFLVBVQkxJQy1TQUZFVFkuSUUtUFVCTElDLVNBRkVUWS5MSU1JVEVELkRFVkVMT1AiLCJ1YWEucmVzb3VyY2UiLCJpZS1jdXJ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TElNSVRFRCJdfQ.tbz0Xp1ie4m5yp--bgfNW8F0SXUf1EsIJHKM6jemBI9kNKzSBIj5ef1BmyBrXPQg6Eia_553_RlobTV8UJx2tDJaiRmHnin3NxCEOTdWYicjrBFLDmP31EMhr8gTGw3xx-a540JQDp1voMysQCqGx1eUj7oIfMbD__vCYko7MRLlPtOssVkvsqUu3DVpo3lof6M2vhbwlcnXCaG6O0ScFP-lpkapzEewnvH8wWjLelntbzlE2c5IS6rhXqNlFBykwyVa6drFUxVhZf8bYwrIrfHuKrfbX0_r9AnhOoh_TGj4S8AniF8gXxS8GWg0LkXWaiqDaxmfCKvIHwiJS8LQwA");
getRequest.addHeader("Predix-Zone-Id", "ics-IE-PUBLIC-SAFETY");
HttpResponse resp = defaulthttpClient.execute(getRequest);
InputStream is = resp.getEntity().getContent();
byte[] baContent = IOUtils.toByteArray(is);
// write to file
String fileName = "/opt/mcx/config/test1.jpeg";
Path file = Paths.get(fileName);
Files.write(file, baContent);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment