Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoribull2010-02-02 23:19:18 +0000
committeribull2010-02-02 23:19:18 +0000
commitdcc11112ef2e6932b0d4093d7f2ea93a48202f48 (patch)
treecb8409df1353ee34d3be7451153b92da4f7e1547 /bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher
parent21f82e22196113b89ba824dc732824c8f15fbb8c (diff)
downloadrt.equinox.p2-dcc11112ef2e6932b0d4093d7f2ea93a48202f48.tar.gz
rt.equinox.p2-dcc11112ef2e6932b0d4093d7f2ea93a48202f48.tar.xz
rt.equinox.p2-dcc11112ef2e6932b0d4093d7f2ea93a48202f48.zip
bug 276834: [publisher] Remember the shape of the repo when publishing categories
https://bugs.eclipse.org/bugs/show_bug.cgi?id=276834
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/AllTests.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/CategoryPublisherTest.java153
2 files changed, 154 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/AllTests.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/AllTests.java
index 97810b63d..259e79f44 100644
--- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/AllTests.java
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/AllTests.java
@@ -21,6 +21,7 @@ public class AllTests extends TestCase {
suite.addTestSuite(AccumulateConfigDataActionTest.class);
suite.addTestSuite(AdviceFileParserTest.class);
suite.addTestSuite(BundlesActionTest.class);
+ suite.addTestSuite(CategoryPublisherTest.class);
suite.addTestSuite(ConfigCUsActionTest.class);
suite.addTestSuite(DefaultCUsActionTest.class);
suite.addTestSuite(EquinoxExecutableActionTest.class);
diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/CategoryPublisherTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/CategoryPublisherTest.java
new file mode 100644
index 000000000..afcb82a4c
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/CategoryPublisherTest.java
@@ -0,0 +1,153 @@
+/*******************************************************************************
+* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
+* program and the accompanying materials are made available under the terms of
+* the Eclipse Public License v1.0 which accompanies this distribution, and is
+* available at http://www.eclipse.org/legal/epl-v10.html
+*
+* Contributors:
+* EclipseSource - initial API and implementation
+******************************************************************************/
+package org.eclipse.equinox.p2.tests.publisher.actions;
+
+import java.io.File;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.equinox.app.IApplicationContext;
+import org.eclipse.equinox.internal.p2.updatesite.CategoryPublisherApplication;
+import org.eclipse.equinox.p2.publisher.AbstractPublisherApplication;
+import org.eclipse.equinox.p2.tests.AbstractProvisioningTest;
+import org.eclipse.equinox.p2.tests.TestData;
+import org.osgi.framework.Bundle;
+
+/**
+ *
+ */
+public class CategoryPublisherTest extends AbstractProvisioningTest {
+
+ /**
+ * runs default director app.
+ */
+ protected void runPublisherApp(AbstractPublisherApplication application, final String[] args) throws Exception {
+
+ application.start(new IApplicationContext() {
+
+ public void applicationRunning() {
+ //empty
+ }
+
+ public Map getArguments() {
+ Map arguments = new HashMap();
+
+ arguments.put(IApplicationContext.APPLICATION_ARGS, args);
+
+ return arguments;
+ }
+
+ public String getBrandingApplication() {
+ return null;
+ }
+
+ public Bundle getBrandingBundle() {
+ return null;
+ }
+
+ public String getBrandingDescription() {
+ return null;
+ }
+
+ public String getBrandingId() {
+ return null;
+ }
+
+ public String getBrandingName() {
+ return null;
+ }
+
+ public String getBrandingProperty(String key) {
+ return null;
+ }
+ });
+ }
+
+ public void testCompressCategoryRepo() throws Exception {
+ File repository = null;
+ try {
+ repository = getTempFolder();
+ URI repositoryURI = repository.toURI();
+ URI category1 = TestData.getFile("CategoryPublisherTests", "category1.xml").toURI();
+ String[] firstRun = new String[] {"-metadataRepository", repositoryURI.toString(), "-categoryDefinition", category1.toString(), "-categoryQualifier", "foo"};
+ String[] secondRun = new String[] {"-metadataRepository", repositoryURI.toString(), "-categoryDefinition", category1.toString(), "-categoryQualifier", "foo", "-compress"};
+
+ CategoryPublisherApplication categoryPublisherApplication = new CategoryPublisherApplication();
+ runPublisherApp(categoryPublisherApplication, firstRun);
+
+ categoryPublisherApplication = new CategoryPublisherApplication();
+ runPublisherApp(categoryPublisherApplication, secondRun);
+
+ assertContains(repository, "content.jar");
+
+ } finally {
+ if (repository != null & repository.exists())
+ delete(repository);
+ }
+ }
+
+ public void testRememberRepoShapeJar() throws Exception {
+ File repository = null;
+ try {
+ repository = getTempFolder();
+ URI repositoryURI = repository.toURI();
+ URI category1 = TestData.getFile("CategoryPublisherTests", "category1.xml").toURI();
+ String[] firstRun = new String[] {"-metadataRepository", repositoryURI.toString(), "-categoryDefinition", category1.toString(), "-categoryQualifier", "foo", "-compress"};
+ String[] secondRun = new String[] {"-metadataRepository", repositoryURI.toString(), "-categoryDefinition", category1.toString(), "-categoryQualifier", "foo"};
+
+ CategoryPublisherApplication categoryPublisherApplication = new CategoryPublisherApplication();
+ runPublisherApp(categoryPublisherApplication, firstRun);
+
+ categoryPublisherApplication = new CategoryPublisherApplication();
+ runPublisherApp(categoryPublisherApplication, secondRun);
+
+ assertContains(repository, "content.jar");
+
+ } finally {
+ if (repository != null & repository.exists())
+ delete(repository);
+ }
+ }
+
+ public void testRememberRepoShapeXML() throws Exception {
+ File repository = null;
+ try {
+ repository = getTempFolder();
+ URI repositoryURI = repository.toURI();
+ URI category1 = TestData.getFile("CategoryPublisherTests", "category1.xml").toURI();
+ String[] firstRun = new String[] {"-metadataRepository", repositoryURI.toString(), "-categoryDefinition", category1.toString(), "-categoryQualifier", "foo"};
+ String[] secondRun = new String[] {"-metadataRepository", repositoryURI.toString(), "-categoryDefinition", category1.toString(), "-categoryQualifier", "foo"};
+
+ CategoryPublisherApplication categoryPublisherApplication = new CategoryPublisherApplication();
+ runPublisherApp(categoryPublisherApplication, firstRun);
+
+ categoryPublisherApplication = new CategoryPublisherApplication();
+ runPublisherApp(categoryPublisherApplication, secondRun);
+
+ assertContains(repository, "content.xml");
+
+ } finally {
+ if (repository != null & repository.exists())
+ delete(repository);
+ }
+ }
+
+ public void assertContains(File directory, String file) {
+ assertNotNull(directory);
+ assertTrue(directory.exists());
+ assertTrue(directory.isDirectory());
+ File[] listFiles = directory.listFiles();
+ for (int i = 0; i < listFiles.length; i++) {
+ if (listFiles[i].getName().equals(file))
+ return;
+ }
+ fail("Directory does not contain file: " + file);
+ }
+}

Back to the top