Skip to content

Commit

Permalink
Merge pull request #420 from Pi4J/build_on_pi_mocks
Browse files Browse the repository at this point in the history
Build on pi requires Mock Providers be loaded for the test case execution
  • Loading branch information
FDelporte authored Nov 22, 2024
2 parents ffcdc13 + 73c8c70 commit 0013c8a
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,14 @@ public Runtime initialize() throws InitializeException {
plugin.initialize(DefaultPluginService.newInstance(this.context(), store));

// if auto-detect providers is enabled,
// OR
// Detecting Mocks is enabled and this is a mock plugin
// then add any detected providers to the collection to load
if (config.autoDetectProviders()) {
if (config.autoDetectProviders() || (config.autoDetectMockPlugins() && plugin.isMock())) {
store.providers.forEach(provider -> addProvider(provider, providers));
}


// if auto-detect platforms is enabled,
// then add any detected platforms to the collection to load
if (config.autoDetectPlatforms()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.newAutoContext();
pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ 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.newAutoContext();
pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();

}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.newAutoContext();
pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.newAutoContext();
pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.newAutoContext();
pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,7 @@ public void beforeTest() {
// Initialize Pi4J with AUTO-DETECT disabled
// we don't want to load any detected Pi4J extension
// libraries (Platforms and Providers) from the class path
pi4j = Pi4J.newContextBuilder()

// add any platforms that we want to work with
.add(new MockPlatform())

// add any providers that we want to work with
.add(MockAnalogInputProvider.newInstance(),
MockAnalogOutputProvider.newInstance(),
MockDigitalInputProvider.newInstance(),
MockDigitalOutputProvider.newInstance(),
MockPwmProvider.newInstance(),
MockI2CProvider.newInstance(),
MockSpiProvider.newInstance(),
MockSerialProvider.newInstance())
.build();
pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.newAutoContext();
pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.newAutoContext();
pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.newAutoContext();
pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();
}

@AfterAll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.newAutoContext();
Context pi4j = Pi4J.newContextBuilder().autoDetectMockPlugins().autoDetectPlatforms().build();

logger.info("-------------------------------------------------");
logger.info("Pi4J CONTEXT <acquired via factory accessor>");
Expand Down

0 comments on commit 0013c8a

Please sign in to comment.