|
17 | 17 |
|
18 | 18 | import static com.cloudinary.utils.ObjectUtils.asArray; |
19 | 19 | import static com.cloudinary.utils.ObjectUtils.asMap; |
| 20 | +import static com.cloudinary.utils.StringUtils.isRemoteUrl; |
20 | 21 | import static org.hamcrest.Matchers.*; |
21 | 22 | import static org.junit.Assert.*; |
22 | 23 | import static org.junit.Assume.assumeNotNull; |
@@ -121,6 +122,28 @@ public void testUpload() throws IOException { |
121 | 122 | assertEquals(result.get("signature"), expected_signature); |
122 | 123 | } |
123 | 124 |
|
| 125 | + @Test |
| 126 | + public void testIsRemoteUrl() { |
| 127 | + String[] urls = new String[]{ |
| 128 | + "ftp://ftp.cloudinary.com/images/old_logo.png", |
| 129 | + "http://cloudinary.com/images/old_logo.png", |
| 130 | + "https://cloudinary.com/images/old_logo.png", |
| 131 | + "s3://s3-us-west-2.amazonaws.com/cloudinary/images/old_logo.png", |
| 132 | + "gs://cloudinary/images/old_logo.png", |
| 133 | + "data:image/gif;charset=utf8;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", |
| 134 | + "data:image/gif;param1=value1;param2=value2;base64," + |
| 135 | + "R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}; |
| 136 | + |
| 137 | + for (String url : urls) { |
| 138 | + assertTrue(isRemoteUrl(url)); |
| 139 | + } |
| 140 | + |
| 141 | + String[] invalidUrls = new String[]{"adsadasdasdasd", " ", ""}; |
| 142 | + |
| 143 | + for (String url : invalidUrls) { |
| 144 | + assertFalse(isRemoteUrl(url)); |
| 145 | + } |
| 146 | + } |
124 | 147 |
|
125 | 148 | @Test |
126 | 149 | public void testUploadUrl() throws IOException { |
|
0 commit comments