Julian Sedding created SLING-4237:
-------------------------------------
Summary: JCR Mock implementation should have "throws
RepositoryException"
Key: SLING-4237
URL: https://issues.apache.org/jira/browse/SLING-4237
Project: Sling
Issue Type: Bug
Components: Testing
Affects Versions: Testing JCR Mock 1.1.0
Reporter: Julian Sedding
Assignee: Julian Sedding
Priority: Minor
Fix For: Testing JCR Mock 1.1.2
MockSession does not play nice with Mockito. When I run this test
{code}
@Test(expected = RepositoryException.class)
public void pathNotFound() throws RepositoryException {
Session session = Mockito.spy(MockJcr.newSession());
doThrow(new
PathNotFoundException("/foo")).when(session).getNode("/foo");
session.getNode("/foo");
}
{code}
the test fails with the following error message:
{code}
rootNotFound(a.b.c.impl.JcrTest) Time elapsed: 0.035 sec <<< ERROR!
java.lang.Exception: Unexpected exception,
expected<javax.jcr.RepositoryException> but
was<org.mockito.exceptions.base.MockitoException>
at a.b.c.impl.JcrTest.rootNotFound(JcrTest.java:40)
{code}
I found a hint on stackoverflow\[0\] that it is due to the fact that the
implementation does not declare any (potentially) thrown exceptions.
Above test passes when {{MockSession#getRootNode()}} is odified to throw a
repositoryException.
\[0\]
http://stackoverflow.com/questions/6647957/mockito-refuses-to-throw-checked-exception
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)