### Question:
ClassLoaderResolver implements Closeable { public ClassLoader resolve(MavenCoordinate mavenCoordinate) throws MojoFailureException, MojoExecutionException { ClassLoader classLoader = classLoaders.get(mavenCoordinate); if (classLoader == null) { classLoader = doResolve(mavenCoordinate); classLoaders.put(mavenCoordinate, classLoader); } return classLoader; } ClassLoaderResolver(Log log, RepositorySystem repositorySystem, RepositorySystemSession repositorySystemSession, List<RemoteRepository> remoteRepositories); ClassLoader resolve(MavenCoordinate mavenCoordinate); void close();  }### Answer:
@Test public void testResolution() throws Exception { assertThat(classLoaderResolver.resolve(new MavenCoordinate(FOO, BAR, QUX, JAR)), sameInstance(classLoaderResolver.resolve(new MavenCoordinate(FOO, BAR, QUX, JAR)))); }
@Test(expected = MojoExecutionException.class) public void testCollectionFailure() throws Exception { when(repositorySystem.collectDependencies(eq(repositorySystemSession), any(CollectRequest.class))) .thenThrow(new DependencyCollectionException(new CollectResult(new CollectRequest()))); classLoaderResolver.resolve(new MavenCoordinate(FOO, BAR, QUX, JAR)); }
@Test(expected = MojoExecutionException.class) public void testResolutionFailure() throws Exception { when(repositorySystem.resolveDependencies(eq(repositorySystemSession), any(DependencyRequest.class))) .thenThrow(new DependencyResolutionException(new DependencyResult(new DependencyRequest(root, mock(DependencyFilter.class))), new Throwable())); classLoaderResolver.resolve(new MavenCoordinate(FOO, BAR, QUX, JAR)); }