@Test
 public void testDuplicateCreateInTXWithRollback() {
   MediaFormat format1 = null;
   final Transaction tx = Transaction.current();
   tx.begin();
   tx.enableDelayedStore(false);
   try {
     format1 = MediaManager.getInstance().createMediaFormat("testFormat1");
     MediaManager.getInstance().createMediaFormat("testFormat1");
   } catch (final Exception e) {
     // meek if exception it's ok
   } finally {
     tx.rollback();
     assertFalse("item is alive after rollback!!", format1.isAlive());
   }
 }
  /**
   * This method will be called by system creator during initialization and system update. Be sure
   * that this method can be called repeatedly.
   *
   * @param context the context provides the selected parameters and values
   */
  @SystemSetup(type = Type.ESSENTIAL, process = Process.ALL)
  public void createEssentialData(final SystemSetupContext context) {
    final boolean importCustomReports =
        getBooleanSystemSetupParameter(context, IMPORT_CUSTOM_REPORTS);

    if (importCustomReports) {
      if (MediaManager.getInstance()
              .getMediaFolderByQualifier(V2kartCockpitsConstants.JASPER_REPORTS_MEDIA_FOLDER)
              .size()
          < 1) {
        MediaManager.getInstance()
            .createMediaFolder(
                V2kartCockpitsConstants.JASPER_REPORTS_MEDIA_FOLDER,
                V2kartCockpitsConstants.JASPER_REPORTS_MEDIA_FOLDER);
      }
      try {
        String prefix = null;
        if (Config.isMySQLUsed()) {
          prefix = "mysql";
        } else if (Config.isHSQLDBUsed()) {
          prefix = "hsqldb";
        } else if (Config.isOracleUsed()) {
          prefix = "oracle";
        } else if (Config.isSQLServerUsed()) {
          prefix = "sqlserver";
        }

        if (prefix != null) {
          importImpexFile(
              context, "/v2kartcockpits/reportcockpit/import/" + prefix + "_jasperreports.impex");
        }
      } catch (final Exception e) {
        LOG.error("Error during Jasper Report files import " + e);
      }
    }
  }