JUnit testy (zatím nic moc netestují).
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/java/sql-java-prihlasovani/test/cz/frantovo/jaas/sql/SQLLoginModulTest.java Thu Jul 21 23:41:05 2011 +0200
1.3 @@ -0,0 +1,12 @@
1.4 +package cz.frantovo.jaas.sql;
1.5 +
1.6 +import org.junit.Test;
1.7 +import static org.junit.Assert.*;
1.8 +
1.9 +/**
1.10 + *
1.11 + * @author fiki
1.12 + */
1.13 +public class SQLLoginModulTest {
1.14 +
1.15 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/java/sql-java-prihlasovani/test/cz/frantovo/jaas/sql/SQLRealmTest.java Thu Jul 21 23:41:05 2011 +0200
2.3 @@ -0,0 +1,41 @@
2.4 +package cz.frantovo.jaas.sql;
2.5 +
2.6 +import com.sun.enterprise.security.auth.realm.BadRealmException;
2.7 +import com.sun.enterprise.security.auth.realm.NoSuchRealmException;
2.8 +import java.util.Properties;
2.9 +import org.junit.Before;
2.10 +import org.junit.Test;
2.11 +import static org.junit.Assert.*;
2.12 +
2.13 +/**
2.14 + *
2.15 + * @author fiki
2.16 + */
2.17 +public class SQLRealmTest {
2.18 +
2.19 + private static final String JAAS_KONTEXT = "sqlRealm_123456";
2.20 + private SQLRealm realm;
2.21 +
2.22 + @Before
2.23 + public void setUp() throws BadRealmException, NoSuchRealmException {
2.24 + Properties parametry = new Properties();
2.25 + parametry.setProperty(SQLRealm.JAAS_CONTEXT_PARAM, JAAS_KONTEXT);
2.26 +
2.27 + realm = new SQLRealm();
2.28 + realm.init(parametry);
2.29 + }
2.30 +
2.31 + @Test
2.32 + public void testJaasKontext() {
2.33 + String kontext = realm.getJAASContext();
2.34 + System.out.println("jaasContext = " + kontext);
2.35 + assertEquals("Kontext je jiný, než jsme nastavili v init parametrech.", JAAS_KONTEXT, kontext);
2.36 + }
2.37 +
2.38 + @Test
2.39 + public void testGetAuthType() {
2.40 + String authType = realm.getAuthType();
2.41 + System.out.println("authType = " + authType);
2.42 + assertTrue("authType musí být nenulový a neprázdný", authType != null && authType.trim().length() > 0);
2.43 + }
2.44 +}