package org.asynchttpclient; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import org.junit.Test; public class TestRealm { @Test public void testBuilderConstructor() { Realm.RealmBuilder builder = new Realm.RealmBuilder(); Realm realm = builder.build(); assertNotNull(realm); } private void testGenerator(String[] values, boolean b) { Realm.RealmBuilder builder = new Realm.RealmBuilder(); String algorithm = values[0]; builder.setAlgorithm(algorithm); String enc = values[1]; builder.setEnconding(enc); String methodName = values[2]; builder.setMethodName(methodName); String nc = values[3]; builder.setNc(nc); String nonce = values[4]; builder.setNonce(nonce); String host = values[5]; builder.setNtlmHost(host); String opaque = values[6]; builder.setOpaque(opaque); String password = values[7]; builder.setPassword(password); String principal = values[8]; builder.setPrincipal(principal); String qop = values[9]; builder.setQop(qop); String realmName = values[10]; builder.setRealmName(realmName); String response = values[11]; builder.setResponse(response); String uri = values[12]; builder.setUri(uri); boolean usePreemptiveAuth = b; builder.setUsePreemptiveAuth(usePreemptiveAuth); Realm realm = builder.build(); assertEquals(realm.getAlgorithm(), algorithm); assertEquals(realm.getEncoding(), enc); assertEquals(realm.getMethodName(), methodName); assertEquals(realm.getNc(), nc); assertEquals(realm.getNonce(), nonce); assertEquals(realm.getNtlmHost(), host); assertEquals(realm.getOpaque(), opaque); assertEquals(realm.getPassword(), password); assertEquals(realm.getPrincipal(), principal); assertEquals(realm.getQop(), qop); assertEquals(realm.getRealmName(), realmName); // assertEquals(realm.getResponse(), response); // depends nonce not set assertEquals(realm.getUri(), uri); assertEquals(realm.getUsePreemptiveAuth(), usePreemptiveAuth); } @Test public void testBuilderResults() { String[] values = { "a", "b", "c", "d", "e", "f", "g", "h", "j", "k", "l", "m", "n" }; testGenerator(values, false); } @Test public void testBuilderResults2() { String[] values = { "h", "j", "k", "l", "m", "n", "a", "b", "c", "d", "e", "f", "g" }; testGenerator(values, true); } }