### Question:
OnDeployScriptBase implements OnDeployScript { public final void execute(ResourceResolver resourceResolver) { this.resourceResolver = resourceResolver; this.pageManager = resourceResolver.adaptTo(PageManager.class); this.session = resourceResolver.adaptTo(Session.class); if (session != null) { this.workspace = session.getWorkspace(); } try { execute(); resourceResolver.commit(); } catch (Exception e) { throw new OnDeployScriptException(e); } }  final void execute(ResourceResolver resourceResolver);  }### Answer:
@Test public void testExecuteException() throws Exception { Exception originalException = new Exception("Oops it broke"); onDeployScript = spy(onDeployScript); doThrow(originalException).when(onDeployScript).execute(); try { onDeployScript.execute(resourceResolver); fail("Expected exception"); } catch (Exception e) { assertTrue(OnDeployScriptException.class.isAssignableFrom(e.getClass())); assertEquals("On-deploy script failure", e.getMessage()); assertEquals(originalException, e.getCause()); } }