Skip to content

Commit

Permalink
Unit test for LogoutCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
ajs6f committed Oct 31, 2013
1 parent 4a0d6cf commit 4c1f8df
Showing 1 changed file with 46 additions and 0 deletions.
@@ -0,0 +1,46 @@
package org.fcrepo.kernel.utils;

import static org.junit.Assert.fail;
import static org.mockito.Mockito.verify;
import static org.mockito.MockitoAnnotations.initMocks;

import javax.jcr.Session;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;


public class LogoutCallbackTest {

private LogoutCallback testLogoutCallback;

@Mock
private Session mockSession;

@Before
public void setUp() {
initMocks(this);
testLogoutCallback = new LogoutCallback(mockSession);
}

@Test
public void testonSuccess() {
testLogoutCallback.onSuccess(null);
verify(mockSession).logout();
}

@Test
public void testonFailure() {
try {
testLogoutCallback.onFailure(new Exception("Expected."));
fail("Should have propagated exception!");
} catch (final RuntimeException e) {
// expected.
}
verify(mockSession).logout();
}



}

0 comments on commit 4c1f8df

Please sign in to comment.