DefaultClassNameResolver extends ClassNameResolver { @Override public boolean isInClassLoader(@Nonnull String cls, @Nonnull ClassLoader classLoader) { DockerCloudUtils.requireNonNull(cls, "Class name cannot be null."); DockerCloudUtils.requireNonNull(classLoader, "Class-loader cannot be null."); try { classLoader.loadClass(cls); return true; } catch (ClassNotFoundException e) { return false; } }  @Override boolean isInClassLoader(@Nonnull String cls, @Nonnull ClassLoader classLoader);  }
@Test public void shouldUseProvidedClassloader() { TestClassLoader cl = new TestClassLoader(); ClassNameResolver.getDefault().isInClassLoader("some.non.existing.class", cl); assertThat(cl.getQueriedClass()).isEqualTo("some.non.existing.class"); }
@Test public void isInClassLoaderReturnsFalseWhenClassNotFound() { TestClassLoader cl = new TestClassLoader(); ClassNameResolver resolver = ClassNameResolver.getDefault();; assertThat(resolver.isInClassLoader("some.non.existing.class", cl)).isFalse(); }
@Test public void isInClassLoaderReturnsTrueWhenClassFound() { TestClassLoader cl = new TestClassLoader(); ClassNameResolver resolver = ClassNameResolver.getDefault();; assertThat(resolver.isInClassLoader(DockerCloudUtils.class.getName(), cl)).isTrue(); }