Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
fcrepo-kernel/src/test/java/org/fcrepo/kernel/utils/LogoutCallbackTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
|
||
|
||
|
||
} |