piyushghai commented on a change in pull request #13807: [MXNET-1180] Java 
Image API
URL: https://github.com/apache/incubator-mxnet/pull/13807#discussion_r248414724
 
 

 ##########
 File path: 
scala-package/core/src/test/java/org/apache/mxnet/javaapi/ImageTest.java
 ##########
 @@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.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.apache.mxnet.javaapi;
+
+import org.apache.commons.io.FileUtils;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import java.io.File;
+import java.net.URL;
+
+import static org.junit.Assert.assertArrayEquals;
+
+public class ImageTest {
+
+    private static String imLocation;
+
+    private static void downloadUrl(String url, String filePath, int maxRetry) 
throws Exception{
+        File tmpFile = new File(filePath);
+        Boolean success = false;
+        if (!tmpFile.exists()) {
+            while (maxRetry > 0 && !success) {
+                try {
+                    FileUtils.copyURLToFile(new URL(url), tmpFile);
+                    success = true;
+                } catch(Exception e){
+                   maxRetry -= 1;
+                }
+            }
+        } else {
+            success = true;
+        }
+        if (!success) throw new Exception("$url Download failed!");
+    }
+
+    @BeforeClass
+    public static void downloadFile() throws Exception {
+        String tempDirPath = System.getProperty("java.io.tmpdir");
+        imLocation = tempDirPath + "/inputImages/Pug-Cookie.jpg";
+        try {
+            
downloadUrl("https://s3.amazonaws.com/model-server/inputs/Pug-Cookie.jpg";,
+                    imLocation, 3);
+        } catch (Exception e) {
 
 Review comment:
   If you are re-throwing the same exception, then you don't need to catch it, 
as your method signature already says that it'll throw an ex.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to