Working upload of photos (individual and zip)
[photos] / src / test / java / org / wamblee / photos / model / AuthorizedAlbumTest.java
diff --git a/src/test/java/org/wamblee/photos/model/AuthorizedAlbumTest.java b/src/test/java/org/wamblee/photos/model/AuthorizedAlbumTest.java
new file mode 100644 (file)
index 0000000..549bf13
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2005-2011 the original author or authors.
+ * 
+ * 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.wamblee.photos.model;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import javax.servlet.http.HttpSession;
+
+import org.wamblee.cache.Cache;
+import org.wamblee.cache.EhCache;
+import org.wamblee.io.ClassPathResource;
+import org.wamblee.photos.model.authorization.AuthorizedAlbum;
+import org.wamblee.security.authorization.AuthorizationService;
+import org.wamblee.security.authorization.Operation;
+import static org.mockito.Mockito.*;
+
+/**
+ * Created with IntelliJ IDEA.
+ * User: erik
+ * Date: 9/23/13
+ * Time: 9:08 PM
+ * To change this template use File | Settings | File Templates.
+ */
+public class AuthorizedAlbumTest extends AlbumTest {
+
+    @Override
+    protected Album createAlbum(File aDir, String aPath, Cache<String, ArrayList<PhotoEntry>> aCache)
+            throws IOException {
+        Album fileSystemAlbum = super.createAlbum(aDir, aPath,
+                aCache);    //To change body of overridden methods use File | Settings | File Templates.
+        AuthorizationService service = mock(AuthorizationService.class);
+        when(service.isAllowed(anyObject(), any(Operation.class))).thenReturn(true);
+        HttpSession session = mock(HttpSession.class);
+        when(session.getId()).thenReturn("myid");
+        Album authorized = new AuthorizedAlbum(fileSystemAlbum, service, createCache(), session);
+        return authorized;
+    }
+
+    @Override
+    protected Cache createCache() {
+        try {
+            return new EhCache(new ClassPathResource("META-INF/ehcache.xml"), "test");
+        }
+        catch (Exception e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+    }
+}