1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.student.git.model;
17
18 import java.io.File;
19 import java.io.IOException;
20 import java.util.List;
21
22 import org.apache.commons.io.FileUtils;
23 import org.apache.commons.io.IOUtils;
24 import org.eclipse.jgit.lib.Constants;
25 import org.eclipse.jgit.lib.FileMode;
26 import org.eclipse.jgit.lib.ObjectId;
27 import org.eclipse.jgit.lib.ObjectLoader;
28 import org.eclipse.jgit.lib.Ref;
29 import org.eclipse.jgit.lib.Repository;
30 import org.eclipse.jgit.revwalk.RevCommit;
31 import org.eclipse.jgit.revwalk.RevWalk;
32 import org.eclipse.jgit.treewalk.TreeWalk;
33 import org.junit.Assert;
34 import org.junit.Test;
35 import org.junit.runner.RunWith;
36 import org.junit.runners.BlockJUnit4ClassRunner;
37 import org.kuali.student.git.importer.GitImporterMain;
38
39
40
41
42
43
44
45
46 @RunWith(BlockJUnit4ClassRunner.class)
47 public class TestKSRevision27975 {
48
49
50
51
52 public TestKSRevision27975() {
53 }
54
55 @Test
56 public void testRevision27975 () throws IOException {
57 File gitRepository = new File ("target/ks-r27975");
58
59 FileUtils.deleteDirectory(gitRepository);
60
61 Repository repository = GitRepositoryUtils
62 .buildFileRepository(gitRepository, true);
63
64 GitImporterMain.main(new String [] {"src/test/resources/ks-r27975.dump.bz2", gitRepository.getAbsolutePath(), "target/ks-r27975-ks-veto.log", "target/ks-r27975-ks-copyFrom-skipped.log", "target/ks-r27975-blob.log", "0", "https://svn.kuali.org/repos/student", "uuid"});
65
66 RevWalk rw = new RevWalk(repository);
67
68 Ref branch = repository.getRef("sandbox_ks-1.3-core-slice-demo_modules_ks-pom_trunk");
69
70 Assert.assertNotNull(branch);
71
72 RevCommit headCommit = rw.parseCommit(branch.getObjectId());
73
74 TreeWalk tw = new TreeWalk(repository);
75
76 tw.addTree(headCommit.getTree().getId());
77
78 tw.setRecursive(true);
79
80 int blobCount = 0;
81
82 ObjectId blobId = null;
83
84 while (tw.next()) {
85
86 if (tw.getFileMode(0) == FileMode.REGULAR_FILE) {
87 blobCount++;
88
89 blobId = tw.getObjectId(0);
90 }
91 }
92
93 Assert.assertEquals(1, blobCount);
94
95 ObjectLoader blobLoader = repository.getObjectDatabase().newReader().open(blobId);
96
97 List<String> lines = IOUtils.readLines(blobLoader.openStream());
98
99 Assert.assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?>", lines.get(0));
100
101 tw.release();
102
103 rw.release();
104 repository.close();
105
106
107 }
108
109
110
111 }