1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/java/sql-java-prihlasovani/test/cz/frantovo/jaas/sql/SQLRealmTest.java Thu Jul 21 23:41:05 2011 +0200
1.3 @@ -0,0 +1,41 @@
1.4 +package cz.frantovo.jaas.sql;
1.5 +
1.6 +import com.sun.enterprise.security.auth.realm.BadRealmException;
1.7 +import com.sun.enterprise.security.auth.realm.NoSuchRealmException;
1.8 +import java.util.Properties;
1.9 +import org.junit.Before;
1.10 +import org.junit.Test;
1.11 +import static org.junit.Assert.*;
1.12 +
1.13 +/**
1.14 + *
1.15 + * @author fiki
1.16 + */
1.17 +public class SQLRealmTest {
1.18 +
1.19 + private static final String JAAS_KONTEXT = "sqlRealm_123456";
1.20 + private SQLRealm realm;
1.21 +
1.22 + @Before
1.23 + public void setUp() throws BadRealmException, NoSuchRealmException {
1.24 + Properties parametry = new Properties();
1.25 + parametry.setProperty(SQLRealm.JAAS_CONTEXT_PARAM, JAAS_KONTEXT);
1.26 +
1.27 + realm = new SQLRealm();
1.28 + realm.init(parametry);
1.29 + }
1.30 +
1.31 + @Test
1.32 + public void testJaasKontext() {
1.33 + String kontext = realm.getJAASContext();
1.34 + System.out.println("jaasContext = " + kontext);
1.35 + assertEquals("Kontext je jiný, než jsme nastavili v init parametrech.", JAAS_KONTEXT, kontext);
1.36 + }
1.37 +
1.38 + @Test
1.39 + public void testGetAuthType() {
1.40 + String authType = realm.getAuthType();
1.41 + System.out.println("authType = " + authType);
1.42 + assertTrue("authType musí být nenulový a neprázdný", authType != null && authType.trim().length() > 0);
1.43 + }
1.44 +}