RuntimeProvider { public static ClassLoader getClassLoader() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); if (classLoader == null) { classLoader = RuntimeProvider.class.getClassLoader(); } return classLoader; } private  RuntimeProvider(); static boolean isAndroid(); static ClassLoader getClassLoader(); static String getDefaultWriter(); static long getProcessId(); static Timestamp getStartTime(); static String getCallerClassName(final int depth); static String getCallerClassName(final String loggerClassName); static StackTraceElement getCallerStackTraceElement(final int depth); static StackTraceElement getCallerStackTraceElement(final String loggerClassName); static Timestamp createTimestamp(); static TimestampFormatter createTimestampFormatter(final String pattern, final Locale locale);  }
@Test public void classLoaderFromThread() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { ClassLoader mock = mock(ClassLoader.class); Thread.currentThread().setContextClassLoader(mock); assertThat(RuntimeProvider.getClassLoader()).isSameAs(mock); } finally { Thread.currentThread().setContextClassLoader(classLoader); } }
@Test public void classLoaderNotFromThread() { ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); try { Thread.currentThread().setContextClassLoader(null); assertThat(RuntimeProvider.getClassLoader()).isNotNull(); } finally { Thread.currentThread().setContextClassLoader(classLoader); } }