summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.pgm.test
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.jgit.pgm.test')
-rw-r--r--org.eclipse.jgit.pgm.test/.classpath2
-rw-r--r--org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs6
-rw-r--r--org.eclipse.jgit.pgm.test/BUCK1
-rw-r--r--org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF38
-rw-r--r--org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java7).launch21
-rw-r--r--org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8) (de).launch2
-rw-r--r--org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8).launch2
-rw-r--r--org.eclipse.jgit.pgm.test/pom.xml2
-rw-r--r--org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java4
-rw-r--r--org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java3
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java24
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CLIGitCommandTest.java2
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java25
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CleanTest.java9
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java232
-rw-r--r--org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ResetTest.java5
16 files changed, 306 insertions, 72 deletions
diff --git a/org.eclipse.jgit.pgm.test/.classpath b/org.eclipse.jgit.pgm.test/.classpath
index 30d83d8e9c..b26f4c45d1 100644
--- a/org.eclipse.jgit.pgm.test/.classpath
+++ b/org.eclipse.jgit.pgm.test/.classpath
@@ -2,7 +2,7 @@
<classpath>
<classpathentry kind="src" path="tst"/>
<classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs
index 87210fb160..10c29d5576 100644
--- a/org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs
+++ b/org.eclipse.jgit.pgm.test/.settings/org.eclipse.jdt.core.prefs
@@ -7,9 +7,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.7
+org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
@@ -112,7 +112,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error
-org.eclipse.jdt.core.compiler.source=1.7
+org.eclipse.jdt.core.compiler.source=1.8
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
diff --git a/org.eclipse.jgit.pgm.test/BUCK b/org.eclipse.jgit.pgm.test/BUCK
index a3859c9b49..cd15510798 100644
--- a/org.eclipse.jgit.pgm.test/BUCK
+++ b/org.eclipse.jgit.pgm.test/BUCK
@@ -21,7 +21,6 @@ for t in TESTS:
'//lib:commons-compress',
'//lib:tukaani-xz',
],
- source_under_test = ['//org.eclipse.jgit.pgm:pgm'],
vm_args = ['-Xmx256m', '-Dfile.encoding=UTF-8'],
)
diff --git a/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF
index e420157915..8e7d5abe2c 100644
--- a/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF
+++ b/org.eclipse.jgit.pgm.test/META-INF/MANIFEST.MF
@@ -2,28 +2,28 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin_name
Bundle-SymbolicName: org.eclipse.jgit.pgm.test
-Bundle-Version: 4.5.6.qualifier
+Bundle-Version: 4.6.2.qualifier
Bundle-Vendor: %provider_name
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-1.7
-Import-Package: org.eclipse.jgit.api;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.api.errors;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.diff;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.dircache;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.internal.storage.file;version="4.5.6",
- org.eclipse.jgit.junit;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.lib;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.merge;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.pgm;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.pgm.internal;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.pgm.opt;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.revwalk;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.storage.file;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.transport;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.treewalk;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.util;version="[4.5.6,4.6.0)",
- org.eclipse.jgit.util.io;version="[4.5.6,4.6.0)",
+Bundle-RequiredExecutionEnvironment: JavaSE-1.8
+Import-Package: org.eclipse.jgit.api;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.api.errors;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.diff;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.dircache;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.internal.storage.file;version="4.6.2",
+ org.eclipse.jgit.junit;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.lib;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.merge;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.pgm;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.pgm.internal;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.pgm.opt;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.revwalk;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.storage.file;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.transport;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.treewalk;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.util;version="[4.6.2,4.7.0)",
+ org.eclipse.jgit.util.io;version="[4.6.2,4.7.0)",
org.hamcrest.core;bundle-version="[1.1.0,2.0.0)",
org.junit;version="[4.11.0,5.0.0)",
org.junit.rules;version="[4.11.0,5.0.0)",
diff --git a/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java7).launch b/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java7).launch
deleted file mode 100644
index 3df0dcb645..0000000000
--- a/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java7).launch
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<launchConfiguration type="org.eclipse.jdt.junit.launchconfig">
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
-<listEntry value="/org.eclipse.jgit.pgm.test/tst"/>
-</listAttribute>
-<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
-<listEntry value="2"/>
-</listAttribute>
-<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
-<listAttribute key="org.eclipse.debug.ui.favoriteGroups">
-<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/>
-<listEntry value="org.eclipse.debug.ui.launchGroup.run"/>
-</listAttribute>
-<stringAttribute key="org.eclipse.jdt.junit.CONTAINER" value="=org.eclipse.jgit.pgm.test/tst"/>
-<booleanAttribute key="org.eclipse.jdt.junit.KEEPRUNNING_ATTR" value="false"/>
-<stringAttribute key="org.eclipse.jdt.junit.TESTNAME" value=""/>
-<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
-<stringAttribute key="org.eclipse.jdt.launching.JRE_CONTAINER" value="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
-<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value=""/>
-<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="org.eclipse.jgit.pgm.test"/>
-</launchConfiguration>
diff --git a/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8) (de).launch b/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8) (de).launch
index 5c137f28fe..e11b72f45e 100644
--- a/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8) (de).launch
+++ b/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8) (de).launch
@@ -20,7 +20,7 @@
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
-<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;org.eclipse.jgit.pgm.test&quot;/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
diff --git a/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8).launch b/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8).launch
index ce473ed03d..8b0452afee 100644
--- a/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8).launch
+++ b/org.eclipse.jgit.pgm.test/org.eclipse.jgit.pgm--All-Tests (Java8).launch
@@ -17,7 +17,7 @@
<stringAttribute key="org.eclipse.jdt.junit.TEST_KIND" value="org.eclipse.jdt.junit.loader.junit4"/>
<booleanAttribute key="org.eclipse.jdt.launching.ATTR_USE_START_ON_FIRST_THREAD" value="true"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
-<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
+<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry id=&quot;org.eclipse.jdt.launching.classpathentry.defaultClasspath&quot;&gt;&#10;&lt;memento exportedEntriesOnly=&quot;false&quot; project=&quot;org.eclipse.jgit.pgm.test&quot;/&gt;&#10;&lt;/runtimeClasspathEntry&gt;&#10;"/>
</listAttribute>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
diff --git a/org.eclipse.jgit.pgm.test/pom.xml b/org.eclipse.jgit.pgm.test/pom.xml
index 504be8a9ce..c8188cb717 100644
--- a/org.eclipse.jgit.pgm.test/pom.xml
+++ b/org.eclipse.jgit.pgm.test/pom.xml
@@ -50,7 +50,7 @@
<parent>
<groupId>org.eclipse.jgit</groupId>
<artifactId>org.eclipse.jgit-parent</artifactId>
- <version>4.5.6-SNAPSHOT</version>
+ <version>4.6.2-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.jgit.pgm.test</artifactId>
diff --git a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java
index a6af077aa5..b675d3c31d 100644
--- a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java
+++ b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/lib/CLIRepositoryTestCase.java
@@ -62,15 +62,11 @@ public class CLIRepositoryTestCase extends LocalDiskRepositoryTestCase {
/** Test repository, initialized for this test case. */
protected Repository db;
- /** Working directory of {@link #db}. */
- protected File trash;
-
@Override
@Before
public void setUp() throws Exception {
super.setUp();
db = createWorkRepository();
- trash = db.getWorkTree();
}
/**
diff --git a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java
index 3f396563c2..b08bc8afe7 100644
--- a/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java
+++ b/org.eclipse.jgit.pgm.test/src/org/eclipse/jgit/pgm/CLIGitCommand.java
@@ -46,7 +46,6 @@ import static org.junit.Assert.assertNull;
import java.io.ByteArrayOutputStream;
import java.io.File;
-
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
@@ -218,7 +217,7 @@ public class CLIGitCommand extends Main {
inquote = !inquote;
continue;
case '\\':
- if (inquote || ip == commandLine.length())
+ if (inDblQuote || inquote || ip == commandLine.length())
r.append(b); // literal within a quote
else
r.append(commandLine.charAt(ip++));
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
index a503ffdad0..35467c6304 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ArchiveTest.java
@@ -528,15 +528,15 @@ public class ArchiveTest extends CLIRepositoryTestCase {
@Test
public void testArchiveWithLongFilename() throws Exception {
- String filename = "";
+ StringBuilder filename = new StringBuilder();
List<String> l = new ArrayList<String>();
for (int i = 0; i < 20; i++) {
- filename = filename + "1234567890/";
- l.add(filename);
+ filename.append("1234567890/");
+ l.add(filename.toString());
}
- filename = filename + "1234567890";
- l.add(filename);
- writeTrashFile(filename, "file with long path");
+ filename.append("1234567890");
+ l.add(filename.toString());
+ writeTrashFile(filename.toString(), "file with long path");
git.add().addFilepattern("1234567890").call();
git.commit().setMessage("file with long name").call();
@@ -548,15 +548,15 @@ public class ArchiveTest extends CLIRepositoryTestCase {
@Test
public void testTarWithLongFilename() throws Exception {
- String filename = "";
+ StringBuilder filename = new StringBuilder();
List<String> l = new ArrayList<String>();
for (int i = 0; i < 20; i++) {
- filename = filename + "1234567890/";
- l.add(filename);
+ filename.append("1234567890/");
+ l.add(filename.toString());
}
- filename = filename + "1234567890";
- l.add(filename);
- writeTrashFile(filename, "file with long path");
+ filename.append("1234567890");
+ l.add(filename.toString());
+ writeTrashFile(filename.toString(), "file with long path");
git.add().addFilepattern("1234567890").call();
git.commit().setMessage("file with long name").call();
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CLIGitCommandTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CLIGitCommandTest.java
index 24788a47bd..58d8e0349f 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CLIGitCommandTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CLIGitCommandTest.java
@@ -51,9 +51,11 @@ public class CLIGitCommandTest {
@Test
public void testSplit() throws Exception {
+ assertArrayEquals(new String[0], split(""));
assertArrayEquals(new String[] { "a" }, split("a"));
assertArrayEquals(new String[] { "a", "b" }, split("a b"));
assertArrayEquals(new String[] { "a", "b c" }, split("a 'b c'"));
assertArrayEquals(new String[] { "a", "b c" }, split("a \"b c\""));
+ assertArrayEquals(new String[] { "a", "b\\c" }, split("a \"b\\c\""));
}
}
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java
index 3651542fc6..4b86b6014e 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CheckoutTest.java
@@ -613,7 +613,30 @@ public class CheckoutTest extends CLIRepositoryTestCase {
}
@Test
- public void testCheckouSingleFile() throws Exception {
+ public void testCheckoutAllPaths() throws Exception {
+ try (Git git = new Git(db)) {
+ writeTrashFile("a", "Hello world a");
+ git.add().addFilepattern(".").call();
+ git.commit().setMessage("commit file a").call();
+ git.branchCreate().setName("branch_1").call();
+ git.checkout().setName("branch_1").call();
+ File b = writeTrashFile("b", "Hello world b");
+ git.add().addFilepattern("b").call();
+ git.commit().setMessage("commit file b").call();
+ File a = writeTrashFile("a", "New Hello world a");
+ git.add().addFilepattern(".").call();
+ git.commit().setMessage("modified a").call();
+ assertArrayEquals(new String[] { "" },
+ execute("git checkout HEAD~2 -- ."));
+ assertEquals("Hello world a", read(a));
+ assertArrayEquals(new String[] { "* branch_1", " master", "" },
+ execute("git branch"));
+ assertEquals("Hello world b", read(b));
+ }
+ }
+
+ @Test
+ public void testCheckoutSingleFile() throws Exception {
try (Git git = new Git(db)) {
File a = writeTrashFile("a", "file a");
git.add().addFilepattern(".").call();
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CleanTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CleanTest.java
index bbac296f16..82c0d989fc 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CleanTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/CleanTest.java
@@ -42,13 +42,14 @@
*/
package org.eclipse.jgit.pgm;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.lib.CLIRepositoryTestCase;
-import org.junit.Test;
import static org.eclipse.jgit.junit.JGitTestUtil.check;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.lib.CLIRepositoryTestCase;
+import org.junit.Test;
public class CleanTest extends CLIRepositoryTestCase {
@Test
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java
new file mode 100644
index 0000000000..06e7a1dbe6
--- /dev/null
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ProxyConfigTest.java
@@ -0,0 +1,232 @@
+/*
+ * Copyright (C) 2016, Chrisian Halstrick <christian.halstrick@sap.com> and
+ * other copyright owners as documented in the project's IP log.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Distribution License v1.0 which accompanies this
+ * distribution, is reproduced below, and is available at
+ * http://www.eclipse.org/org/documents/edl-v10.php
+ *
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ * - Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright notice,
+ * this list of conditions and the following disclaimer in the documentation
+ * and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Eclipse Foundation, Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from this
+ * software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.eclipse.jgit.pgm;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test how the content of the environment variables http[s]_proxy (upper- and
+ * lowercase) influence the setting of the system properties
+ * http[s].proxy[Host|Port]
+ */
+public class ProxyConfigTest {
+ private ProcessBuilder processBuilder;
+
+ private Map<String, String> environment;
+
+ @Before
+ public void setUp() {
+ String separator = System.getProperty("file.separator");
+ String classpath = System.getProperty("java.class.path");
+ String path = System.getProperty("java.home") + separator + "bin"
+ + separator + "java";
+ processBuilder = new ProcessBuilder(path, "-cp", classpath,
+ ProxyPropertiesDumper.class.getName());
+ environment = processBuilder.environment();
+ environment.remove("http_proxy");
+ environment.remove("https_proxy");
+ environment.remove("HTTP_PROXY");
+ environment.remove("HTTPS_PROXY");
+ }
+
+ @Test
+ public void testNoSetting() throws Exception {
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: null, http.proxyPort: null, https.proxyHost: null, https.proxyPort: null",
+ getOutput(start));
+ }
+
+ @Test
+ public void testHttpProxy_lowerCase() throws Exception {
+ environment.put("http_proxy", "http://xx:1234");
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: xx, http.proxyPort: 1234, https.proxyHost: null, https.proxyPort: null",
+ getOutput(start));
+ }
+
+ @Test
+ public void testHttpProxy_upperCase() throws Exception {
+ environment.put("HTTP_PROXY", "http://XX:1234");
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: null, http.proxyPort: null, https.proxyHost: null, https.proxyPort: null",
+ getOutput(start));
+ }
+
+ @Test
+ public void testHttpProxy_bothCases() throws Exception {
+ environment.put("http_proxy", "http://xx:1234");
+ environment.put("HTTP_PROXY", "http://XX:1234");
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: xx, http.proxyPort: 1234, https.proxyHost: null, https.proxyPort: null",
+ getOutput(start));
+ }
+
+ @Test
+ public void testHttpsProxy_lowerCase() throws Exception {
+ environment.put("https_proxy", "http://xx:1234");
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: null, http.proxyPort: null, https.proxyHost: xx, https.proxyPort: 1234",
+ getOutput(start));
+ }
+
+ @Test
+ public void testHttpsProxy_upperCase() throws Exception {
+ environment.put("HTTPS_PROXY", "http://XX:1234");
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: null, http.proxyPort: null, https.proxyHost: XX, https.proxyPort: 1234",
+ getOutput(start));
+ }
+
+ @Test
+ public void testHttpsProxy_bothCases() throws Exception {
+ environment.put("https_proxy", "http://xx:1234");
+ environment.put("HTTPS_PROXY", "http://XX:1234");
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: null, http.proxyPort: null, https.proxyHost: xx, https.proxyPort: 1234",
+ getOutput(start));
+ }
+
+ @Test
+ public void testAll() throws Exception {
+ environment.put("http_proxy", "http://xx:1234");
+ environment.put("HTTP_PROXY", "http://XX:1234");
+ environment.put("https_proxy", "http://yy:1234");
+ environment.put("HTTPS_PROXY", "http://YY:1234");
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: xx, http.proxyPort: 1234, https.proxyHost: yy, https.proxyPort: 1234",
+ getOutput(start));
+ }
+
+ @Test
+ public void testDontOverwriteHttp()
+ throws IOException, InterruptedException {
+ environment.put("http_proxy", "http://xx:1234");
+ environment.put("HTTP_PROXY", "http://XX:1234");
+ environment.put("https_proxy", "http://yy:1234");
+ environment.put("HTTPS_PROXY", "http://YY:1234");
+ List<String> command = processBuilder.command();
+ command.add(1, "-Dhttp.proxyHost=gondola");
+ command.add(2, "-Dhttp.proxyPort=5678");
+ command.add("dontClearProperties");
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: gondola, http.proxyPort: 5678, https.proxyHost: yy, https.proxyPort: 1234",
+ getOutput(start));
+ }
+
+ @Test
+ public void testOverwriteHttpPort()
+ throws IOException, InterruptedException {
+ environment.put("http_proxy", "http://xx:1234");
+ environment.put("HTTP_PROXY", "http://XX:1234");
+ environment.put("https_proxy", "http://yy:1234");
+ environment.put("HTTPS_PROXY", "http://YY:1234");
+ List<String> command = processBuilder.command();
+ command.add(1, "-Dhttp.proxyPort=5678");
+ command.add("dontClearProperties");
+ Process start = processBuilder.start();
+ start.waitFor();
+ assertEquals(
+ "http.proxyHost: xx, http.proxyPort: 1234, https.proxyHost: yy, https.proxyPort: 1234",
+ getOutput(start));
+ }
+
+ private static String getOutput(Process p)
+ throws IOException, UnsupportedEncodingException {
+ try (InputStream inputStream = p.getInputStream()) {
+ ByteArrayOutputStream result = new ByteArrayOutputStream();
+ byte[] buffer = new byte[1024];
+ int length;
+ while ((length = inputStream.read(buffer)) != -1) {
+ result.write(buffer, 0, length);
+ }
+ return result.toString("UTF-8");
+ }
+ }
+}
+
+class ProxyPropertiesDumper {
+ public static void main(String args[]) {
+ try {
+ if (args.length == 0 || !args[0].equals("dontClearProperties")) {
+ System.clearProperty("http.proxyHost");
+ System.clearProperty("http.proxyPort");
+ System.clearProperty("https.proxyHost");
+ System.clearProperty("https.proxyPort");
+ }
+ Main.configureHttpProxy();
+ System.out.printf(
+ "http.proxyHost: %s, http.proxyPort: %s, https.proxyHost: %s, https.proxyPort: %s",
+ System.getProperty("http.proxyHost"),
+ System.getProperty("http.proxyPort"),
+ System.getProperty("https.proxyHost"),
+ System.getProperty("https.proxyPort"));
+ System.out.flush();
+ } catch (MalformedURLException e) {
+ System.out.println("exception: " + e);
+ }
+ }
+}
diff --git a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ResetTest.java b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ResetTest.java
index 16c5889c48..44a7630c8a 100644
--- a/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ResetTest.java
+++ b/org.eclipse.jgit.pgm.test/tst/org/eclipse/jgit/pgm/ResetTest.java
@@ -42,7 +42,10 @@
*/
package org.eclipse.jgit.pgm;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.lib.CLIRepositoryTestCase;