1616 */
1717package org .apache .logging .log4j .osgi .tests ;
1818
19- import static org .junit .Assert .assertEquals ;
20- import static org .junit .Assert .assertTrue ;
19+ import static org .junit .jupiter .api .Assertions .assertEquals ;
20+ import static org .junit .jupiter .api .Assertions .assertNotEquals ;
21+ import static org .junit .jupiter .api .Assertions .assertTrue ;
2122
2223import java .lang .reflect .Method ;
2324import java .util .List ;
2425import java .util .stream .Collectors ;
2526import java .util .stream .Stream ;
2627import org .apache .logging .log4j .util .ServiceLoaderUtil ;
27- import org .junit .Assert ;
28- import org .junit .Before ;
29- import org .junit .Rule ;
30- import org .junit .Test ;
28+ import org .junit .jupiter .api .BeforeEach ;
29+ import org .junit .jupiter .api .Test ;
30+ import org .junit .jupiter .api .extension .RegisterExtension ;
3131import org .junit .jupiter .api .function .ThrowingConsumer ;
3232import org .osgi .framework .Bundle ;
3333import org .osgi .framework .BundleContext ;
@@ -41,14 +41,14 @@ abstract class AbstractLoadBundleTest {
4141
4242 private BundleContext bundleContext ;
4343
44- @ Rule
45- public final OsgiRule osgi ;
44+ @ RegisterExtension
45+ public final OsgiExt osgi ;
4646
4747 AbstractLoadBundleTest (final FrameworkFactory frameworkFactory ) {
48- this .osgi = new OsgiRule (frameworkFactory );
48+ this .osgi = new OsgiExt (frameworkFactory );
4949 }
5050
51- @ Before
51+ @ BeforeEach
5252 public void before () {
5353 bundleContext = osgi .getFramework ().getBundleContext ();
5454 }
@@ -83,9 +83,8 @@ public void testApiCoreStartStopStartStop() throws BundleException {
8383
8484 final Bundle api = getApiBundle ();
8585 final Bundle core = getCoreBundle ();
86-
87- Assert .assertEquals ("api is not in INSTALLED state" , Bundle .INSTALLED , api .getState ());
88- Assert .assertEquals ("core is not in INSTALLED state" , Bundle .INSTALLED , core .getState ());
86+ assertEquals (Bundle .INSTALLED , api .getState (), "api is not in INSTALLED state" );
87+ assertEquals (Bundle .INSTALLED , core .getState (), "core is not in INSTALLED state" );
8988
9089 // 1st start-stop
9190 doOnBundlesAndVerifyState (Bundle ::start , Bundle .ACTIVE , api , core );
@@ -125,7 +124,7 @@ public void testClassNotFoundErrorLogger() throws BundleException {
125124 throw error0 ;
126125 }
127126 }
128- assertEquals (String .format ("`%s` bundle state mismatch" , core ), Bundle . ACTIVE , core . getState ( ));
127+ assertEquals (Bundle . ACTIVE , core . getState (), String .format ("`%s` bundle state mismatch" , core ));
129128
130129 doOnBundlesAndVerifyState (Bundle ::stop , Bundle .RESOLVED , core , api );
131130 doOnBundlesAndVerifyState (Bundle ::uninstall , Bundle .UNINSTALLED , core , api );
@@ -148,14 +147,14 @@ public void testLog4J12Fragement() throws BundleException, ReflectiveOperationEx
148147 final Class <?> levelClassFrom12API = core .loadClass ("org.apache.log4j.Level" );
149148 final Class <?> levelClassFromAPI = core .loadClass ("org.apache.logging.log4j.Level" );
150149
151- Assert .assertEquals (
152- "expected 1.2 API Level to have the same class loader as Core" ,
150+ assertEquals (
153151 levelClassFrom12API .getClassLoader (),
154- coreClassFromCore .getClassLoader ());
155- Assert . assertNotEquals (
156- "expected 1.2 API Level NOT to have the same class loader as API Level" ,
152+ coreClassFromCore .getClassLoader (),
153+ "expected 1.2 API Level to have the same class loader as Core" );
154+ assertNotEquals (
157155 levelClassFrom12API .getClassLoader (),
158- levelClassFromAPI .getClassLoader ());
156+ levelClassFromAPI .getClassLoader (),
157+ "expected 1.2 API Level NOT to have the same class loader as API Level" );
159158
160159 doOnBundlesAndVerifyState (Bundle ::stop , Bundle .RESOLVED , core , api );
161160 doOnBundlesAndVerifyState (Bundle ::uninstall , Bundle .UNINSTALLED , compat , core , api );
@@ -171,8 +170,7 @@ public void testServiceLoader() throws BundleException, ReflectiveOperationExcep
171170 final Bundle apiTests = getApiTestsBundle ();
172171
173172 final Class <?> osgiServiceLocator = api .loadClass ("org.apache.logging.log4j.util.OsgiServiceLocator" );
174- assertTrue ("OsgiServiceLocator is active" , (boolean )
175- osgiServiceLocator .getMethod ("isAvailable" ).invoke (null ));
173+ assertTrue ((boolean ) osgiServiceLocator .getMethod ("isAvailable" ).invoke (null ), "OsgiServiceLocator is active" );
176174
177175 doOnBundlesAndVerifyState (Bundle ::start , Bundle .ACTIVE , api , core , apiTests );
178176
@@ -202,7 +200,7 @@ private static void doOnBundlesAndVerifyState(
202200 final String message = String .format ("operation failure for bundle `%s`" , bundle );
203201 throw new RuntimeException (message , error );
204202 }
205- assertEquals (String .format ("`%s` bundle state mismatch" , bundle ), expectedState , bundle . getState ( ));
203+ assertEquals (expectedState , bundle . getState (), String .format ("`%s` bundle state mismatch" , bundle ));
206204 }
207205 }
208206}
0 commit comments