|
4 | 4 |
|
5 | 5 | import static org.junit.Assert.assertNotNull; |
6 | 6 |
|
7 | | -import java.io.ByteArrayOutputStream; |
8 | | -import java.io.File; |
9 | | -import java.io.FileInputStream; |
10 | | -import java.io.IOException; |
11 | | -import java.io.InputStream; |
12 | | - |
13 | | -import org.junit.Test; |
14 | | - |
15 | 7 | import com.flickr4java.flickr.FlickrException; |
16 | 8 | import com.flickr4java.flickr.photos.PhotosInterface; |
17 | 9 | import com.flickr4java.flickr.uploader.UploadMetaData; |
18 | 10 | import com.flickr4java.flickr.uploader.Uploader; |
19 | 11 | import com.flickr4java.flickr.util.IOUtilities; |
20 | 12 |
|
| 13 | +import org.junit.Test; |
| 14 | + |
| 15 | +import java.io.ByteArrayOutputStream; |
| 16 | +import java.io.File; |
| 17 | +import java.io.FileInputStream; |
| 18 | +import java.io.IOException; |
| 19 | +import java.io.InputStream; |
| 20 | + |
21 | 21 | /** |
22 | 22 | * @author Anthony Eden |
23 | 23 | */ |
@@ -49,7 +49,15 @@ public void testUploadByteArray() throws IOException, FlickrException { |
49 | 49 | metaData.setTitle("óöä"); |
50 | 50 | String photoId = uploader.upload(out.toByteArray(), metaData); |
51 | 51 | assertNotNull(photoId); |
52 | | - pint.delete(photoId); |
| 52 | + try { |
| 53 | + pint.delete(photoId); |
| 54 | + } catch (FlickrException e) { |
| 55 | + // Ignore if user doesn't have delete permissions |
| 56 | + // This will leave a *private* photo in the test account's photostream! |
| 57 | + if (!e.getErrorCode().equals("99")) { |
| 58 | + throw e; |
| 59 | + } |
| 60 | + } |
53 | 61 | } finally { |
54 | 62 | IOUtilities.close(in); |
55 | 63 | IOUtilities.close(out); |
@@ -77,7 +85,16 @@ public void testUploadInputStream() throws IOException, FlickrException { |
77 | 85 | metaData.setTitle("óöä"); |
78 | 86 | String photoId = uploader.upload(in, metaData); |
79 | 87 | assertNotNull(photoId); |
80 | | - pint.delete(photoId); |
| 88 | + try { |
| 89 | + pint.delete(photoId); |
| 90 | + } catch (FlickrException e) { |
| 91 | + // Ignore if user doesn't have delete permissions |
| 92 | + // This will leave a *private* photo in the test account's photostream! |
| 93 | + if (!e.getErrorCode().equals("99")) { |
| 94 | + throw e; |
| 95 | + } |
| 96 | + } |
| 97 | + |
81 | 98 | } finally { |
82 | 99 | IOUtilities.close(in); |
83 | 100 | } |
@@ -119,7 +136,16 @@ public void testReplaceInputStream() throws IOException, FlickrException { |
119 | 136 | throw e; |
120 | 137 | } |
121 | 138 | } |
122 | | - pint.delete(photoId); |
| 139 | + try { |
| 140 | + pint.delete(photoId); |
| 141 | + } catch (FlickrException e) { |
| 142 | + // Ignore if user doesn't have delete permissions |
| 143 | + // This will leave a *private* photo in the test account's photostream! |
| 144 | + if (!e.getErrorCode().equals("99")) { |
| 145 | + throw e; |
| 146 | + } |
| 147 | + } |
| 148 | + |
123 | 149 | } finally { |
124 | 150 | IOUtilities.close(replaceIS); |
125 | 151 | } |
@@ -161,7 +187,16 @@ public void testReplaceByteArray() throws IOException, FlickrException { |
161 | 187 | } |
162 | 188 | } |
163 | 189 |
|
164 | | - pint.delete(photoId); |
| 190 | + try { |
| 191 | + pint.delete(photoId); |
| 192 | + } catch (FlickrException e) { |
| 193 | + // Ignore if user doesn't have delete permissions |
| 194 | + // This will leave a *private* photo in the test account's photostream! |
| 195 | + if (!e.getErrorCode().equals("99")) { |
| 196 | + throw e; |
| 197 | + } |
| 198 | + } |
| 199 | + |
165 | 200 | } finally { |
166 | 201 | IOUtilities.close(in); |
167 | 202 | } |
|
0 commit comments