1818import org .apache .commons .lang3 .StringUtils ;
1919import org .apache .commons .lang3 .SystemUtils ;
2020import org .labkey .serverapi .reader .Readers ;
21+ import org .labkey .test .util .CspLogUtil ;
2122import org .labkey .test .util .TestLogger ;
2223import org .openqa .selenium .Dimension ;
2324
3031import java .time .LocalDateTime ;
3132import java .time .ZoneId ;
3233import java .util .Arrays ;
34+ import java .util .Collections ;
3335import java .util .HashMap ;
3436import java .util .Iterator ;
3537import java .util .List ;
@@ -78,6 +80,7 @@ public abstract class TestProperties
7880 public static void load ()
7981 {
8082 /* Force static block to run */
83+ CspLogUtil .init ();
8184 }
8285
8386 public static boolean isTestCleanupSkipped ()
@@ -129,7 +132,7 @@ public static boolean isQueryCheckSkipped()
129132
130133 public static boolean isCspCheckSkipped ()
131134 {
132- return !getBooleanProperty ("webtest.cspCheck" , false );
135+ return !getBooleanProperty ("webtest.cspCheck" , true );
133136 }
134137
135138 public static boolean isNewWebDriverForEachTest ()
@@ -264,6 +267,10 @@ public static boolean isAssayProductFeatureAvailable()
264267 return isProductFeatureAvailable ("assay" );
265268 }
266269
270+ /**
271+ * Product features are assumed to be available unless the test environment (usually TeamCity) explicitly specifies
272+ * that it is not.
273+ */
267274 public static boolean isProductFeatureAvailable (String feature )
268275 {
269276 return "true" .equals (System .getProperty ("webtest.productFeature." + feature .toLowerCase (), "true" ));
@@ -276,7 +283,7 @@ public static boolean ignoreDatabaseNotSupportedException()
276283
277284 /**
278285 * Parses system property 'webtest.server.startup.timeout' to determine maximum allowed server startup time.
279- * If property is not defined or is not an integer, it defaults to 60 seconds.
286+ * If property is not defined or is not an integer, it defaults to 120 seconds.
280287 * @return Maximum number of seconds to wait for server startup
281288 */
282289 public static int getServerStartupTimeout ()
@@ -289,34 +296,48 @@ public static String getAdditionalPipelineTools()
289296 return System .getProperty ("additional.pipeline.tools" );
290297 }
291298
299+ private static Map <String , Boolean > _optionalFeatures = null ;
292300 public static Map <String , Boolean > getOptionalFeatures ()
293301 {
294- Map <String , Boolean > features = new HashMap <>();
295-
296- Properties props = System .getProperties ();
297- for (Map .Entry <Object , Object > entry : props .entrySet ())
302+ if (_optionalFeatures == null )
298303 {
299- String key = String .valueOf (entry .getKey ());
300- Boolean value = (entry .getValue () instanceof Boolean )
301- ? (Boolean )entry .getValue ()
302- : Boolean .valueOf (String .valueOf (entry .getValue ()));
304+ Map <String , Boolean > features = new HashMap <>();
303305
304- String prefix = "webtest.experimental." ; // Can be used with any optional feature flags; "experimental" is used for backward-compatibility purposes.
305- if ( key . startsWith ( prefix ))
306+ Properties props = System . getProperties ();
307+ for ( Map . Entry < Object , Object > entry : props . entrySet ( ))
306308 {
307- String feature = key .substring (prefix .length ());
308- features .put (feature , value );
309+ String key = String .valueOf (entry .getKey ());
310+
311+ String expPrefix = "webtest.experimental." ; // "experimental" is accepted for backward-compatibility purposes.
312+ String optPrefix = "webtest.optional." ; // Preferred prefix
313+ for (String prefix : List .of (expPrefix , optPrefix ))
314+ {
315+ if (key .startsWith (prefix ))
316+ {
317+ Boolean value = (entry .getValue () instanceof Boolean )
318+ ? (Boolean ) entry .getValue ()
319+ : Boolean .valueOf (String .valueOf (entry .getValue ()));
320+ String feature = key .substring (prefix .length ());
321+ features .put (feature , value );
322+ }
323+ }
309324 }
310- }
311325
312- return features ;
326+ _optionalFeatures = Collections .unmodifiableMap (features );
327+ }
328+ return _optionalFeatures ;
313329 }
314330
331+ private static List <String > debugLoggingPackages = null ;
315332 public static List <String > getDebugLoggingPackages ()
316333 {
317- String prop = System .getProperty ("webtest.debug.server.packages" , "" );
318- String [] packages = prop .split ("\\ s*,\\ s*" );
319- return Arrays .stream (packages ).map (String ::trim ).filter (s -> !s .isEmpty ()).collect (Collectors .toList ());
334+ if (debugLoggingPackages == null )
335+ {
336+ String prop = System .getProperty ("webtest.debug.server.packages" , "" );
337+ String [] packages = prop .split ("," );
338+ debugLoggingPackages = Arrays .stream (packages ).map (String ::trim ).filter (s -> !s .isEmpty ()).collect (Collectors .toList ());
339+ }
340+ return debugLoggingPackages ;
320341 }
321342
322343 private static File dumpDir = null ;
0 commit comments