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