Update Guice's maven build system to run the unit tests in three configurations, representing the three different values for stack-trace inclusion in error messages. Additionally, modify the open-source InternalFlags to log a warning if a value is passed to the flag that does not correspond to the Enum.
Tested:
normal open-source tests in google's internal build
full maven build from MOE's assembly of the open-source project
-------------
Created by MOE: http://code.google.com/p/moe-java
MOE_MIGRATED_REVID=54815820
diff --git a/core/src/com/google/inject/internal/InternalFlags.java b/core/src/com/google/inject/internal/InternalFlags.java
index 9458281..2c4ed75 100644
--- a/core/src/com/google/inject/internal/InternalFlags.java
+++ b/core/src/com/google/inject/internal/InternalFlags.java
@@ -1,33 +1,36 @@
package com.google.inject.internal;
-
+import java.util.Arrays;
+import java.util.logging.Logger;
/**
* Contains flags for Guice.
*/
public class InternalFlags {
-
+ private final static Logger logger = Logger.getLogger(InternalFlags.class.getName());
/**
* The options for Guice stack trace collection.
*/
public enum IncludeStackTraceOption {
- // No stack trace collection
+ /** No stack trace collection */
OFF,
- // Minimum stack trace collection (Default)
+ /** Minimum stack trace collection (Default) */
ONLY_FOR_DECLARING_SOURCE,
- // Full stack trace for everything
+ /** Full stack trace for everything */
COMPLETE
}
public static IncludeStackTraceOption getIncludeStackTraceOption() {
- String propertyValue = System.getProperty(
- "guice_include_stack_traces");
- if (IncludeStackTraceOption.OFF.name().equals(propertyValue)) {
- return IncludeStackTraceOption.OFF;
+ String flag = System.getProperty("guice_include_stack_traces");
+ try {
+ return (flag == null || flag.length() == 0)
+ ? IncludeStackTraceOption.ONLY_FOR_DECLARING_SOURCE
+ : IncludeStackTraceOption.valueOf(flag);
+ } catch (IllegalArgumentException e) {
+ logger.warning(flag
+ + " is not a valid flag value for guice_include_stack_traces. "
+ + " Values must be one of " + Arrays.asList(IncludeStackTraceOption.values()));
+ return IncludeStackTraceOption.ONLY_FOR_DECLARING_SOURCE;
}
- if (IncludeStackTraceOption.COMPLETE.name().equals(propertyValue)) {
- return IncludeStackTraceOption.COMPLETE;
- }
- return IncludeStackTraceOption.ONLY_FOR_DECLARING_SOURCE;
}
}
diff --git a/pom.xml b/pom.xml
index 48863a5..23aaf7c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -275,6 +275,32 @@
<redirectTestOutputToFile>true</redirectTestOutputToFile>
<!--<argLine>-Dguice_include_stack_traces=OFF</argLine>-->
</configuration>
+ <executions>
+ <execution>
+ <id>stack-traces-off</id>
+ <phase>test</phase>
+ <goals><goal>test</goal></goals>
+ <configuration>
+ <argLine>-Dguice_include_stack_traces=OFF</argLine>
+ </configuration>
+ </execution>
+ <execution>
+ <id>stack-traces-complete</id>
+ <phase>test</phase>
+ <goals><goal>test</goal></goals>
+ <configuration>
+ <argLine>-Dguice_include_stack_traces=COMPLETE</argLine>
+ </configuration>
+ </execution>
+ <execution>
+ <id>default-test</id>
+ <phase>test</phase>
+ <goals><goal>test</goal></goals>
+ <configuration>
+ <argLine>-Dguice_include_stack_traces=ONLY_FOR_DECLARING_SOURCE</argLine>
+ </configuration>
+ </execution>
+ </executions>
</plugin>
<!--
| Shared OSGi manifest configuration