From 388ff8b2e0fea1e758ed5685d535e26b7a6131a9 Mon Sep 17 00:00:00 2001
From: Robert von Burg enableShutdownHook. disableShutdownHook. setShutdownHook. toConfig. enableShutdownHook. getAutoInject.
This method does not allow mock plugins to be used. If this is required, e.g. for testing then use {@link #newAutoContextAllowMocks()}
- * * @return Context */ public static Context newAutoContext() { @@ -73,21 +70,6 @@ public static Context newAutoContext() { return newContextBuilder().autoDetect().build(); } - /** - *Returns a new 'Context' instance which represents the Pi4J runtime - * state and lifecycle. This 'Context' instance will automatically - * load all detected 'Platforms' and 'Providers' that are detected - * in the application's class-path.
- * - *In contrast to {@link #newAutoContext()} this method will allow mocks to be added to the runtime.
- * - * @return Context - */ - public static Context newAutoContextAllowMocks() { - logger.info("New auto context"); - return newContextBuilder().autoDetect().autoDetectMockPlugins().build(); - } - /** * Returns a new empty 'Context' instance which represents the Pi4J * runtime state and lifecycle. This empty 'Context' will not contain diff --git a/pi4j-core/src/main/java/com/pi4j/context/impl/DefaultContextBuilder.java b/pi4j-core/src/main/java/com/pi4j/context/impl/DefaultContextBuilder.java index cd88e7f7..de43b392 100644 --- a/pi4j-core/src/main/java/com/pi4j/context/impl/DefaultContextBuilder.java +++ b/pi4j-core/src/main/java/com/pi4j/context/impl/DefaultContextBuilder.java @@ -25,6 +25,7 @@ * #L% */ +import com.pi4j.boardinfo.util.BoardInfoHelper; import com.pi4j.context.Context; import com.pi4j.context.ContextBuilder; import com.pi4j.context.ContextConfig; @@ -50,7 +51,7 @@ public class DefaultContextBuilder implements ContextBuilder { protected Logger logger = LoggerFactory.getLogger(DefaultContextBuilder.class); // auto detection flags - protected boolean autoDetectMockPlugins = false; + protected boolean autoDetectMockPlugins = !BoardInfoHelper.runningOnRaspberryPi(); protected boolean autoDetectPlatforms = false; protected boolean autoDetectProviders = false; protected boolean autoInject = false; diff --git a/pi4j-test/src/test/java/com/pi4j/test/context/ContextTest.java b/pi4j-test/src/test/java/com/pi4j/test/context/ContextTest.java index 10c04d6c..f7ba37a5 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/context/ContextTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/context/ContextTest.java @@ -51,7 +51,7 @@ public void beforeTest() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContextAllowMocks(); + pi4j = Pi4J.newAutoContext(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java index 22bae0fe..71f0a953 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRawDataTest.java @@ -67,7 +67,7 @@ public void beforeTest() throws Pi4JException { // An auto context enabled AUTO-DETECT loading // which will load any detected Pi4J extension // libraries (Platforms and Providers) from the class path - pi4j = Pi4J.newAutoContextAllowMocks(); + pi4j = Pi4J.newAutoContext(); } @AfterEach diff --git a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRegisterDataTest.java b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRegisterDataTest.java index b432b41c..99fb3053 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRegisterDataTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/io/i2c/I2CRegisterDataTest.java @@ -68,7 +68,7 @@ public void beforeTest() throws Pi4JException { // An auto context enabled AUTO-DETECT loading // which will load any detected Pi4J extension // libraries (Platforms and Providers) from the class path - pi4j = Pi4J.newAutoContextAllowMocks(); + pi4j = Pi4J.newAutoContext(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java b/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java index 1b16ed1c..c3202b4c 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/io/spi/SpiRawDataTest.java @@ -66,7 +66,7 @@ public void beforeTest() throws Pi4JException { // An auto context enabled AUTO-DETECT loading // which will load any detected Pi4J extension // libraries (Platforms and Providers) from the class path - pi4j = Pi4J.newAutoContextAllowMocks(); + pi4j = Pi4J.newAutoContext(); } @AfterEach diff --git a/pi4j-test/src/test/java/com/pi4j/test/platform/AutoPlatformsTest.java b/pi4j-test/src/test/java/com/pi4j/test/platform/AutoPlatformsTest.java index 94d9f6b0..fe844f34 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/platform/AutoPlatformsTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/platform/AutoPlatformsTest.java @@ -48,7 +48,7 @@ public void beforeTest() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContextAllowMocks(); + pi4j = Pi4J.newAutoContext(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/provider/AutoProvidersTest.java b/pi4j-test/src/test/java/com/pi4j/test/provider/AutoProvidersTest.java index 02410476..c18bf9a6 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/provider/AutoProvidersTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/provider/AutoProvidersTest.java @@ -51,7 +51,7 @@ public void beforeTest() { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContextAllowMocks(); + pi4j = Pi4J.newAutoContext(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryGetIoInstance.java b/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryGetIoInstance.java index 1c1c5859..96d1bad8 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryGetIoInstance.java +++ b/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryGetIoInstance.java @@ -53,7 +53,7 @@ public void beforeTest() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContextAllowMocks(); + pi4j = Pi4J.newAutoContext(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryTest.java b/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryTest.java index c7c9ba51..92fcf70d 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/registry/RegistryTest.java @@ -52,7 +52,7 @@ public void beforeTest() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - pi4j = Pi4J.newAutoContextAllowMocks(); + pi4j = Pi4J.newAutoContext(); } @AfterAll diff --git a/pi4j-test/src/test/java/com/pi4j/test/runtime/RuntimeTest.java b/pi4j-test/src/test/java/com/pi4j/test/runtime/RuntimeTest.java index 9c1d58ce..32988406 100644 --- a/pi4j-test/src/test/java/com/pi4j/test/runtime/RuntimeTest.java +++ b/pi4j-test/src/test/java/com/pi4j/test/runtime/RuntimeTest.java @@ -52,7 +52,7 @@ public void testRuntimeShutdownEvents() throws Pi4JException { // An auto context includes AUTO-DETECT BINDINGS enabled // which will load all detected Pi4J extension libraries // (Platforms and Providers) in the class path - Context pi4j = Pi4J.newAutoContextAllowMocks(); + Context pi4j = Pi4J.newAutoContext(); logger.info("-------------------------------------------------"); logger.info("Pi4J CONTEXT