2 * Copyright 2005-2011 the original author or authors.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.wamblee.photos.model;
19 import java.io.IOException;
20 import java.util.ArrayList;
21 import javax.servlet.http.HttpSession;
23 import org.wamblee.cache.Cache;
24 import org.wamblee.cache.EhCache;
25 import org.wamblee.io.ClassPathResource;
26 import org.wamblee.photos.model.authorization.AuthorizedAlbum;
27 import org.wamblee.security.authorization.AuthorizationService;
28 import org.wamblee.security.authorization.Operation;
29 import static org.mockito.Mockito.*;
32 * Created with IntelliJ IDEA.
36 * To change this template use File | Settings | File Templates.
38 public class AuthorizedAlbumTest extends AlbumTest {
41 protected Album createAlbum(File aDir, String aPath, Cache<String, ArrayList<PhotoEntry>> aCache)
43 Album fileSystemAlbum = super.createAlbum(aDir, aPath,
44 aCache); //To change body of overridden methods use File | Settings | File Templates.
45 AuthorizationService service = mock(AuthorizationService.class);
46 when(service.isAllowed(anyObject(), any(Operation.class))).thenReturn(true);
47 HttpSession session = mock(HttpSession.class);
48 when(session.getId()).thenReturn("myid");
49 Album authorized = new AuthorizedAlbum(fileSystemAlbum, service, createCache(), session);
54 protected Cache createCache() {
56 return new EhCache(new ClassPathResource("META-INF/ehcache.xml"), "test");
59 throw new RuntimeException(e.getMessage(), e);