    1   /*
    2    * Copyright (c) 2003
    3    * Information Desire GmbH
    4    * All rights reserved.
    5    */
    6   package com.infodesire.infobit;
    7
    8   import junit.framework.TestCase;
    9   import junit.framework.TestSuite;
    10
    11  import java.util.ArrayList;
    12  import com.infodesire.infobit.security.SecurityProvider;
    13  import com.infodesire.infobit.security.DefaultSecurityProvider;
    14  import com.infodesire.infobit.hibernate.SessionProvider;
    15  import com.infodesire.infobit.hibernate.ThreadLocalSessionProvider;
    16  import java.util.ArrayList;
    17
    18  /***
    19   * test infobit pool configuration
    20   *
    21   * @author    konstantin
    22   * @created   August 8, 2003
    23   * @version   $Revision: 1.5 $
    24   */
    25  public class InfobitPoolConfigurationTest extends TestCase {
    26
    27      /***
    28       * Constructor for the InfobitTest object
    29       *
    30       * @param name  Description of Parameter
    31       */
    32      public InfobitPoolConfigurationTest(String name) {
    33          super(name);
    34      }
    35
    36
    37      /***
    38       * test proper loading of configuration.
    39       *
    40       * @exception Exception  Description of Exception
    41       */
    42      public void testConfiguration() throws Exception {
    43          InfobitConfiguration configuration = InfobitConfiguration.getInstance();
    44          InfobitPool pool = configuration.getPool("pool_one");
    45          assertSame(pool, InfobitConfiguration.getInstance().getPool("pool_one"));
    46          assertSame(configuration, InfobitConfiguration.getInstance());
    47          assertEquals(pool.getName(), "pool_one");
    48
    49          assertTrue(pool.getSecurityProvider() instanceof DefaultSecurityProvider);
    50          assertTrue(pool.getSessionProvider() instanceof ThreadLocalSessionProvider);
    51
    52          // test that default security provider was configured correcly
    53          assertEquals("foo", pool.getSecurityProvider().getName());
    54          assertTrue(pool.getSecurityProvider().hasRole("foo"));
    55          assertTrue(pool.getSecurityProvider().hasRole("bar"));
    56          assertTrue(pool.getSecurityProvider().hasRole("baz"));
    57          assertTrue(pool.getSecurityProvider().hasRole("bang"));
    58          assertFalse(pool.getSecurityProvider().hasRole("blurge"));
    59
    60          ArrayList roles = new ArrayList();
    61          roles.add("blabla");
    62          roles.add("fringe");
    63          roles.add("blurge");
    64          assertFalse(pool.getSecurityProvider().hasRole(roles));
    65
    66          roles.add("bang");
    67          assertTrue(pool.getSecurityProvider().hasRole(roles));
    68      }
    69
    70  }

This page was automatically generated by Maven