Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2009-08-28 20:06:59 +0000
committerAndrew Niefer2009-08-28 20:06:59 +0000
commit22c2da9a903c0996a12104e19884e3fd265d9d75 (patch)
treed7396790c75a868a76e6f5e93641ae796b0a2c89 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher
parented135c1460c846c77bc31a9a0a13895ba8967245 (diff)
downloadrt.equinox.p2-22c2da9a903c0996a12104e19884e3fd265d9d75.tar.gz
rt.equinox.p2-22c2da9a903c0996a12104e19884e3fd265d9d75.tar.xz
rt.equinox.p2-22c2da9a903c0996a12104e19884e3fd265d9d75.zip
280339 - [publisher] Allow quoting of spaces in .product arguments
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher')
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java49
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java12
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java11
3 files changed, 61 insertions, 11 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java
index 66d03c1fc..abe3fb259 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/GeneralPublisherTests.java
@@ -11,8 +11,10 @@
package org.eclipse.equinox.p2.tests.publisher;
import java.lang.reflect.Method;
+import java.util.NoSuchElementException;
import junit.framework.TestCase;
import org.eclipse.equinox.internal.p2.publisher.Messages;
+import org.eclipse.equinox.internal.p2.publisher.QuotedTokenizer;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
import org.eclipse.equinox.p2.publisher.eclipse.FeaturesAndBundlesPublisherApplication;
@@ -51,4 +53,51 @@ public class GeneralPublisherTests extends TestCase {
assertEquals("1.1", Messages.exception_noArtifactRepo, application.getStatus().getMessage());
}
+
+ public void testQuotedTokenizer() throws Exception {
+ QuotedTokenizer tokenizer = new QuotedTokenizer("abra ca dabra");
+ assertEquals("abra", tokenizer.nextToken());
+ assertEquals("ca", tokenizer.nextToken());
+ assertTrue(tokenizer.hasMoreTokens());
+ assertEquals("dabra", tokenizer.nextToken());
+ assertFalse(tokenizer.hasMoreTokens());
+
+ boolean exception = false;
+ try {
+ tokenizer.nextToken();
+ } catch (NoSuchElementException e) {
+ exception = true;
+ }
+ assertTrue(exception);
+
+ tokenizer = new QuotedTokenizer("ab c\"de fg\" hi");
+ assertEquals("ab", tokenizer.nextToken());
+ assertEquals("cde fg", tokenizer.nextToken());
+ assertEquals("hi", tokenizer.nextToken());
+ assertFalse(tokenizer.hasMoreTokens());
+
+ tokenizer = new QuotedTokenizer("a,b c,d", ",");
+ assertEquals("a", tokenizer.nextToken());
+ assertEquals("b c", tokenizer.nextToken());
+ assertEquals("d", tokenizer.nextToken());
+ assertFalse(tokenizer.hasMoreTokens());
+
+ tokenizer = new QuotedTokenizer("a bcd" + '\u7432' + "e fg");
+ assertEquals("a", tokenizer.nextToken());
+ assertEquals("bcd" + '\u7432' + "e", tokenizer.nextToken());
+ assertEquals("fg", tokenizer.nextToken());
+ assertFalse(tokenizer.hasMoreTokens());
+
+ tokenizer = new QuotedTokenizer(" ");
+ assertFalse(tokenizer.hasMoreTokens());
+
+ tokenizer = new QuotedTokenizer(",,,", ",");
+ assertFalse(tokenizer.hasMoreElements());
+
+ tokenizer = new QuotedTokenizer("a \"b\\\" c\" d");
+ assertEquals("a", tokenizer.nextToken());
+ assertEquals("b\" c", tokenizer.nextToken());
+ assertEquals("d", tokenizer.nextToken());
+ assertFalse(tokenizer.hasMoreTokens());
+ }
}
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java
index b39994938..1558ca18a 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileAdviceTest.java
@@ -11,7 +11,7 @@
package org.eclipse.equinox.p2.tests.publisher.actions;
import java.io.File;
-import java.util.*;
+import java.util.Properties;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.p2.publisher.eclipse.ProductFileAdvice;
@@ -52,9 +52,10 @@ public class ProductFileAdviceTest extends AbstractProvisioningTest {
*/
public void testGetProgramArguments() {
String[] programArgumentsWin32 = productFileAdviceWin32.getProgramArguments();
- List listOfArguments = Arrays.asList(programArgumentsWin32);
- assertEquals("1.0", 1, listOfArguments.size());
- assertTrue("1.0", listOfArguments.contains("programArg"));
+ assertEquals("1.0", 3, programArgumentsWin32.length);
+ assertEquals("1.1", "programArg", programArgumentsWin32[0]);
+ assertEquals("1.2", "-name", programArgumentsWin32[1]);
+ assertEquals("1.3", "My Name", programArgumentsWin32[2]);
String[] programArguments2 = productFileAdvice2.getProgramArguments();
assertEquals("2.0", 0, programArguments2.length);
@@ -65,8 +66,9 @@ public class ProductFileAdviceTest extends AbstractProvisioningTest {
*/
public void testGetVMArguments() {
String[] vmArgumentsWin32 = productFileAdviceWin32.getVMArguments();
- assertEquals("1.0", 1, vmArgumentsWin32.length);
+ assertEquals("1.0", 2, vmArgumentsWin32.length);
assertEquals("1.1", "vmArg", vmArgumentsWin32[0]);
+ assertEquals("1.2", "-Dfoo=b a r", vmArgumentsWin32[1]);
String[] vmArguments2 = productFileAdvice2.getVMArguments();
assertEquals("2.0", 0, vmArguments2.length);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java
index 30eeea0ff..b147f992e 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/ProductFileTest.java
@@ -9,14 +9,13 @@
******************************************************************************/
package org.eclipse.equinox.p2.tests.publisher.actions;
-import org.eclipse.equinox.internal.provisional.p2.core.VersionedName;
-
import java.util.List;
import java.util.Properties;
import junit.framework.TestCase;
import org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile;
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
import org.eclipse.equinox.internal.provisional.p2.core.Version;
+import org.eclipse.equinox.internal.provisional.p2.core.VersionedName;
import org.eclipse.equinox.p2.tests.TestData;
/**
@@ -182,9 +181,9 @@ public class ProductFileTest extends TestCase {
*/
public void testGetVMArguments() {
String vmArguments = productFile.getVMArguments("");
- assertEquals("1.0", "vmArg", vmArguments);
+ assertEquals("1.0", "vmArg -Dfoo=\"b a r\"", vmArguments);
vmArguments = productFile.getVMArguments(null);
- assertEquals("1.1", "vmArg", vmArguments);
+ assertEquals("1.1", "vmArg -Dfoo=\"b a r\"", vmArguments);
}
/**
@@ -192,9 +191,9 @@ public class ProductFileTest extends TestCase {
*/
public void testGetProgramArguments() {
String programArguments = productFile.getProgramArguments("");
- assertEquals("1.0", "programArg", programArguments);
+ assertEquals("1.0", "programArg -name \"My Name\"", programArguments);
programArguments = productFile.getProgramArguments(null);
- assertEquals("1.1", "programArg", programArguments);
+ assertEquals("1.1", "programArg -name \"My Name\"", programArguments);
}
public void testGetLicenseURL() throws Exception {

Back to the top