@Test
  public void testFailedPortletLocalPublishing() throws Exception {
    User user = TestPropsValues.getUser();

    try (CaptureAppender captureAppender =
        Log4JLoggerTestUtil.configureLog4JLogger(
            BackgroundTaskMessageListener.class.getName(), Level.ERROR)) {

      StagingUtil.publishPortlet(
          user.getUserId(),
          _group.getGroupId(),
          _liveGroup.getGroupId(),
          0,
          0,
          StringPool.BLANK,
          _parameterMap);

      List<LoggingEvent> loggingEvents = captureAppender.getLoggingEvents();

      LoggingEvent loggingEvent = loggingEvents.get(0);

      Assert.assertEquals("Unable to execute background task", loggingEvent.getMessage());

      ThrowableInformation throwableInformation = loggingEvent.getThrowableInformation();

      Throwable throwable = throwableInformation.getThrowable();

      Assert.assertSame(NoSuchLayoutException.class, throwable.getClass());
    }

    Assert.assertTrue(
        _firedExportImportLifecycleEventsMap.containsKey(
            ExportImportLifecycleConstants.EVENT_PUBLICATION_PORTLET_LOCAL_FAILED));
  }
  @Test
  public void testMigratedPortalKeys() throws Exception {
    String[][] originalMigratedPortalKeys =
        ReflectionTestUtil.getFieldValue(VerifyProperties.class, "_MIGRATED_PORTAL_KEYS");

    String migratedPortalKey = getFirstPortalPropertyKey();

    ReflectionTestUtil.setFieldValue(
        VerifyProperties.class,
        "_MIGRATED_PORTAL_KEYS",
        new String[][] {new String[] {migratedPortalKey, migratedPortalKey}});

    try (CaptureAppender captureAppender =
        Log4JLoggerTestUtil.configureLog4JLogger(VerifyProperties.class.getName(), Level.ERROR)) {

      doVerify();

      List<LoggingEvent> loggingEvents = captureAppender.getLoggingEvents();

      Assert.assertEquals(1, loggingEvents.size());

      LoggingEvent loggingEvent = loggingEvents.get(0);

      Assert.assertEquals(
          "Portal property \""
              + migratedPortalKey
              + "\" was migrated to the system property \""
              + migratedPortalKey
              + "\"",
          loggingEvent.getMessage());
    } finally {
      ReflectionTestUtil.setFieldValue(
          VerifyProperties.class, "_MIGRATED_PORTAL_KEYS", originalMigratedPortalKeys);
    }
  }
  @Test
  public void testRenamedSystemKeys() throws Exception {
    String[][] originalRenamedSystemKeys =
        ReflectionTestUtil.getFieldValue(VerifyProperties.class, "_RENAMED_SYSTEM_KEYS");

    String renamedSystemKey = getFirstSystemPropertyKey();

    ReflectionTestUtil.setFieldValue(
        VerifyProperties.class,
        "_RENAMED_SYSTEM_KEYS",
        new String[][] {new String[] {renamedSystemKey, renamedSystemKey}});

    try (CaptureAppender captureAppender =
        Log4JLoggerTestUtil.configureLog4JLogger(VerifyProperties.class.getName(), Level.ERROR)) {

      doVerify();

      List<LoggingEvent> loggingEvents = captureAppender.getLoggingEvents();

      Assert.assertEquals(1, loggingEvents.size());

      LoggingEvent loggingEvent = loggingEvents.get(0);

      Assert.assertEquals(
          "System property \""
              + renamedSystemKey
              + "\" was renamed to \""
              + renamedSystemKey
              + "\"",
          loggingEvent.getMessage());
    } finally {
      ReflectionTestUtil.setFieldValue(
          VerifyProperties.class, "_RENAMED_SYSTEM_KEYS", originalRenamedSystemKeys);
    }
  }
  @Test
  public void testObsoletePortalKeys() throws Exception {
    String[] originalObsoletePortalKeys =
        ReflectionTestUtil.getFieldValue(VerifyProperties.class, "_OBSOLETE_PORTAL_KEYS");

    String obsoletePortalKey = getFirstPortalPropertyKey();

    ReflectionTestUtil.setFieldValue(
        VerifyProperties.class, "_OBSOLETE_PORTAL_KEYS", new String[] {obsoletePortalKey});

    try (CaptureAppender captureAppender =
        Log4JLoggerTestUtil.configureLog4JLogger(VerifyProperties.class.getName(), Level.ERROR)) {

      doVerify();

      List<LoggingEvent> loggingEvents = captureAppender.getLoggingEvents();

      Assert.assertEquals(1, loggingEvents.size());

      LoggingEvent loggingEvent = loggingEvents.get(0);

      Assert.assertEquals(
          "Portal property \"" + obsoletePortalKey + "\" is obsolete", loggingEvent.getMessage());
    } finally {
      ReflectionTestUtil.setFieldValue(
          VerifyProperties.class, "_OBSOLETE_PORTAL_KEYS", originalObsoletePortalKeys);
    }
  }
  @Override
  @Test
  public void testVerify() throws Exception {
    try (CaptureAppender captureAppender =
        Log4JLoggerTestUtil.configureLog4JLogger(VerifyProperties.class.getName(), Level.ERROR)) {

      doVerify();

      List<LoggingEvent> loggingEvents = captureAppender.getLoggingEvents();

      Assert.assertTrue(loggingEvents.isEmpty());
    }
  }
  @JVMArgsLine("-Dcatalina.base=. -D" + _HIKARICP_JAR_URL + "=${" + _HIKARICP_JAR_URL + "}")
  @NewEnv(type = NewEnv.Type.JVM)
  @Test
  public void testHikariCP() throws Exception {
    RegistryUtil.setRegistry(new BasicRegistryImpl());

    System.setProperty("portal:jdbc.default.liferay.pool.provider", "hikaricp");

    String hikaricpJarURL = System.getProperty(_HIKARICP_JAR_URL);

    if (hikaricpJarURL != null) {
      System.setProperty(
          "portal:" + PropsKeys.SETUP_LIFERAY_POOL_PROVIDER_JAR_URL + "[hikaricp]", hikaricpJarURL);
    }

    InitUtil.init();

    DataSource dataSource = null;

    try (CaptureAppender captureAppender =
        Log4JLoggerTestUtil.configureLog4JLogger(JarUtil.class.getName(), Level.INFO)) {

      dataSource = DataSourceFactoryUtil.initDataSource(_properties);

      List<LoggingEvent> loggingEvents = captureAppender.getLoggingEvents();

      Assert.assertEquals(4, loggingEvents.size());

      LoggingEvent loggingEvent = loggingEvents.get(0);

      String message = (String) loggingEvent.getMessage();

      Assert.assertTrue(message.startsWith("Downloading "));

      loggingEvent = loggingEvents.get(1);

      message = (String) loggingEvent.getMessage();

      Assert.assertTrue(message.startsWith("Downloaded "));

      loggingEvent = loggingEvents.get(2);

      message = (String) loggingEvent.getMessage();

      Assert.assertTrue(message.startsWith("Installing "));

      loggingEvent = loggingEvents.get(3);

      message = (String) loggingEvent.getMessage();

      Assert.assertTrue(message.startsWith("Installed "));
    }

    Class<?> dataSourceClass = dataSource.getClass();

    Assert.assertEquals("com.zaxxer.hikari.HikariDataSource", dataSourceClass.getName());

    for (int i = 0; i < _CHECKOUT_COUNT; i++) {
      Connection connection = dataSource.getConnection();

      PreparedStatement preparedStatement =
          connection.prepareStatement("SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS");

      preparedStatement.execute();
    }

    MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();

    ObjectName poolName = new ObjectName("com.zaxxer.hikari:type=Pool (TestJDBCPool)");

    int activeConnections = (int) mBeanServer.getAttribute(poolName, "ActiveConnections");

    Assert.assertEquals(_CHECKOUT_COUNT, activeConnections);

    int idleConnections = (int) mBeanServer.getAttribute(poolName, "IdleConnections");

    int totalConnections = (int) mBeanServer.getAttribute(poolName, "TotalConnections");

    Assert.assertEquals(totalConnections, activeConnections + idleConnections);
  }