import java.net.HttpURLConnection;
public class JU_AbsAuthentication {
-
- private final static String ID = "id";
- private final static String PASSWORD = "password";
- private final static String WARNING = "Your service has 1000 consecutive bad service " +
- "logins to AAF. AAF Access will be disabled after 10000\n";
-
- private static ByteArrayOutputStream errStream;
-
- @Before
- public void setup() {
- errStream = new ByteArrayOutputStream();
- System.setErr(new PrintStream(errStream));
- }
-
- @After
- public void tearDown() {
- System.setErr(System.err);
- }
+
+ private final static String ID = "id";
+ private final static String PASSWORD = "password";
+ private final static String WARNING = "Your service has 1000 consecutive bad service " +
+ "logins to AAF. AAF Access will be disabled after 10000\n";
+
+ private static ByteArrayOutputStream errStream;
+
+ @Before
+ public void setup() {
+ errStream = new ByteArrayOutputStream();
+ System.setErr(new PrintStream(errStream));
+ }
+
+ @After
+ public void tearDown() {
+ System.setErr(System.err);
+ }
- @Test
- public void test() throws IOException, InterruptedException {
- AuthStub stub = new AuthStub(null, null, null);
- assertThat(stub.getID(), is(nullValue()));
- assertThat(stub.headValue(), is(""));
- assertThat(stub.count(), is(0));
-
- stub.setUser(ID);
- assertThat(stub.getID(), is(ID));
+ @Test
+ public void test() throws IOException, InterruptedException {
+ AuthStub stub = new AuthStub(null, null, null);
+ assertThat(stub.getID(), is(nullValue()));
+ assertThat(stub.headValue(), is(""));
+ assertThat(stub.count(), is(0));
+
+ stub.setUser(ID);
+ assertThat(stub.getID(), is(ID));
- stub = new AuthStub(null, ID, PASSWORD.getBytes());
- assertThat(stub.getID(), is(ID));
- assertThat(stub.headValue(), is(PASSWORD));
- assertThat(stub.count(), is(0));
-
- assertThat(stub.setLastResponse(200), is(0));
- assertThat(stub.isDenied(), is(false));
+ stub = new AuthStub(null, ID, PASSWORD.getBytes());
+ assertThat(stub.getID(), is(ID));
+ assertThat(stub.headValue(), is(PASSWORD));
+ assertThat(stub.count(), is(0));
+
+ assertThat(stub.setLastResponse(200), is(0));
+ assertThat(stub.isDenied(), is(false));
- for (int i = 1; i <= 10; i++) {
- assertThat(stub.setLastResponse(401), is(i));
- assertThat(stub.isDenied(), is(false));
- }
- assertThat(stub.setLastResponse(401), is(11));
- assertThat(stub.isDenied(), is(true));
+ for (int i = 1; i <= 10; i++) {
+ assertThat(stub.setLastResponse(401), is(i));
+ assertThat(stub.isDenied(), is(false));
+ }
+ assertThat(stub.setLastResponse(401), is(11));
+ assertThat(stub.isDenied(), is(true));
- stub.setCount(999);
- assertThat(stub.setLastResponse(401), is(1000));
- assertThat(errStream.toString(), is(WARNING));
-
- // coverage...
- stub.setLastMiss(1);
- assertThat(stub.isDenied(), is(false));
- }
-
- private class AuthStub extends AbsAuthentication<HttpURLConnection> {
+ stub.setCount(999);
+ assertThat(stub.setLastResponse(401), is(1000));
+ assertThat(errStream.toString(), is(WARNING));
+
+ // coverage...
+ stub.setLastMiss(1);
+ assertThat(stub.isDenied(), is(false));
+ }
+
+ private class AuthStub extends AbsAuthentication<HttpURLConnection> {
- public AuthStub(SecurityInfoC<HttpURLConnection> securityInfo, String user, byte[] headValue)
- throws IOException { super(securityInfo, user, headValue); }
+ public AuthStub(SecurityInfoC<HttpURLConnection> securityInfo, String user, byte[] headValue)
+ throws IOException { super(securityInfo, user, headValue); }
- @Override public void setSecurity(HttpURLConnection client) throws CadiException { }
- @Override public void setUser(String id) { super.setUser(id); }
- @Override public String headValue() throws IOException { return super.headValue(); }
-
- public void setLastMiss(long lastMiss) { this.lastMiss = lastMiss; }
- public void setCount(int count) { this.count = count; }
- }
+ @Override public void setSecurity(HttpURLConnection client) throws CadiException { }
+ @Override public void setUser(String id) { super.setUser(id); }
+ @Override public String headValue() throws IOException { return super.headValue(); }
+
+ public void setLastMiss(long lastMiss) { this.lastMiss = lastMiss; }
+ public void setCount(int count) { this.count = count; }
+ }
}