You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Julian Sedding (JIRA)" <ji...@apache.org> on 2014/12/11 13:54:13 UTC
[jira] [Commented] (SLING-4237) JCR Mock implementation should have
"throws RepositoryException"
[ https://issues.apache.org/jira/browse/SLING-4237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14242493#comment-14242493 ]
Julian Sedding commented on SLING-4237:
---------------------------------------
I introduced some redundant imports in the previous commit. Fixed in rev1644616.
> 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
> Labels: mocks
> 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)