Project

General

Profile

Revision 54056cbe

ID54056cbecdf853c3ee9c3a24b41bc37a4cc4ee0c
Parent a0d0bb14
Child d2804b99

Added by Cherian Mathew over 8 years ago

added test from CDM Authority parsing

View differences:

.gitattributes
1459 1459
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonDaoHibernateImplTest.java -text
1460 1460
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/taxon/TaxonNodeDaoHibernateImplTest.java -text
1461 1461
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/dao/hibernate/view/AuditEventDaoTest.java -text
1462
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibenate/permission/CdmAuthorityTest.java -text
1462 1463
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/CacheStrategyGeneratorTest.java -text
1463 1464
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/CdmDeleteListenerTest.java -text
1464 1465
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibernate/replace/ReferringObjectMetadataFactoryTest.java -text
cdmlib-persistence/src/test/java/eu/etaxonomy/cdm/persistence/hibenate/permission/CdmAuthorityTest.java
1
/**
2
* Copyright (C) 2007 EDIT
3
* European Distributed Institute of Taxonomy 
4
* http://www.e-taxonomy.eu
5
* 
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9

  
10
package eu.etaxonomy.cdm.persistence.hibenate.permission;
11

  
12
import static org.junit.Assert.*;
13

  
14
import java.util.EnumSet;
15
import java.util.UUID;
16

  
17
import org.junit.Before;
18
import org.junit.Test;
19
import org.springframework.security.core.GrantedAuthority;
20

  
21
import sun.security.provider.PolicyParser.ParsingException;
22

  
23
import eu.etaxonomy.cdm.model.common.GrantedAuthorityImpl;
24
import eu.etaxonomy.cdm.persistence.hibernate.permission.CRUD;
25
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmAuthority;
26
import eu.etaxonomy.cdm.persistence.hibernate.permission.CdmPermissionClass;
27

  
28
/**
29
 * @author c.mathew
30
 * @created Mar 26, 2013
31
 * @version 1.0
32
 */
33
public class CdmAuthorityTest {
34

  
35
	private GrantedAuthorityImpl grantedAuthority;
36
	private String authority;
37
	
38
	/**
39
	 * @throws java.lang.Exception
40
	 */
41
	@Before
42
	public void setUp() throws Exception {
43
		grantedAuthority = GrantedAuthorityImpl.NewInstance();
44
		authority = "";
45
	}
46

  
47
	/**
48
	 * Test method for {@link eu.etaxonomy.cdm.persistence.hibernate.permission#getAuthority()}.
49
	 * @throws ParsingException 
50
	 */
51
	@Test
52
	public final void testGetAuthority() throws ParsingException {
53
		// create CdmAuthority object manually
54
		CdmPermissionClass tnClass = CdmPermissionClass.TAXONBASE;
55
		String property = "Taxon";
56
		EnumSet<CRUD> operation = EnumSet.noneOf(CRUD.class);
57
		operation.add(CRUD.READ);
58
		operation.add(CRUD.UPDATE);
59
		UUID uuid = UUID.fromString("e0358c98-4222-4d17-811c-7ce18bd565ee");
60
		CdmAuthority cdma = new CdmAuthority(tnClass,property, operation, uuid);
61
		String expectedAuthority = "TAXONBASE(Taxon).[READ, UPDATE]{e0358c98-4222-4d17-811c-7ce18bd565ee}";
62
		System.out.println(cdma.getAuthority());
63
		System.out.println(expectedAuthority);
64
		// check object getAuthority with expectedAuthority
65
		assertEquals(expectedAuthority, cdma.getAuthority());
66
		//check programmatic generation of CdmAuthority by parsing authority string
67
		cdma = CdmAuthority.fromGrantedAuthority(cdma);		
68
		assertEquals(expectedAuthority, cdma.getAuthority());
69
	}
70

  
71

  
72

  
73
}
74

  

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)