@Test
  public void testUpdateExisting() throws Exception {
    long pk = ServiceTestUtil.nextLong();

    Release newRelease = _persistence.create(pk);

    newRelease.setMvccVersion(ServiceTestUtil.nextLong());

    newRelease.setCreateDate(ServiceTestUtil.nextDate());

    newRelease.setModifiedDate(ServiceTestUtil.nextDate());

    newRelease.setServletContextName(ServiceTestUtil.randomString());

    newRelease.setBuildNumber(ServiceTestUtil.nextInt());

    newRelease.setBuildDate(ServiceTestUtil.nextDate());

    newRelease.setVerified(ServiceTestUtil.randomBoolean());

    newRelease.setState(ServiceTestUtil.nextInt());

    newRelease.setTestString(ServiceTestUtil.randomString());

    _persistence.update(newRelease);

    Release existingRelease = _persistence.findByPrimaryKey(newRelease.getPrimaryKey());

    Assert.assertEquals(existingRelease.getMvccVersion(), newRelease.getMvccVersion());
    Assert.assertEquals(existingRelease.getReleaseId(), newRelease.getReleaseId());
    Assert.assertEquals(
        Time.getShortTimestamp(existingRelease.getCreateDate()),
        Time.getShortTimestamp(newRelease.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingRelease.getModifiedDate()),
        Time.getShortTimestamp(newRelease.getModifiedDate()));
    Assert.assertEquals(
        existingRelease.getServletContextName(), newRelease.getServletContextName());
    Assert.assertEquals(existingRelease.getBuildNumber(), newRelease.getBuildNumber());
    Assert.assertEquals(
        Time.getShortTimestamp(existingRelease.getBuildDate()),
        Time.getShortTimestamp(newRelease.getBuildDate()));
    Assert.assertEquals(existingRelease.getVerified(), newRelease.getVerified());
    Assert.assertEquals(existingRelease.getState(), newRelease.getState());
    Assert.assertEquals(existingRelease.getTestString(), newRelease.getTestString());
  }
Example #2
0
  protected Release toUnwrappedModel(Release release) {
    if (release instanceof ReleaseImpl) {
      return release;
    }

    ReleaseImpl releaseImpl = new ReleaseImpl();

    releaseImpl.setNew(release.isNew());
    releaseImpl.setPrimaryKey(release.getPrimaryKey());

    releaseImpl.setReleaseId(release.getReleaseId());
    releaseImpl.setCreateDate(release.getCreateDate());
    releaseImpl.setModifiedDate(release.getModifiedDate());
    releaseImpl.setServletContextName(release.getServletContextName());
    releaseImpl.setBuildNumber(release.getBuildNumber());
    releaseImpl.setBuildDate(release.getBuildDate());
    releaseImpl.setVerified(release.isVerified());
    releaseImpl.setState(release.getState());
    releaseImpl.setTestString(release.getTestString());

    return releaseImpl;
  }
Example #3
0
  public static void verify() throws Exception {

    // Check release

    Release release =
        ReleaseLocalServiceUtil.fetchRelease(ReleaseConstants.DEFAULT_SERVLET_CONTEXT_NAME);

    if (release == null) {
      release =
          ReleaseLocalServiceUtil.addRelease(
              ReleaseConstants.DEFAULT_SERVLET_CONTEXT_NAME, ReleaseInfo.getParentBuildNumber());
    }

    _checkReleaseState(release.getState());

    // Update indexes

    if (PropsValues.DATABASE_INDEXES_UPDATE_ON_STARTUP) {
      StartupHelperUtil.setDropIndexes(true);

      StartupHelperUtil.updateIndexes();
    } else if (StartupHelperUtil.isUpgraded()) {
      StartupHelperUtil.updateIndexes();
    }

    // Verify

    if (PropsValues.VERIFY_DATABASE_TRANSACTIONS_DISABLED) {
      _disableTransactions();
    }

    boolean newBuildNumber = false;

    if (ReleaseInfo.getBuildNumber() > release.getBuildNumber()) {
      newBuildNumber = true;
    }

    try {
      StartupHelperUtil.verifyProcess(newBuildNumber, release.isVerified());
    } catch (Exception e) {
      _updateReleaseState(ReleaseConstants.STATE_VERIFY_FAILURE);

      throw e;
    } finally {
      if (PropsValues.VERIFY_DATABASE_TRANSACTIONS_DISABLED) {
        _enableTransactions();
      }
    }

    // Update indexes

    if (PropsValues.DATABASE_INDEXES_UPDATE_ON_STARTUP || StartupHelperUtil.isUpgraded()) {

      StartupHelperUtil.updateIndexes(false);
    }

    // Update release

    boolean verified = StartupHelperUtil.isVerified();

    if (release.isVerified()) {
      verified = true;
    }

    ReleaseLocalServiceUtil.updateRelease(
        release.getReleaseId(),
        ReleaseInfo.getParentBuildNumber(),
        ReleaseInfo.getBuildDate(),
        verified);

    // Enable database caching after verify

    CacheRegistryUtil.setActive(true);
  }