001package ca.uhn.fhir.system; 002 003/*- 004 * #%L 005 * HAPI FHIR Test Utilities 006 * %% 007 * Copyright (C) 2014 - 2023 Smile CDR, Inc. 008 * %% 009 * Licensed under the Apache License, Version 2.0 (the "License"); 010 * you may not use this file except in compliance with the License. 011 * You may obtain a copy of the License at 012 * 013 * http://www.apache.org/licenses/LICENSE-2.0 014 * 015 * Unless required by applicable law or agreed to in writing, software 016 * distributed under the License is distributed on an "AS IS" BASIS, 017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 018 * See the License for the specific language governing permissions and 019 * limitations under the License. 020 * #L% 021 */ 022 023public final class HapiTestSystemProperties { 024 private static final String MASS_INGESTION_MODE = "mass_ingestion_mode"; 025 private static final String SINGLE_DB_CONNECTION = "single_db_connection"; 026 private static final String UNLIMITED_DB_CONNECTION = "unlimited_db_connection"; 027 028 private HapiTestSystemProperties() {} 029 030 /** 031 * Set the database connection pool size to 100 032 */ 033 public static void enableUnlimitedDbConnections() { 034 System.setProperty(UNLIMITED_DB_CONNECTION, "true"); 035 } 036 037 public static boolean isUnlimitedDbConnectionsEnabled() { 038 return "true".equals(System.getProperty(UNLIMITED_DB_CONNECTION)); 039 } 040 041 public static void disableUnlimitedDbConnections() { 042 System.clearProperty(UNLIMITED_DB_CONNECTION); 043 } 044 045 /** 046 * Creates a DaoConfig with setMassIngestionMode(true) at test app context startup time 047 */ 048 public static void enableMassIngestionMode() { 049 System.setProperty(MASS_INGESTION_MODE, "true"); 050 } 051 052 public static boolean isMassIngestionModeEnabled() { 053 return "true".equals(System.getProperty(MASS_INGESTION_MODE)); 054 } 055 056 public static void disableMassIngestionMode() { 057 System.clearProperty(MASS_INGESTION_MODE); 058 } 059 060 /** 061 * Set the database connection pool size to 1 062 */ 063 public static boolean isSingleDbConnectionEnabled() { 064 return "true".equals(System.getProperty(SINGLE_DB_CONNECTION)); 065 } 066 067 public static void enableSingleDbConnection() { 068 System.setProperty(SINGLE_DB_CONNECTION, "true"); 069 } 070 071 public static void disableSingleDbConnection() { 072 System.clearProperty(SINGLE_DB_CONNECTION); 073 } 074}