Changeset 687


Ignore:
Timestamp:
04/14/11 16:17:43 (8 years ago)
Author:
philsmart
Message:
 
Location:
raptor-client/trunk
Files:
5 added
2 edited

Legend:

Unmodified
Added
Removed
  • raptor-client/trunk/pom.xml

    r686 r687  
    3838            <version>3.0-SNAPSHOT</version> 
    3939        </dependency> 
    40          
     40 
    4141        <dependency> 
    4242            <groupId>net.shibboleth.idp</groupId> 
  • raptor-client/trunk/src/test/java/uk/ac/cardiff/raptor/event/expansion/AttributeAssociationTest.java

    r686 r687  
    1111 
    1212import net.shibboleth.idp.attribute.Attribute; 
     13import net.shibboleth.idp.attribute.resolver.AttributeResolutionContext; 
    1314import net.shibboleth.idp.attribute.resolver.AttributeResolutionException; 
    1415import net.shibboleth.idp.attribute.resolver.AttributeResolver; 
    1516import net.shibboleth.idp.attribute.resolver.BaseDataConnector; 
    16 import net.shibboleth.idp.attribute.resolver.MockDataConnector; 
     17 
    1718import net.shibboleth.idp.attribute.resolver.ResolvedDataConnector; 
    1819 
     
    2829 
    2930    @org.junit.Test 
    30     public void testSetAttributeDefinitions() { 
     31    public void testSetAttributeDefinitions() throws Exception{ 
    3132        System.out.println("Do Test"); 
    3233        AttributeResolver resolver = new AttributeResolver("foo"); 
    3334 
    34         LazySet<BaseDataConnector> connectors = null; 
    35         resolver.setDataConnectors(connectors); 
    36         Assert.assertNotNull(resolver.getDataConnectors()); 
    37         Assert.assertTrue(resolver.getDataConnectors().isEmpty()); 
     35        AttributeResolutionContext context = new AttributeResolutionContext(null); 
    3836 
    39         connectors = new LazySet<BaseDataConnector>(); 
    40         resolver.setDataConnectors(connectors); 
    41         Assert.assertNotNull(resolver.getDataConnectors()); 
    42         Assert.assertTrue(resolver.getDataConnectors().isEmpty()); 
     37        MockBaseDataConnector connector = new MockBaseDataConnector("foo", (Map<String, Attribute<?>>)null); 
     38        Assert.assertNull(connector.resolve(context)); 
    4339 
    44         connectors.add(new MockDataConnector("foo", (Map)null)); 
    45         connectors.add(null); 
    46         connectors.add(new MockDataConnector("bar", (Map)null)); 
    47         connectors.add(new MockDataConnector("foo", (Map)null)); 
    48         resolver.setDataConnectors(connectors); 
    49         Assert.assertNotNull(resolver.getDataConnectors()); 
    50         Assert.assertEquals(resolver.getDataConnectors().size(), 2); 
     40        //String id, String ldapUrl, String ldapBaseDn, boolean startTls, int maxIdle, int initIdleCapacity 
     41        LdapDataConnector ldapConnector = new LdapDataConnector("ldap","","",false,100,100); 
    5142 
    52         connectors.clear(); 
    53         Assert.assertNotNull(resolver.getDataConnectors()); 
    54         Assert.assertEquals(resolver.getDataConnectors().size(), 2); 
     43        HashMap<String, Attribute<?>> values = new HashMap<String, Attribute<?>>(); 
     44        connector = new MockBaseDataConnector("foo", values); 
     45        Assert.assertNotNull(connector.resolve(context)); 
    5546 
    56         resolver.setDataConnectors(connectors); 
    57         Assert.assertNotNull(resolver.getDataConnectors()); 
    58         Assert.assertTrue(resolver.getDataConnectors().isEmpty()); 
     47        Attribute<?> attribute = new Attribute<String>("foo"); 
     48        values.put(attribute.getId(), attribute); 
     49 
     50        connector = new MockBaseDataConnector("foo", values); 
     51        Map<String, Attribute<?>> result = connector.resolve(context); 
     52        Assert.assertTrue(result.containsKey(attribute.getId())); 
     53        Assert.assertEquals(result.get(attribute.getId()), attribute); 
     54    } 
     55 
     56 
     57    /** 
     58     * This class implements the minimal level of functionality and is meant only as a means of testing the abstract 
     59     * {@link BaseDataConnector}. 
     60     */ 
     61    private static final class MockBaseDataConnector extends BaseDataConnector { 
     62 
     63        /** Static values returned for {@link #resolve(AttributeResolutionContext)}. */ 
     64        private Map<String, Attribute<?>> staticValues; 
     65 
     66        /** 
     67         * Constructor. 
     68         * 
     69         * @param id id of the data connector 
     70         * @param values values returned for {@link #resolve(AttributeResolutionContext)} 
     71         */ 
     72        public MockBaseDataConnector(final String id, final Map<String, Attribute<?>> values) { 
     73            super(id); 
     74            staticValues = values; 
     75        } 
     76 
     77        /** {@inheritDoc} */ 
     78        protected Map<String, Attribute<?>> doDataConnectorResolve(AttributeResolutionContext resolutionContext) 
     79                throws AttributeResolutionException { 
     80            return staticValues; 
     81        } 
    5982    } 
    6083 
Note: See TracChangeset for help on using the changeset viewer.