Bumping jgit to 5.1.3.201810200350-r (#1179)

* Bumping jgit

* Updated tests
This commit is contained in:
Marcin Grzejszczak
2018-11-07 15:38:36 +01:00
committed by GitHub
parent 154e279f26
commit c0faa81676
2 changed files with 63 additions and 9 deletions

View File

@@ -14,7 +14,7 @@
<name>spring-cloud-config-dependencies</name>
<description>Spring Cloud Config Dependencies</description>
<properties>
<jgit.version>4.11.0.201803080745-r</jgit.version>
<jgit.version>5.1.3.201810200350-r</jgit.version>
</properties>
<dependencyManagement>
<dependencies>

View File

@@ -41,8 +41,13 @@ 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.attributes.AttributesNodeProvider;
import org.eclipse.jgit.lib.BaseRepositoryBuilder;
import org.eclipse.jgit.lib.ObjectDatabase;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.RefDatabase;
import org.eclipse.jgit.lib.ReflogReader;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.transport.CredentialItem;
@@ -76,6 +81,7 @@ import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockingDetails;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -91,6 +97,9 @@ public class JGitEnvironmentRepositoryTests {
private File basedir = new File("target/config");
RefDatabase database = Mockito.mock(RefDatabase.class);
@Rule
public final ExpectedException exception = ExpectedException.none();
@@ -409,7 +418,8 @@ public class JGitEnvironmentRepositoryTests {
StatusCommand statusCommand = mock(StatusCommand.class);
Status status = mock(Status.class);
when(git.status()).thenReturn(statusCommand);
Repository repository = mock(Repository.class);
Repository repository = stubbedRepo();
when(git.getRepository()).thenReturn(repository);
StoredConfig storedConfig = mock(StoredConfig.class);
when(repository.getConfig()).thenReturn(storedConfig);
@@ -455,7 +465,7 @@ public class JGitEnvironmentRepositoryTests {
// refresh()->return
// git.getRepository().findRef("HEAD").getObjectId().getName();
Ref headRef = mock(Ref.class);
when(repository.findRef(anyString())).thenReturn(headRef);
when(database.getRef(anyString())).thenReturn(headRef);
ObjectId newObjectId = ObjectId.fromRaw(new int[] { 1, 2, 3, 4, 5 });
when(headRef.getObjectId()).thenReturn(newObjectId);
@@ -466,6 +476,50 @@ public class JGitEnvironmentRepositoryTests {
verify(git, times(0)).branchDelete();
}
private Repository stubbedRepo() {
return spy(new Repository(new BaseRepositoryBuilder()) {
@Override
public void create(boolean bare) throws IOException {
}
@Override
public ObjectDatabase getObjectDatabase() {
return null;
}
@Override
public RefDatabase getRefDatabase() {
return database;
}
@Override
public StoredConfig getConfig() {
return null;
}
@Override
public AttributesNodeProvider createAttributesNodeProvider() {
return null;
}
@Override
public void scanForRepoChanges() throws IOException {
}
@Override
public void notifyIndexChanged(boolean internal) {
}
@Override
public ReflogReader getReflogReader(String refName) throws IOException {
return null;
}
});
}
@Test
public void testMergeException() throws Exception {
@@ -478,7 +532,7 @@ public class JGitEnvironmentRepositoryTests {
StatusCommand statusCommand = mock(StatusCommand.class);
Status status = mock(Status.class);
when(git.status()).thenReturn(statusCommand);
Repository repository = mock(Repository.class);
Repository repository = stubbedRepo();
when(git.getRepository()).thenReturn(repository);
StoredConfig storedConfig = mock(StoredConfig.class);
when(repository.getConfig()).thenReturn(storedConfig);
@@ -513,7 +567,7 @@ public class JGitEnvironmentRepositoryTests {
//refresh()->return git.getRepository().findRef("HEAD").getObjectId().getName();
Ref headRef = mock(Ref.class);
when(repository.findRef(anyString())).thenReturn(headRef);
when(database.getRef(anyString())).thenReturn(headRef);
ObjectId newObjectId = ObjectId.fromRaw(new int[]{1,2,3,4,5});
when(headRef.getObjectId()).thenReturn(newObjectId);
@@ -589,7 +643,7 @@ public class JGitEnvironmentRepositoryTests {
StatusCommand statusCommand = mock(StatusCommand.class);
Status status = mock(Status.class);
when(git.status()).thenReturn(statusCommand);
Repository repository = mock(Repository.class);
Repository repository = stubbedRepo();
when(git.getRepository()).thenReturn(repository);
StoredConfig storedConfig = mock(StoredConfig.class);
when(repository.getConfig()).thenReturn(storedConfig);
@@ -636,7 +690,7 @@ public class JGitEnvironmentRepositoryTests {
// refresh()->return
// git.getRepository().findRef("HEAD").getObjectId().getName();
Ref headRef = mock(Ref.class);
when(repository.findRef(anyString())).thenReturn(headRef);
when(database.getRef(anyString())).thenReturn(headRef);
ObjectId newObjectId = ObjectId.fromRaw(new int[] { 1, 2, 3, 4, 5 });
when(headRef.getObjectId()).thenReturn(newObjectId);
@@ -921,7 +975,7 @@ public class JGitEnvironmentRepositoryTests {
StatusCommand statusCommand = mock(StatusCommand.class);
Status status = mock(Status.class);
when(git.status()).thenReturn(statusCommand);
Repository repository = mock(Repository.class);
Repository repository = stubbedRepo();
when(git.getRepository()).thenReturn(repository);
StoredConfig storedConfig = mock(StoredConfig.class);
when(repository.getConfig()).thenReturn(storedConfig);
@@ -983,7 +1037,7 @@ public class JGitEnvironmentRepositoryTests {
// refresh()->return
// git.getRepository().findRef("HEAD").getObjectId().getName();
Ref headRef = mock(Ref.class);
when(repository.findRef(anyString())).thenReturn(headRef);
when(database.getRef(anyString())).thenReturn(headRef);
ObjectId newObjectId = ObjectId.fromRaw(new int[]{1, 2, 3, 4, 5});
when(headRef.getObjectId()).thenReturn(newObjectId);