Clover Coverage Report - Pebble 2.5-SNAPSHOT
Coverage timestamp: Sat Jun 12 2010 09:39:29 EST
19   51   3   6,33
0   34   0,16   3
3     1  
1    
This report was generated with an evaluation server license. Purchase Clover or configure your license.
 
  PebbleUserDetailsTest       Line # 16 19 0% 3 0 100% 1.0
 
  (4)
 
1    package net.sourceforge.pebble.security;
2   
3    import junit.framework.TestCase;
4    import net.sourceforge.pebble.Constants;
5    import org.acegisecurity.GrantedAuthorityImpl;
6   
7    import java.util.Arrays;
8    import java.util.List;
9    import java.util.HashMap;
10   
11    /**
12    * Tests for the PebbleUserDetails class.
13    *
14    * @author Simon Brown
15    */
 
16    public class PebbleUserDetailsTest extends TestCase {
17   
18    private PebbleUserDetails user;
19   
 
20  4 toggle protected void setUp() throws Exception {
21  4 user = new PebbleUserDetails("username", "password", "A user", "emailAddress", "website", "profile", new String[] {Constants.BLOG_OWNER_ROLE}, new HashMap<String,String>(), true);
22    }
23   
 
24  2 toggle public void testConstruction() {
25  2 assertEquals("username", user.getUsername());
26  2 assertEquals("password", user.getPassword());
27  2 assertEquals("A user", user.getName());
28  2 assertEquals("emailAddress", user.getEmailAddress());
29  2 assertEquals("website", user.getWebsite());
30   
31  2 List authorities = Arrays.asList(user.getAuthorities());
32  2 assertEquals(2, authorities.size());
33  2 assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_OWNER_ROLE)));
34  2 assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_READER_ROLE)));
35    }
36   
 
37  2 toggle public void testConstructionWithNoExplicitRoles() {
38  2 user = new PebbleUserDetails("username", "password", "A user", "emailAddress", "website", "profile", null, new HashMap<String,String>(), true);
39   
40  2 assertEquals("username", user.getUsername());
41  2 assertEquals("password", user.getPassword());
42  2 assertEquals("A user", user.getName());
43  2 assertEquals("emailAddress", user.getEmailAddress());
44  2 assertEquals("website", user.getWebsite());
45   
46  2 List authorities = Arrays.asList(user.getAuthorities());
47  2 assertEquals(1, authorities.size());
48  2 assertTrue(authorities.contains(new GrantedAuthorityImpl(Constants.BLOG_READER_ROLE)));
49    }
50   
51    }