From 2efe1a4134dc9a735eff1075fa5bc4b633efebe7 Mon Sep 17 00:00:00 2001 From: Spencer Gibb Date: Mon, 16 Jan 2017 11:09:57 -0700 Subject: [PATCH] polish --- .../JGitEnvironmentRepository.java | 10 +++++++--- ...EnvironmentRepositoryIntegrationTests.java | 14 +++++++------- .../JGitEnvironmentRepositoryTests.java | 19 +++++++++---------- 3 files changed, 23 insertions(+), 20 deletions(-) diff --git a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java index e4e354c6..cfacb856 100644 --- a/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java +++ b/spring-cloud-config-server/src/main/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepository.java @@ -16,8 +16,6 @@ package org.springframework.cloud.config.server.environment; -import static org.springframework.util.StringUtils.hasText; - import java.io.File; import java.io.IOException; import java.util.HashSet; @@ -41,8 +39,12 @@ import org.eclipse.jgit.api.TransportCommand; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.RefNotFoundException; import org.eclipse.jgit.lib.Ref; -import org.eclipse.jgit.transport.*; +import org.eclipse.jgit.transport.FetchResult; +import org.eclipse.jgit.transport.JschConfigSessionFactory; import org.eclipse.jgit.transport.OpenSshConfig.Host; +import org.eclipse.jgit.transport.SshSessionFactory; +import org.eclipse.jgit.transport.TagOpt; +import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.eclipse.jgit.util.FileUtils; import org.springframework.beans.factory.InitializingBean; import org.springframework.cloud.config.server.support.PassphraseCredentialsProvider; @@ -53,6 +55,8 @@ import org.springframework.util.StringUtils; import com.jcraft.jsch.Session; +import static org.springframework.util.StringUtils.hasText; + /** * An {@link EnvironmentRepository} backed by a single git repository. * diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryIntegrationTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryIntegrationTests.java index 9ce581df..09d9dcf3 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryIntegrationTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryIntegrationTests.java @@ -16,13 +16,6 @@ package org.springframework.cloud.config.server.environment; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.assertTrue; - import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -59,6 +52,13 @@ import org.springframework.context.annotation.Import; import org.springframework.util.ResourceUtils; import org.springframework.util.StreamUtils; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; + /** * @author Dave Syer * @author Roy Clarkson diff --git a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryTests.java b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryTests.java index 0714d649..c3f6e1e5 100644 --- a/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryTests.java +++ b/spring-cloud-config-server/src/test/java/org/springframework/cloud/config/server/environment/JGitEnvironmentRepositoryTests.java @@ -18,13 +18,12 @@ package org.springframework.cloud.config.server.environment; import java.io.File; import java.io.IOException; +import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collections; import java.util.List; - import org.eclipse.jgit.api.CheckoutCommand; -import com.jcraft.jsch.Session; import org.eclipse.jgit.api.CloneCommand; import org.eclipse.jgit.api.FetchCommand; import org.eclipse.jgit.api.Git; @@ -33,17 +32,17 @@ import org.eclipse.jgit.api.MergeCommand; import org.eclipse.jgit.api.ResetCommand; import org.eclipse.jgit.api.Status; import org.eclipse.jgit.api.StatusCommand; -import org.eclipse.jgit.api.errors.TransportException; +import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.api.errors.InvalidRemoteException; import org.eclipse.jgit.api.errors.NotMergedException; +import org.eclipse.jgit.api.errors.TransportException; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.lib.StoredConfig; -import org.eclipse.jgit.transport.FetchResult; -import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.transport.CredentialItem; import org.eclipse.jgit.transport.CredentialsProvider; +import org.eclipse.jgit.transport.FetchResult; import org.eclipse.jgit.transport.JschConfigSessionFactory; import org.eclipse.jgit.transport.OpenSshConfig; import org.eclipse.jgit.transport.SshSessionFactory; @@ -61,7 +60,7 @@ import org.springframework.cloud.config.server.support.PassphraseCredentialsProv import org.springframework.cloud.config.server.test.ConfigServerTestUtils; import org.springframework.core.env.StandardEnvironment; -import java.lang.reflect.Method; +import com.jcraft.jsch.Session; import static junit.framework.TestCase.assertTrue; import static org.hamcrest.Matchers.is; @@ -71,7 +70,10 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Matchers.anyString; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; /** * @author Dave Syer @@ -196,8 +198,6 @@ public class JGitEnvironmentRepositoryTests { assertVersion(environment); } - - @Test public void uriWithHostOnly() throws Exception { this.repository.setUri("git://localhost"); @@ -391,7 +391,6 @@ public class JGitEnvironmentRepositoryTests { assertEquals(locations.getVersion(),newObjectId.getName()); } - @Test public void testMergeException() throws Exception {