java/sql-java-prihlasovani/test/cz/frantovo/jaas/sql/SQLRealmTest.java
author František Kučera <franta-hg@frantovo.cz>
Tue, 07 Feb 2012 00:27:39 +0100
changeset 6 aff44e80f418
parent 5 e013564c8e6f
child 7 46bb283a674d
permissions -rw-r--r--
Napojení na SQL databázi.
     1 package cz.frantovo.jaas.sql;
     2 
     3 import com.sun.enterprise.security.auth.realm.BadRealmException;
     4 import com.sun.enterprise.security.auth.realm.NoSuchRealmException;
     5 import java.util.Properties;
     6 import org.junit.Before;
     7 import org.junit.Test;
     8 import static org.junit.Assert.*;
     9 
    10 /**
    11  *
    12  * @author fiki
    13  */
    14 public class SQLRealmTest {
    15 
    16 	private static final String JAAS_KONTEXT = "sqlRealm_123456";
    17 	private SQLRealm realm;
    18 
    19 	@Before
    20 	public void setUp() throws BadRealmException, NoSuchRealmException {
    21 		Properties parametry = new Properties();
    22 		parametry.setProperty(SQLRealm.JAAS_CONTEXT_PARAM, JAAS_KONTEXT);
    23 
    24 		realm = new SQLRealm();
    25 		realm.init(parametry);
    26 	}
    27 
    28 	@Test
    29 	public void testJaasKontext() {
    30 		String kontext = realm.getJAASContext();
    31 		System.out.println("jaasContext = " + kontext);
    32 		assertEquals("Kontext je jiný, než jsme nastavili v init parametrech.", JAAS_KONTEXT, kontext);
    33 	}
    34 
    35 	@Test
    36 	public void testGetAuthType() {
    37 		String authType = realm.getAuthType();
    38 		System.out.println("authType = " + authType);
    39 		assertTrue("authType musí být nenulový", authType != null);
    40 		assertTrue("authType musí být neprázdný", authType.trim().length() > 0);
    41 	}
    42 }