33
44import static org .junit .Assert .assertTrue ;
55
6- import java .io .File ;
76import java .io .IOException ;
8- import java .io .PrintWriter ;
97import java .util .HashSet ;
108import java .util .Set ;
119
@@ -83,7 +81,7 @@ private static String getJvmProperty(String name) {
8381
8482
8583 @ Override
86- public void setUp () throws IOException {
84+ public void setUp () throws Exception {
8785 super .setUp ();
8886 github = GitHub .connectUsingPassword (GITHUB_USER , GITHUB_PASS );
8987 gitHubRepo = github .createRepository (repoName )
@@ -104,39 +102,37 @@ public void tearDown() {
104102 }
105103
106104 @ Override
107- protected void createTestContent (String filePath , String fileContent , String branchName ,
108- String commitMessage ) throws Exception {
109- try (IVCSLockedWorkingCopy wc = localVCSRepo .getVCSLockedWorkingCopy ()) {
110- try (Git git = ((GitVCS ) vcs ).getLocalGit (wc )) {
111- checkout (branchName , git );
112-
113- File file = new File (wc .getFolder (), filePath );
114- file .getParentFile ().mkdirs ();
115- file .createNewFile ();
116- PrintWriter out = new PrintWriter (file );
117- out .print (fileContent );
118- out .close ();
119-
120- git
121- .add ()
122- .addFilepattern (filePath )
123- .call ();
124-
125- git
126- .commit ()
127- .setMessage (commitMessage )
128- .call ();
129-
130- RefSpec spec = new RefSpec (branchName + ":" + branchName );
131- git
132- .push ()
133- .setRefSpecs (spec )
134- .setRemote ("origin" )
135- .setCredentialsProvider (((GitVCS ) vcs ).getCredentials ())
136- .call ();
137-
138- git .getRepository ().close ();
139- }
105+ protected void sendFile (IVCSLockedWorkingCopy wc , String branchName , String filePath , String commitMessage ) throws Exception {
106+ try (Git git = ((GitVCS ) vcs ).getLocalGit (wc )) {
107+ checkout (branchName , git );
108+
109+ git
110+ .add ()
111+ .addFilepattern (filePath )
112+ .call ();
113+
114+ git
115+ .commit ()
116+ .setMessage (commitMessage )
117+ .call ();
118+
119+ RefSpec spec = new RefSpec (branchName + ":" + branchName );
120+ git
121+ .push ()
122+ .setRefSpecs (spec )
123+ .setRemote ("origin" )
124+ .setCredentialsProvider (((GitVCS ) vcs ).getCredentials ())
125+ .call ();
126+
127+ git .getRepository ().close ();
128+ }
129+ }
130+
131+ @ Override
132+ protected void checkout (String branchName , IVCSLockedWorkingCopy wc ) throws Exception {
133+ try (Git git = ((GitVCS ) vcs ).getLocalGit (wc )) {
134+ checkout (branchName , git );
135+ git .getRepository ().close ();
140136 }
141137 }
142138
@@ -206,5 +202,9 @@ protected void setMakeFailureOnVCSReset(Boolean doMakeFailure) {
206202 mockedGit = null ;
207203 }
208204 }
205+
206+
207+
208+
209209}
210210
0 commit comments