UpgradeStatus { public void update(InstallContext ctx, boolean failed) throws RepositoryException { getNode().setProperty(PN_UPGRADE_TIME, Calendar.getInstance()); String versionString = ctx.getPackage().getId().getVersionString(); getNode().setProperty(PN_VERSION, versionString); getNode().setProperty(PN_STATUS, failed ? "FAILED" : "SUCCESS"); LOG.info(ctx, "stored new status [{}]: [{}]", getNode(), versionString); } UpgradeStatus(InstallContext ctx, String path); boolean isExecuted(InstallContext ctx, UpgradeInfo info, UpgradeAction action); void update(InstallContext ctx, boolean failed); void update(InstallContext ctx, UpgradeInfo info); @Override String toString(); Node getNode(); Version getVersion(); static final String PN_UPGRADE_TIME; static final String PN_VERSION; static final String PN_STATUS; static final String PN_ACTIONS; }
@Test public void testGeneralUpdate() throws Exception { Mockito.when(ctx.getPackage().getId().getVersionString()).thenReturn("2.1.0"); status.update(ctx, false); Assert.assertEquals("2.1.0", JcrUtils.getStringProperty(session, "/test/" + UpgradeStatus.PN_VERSION, "failed")); Assert.assertNotNull(JcrUtils.getDateProperty(session, "/test/" + UpgradeStatus.PN_UPGRADE_TIME, null)); }