-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
All unit tests use the same testing logging provider (#8593)
Make sure that the correct test logging provider is loaded in `project-manager/Test`, so that only WARN and ERROR log messages are displayed. Also, make sure that the test log provider parses the correct configuration file - Rename all the `application.conf` files in the test resources to `application-test.conf`. The problem was introduced in #8467
- Loading branch information
Showing
14 changed files
with
99 additions
and
182 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
engine/runtime/src/test/java/org/enso/interpreter/test/TestLogProviderOnClasspath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.enso.interpreter.test; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.*; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.ServiceLoader; | ||
import java.util.stream.Collectors; | ||
import org.junit.Test; | ||
import org.slf4j.spi.SLF4JServiceProvider; | ||
|
||
/** | ||
* In the `runtime/Test` testing suite, {@link org.enso.logger.TestLogProvider} should be among the | ||
* logging providers, because it is explicitly chosen as the logging provider for the tests. | ||
*/ | ||
public class TestLogProviderOnClasspath { | ||
@Test | ||
public void testLogProviderOnClasspath() { | ||
var sl = ServiceLoader.load(SLF4JServiceProvider.class); | ||
var serviceIterator = sl.iterator(); | ||
List<SLF4JServiceProvider> providers = new ArrayList<>(); | ||
while (serviceIterator.hasNext()) { | ||
providers.add(serviceIterator.next()); | ||
} | ||
List<String> providerNames = | ||
providers.stream().map(elem -> elem.getClass().getName()).collect(Collectors.toList()); | ||
assertThat(providerNames, hasItem("org.enso.logger.TestLogProvider")); | ||
} | ||
|
||
@Test | ||
public void testLogProviderIsInUnnamedModule() throws Exception { | ||
var testLogProviderClass = Class.forName("org.enso.logger.TestLogProvider"); | ||
var mod = testLogProviderClass.getModule(); | ||
assertThat(mod, notNullValue()); | ||
assertThat("Should be an unnamed module - with null name", mod.getName(), nullValue()); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Empty |
1 change: 1 addition & 0 deletions
1
lib/scala/library-manager-test/src/test/resources/application-test.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Empty |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...ala/project-manager/src/test/java/org/enso/projectmanager/TestLogProviderOnClasspath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.enso.projectmanager; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.*; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.ServiceLoader; | ||
import java.util.stream.Collectors; | ||
import org.junit.Test; | ||
import org.slf4j.spi.SLF4JServiceProvider; | ||
|
||
/** | ||
* In the `runtime/Test` testing suite, {@link }org.enso.logger.TestLogProvider} should be among the | ||
* logging providers, because it is explicitly chosen as the logging provider for the tests. | ||
* | ||
* <p>Note that the same test is in the `runtime/Test` project. | ||
*/ | ||
public class TestLogProviderOnClasspath { | ||
@Test | ||
public void testLogProviderIsOnClasspath() { | ||
var sl = ServiceLoader.load(SLF4JServiceProvider.class); | ||
var serviceIterator = sl.iterator(); | ||
List<SLF4JServiceProvider> providers = new ArrayList<>(); | ||
while (serviceIterator.hasNext()) { | ||
providers.add(serviceIterator.next()); | ||
} | ||
List<String> providerNames = | ||
providers.stream().map(elem -> elem.getClass().getName()).collect(Collectors.toList()); | ||
assertThat(providerNames, hasItem("org.enso.logger.TestLogProvider")); | ||
} | ||
|
||
@Test | ||
public void testLogProviderIsInUnnamedModule() { | ||
Class<?> testLogProviderClass = null; | ||
try { | ||
testLogProviderClass = Class.forName("org.enso.logger.TestLogProvider"); | ||
} catch (ClassNotFoundException e) { | ||
fail("TestLogProvider class not found"); | ||
} | ||
var mod = testLogProviderClass.getModule(); | ||
assertThat(mod, notNullValue()); | ||
assertThat("Should be an unnamed module - with null name", mod.getName(), nullValue()); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.