1 package com.atlassian.user.impl.readonly;
2
3 import com.atlassian.user.EntityException;
4 import com.atlassian.user.Group;
5 import com.atlassian.user.GroupManager;
6 import com.atlassian.user.impl.DefaultGroup;
7 import com.atlassian.user.impl.memory.MemoryGroupManagerReadOnly;
8 import com.atlassian.user.impl.memory.provider.MemoryProvider;
9 import com.atlassian.user.repository.DefaultRepositoryIdentifier;
10 import com.atlassian.user.repository.RepositoryIdentifier;
11 import junit.framework.TestCase;
12
13 public class TestGroupManagerReadOnly extends TestCase
14 {
15 private GroupManager groupManager;
16
17 public void setUp() throws Exception
18 {
19 RepositoryIdentifier repository = new DefaultRepositoryIdentifier("default", "My repository");
20 MemoryProvider provider = new MemoryProvider();
21 groupManager = new MemoryGroupManagerReadOnly(repository, provider);
22 }
23
24 public void testCreateGroup()
25 {
26 try
27 {
28 groupManager.createGroup("test");
29 fail("read-only implementation is not throwing an UnsupportedOperationException when a write behaviour is called");
30 }
31 catch (EntityException e)
32 {
33 fail("Expected UnsupportedOperationException, but caught EntityException: " + e);
34 }
35 catch (UnsupportedOperationException e)
36 {
37
38 }
39 }
40
41 public void testRemoveGroup() throws EntityException
42 {
43
44 Group group = new DefaultGroup("testgroup");
45 try
46 {
47 groupManager.removeGroup(group);
48 fail("read-only implementation is not throwing an UnsupportedOperationException when a write behaviour is called");
49 }
50 catch (EntityException e)
51 {
52 fail("Expected UnsupportedOperationException, but caught EntityException: " + e);
53 }
54 catch (UnsupportedOperationException e)
55 {
56
57 }
58 }
59 }