You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2015/07/18 11:09:29 UTC
[12/23] camel git commit: CAMEL-7982: camel-git - A generic git
component, add tag consumer
http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java
deleted file mode 100644
index 085fa1c..0000000
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.github.producer;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.git.GitConstants;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.PullResult;
-import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-import org.eclipse.jgit.transport.PushResult;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class GitRemoteProducerTest extends GitTestSupport {
-
- @Ignore("Require a remote git repository")
- @Test
- public void pushTest() throws Exception {
-
- Repository repository = getTestRepository();
-
- File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
- fileToAdd.createNewFile();
-
- template.send("direct:add", new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
- }
- });
- File gitDir = new File(GIT_LOCAL_REPO, ".git");
- assertEquals(gitDir.exists(), true);
-
- Status status = new Git(repository).status().call();
- assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-
- template.send("direct:commit", new Processor() {
- @Override
- public void process(Exchange exchange) throws Exception {
- exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
- }
- });
-
- Iterable<PushResult> result = template.requestBody("direct:push", "", Iterable.class);
-
- repository.close();
- }
-
- @Override
- protected RouteBuilder createRouteBuilder() throws Exception {
- return new RouteBuilder() {
- @Override
- public void configure() throws Exception {
- from("direct:add")
- .to("git://" + GIT_LOCAL_REPO + "?operation=add");
- from("direct:commit")
- .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
- from("direct:push")
- .to("git://" + GIT_LOCAL_REPO + "?operation=push&remotePath=remoteURL&username=xxx&password=xxx" );
- }
- };
- }
-
-}
http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
deleted file mode 100644
index 7c15386..0000000
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.github.producer;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-
-public class GitTestSupport extends CamelTestSupport {
-
- public final static String GIT_LOCAL_REPO = "testRepo";
-
- public final static String FILENAME_TO_ADD = "filetest.txt";
-
- public final static String FILENAME_BRANCH_TO_ADD = "filetest1.txt";
-
- public final static String COMMIT_MESSAGE = "Test commit";
-
- public final static String COMMIT_MESSAGE_ALL = "Test commit all";
-
- public final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
-
- public final static String BRANCH_TEST = "testBranch";
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- File localPath = File.createTempFile(GIT_LOCAL_REPO, "");
- localPath.delete();
- File path = new File(GIT_LOCAL_REPO);
- path.deleteOnExit();
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- File path = new File(GIT_LOCAL_REPO);
- deleteDirectory(path);
- }
-
- protected Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
- File gitRepo = new File(GIT_LOCAL_REPO, ".git");
- Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).setBare(false).call();
- // now open the resulting repository with a FileRepositoryBuilder
- FileRepositoryBuilder builder = new FileRepositoryBuilder();
- Repository repo = builder.setGitDir(gitRepo)
- .readEnvironment() // scan environment GIT_* variables
- .findGitDir() // scan up the file system tree
- .build();
- return repo;
- }
-
- static public boolean deleteDirectory(File path) {
- if( path.exists() ) {
- File[] files = path.listFiles();
- for(int i=0; i<files.length; i++) {
- if(files[i].isDirectory()) {
- deleteDirectory(files[i]);
- }
- else {
- files[i].delete();
- }
- }
- }
- return( path.delete() );
- }
-}