franta-hg@5: package cz.frantovo.jaas.sql; franta-hg@5: franta-hg@5: import com.sun.enterprise.security.auth.realm.BadRealmException; franta-hg@5: import com.sun.enterprise.security.auth.realm.NoSuchRealmException; franta-hg@5: import java.util.Properties; franta-hg@5: import org.junit.Before; franta-hg@5: import org.junit.Test; franta-hg@5: import static org.junit.Assert.*; franta-hg@5: franta-hg@5: /** franta-hg@5: * franta-hg@5: * @author fiki franta-hg@5: */ franta-hg@5: public class SQLRealmTest { franta-hg@5: franta-hg@5: private static final String JAAS_KONTEXT = "sqlRealm_123456"; franta-hg@5: private SQLRealm realm; franta-hg@5: franta-hg@5: @Before franta-hg@5: public void setUp() throws BadRealmException, NoSuchRealmException { franta-hg@5: Properties parametry = new Properties(); franta-hg@5: parametry.setProperty(SQLRealm.JAAS_CONTEXT_PARAM, JAAS_KONTEXT); franta-hg@5: franta-hg@5: realm = new SQLRealm(); franta-hg@5: realm.init(parametry); franta-hg@5: } franta-hg@5: franta-hg@5: @Test franta-hg@5: public void testJaasKontext() { franta-hg@5: String kontext = realm.getJAASContext(); franta-hg@5: System.out.println("jaasContext = " + kontext); franta-hg@5: assertEquals("Kontext je jiný, než jsme nastavili v init parametrech.", JAAS_KONTEXT, kontext); franta-hg@5: } franta-hg@5: franta-hg@5: @Test franta-hg@5: public void testGetAuthType() { franta-hg@5: String authType = realm.getAuthType(); franta-hg@5: System.out.println("authType = " + authType); franta-hg@6: assertTrue("authType musí být nenulový", authType != null); franta-hg@6: assertTrue("authType musí být neprázdný", authType.trim().length() > 0); franta-hg@5: } franta-hg@5: }