Reformat code use Eclipse Mars

This commit is contained in:
Phillip Webb
2015-10-07 23:32:31 -07:00
parent ba7c1fda72
commit 6ab376e2e8
652 changed files with 4151 additions and 3919 deletions

View File

@@ -160,8 +160,8 @@ public class CliTester implements TestRule {
@Override
public Statement apply(final Statement base, final Description description) {
final Statement statement = CliTester.this.outputCapture.apply(
new RunLauncherStatement(base), description);
final Statement statement = CliTester.this.outputCapture
.apply(new RunLauncherStatement(base), description);
return new Statement() {
@Override
@@ -181,8 +181,8 @@ public class CliTester implements TestRule {
public String getHttpOutput(String uri) {
try {
InputStream stream = URI.create("http://localhost:" + this.port + uri)
.toURL().openStream();
InputStream stream = URI.create("http://localhost:" + this.port + uri).toURL()
.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
String line;
StringBuilder result = new StringBuilder();

View File

@@ -155,8 +155,8 @@ public class CommandRunnerTests {
willThrow(new NullPointerException()).given(this.regularCommand).run();
int status = this.commandRunner.runAndHandleErrors("command");
assertThat(status, equalTo(1));
assertThat(this.calls, equalTo((Set<Call>) EnumSet.of(Call.ERROR_MESSAGE,
Call.PRINT_STACK_TRACE)));
assertThat(this.calls, equalTo(
(Set<Call>) EnumSet.of(Call.ERROR_MESSAGE, Call.PRINT_STACK_TRACE)));
}
@Test
@@ -165,8 +165,8 @@ public class CommandRunnerTests {
int status = this.commandRunner.runAndHandleErrors("command", "-d");
assertEquals("true", System.getProperty("debug"));
assertThat(status, equalTo(1));
assertThat(this.calls, equalTo((Set<Call>) EnumSet.of(Call.ERROR_MESSAGE,
Call.PRINT_STACK_TRACE)));
assertThat(this.calls, equalTo(
(Set<Call>) EnumSet.of(Call.ERROR_MESSAGE, Call.PRINT_STACK_TRACE)));
}
@Test
@@ -175,8 +175,8 @@ public class CommandRunnerTests {
int status = this.commandRunner.runAndHandleErrors("command", "--debug");
assertEquals("true", System.getProperty("debug"));
assertThat(status, equalTo(1));
assertThat(this.calls, equalTo((Set<Call>) EnumSet.of(Call.ERROR_MESSAGE,
Call.PRINT_STACK_TRACE)));
assertThat(this.calls, equalTo(
(Set<Call>) EnumSet.of(Call.ERROR_MESSAGE, Call.PRINT_STACK_TRACE)));
}
@Test

View File

@@ -87,8 +87,8 @@ public abstract class AbstractHttpClientMockTests {
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
mockHttpEntity(response, request.content, request.contentType);
mockStatus(response, 200);
String header = (request.fileName != null ? contentDispositionValue(request.fileName)
: null);
String header = (request.fileName != null
? contentDispositionValue(request.fileName) : null);
mockHttpHeader(response, "Content-Disposition", header);
given(this.http.execute(argThat(getForNonMetadata()))).willReturn(response);
}
@@ -117,8 +117,8 @@ public abstract class AbstractHttpClientMockTests {
try {
HttpEntity entity = mock(HttpEntity.class);
given(entity.getContent()).willReturn(new ByteArrayInputStream(content));
Header contentTypeHeader = contentType != null ? new BasicHeader(
"Content-Type", contentType) : null;
Header contentTypeHeader = contentType != null
? new BasicHeader("Content-Type", contentType) : null;
given(entity.getContentType()).willReturn(contentTypeHeader);
given(response.getEntity()).willReturn(entity);
return entity;

View File

@@ -241,7 +241,8 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
MockHttpProjectGenerationRequest request = new MockHttpProjectGenerationRequest(
"application/zip", file.getAbsolutePath());
mockSuccessfulProjectGeneration(request);
assertEquals("Should not have failed", ExitStatus.OK, this.command.run("--force"));
assertEquals("Should not have failed", ExitStatus.OK,
this.command.run("--force"));
assertTrue("File should have changed", fileLength != file.length());
}
@@ -369,8 +370,8 @@ public class InitCommandTests extends AbstractHttpClientMockTests {
return bos.toByteArray();
}
private static class TestableInitCommandOptionHandler extends
InitCommand.InitOptionHandler {
private static class TestableInitCommandOptionHandler
extends InitCommand.InitOptionHandler {
private boolean disableProjectGeneration;

View File

@@ -62,8 +62,8 @@ public class InitializrServiceMetadataTests {
// Security description
assertEquals("AOP", metadata.getDependency("aop").getName());
assertEquals("Security", metadata.getDependency("security").getName());
assertEquals("Security description", metadata.getDependency("security")
.getDescription());
assertEquals("Security description",
metadata.getDependency("security").getDescription());
assertEquals("JDBC", metadata.getDependency("jdbc").getName());
assertEquals("JPA", metadata.getDependency("data-jpa").getName());
assertEquals("MongoDB", metadata.getDependency("data-mongodb").getName());
@@ -88,12 +88,12 @@ public class InitializrServiceMetadataTests {
}
private static JSONObject readJson(String version) throws IOException {
Resource resource = new ClassPathResource("metadata/service-metadata-" + version
+ ".json");
Resource resource = new ClassPathResource(
"metadata/service-metadata-" + version + ".json");
InputStream stream = resource.getInputStream();
try {
return new JSONObject(StreamUtils.copyToString(stream,
Charset.forName("UTF-8")));
return new JSONObject(
StreamUtils.copyToString(stream, Charset.forName("UTF-8")));
}
finally {
stream.close();

View File

@@ -57,7 +57,8 @@ public class InitializrServiceTests extends AbstractHttpClientMockTests {
MockHttpProjectGenerationRequest mockHttpRequest = new MockHttpProjectGenerationRequest(
"application/xml", "foo.zip");
ProjectGenerationResponse entity = generateProject(request, mockHttpRequest);
assertProjectEntity(entity, mockHttpRequest.contentType, mockHttpRequest.fileName);
assertProjectEntity(entity, mockHttpRequest.contentType,
mockHttpRequest.fileName);
}
@Test
@@ -158,8 +159,8 @@ public class InitializrServiceTests extends AbstractHttpClientMockTests {
assertNull("No content type expected", entity.getContentType());
}
else {
assertEquals("wrong mime type", mimeType, entity.getContentType()
.getMimeType());
assertEquals("wrong mime type", mimeType,
entity.getContentType().getMimeType());
}
assertEquals("wrong filename", fileName, entity.getFileName());
}

View File

@@ -59,8 +59,9 @@ public class ProjectGenerationRequestTests {
String customServerUrl = "http://foo:8080/initializr";
this.request.setServiceUrl(customServerUrl);
this.request.getDependencies().add("security");
assertEquals(new URI(customServerUrl
+ "/starter.zip?dependencies=security&type=test-type"),
assertEquals(
new URI(customServerUrl
+ "/starter.zip?dependencies=security&type=test-type"),
this.request.generateUrl(createDefaultMetadata()));
}
@@ -107,8 +108,9 @@ public class ProjectGenerationRequestTests {
InitializrServiceMetadata metadata = new InitializrServiceMetadata(projectType);
this.request.setType("custom");
this.request.getDependencies().add("data-rest");
assertEquals(new URI(ProjectGenerationRequest.DEFAULT_SERVICE_URL
+ "/foo?dependencies=data-rest&type=custom"),
assertEquals(
new URI(ProjectGenerationRequest.DEFAULT_SERVICE_URL
+ "/foo?dependencies=data-rest&type=custom"),
this.request.generateUrl(metadata));
}
@@ -193,8 +195,8 @@ public class ProjectGenerationRequestTests {
private static InitializrServiceMetadata readMetadata(String version) {
try {
Resource resource = new ClassPathResource("metadata/service-metadata-"
+ version + ".json");
Resource resource = new ClassPathResource(
"metadata/service-metadata-" + version + ".json");
String content = StreamUtils.copyToString(resource.getInputStream(),
Charset.forName("UTF-8"));
JSONObject json = new JSONObject(content);

View File

@@ -85,16 +85,16 @@ public class GroovyGrabDependencyResolverTests {
@Test
public void resolveArtifactWithNoDependencies() throws Exception {
List<File> resolved = this.resolver.resolve(Arrays
.asList("commons-logging:commons-logging:1.1.3"));
List<File> resolved = this.resolver
.resolve(Arrays.asList("commons-logging:commons-logging:1.1.3"));
assertThat(resolved, hasSize(1));
assertThat(getNames(resolved), hasItems("commons-logging-1.1.3.jar"));
}
@Test
public void resolveArtifactWithDependencies() throws Exception {
List<File> resolved = this.resolver.resolve(Arrays
.asList("org.springframework:spring-core:4.1.1.RELEASE"));
List<File> resolved = this.resolver
.resolve(Arrays.asList("org.springframework:spring-core:4.1.1.RELEASE"));
assertThat(resolved, hasSize(2));
assertThat(getNames(resolved),
hasItems("commons-logging-1.1.3.jar", "spring-core-4.1.1.RELEASE.jar"));
@@ -114,10 +114,8 @@ public class GroovyGrabDependencyResolverTests {
List<File> resolved = this.resolver.resolve(Arrays.asList("junit:junit:4.11",
"commons-logging:commons-logging:1.1.3"));
assertThat(resolved, hasSize(3));
assertThat(
getNames(resolved),
hasItems("junit-4.11.jar", "commons-logging-1.1.3.jar",
"hamcrest-core-1.3.jar"));
assertThat(getNames(resolved), hasItems("junit-4.11.jar",
"commons-logging-1.1.3.jar", "hamcrest-core-1.3.jar"));
}
public Set<String> getNames(Collection<File> files) {

View File

@@ -84,18 +84,18 @@ public class InstallerTests {
File alpha = createTemporaryFile("alpha.jar");
File bravo = createTemporaryFile("bravo.jar");
File charlie = createTemporaryFile("charlie.jar");
given(this.resolver.resolve(Arrays.asList("bravo"))).willReturn(
Arrays.asList(bravo, alpha));
given(this.resolver.resolve(Arrays.asList("charlie"))).willReturn(
Arrays.asList(charlie, alpha));
given(this.resolver.resolve(Arrays.asList("bravo")))
.willReturn(Arrays.asList(bravo, alpha));
given(this.resolver.resolve(Arrays.asList("charlie")))
.willReturn(Arrays.asList(charlie, alpha));
this.installer.install(Arrays.asList("bravo"));
assertThat(getNamesOfFilesInLib(),
containsInAnyOrder("alpha.jar", "bravo.jar", ".installed"));
this.installer.install(Arrays.asList("charlie"));
assertThat(getNamesOfFilesInLib(),
containsInAnyOrder("alpha.jar", "bravo.jar", "charlie.jar", ".installed"));
assertThat(getNamesOfFilesInLib(), containsInAnyOrder("alpha.jar", "bravo.jar",
"charlie.jar", ".installed"));
this.installer.uninstall(Arrays.asList("bravo"));
assertThat(getNamesOfFilesInLib(),
@@ -111,15 +111,15 @@ public class InstallerTests {
File bravo = createTemporaryFile("bravo.jar");
File charlie = createTemporaryFile("charlie.jar");
given(this.resolver.resolve(Arrays.asList("bravo"))).willReturn(
Arrays.asList(bravo, alpha));
given(this.resolver.resolve(Arrays.asList("charlie"))).willReturn(
Arrays.asList(charlie, alpha));
given(this.resolver.resolve(Arrays.asList("bravo")))
.willReturn(Arrays.asList(bravo, alpha));
given(this.resolver.resolve(Arrays.asList("charlie")))
.willReturn(Arrays.asList(charlie, alpha));
this.installer.install(Arrays.asList("bravo"));
this.installer.install(Arrays.asList("charlie"));
assertThat(getNamesOfFilesInLib(),
containsInAnyOrder("alpha.jar", "bravo.jar", "charlie.jar", ".installed"));
assertThat(getNamesOfFilesInLib(), containsInAnyOrder("alpha.jar", "bravo.jar",
"charlie.jar", ".installed"));
this.installer.uninstallAll();
assertThat(getNamesOfFilesInLib(), containsInAnyOrder(".installed"));

View File

@@ -45,10 +45,11 @@ public class ResourceMatcherTests {
@Test
public void nonExistentRoot() throws IOException {
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("alpha/**",
"bravo/*", "*"), Arrays.asList(".*", "alpha/**/excluded"));
List<MatchedResource> matchedResources = resourceMatcher.find(Arrays
.asList(new File("does-not-exist")));
ResourceMatcher resourceMatcher = new ResourceMatcher(
Arrays.asList("alpha/**", "bravo/*", "*"),
Arrays.asList(".*", "alpha/**/excluded"));
List<MatchedResource> matchedResources = resourceMatcher
.find(Arrays.asList(new File("does-not-exist")));
assertEquals(0, matchedResources.size());
}
@@ -67,18 +68,18 @@ public class ResourceMatcherTests {
public void excludedWins() throws Exception {
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("*"),
Arrays.asList("**/*.jar"));
List<MatchedResource> found = resourceMatcher.find(Arrays.asList(new File(
"src/test/resources")));
List<MatchedResource> found = resourceMatcher
.find(Arrays.asList(new File("src/test/resources")));
assertThat(found, not(hasItem(new FooJarMatcher(MatchedResource.class))));
}
@SuppressWarnings("unchecked")
@Test
public void includedDeltas() throws Exception {
ResourceMatcher resourceMatcher = new ResourceMatcher(
Arrays.asList("-static/**"), Arrays.asList(""));
Collection<String> includes = (Collection<String>) ReflectionTestUtils.getField(
resourceMatcher, "includes");
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("-static/**"),
Arrays.asList(""));
Collection<String> includes = (Collection<String>) ReflectionTestUtils
.getField(resourceMatcher, "includes");
assertTrue(includes.contains("templates/**"));
assertFalse(includes.contains("static/**"));
}
@@ -86,10 +87,10 @@ public class ResourceMatcherTests {
@SuppressWarnings("unchecked")
@Test
public void includedDeltasAndNewEntries() throws Exception {
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("-static/**",
"foo.jar"), Arrays.asList("-**/*.jar"));
Collection<String> includes = (Collection<String>) ReflectionTestUtils.getField(
resourceMatcher, "includes");
ResourceMatcher resourceMatcher = new ResourceMatcher(
Arrays.asList("-static/**", "foo.jar"), Arrays.asList("-**/*.jar"));
Collection<String> includes = (Collection<String>) ReflectionTestUtils
.getField(resourceMatcher, "includes");
assertTrue(includes.contains("foo.jar"));
assertTrue(includes.contains("templates/**"));
assertFalse(includes.contains("static/**"));
@@ -110,8 +111,9 @@ public class ResourceMatcherTests {
public void jarFileAlwaysMatches() throws Exception {
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("*"),
Arrays.asList("**/*.jar"));
List<MatchedResource> found = resourceMatcher.find(Arrays.asList(new File(
"src/test/resources/templates"), new File("src/test/resources/foo.jar")));
List<MatchedResource> found = resourceMatcher
.find(Arrays.asList(new File("src/test/resources/templates"),
new File("src/test/resources/foo.jar")));
FooJarMatcher matcher = new FooJarMatcher(MatchedResource.class);
assertThat(found, hasItem(matcher));
// A jar file is always treated as a dependency (stick it in /lib)
@@ -120,12 +122,13 @@ public class ResourceMatcherTests {
@Test
public void resourceMatching() throws IOException {
ResourceMatcher resourceMatcher = new ResourceMatcher(Arrays.asList("alpha/**",
"bravo/*", "*"), Arrays.asList(".*", "alpha/**/excluded"));
List<MatchedResource> matchedResources = resourceMatcher.find(Arrays.asList(
new File("src/test/resources/resource-matcher/one"), new File(
"src/test/resources/resource-matcher/two"), new File(
"src/test/resources/resource-matcher/three")));
ResourceMatcher resourceMatcher = new ResourceMatcher(
Arrays.asList("alpha/**", "bravo/*", "*"),
Arrays.asList(".*", "alpha/**/excluded"));
List<MatchedResource> matchedResources = resourceMatcher
.find(Arrays.asList(new File("src/test/resources/resource-matcher/one"),
new File("src/test/resources/resource-matcher/two"),
new File("src/test/resources/resource-matcher/three")));
System.out.println(matchedResources);
List<String> paths = new ArrayList<String>();
for (MatchedResource resource : matchedResources) {

View File

@@ -35,8 +35,8 @@ public class EscapeAwareWhiteSpaceArgumentDelimiterTests {
@Test
public void simple() throws Exception {
String s = "one two";
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
"one", "two" }));
assertThat(this.delimiter.delimit(s, 0).getArguments(),
equalTo(new String[] { "one", "two" }));
assertThat(this.delimiter.parseArguments(s),
equalTo(new String[] { "one", "two" }));
assertThat(this.delimiter.isDelimiter(s, 2), equalTo(false));
@@ -47,8 +47,8 @@ public class EscapeAwareWhiteSpaceArgumentDelimiterTests {
@Test
public void escaped() throws Exception {
String s = "o\\ ne two";
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
"o\\ ne", "two" }));
assertThat(this.delimiter.delimit(s, 0).getArguments(),
equalTo(new String[] { "o\\ ne", "two" }));
assertThat(this.delimiter.parseArguments(s),
equalTo(new String[] { "o ne", "two" }));
assertThat(this.delimiter.isDelimiter(s, 2), equalTo(false));
@@ -60,28 +60,28 @@ public class EscapeAwareWhiteSpaceArgumentDelimiterTests {
@Test
public void quoted() throws Exception {
String s = "'o ne' 't w o'";
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
"'o ne'", "'t w o'" }));
assertThat(this.delimiter.parseArguments(s), equalTo(new String[] { "o ne",
"t w o" }));
assertThat(this.delimiter.delimit(s, 0).getArguments(),
equalTo(new String[] { "'o ne'", "'t w o'" }));
assertThat(this.delimiter.parseArguments(s),
equalTo(new String[] { "o ne", "t w o" }));
}
@Test
public void doubleQuoted() throws Exception {
String s = "\"o ne\" \"t w o\"";
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
"\"o ne\"", "\"t w o\"" }));
assertThat(this.delimiter.parseArguments(s), equalTo(new String[] { "o ne",
"t w o" }));
assertThat(this.delimiter.delimit(s, 0).getArguments(),
equalTo(new String[] { "\"o ne\"", "\"t w o\"" }));
assertThat(this.delimiter.parseArguments(s),
equalTo(new String[] { "o ne", "t w o" }));
}
@Test
public void nestedQuotes() throws Exception {
String s = "\"o 'n''e\" 't \"w o'";
assertThat(this.delimiter.delimit(s, 0).getArguments(), equalTo(new String[] {
"\"o 'n''e\"", "'t \"w o'" }));
assertThat(this.delimiter.parseArguments(s), equalTo(new String[] { "o 'n''e",
"t \"w o" }));
assertThat(this.delimiter.delimit(s, 0).getArguments(),
equalTo(new String[] { "\"o 'n''e\"", "'t \"w o'" }));
assertThat(this.delimiter.parseArguments(s),
equalTo(new String[] { "o 'n''e", "t \"w o" }));
}
@Test
@@ -95,7 +95,8 @@ public class EscapeAwareWhiteSpaceArgumentDelimiterTests {
@Test
public void escapes() throws Exception {
String s = "\\ \\\\.\\\\\\t";
assertThat(this.delimiter.parseArguments(s), equalTo(new String[] { " \\.\\\t" }));
assertThat(this.delimiter.parseArguments(s),
equalTo(new String[] { " \\.\\\t" }));
}
}

View File

@@ -56,15 +56,15 @@ public class DependencyCustomizerTests {
@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
given(this.resolver.getGroupId("spring-boot-starter-logging")).willReturn(
"org.springframework.boot");
given(this.resolver.getArtifactId("spring-boot-starter-logging")).willReturn(
"spring-boot-starter-logging");
given(this.resolver.getGroupId("spring-boot-starter-logging"))
.willReturn("org.springframework.boot");
given(this.resolver.getArtifactId("spring-boot-starter-logging"))
.willReturn("spring-boot-starter-logging");
given(this.resolver.getVersion("spring-boot-starter-logging"))
.willReturn("1.2.3");
this.moduleNode.addClass(this.classNode);
this.dependencyCustomizer = new DependencyCustomizer(new GroovyClassLoader(
getClass().getClassLoader()), this.moduleNode,
this.dependencyCustomizer = new DependencyCustomizer(
new GroovyClassLoader(getClass().getClassLoader()), this.moduleNode,
new DependencyResolutionContext(this.resolver));
}
@@ -99,48 +99,52 @@ public class DependencyCustomizerTests {
assertEquals(1, grabAnnotations.size());
AnnotationNode annotationNode = grabAnnotations.get(0);
assertGrabAnnotation(annotationNode, "org.springframework.boot",
"spring-boot-starter-logging", "1.2.3", "my-classifier", "my-type", false);
"spring-boot-starter-logging", "1.2.3", "my-classifier", "my-type",
false);
}
@Test
public void anyMissingClassesWithMissingClassesPerformsAdd() {
this.dependencyCustomizer.ifAnyMissingClasses("does.not.Exist").add(
"spring-boot-starter-logging");
this.dependencyCustomizer.ifAnyMissingClasses("does.not.Exist")
.add("spring-boot-starter-logging");
assertEquals(1, this.classNode.getAnnotations(new ClassNode(Grab.class)).size());
}
@Test
public void anyMissingClassesWithMixtureOfClassesPerformsAdd() {
this.dependencyCustomizer.ifAnyMissingClasses(getClass().getName(),
"does.not.Exist").add("spring-boot-starter-logging");
this.dependencyCustomizer
.ifAnyMissingClasses(getClass().getName(), "does.not.Exist")
.add("spring-boot-starter-logging");
assertEquals(1, this.classNode.getAnnotations(new ClassNode(Grab.class)).size());
}
@Test
public void anyMissingClassesWithNoMissingClassesDoesNotPerformAdd() {
this.dependencyCustomizer.ifAnyMissingClasses(getClass().getName()).add(
"spring-boot-starter-logging");
this.dependencyCustomizer.ifAnyMissingClasses(getClass().getName())
.add("spring-boot-starter-logging");
assertEquals(0, this.classNode.getAnnotations(new ClassNode(Grab.class)).size());
}
@Test
public void allMissingClassesWithNoMissingClassesDoesNotPerformAdd() {
this.dependencyCustomizer.ifAllMissingClasses(getClass().getName()).add(
"spring-boot-starter-logging");
this.dependencyCustomizer.ifAllMissingClasses(getClass().getName())
.add("spring-boot-starter-logging");
assertEquals(0, this.classNode.getAnnotations(new ClassNode(Grab.class)).size());
}
@Test
public void allMissingClassesWithMixtureOfClassesDoesNotPerformAdd() {
this.dependencyCustomizer.ifAllMissingClasses(getClass().getName(),
"does.not.Exist").add("spring-boot-starter-logging");
this.dependencyCustomizer
.ifAllMissingClasses(getClass().getName(), "does.not.Exist")
.add("spring-boot-starter-logging");
assertEquals(0, this.classNode.getAnnotations(new ClassNode(Grab.class)).size());
}
@Test
public void allMissingClassesWithAllClassesMissingPerformsAdd() {
this.dependencyCustomizer.ifAllMissingClasses("does.not.Exist",
"does.not.exist.Either").add("spring-boot-starter-logging");
this.dependencyCustomizer
.ifAllMissingClasses("does.not.Exist", "does.not.exist.Either")
.add("spring-boot-starter-logging");
assertEquals(1, this.classNode.getAnnotations(new ClassNode(Grab.class)).size());
}

View File

@@ -63,7 +63,8 @@ public final class ResolveDependencyCoordinatesTransformationTests {
private final AnnotationNode grabAnnotation = createGrabAnnotation();
private final ArtifactCoordinatesResolver coordinatesResolver = mock(ArtifactCoordinatesResolver.class);
private final ArtifactCoordinatesResolver coordinatesResolver = mock(
ArtifactCoordinatesResolver.class);
private final DependencyResolutionContext resolutionContext = new DependencyResolutionContext(
this.coordinatesResolver);
@@ -73,8 +74,8 @@ public final class ResolveDependencyCoordinatesTransformationTests {
@Before
public void setupExpectations() {
given(this.coordinatesResolver.getGroupId("spring-core")).willReturn(
"org.springframework");
given(this.coordinatesResolver.getGroupId("spring-core"))
.willReturn("org.springframework");
given(this.coordinatesResolver.getVersion("spring-core")).willReturn("4.0.0.RC1");
}
@@ -229,8 +230,8 @@ public final class ResolveDependencyCoordinatesTransformationTests {
return null;
}
else {
throw new IllegalStateException("Member '" + memberName
+ "' is not a ConstantExpression");
throw new IllegalStateException(
"Member '" + memberName + "' is not a ConstantExpression");
}
}

View File

@@ -49,9 +49,9 @@ public class AetherGrapeEngineTests {
private final AetherGrapeEngine grapeEngine = createGrapeEngine();
private AetherGrapeEngine createGrapeEngine() {
return AetherGrapeEngineFactory.create(this.groovyClassLoader, Arrays
.asList(new RepositoryConfiguration("central", URI
.create("http://repo1.maven.org/maven2"), false)),
return AetherGrapeEngineFactory.create(this.groovyClassLoader,
Arrays.asList(new RepositoryConfiguration("central",
URI.create("http://repo1.maven.org/maven2"), false)),
new DependencyResolutionContext());
}
@@ -134,10 +134,8 @@ public class AetherGrapeEngineTests {
public void nonTransitiveDependencyResolution() {
Map<String, Object> args = new HashMap<String, Object>();
this.grapeEngine.grab(
args,
createDependency("org.springframework", "spring-jdbc", "3.2.4.RELEASE",
false));
this.grapeEngine.grab(args, createDependency("org.springframework", "spring-jdbc",
"3.2.4.RELEASE", false));
assertEquals(1, this.groovyClassLoader.getURLs().length);
}
@@ -158,8 +156,8 @@ public class AetherGrapeEngineTests {
@Test
public void resolutionWithCustomResolver() {
Map<String, Object> args = new HashMap<String, Object>();
this.grapeEngine.addResolver(createResolver("restlet.org",
"http://maven.restlet.org"));
this.grapeEngine
.addResolver(createResolver("restlet.org", "http://maven.restlet.org"));
this.grapeEngine.grab(args,
createDependency("org.restlet", "org.restlet", "1.1.6"));
assertEquals(1, this.groovyClassLoader.getURLs().length);

View File

@@ -58,38 +58,36 @@ public class GrapeRootRepositorySystemSessionAutoConfigurationTests {
@Test
public void noLocalRepositoryWhenNoGrapeRoot() {
given(
this.repositorySystem.newLocalRepositoryManager(eq(this.session),
any(LocalRepository.class))).willAnswer(
new Answer<LocalRepositoryManager>() {
given(this.repositorySystem.newLocalRepositoryManager(eq(this.session),
any(LocalRepository.class)))
.willAnswer(new Answer<LocalRepositoryManager>() {
@Override
public LocalRepositoryManager answer(InvocationOnMock invocation)
throws Throwable {
LocalRepository localRepository = invocation.getArgumentAt(1,
LocalRepository.class);
return new SimpleLocalRepositoryManagerFactory()
.newInstance(
GrapeRootRepositorySystemSessionAutoConfigurationTests.this.session,
localRepository);
}
});
@Override
public LocalRepositoryManager answer(
InvocationOnMock invocation) throws Throwable {
LocalRepository localRepository = invocation
.getArgumentAt(1, LocalRepository.class);
return new SimpleLocalRepositoryManagerFactory()
.newInstance(
GrapeRootRepositorySystemSessionAutoConfigurationTests.this.session,
localRepository);
}
});
new GrapeRootRepositorySystemSessionAutoConfiguration().apply(this.session,
this.repositorySystem);
verify(this.repositorySystem, times(0)).newLocalRepositoryManager(
eq(this.session), any(LocalRepository.class));
verify(this.repositorySystem, times(0))
.newLocalRepositoryManager(eq(this.session), any(LocalRepository.class));
assertThat(this.session.getLocalRepository(), is(nullValue()));
}
@Test
public void grapeRootConfiguresLocalRepositoryLocation() {
given(
this.repositorySystem.newLocalRepositoryManager(eq(this.session),
any(LocalRepository.class))).willAnswer(
new LocalRepositoryManagerAnswer());
given(this.repositorySystem.newLocalRepositoryManager(eq(this.session),
any(LocalRepository.class)))
.willAnswer(new LocalRepositoryManagerAnswer());
System.setProperty("grape.root", "foo");
try {
@@ -100,8 +98,8 @@ public class GrapeRootRepositorySystemSessionAutoConfigurationTests {
System.clearProperty("grape.root");
}
verify(this.repositorySystem, times(1)).newLocalRepositoryManager(
eq(this.session), any(LocalRepository.class));
verify(this.repositorySystem, times(1))
.newLocalRepositoryManager(eq(this.session), any(LocalRepository.class));
assertThat(this.session.getLocalRepository(), is(notNullValue()));
assertThat(this.session.getLocalRepository().getBasedir().getAbsolutePath(),

View File

@@ -74,26 +74,25 @@ public class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
public void propertyInterpolation() throws SettingsBuildingException {
final DefaultRepositorySystemSession session = MavenRepositorySystemUtils
.newSession();
given(
this.repositorySystem.newLocalRepositoryManager(eq(session),
any(LocalRepository.class))).willAnswer(
new Answer<LocalRepositoryManager>() {
given(this.repositorySystem.newLocalRepositoryManager(eq(session),
any(LocalRepository.class)))
.willAnswer(new Answer<LocalRepositoryManager>() {
@Override
public LocalRepositoryManager answer(InvocationOnMock invocation)
throws Throwable {
LocalRepository localRepository = invocation.getArgumentAt(1,
LocalRepository.class);
return new SimpleLocalRepositoryManagerFactory().newInstance(
session, localRepository);
}
});
@Override
public LocalRepositoryManager answer(
InvocationOnMock invocation) throws Throwable {
LocalRepository localRepository = invocation
.getArgumentAt(1, LocalRepository.class);
return new SimpleLocalRepositoryManagerFactory()
.newInstance(session, localRepository);
}
});
System.setProperty("foo", "bar");
try {
new SettingsXmlRepositorySystemSessionAutoConfiguration(
"src/test/resources/maven-settings/property-interpolation").apply(
session, this.repositorySystem);
"src/test/resources/maven-settings/property-interpolation")
.apply(session, this.repositorySystem);
}
finally {
System.clearProperty("foo");
@@ -109,8 +108,8 @@ public class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
new SettingsXmlRepositorySystemSessionAutoConfiguration(userHome).apply(session,
this.repositorySystem);
RemoteRepository repository = new RemoteRepository.Builder("my-server",
"default", "http://maven.example.com").build();
RemoteRepository repository = new RemoteRepository.Builder("my-server", "default",
"http://maven.example.com").build();
assertMirrorSelectorConfiguration(session, repository);
assertProxySelectorConfiguration(session, repository);
@@ -121,8 +120,8 @@ public class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
RemoteRepository repository) {
Proxy proxy = session.getProxySelector().getProxy(repository);
repository = new RemoteRepository.Builder(repository).setProxy(proxy).build();
AuthenticationContext authenticationContext = AuthenticationContext.forProxy(
session, repository);
AuthenticationContext authenticationContext = AuthenticationContext
.forProxy(session, repository);
assertEquals("proxy.example.com", proxy.getHost());
assertEquals("proxyuser",
authenticationContext.get(AuthenticationContext.USERNAME));
@@ -130,10 +129,11 @@ public class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
authenticationContext.get(AuthenticationContext.PASSWORD));
}
private void assertMirrorSelectorConfiguration(
DefaultRepositorySystemSession session, RemoteRepository repository) {
private void assertMirrorSelectorConfiguration(DefaultRepositorySystemSession session,
RemoteRepository repository) {
RemoteRepository mirror = session.getMirrorSelector().getMirror(repository);
assertNotNull("No mirror configured for repository " + repository.getId(), mirror);
assertNotNull("No mirror configured for repository " + repository.getId(),
mirror);
assertEquals("maven.example.com", mirror.getHost());
}
@@ -142,8 +142,8 @@ public class SettingsXmlRepositorySystemSessionAutoConfigurationTests {
Authentication authentication = session.getAuthenticationSelector()
.getAuthentication(repository);
repository = new RemoteRepository.Builder(repository).setAuthentication(
authentication).build();
repository = new RemoteRepository.Builder(repository)
.setAuthentication(authentication).build();
AuthenticationContext authenticationContext = AuthenticationContext
.forRepository(session, repository);