Napojení na SQL databázi.
1 package cz.frantovo.jaas.sql;
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;
8 import static org.junit.Assert.*;
14 public class SQLRealmTest {
16 private static final String JAAS_KONTEXT = "sqlRealm_123456";
17 private SQLRealm realm;
20 public void setUp() throws BadRealmException, NoSuchRealmException {
21 Properties parametry = new Properties();
22 parametry.setProperty(SQLRealm.JAAS_CONTEXT_PARAM, JAAS_KONTEXT);
24 realm = new SQLRealm();
25 realm.init(parametry);
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);
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);