Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMarkus Knauer2007-03-27 19:14:44 +0000
committerMarkus Knauer2007-03-27 19:14:44 +0000
commit8c0231a278baced12aa4dd7fe2465dd8b2293a7e (patch)
tree4406cf36910b78de7152e6d750df2858d2dd611b /test
parentf29326697113124cf69c6b7bac04aaa803170939 (diff)
downloadorg.eclipse.epp.packages-8c0231a278baced12aa4dd7fe2465dd8b2293a7e.tar.gz
org.eclipse.epp.packages-8c0231a278baced12aa4dd7fe2465dd8b2293a7e.tar.xz
org.eclipse.epp.packages-8c0231a278baced12aa4dd7fe2465dd8b2293a7e.zip
initi
Diffstat (limited to 'test')
-rw-r--r--test/org.eclipse.epp.packaging.core.test/.classpath7
-rw-r--r--test/org.eclipse.epp.packaging.core.test/.project29
-rw-r--r--test/org.eclipse.epp.packaging.core.test/.settings/org.eclipse.jdt.core.prefs7
-rw-r--r--test/org.eclipse.epp.packaging.core.test/META-INF/MANIFEST.MF12
-rw-r--r--test/org.eclipse.epp.packaging.core.test/build.properties6
-rw-r--r--test/org.eclipse.epp.packaging.core.test/plugin.properties14
-rw-r--r--test/org.eclipse.epp.packaging.core.test/resources/test/singleentryfile1
-rw-r--r--test/org.eclipse.epp.packaging.core.test/resources/test/updatesite/features/org.eclipse.buckminster.core.feature_1.0.0.v20070205.jarbin0 -> 16332 bytes
-rw-r--r--test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/DummyPackagerConfiguration.java92
-rw-r--r--test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/assembly/PluginUtils_PdeTest.java26
-rw-r--r--test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/CommandLineParser_Test.java56
-rw-r--r--test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/Platform_Test.java47
-rw-r--r--test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser_PdeTest.java117
-rw-r--r--test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/download/SiteCreator_PdeTest.java62
-rw-r--r--test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/download/UpdateSiteManager_PdeTest.java65
-rw-r--r--test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/io/FileUtils_Test.java47
-rw-r--r--test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/io/Zip_Test.java71
17 files changed, 659 insertions, 0 deletions
diff --git a/test/org.eclipse.epp.packaging.core.test/.classpath b/test/org.eclipse.epp.packaging.core.test/.classpath
new file mode 100644
index 00000000..304e8618
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/test/org.eclipse.epp.packaging.core.test/.project b/test/org.eclipse.epp.packaging.core.test/.project
new file mode 100644
index 00000000..5bc155ac
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/.project
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.epp.packaging.core.test</name>
+ <comment></comment>
+ <projects>
+ <project>org.eclipse.epp.packaging.core</project>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
diff --git a/test/org.eclipse.epp.packaging.core.test/.settings/org.eclipse.jdt.core.prefs b/test/org.eclipse.epp.packaging.core.test/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 00000000..27ed6930
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Tue Mar 27 18:41:53 CEST 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/test/org.eclipse.epp.packaging.core.test/META-INF/MANIFEST.MF b/test/org.eclipse.epp.packaging.core.test/META-INF/MANIFEST.MF
new file mode 100644
index 00000000..0d255122
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/META-INF/MANIFEST.MF
@@ -0,0 +1,12 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.epp.packaging.core.test;singleton:=true
+Bundle-Version: 0.5.0.qualifier
+Bundle-Vendor: %Bundle-Vendor
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.update.core,
+ org.junit,
+ org.eclipse.epp.packaging.core
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
diff --git a/test/org.eclipse.epp.packaging.core.test/build.properties b/test/org.eclipse.epp.packaging.core.test/build.properties
new file mode 100644
index 00000000..4d892a61
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/build.properties
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties,\
+ resources/
diff --git a/test/org.eclipse.epp.packaging.core.test/plugin.properties b/test/org.eclipse.epp.packaging.core.test/plugin.properties
new file mode 100644
index 00000000..11b98fec
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/plugin.properties
@@ -0,0 +1,14 @@
+###############################################################################
+# Copyright (c) 2007 Innoopract Informationssysteme GmbH
+# 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:
+# Innoopract - initial API and implementation
+###############################################################################
+
+# properties file for org.eclipse.epp.packaging.core.test
+Bundle-Vendor = Eclipse.org
+Bundle-Name = EPP Core Tests \ No newline at end of file
diff --git a/test/org.eclipse.epp.packaging.core.test/resources/test/singleentryfile b/test/org.eclipse.epp.packaging.core.test/resources/test/singleentryfile
new file mode 100644
index 00000000..f7fe244d
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/resources/test/singleentryfile
@@ -0,0 +1 @@
+Entry \ No newline at end of file
diff --git a/test/org.eclipse.epp.packaging.core.test/resources/test/updatesite/features/org.eclipse.buckminster.core.feature_1.0.0.v20070205.jar b/test/org.eclipse.epp.packaging.core.test/resources/test/updatesite/features/org.eclipse.buckminster.core.feature_1.0.0.v20070205.jar
new file mode 100644
index 00000000..b86058d4
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/resources/test/updatesite/features/org.eclipse.buckminster.core.feature_1.0.0.v20070205.jar
Binary files differ
diff --git a/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/DummyPackagerConfiguration.java b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/DummyPackagerConfiguration.java
new file mode 100644
index 00000000..fb328aec
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/DummyPackagerConfiguration.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * 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:
+ * Innoopract - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.epp.packaging.core;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration;
+import org.eclipse.epp.packaging.core.configuration.IPlatform;
+import org.eclipse.update.core.VersionedIdentifier;
+
+/** Test class */
+public class DummyPackagerConfiguration implements IPackagerConfiguration {
+
+ private URL siteUrl;
+ private IPlatform[] platforms;
+ private File baseDir;
+ private List<VersionedIdentifier> identifiers = new ArrayList<VersionedIdentifier>();
+
+ public File getExtensionSite() {
+ throw new UnsupportedOperationException( "Not yet implemented." ); //$NON-NLS-1$
+ }
+
+ public File getTargetFolder() {
+ return baseDir;
+ }
+
+ public File getPackagerConfigurationFolder() {
+ throw new UnsupportedOperationException( "Not yet implemented." ); //$NON-NLS-1$
+ }
+
+ public void addRequiredFeature( final VersionedIdentifier identifier ) {
+ identifiers.add( identifier );
+ }
+
+ public VersionedIdentifier[] getRequiredFeatures() {
+ return identifiers.toArray( new VersionedIdentifier[ identifiers.size() ] );
+ }
+
+ public IPlatform[] getTargetPlatforms() {
+ return platforms;
+ }
+
+ public String getRootFileBaseName() {
+ return "Rootfile"; //$NON-NLS-1$
+ }
+
+ public URL[] getUpdateSites() {
+ return new URL[]{
+ siteUrl
+ };
+ }
+
+ public void setUpdateSite( final String site ) throws MalformedURLException {
+ this.siteUrl = new URL( site );
+ }
+
+ public void setTargetPlatforms( final IPlatform[] platformArray ) {
+ this.platforms = platformArray;
+ }
+
+ public void setBaseFolder( final String baseFolder ) {
+ this.baseDir = new File( baseFolder );
+ }
+
+ public File getRootFileFolder() {
+ throw new UnsupportedOperationException( "Not yet implemented." ); //$NON-NLS-1$
+ }
+
+ public File getConfigIni() {
+ throw new UnsupportedOperationException( "Not yet implemented." ); //$NON-NLS-1$
+ }
+
+ public String getProductName() {
+ throw new UnsupportedOperationException( "Not yet implemented." ); //$NON-NLS-1$
+ }
+
+ public String getInstallerConfigurationFolder() {
+ throw new UnsupportedOperationException( "Not yet implemented." ); //$NON-NLS-1$;
+ }
+} \ No newline at end of file
diff --git a/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/assembly/PluginUtils_PdeTest.java b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/assembly/PluginUtils_PdeTest.java
new file mode 100644
index 00000000..1b4adcb4
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/assembly/PluginUtils_PdeTest.java
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * 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:
+ * Innoopract - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.epp.packaging.core.assembly;
+
+import java.io.File;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/** Test class*/
+public class PluginUtils_PdeTest extends TestCase {
+
+ public void testFindRuntimeCore() throws Exception {
+ String pluginPath = PluginUtils.getPluginPath( "org.eclipse.core.runtime" ); //$NON-NLS-1$
+ Assert.assertNotNull( pluginPath );
+ Assert.assertTrue( new File( pluginPath ).exists() );
+ }
+} \ No newline at end of file
diff --git a/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/CommandLineParser_Test.java b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/CommandLineParser_Test.java
new file mode 100644
index 00000000..15e12a1f
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/CommandLineParser_Test.java
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * 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:
+ * Innoopract - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.epp.packaging.core.configuration;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/** Test class */
+public class CommandLineParser_Test extends TestCase {
+
+ public void testParsesConfigFile() throws Exception {
+ ICommands command = ArgumentParser.parse( new String[]{
+ "eclipsepackager.xml"} ); //$NON-NLS-1$
+ Assert.assertEquals( "eclipsepackager.xml", command.getConfigurationFile().getName() ); //$NON-NLS-1$
+ }
+
+ public void testDefaultTasks() {
+ ICommands command = ArgumentParser.parse( new String[]{
+ "eclipsepackager.xml"} ); //$NON-NLS-1$
+ Assert.assertTrue( command.mustDo( Task.CHECK ) );
+ Assert.assertTrue( command.mustDo( Task.INSTALL ) );
+ Assert.assertTrue( command.mustDo( Task.BUILD ) );
+ }
+
+ public void testParsesTasks() throws Exception {
+ ICommands command = ArgumentParser.parse( new String[]{
+ "eclipsepackager.xml", "check", "install"} ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Assert.assertTrue( command.mustDo( Task.CHECK ) );
+ Assert.assertTrue( command.mustDo( Task.INSTALL ) );
+ }
+
+ public void testParsesAllTasks() throws Exception {
+ ICommands command = ArgumentParser.parse( new String[]{
+ "eclipsepackager.xml", "check", "install", "build"} ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Assert.assertTrue( command.mustDo( Task.CHECK ) );
+ Assert.assertTrue( command.mustDo( Task.INSTALL ) );
+ Assert.assertTrue( command.mustDo( Task.BUILD ) );
+ }
+
+ public void testBadArgumentType() throws Exception {
+ try {
+ ArgumentParser.parse( Boolean.TRUE );
+ fail();
+ } catch( IllegalArgumentException e ) {
+ // expected exception
+ }
+ }
+} \ No newline at end of file
diff --git a/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/Platform_Test.java b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/Platform_Test.java
new file mode 100644
index 00000000..5c07fb86
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/Platform_Test.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * 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:
+ * Innoopract - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.epp.packaging.core.configuration;
+
+import org.eclipse.epp.packaging.core.configuration.Platform;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/**Test class */
+public class Platform_Test extends TestCase {
+
+ public void testEquals() throws Exception {
+ Platform platform = new Platform( "win32", "win32", "x86" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Platform secondPlatform = new Platform( "win32", "win32", "x86" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertTrue( platform.equals( secondPlatform ) );
+ }
+
+ public void testToString() throws Exception {
+ Platform platform = new Platform( "win32", "win32", "x86" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Assert.assertEquals( "win32,win32,x86", platform.toString() ); //$NON-NLS-1$
+ }
+
+ public void testAdvancedToString() throws Exception {
+ Platform platform = new Platform( "win32", "win32", "x86" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Assert.assertEquals( "win32nwin32nx86", platform.toString( 'n' ) ); //$NON-NLS-1$
+ }
+
+ public void testDefaultArchiveFormat() {
+ Platform platform = new Platform( "win32", "win32", "x86" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Assert.assertEquals( "antZip", platform.getArchiveFormat().name() ); //$NON-NLS-1$
+ }
+
+ public void testSetArchiveFormat() throws Exception {
+ Platform platform = new Platform( "win32", "win32", "x86" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ platform.setArchiveFormat( "tar" ); //$NON-NLS-1$
+ Assert.assertEquals( "tar", platform.getArchiveFormat().name() ); //$NON-NLS-1$
+ }
+} \ No newline at end of file
diff --git a/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser_PdeTest.java b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser_PdeTest.java
new file mode 100644
index 00000000..b1756706
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/configuration/xml/ConfigurationParser_PdeTest.java
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * 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:
+ * Innoopract - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.epp.packaging.core.configuration.xml;
+
+import java.io.File;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.epp.packaging.core.configuration.ArchiveFormat;
+import org.eclipse.epp.packaging.core.configuration.IPackagerConfiguration;
+import org.eclipse.epp.packaging.core.configuration.IPlatform;
+import org.eclipse.epp.packaging.core.configuration.Platform;
+import org.eclipse.epp.packaging.core.configuration.xml.ConfigurationParser;
+import org.eclipse.update.core.VersionedIdentifier;
+
+/** Test class */
+public class ConfigurationParser_PdeTest extends TestCase {
+
+ private final static String xml = "<configuration>" //$NON-NLS-1$
+ + "<rcp version=\"3.2\"/>" //$NON-NLS-1$
+ + "<product name=\"EPPBuild\" configIni=\"/home/urs/config.ini\"/>" //$NON-NLS-1$
+ + "<updateSites>" //$NON-NLS-1$
+ + " <updateSite url=\"http://update.eclipse.org/updates/3.2/\"/>" //$NON-NLS-1$
+ + "</updateSites>" //$NON-NLS-1$
+ + "<requiredFeatures>" //$NON-NLS-1$
+ + " <feature id=\"org.eclipse.rcp\" version=\"3.1.1\"/>" //$NON-NLS-1$
+ + "</requiredFeatures>" //$NON-NLS-1$
+ + "<packagerConfigurationFolder folder=\"/home/help\"/>" //$NON-NLS-1$
+ + "<installerConfigurationFolder folder=\"/home/installer\"/>" //$NON-NLS-1$
+ + "<rootFileFolder folder=\"/home/root\"/>" //$NON-NLS-1$
+ + "<extensionSite relativeFolder=\"site\"/>" //$NON-NLS-1$
+ + "<targetPlatforms>" //$NON-NLS-1$
+ + " <platform os=\"linux\" ws=\"gtk\" arch=\"x86\"/>" //$NON-NLS-1$
+ + " <platform os=\"win32\" ws=\"win32\" arch=\"x86\">" //$NON-NLS-1$
+ + " <archiveFormat format=\"tar\"/>" //$NON-NLS-1$
+ + " </platform>" //$NON-NLS-1$
+ + "</targetPlatforms>" //$NON-NLS-1$
+ + "</configuration>"; //$NON-NLS-1$
+
+ public void testParseUpdateSites() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ Assert.assertEquals( "http://update.eclipse.org/updates/3.2/", //$NON-NLS-1$
+ config.getUpdateSites()[ 0 ].toExternalForm() );
+ }
+
+ public void testParseFeatures() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ Assert.assertEquals( new VersionedIdentifier( "org.eclipse.rcp", "3.1.1" ), //$NON-NLS-1$ //$NON-NLS-2$
+ config.getRequiredFeatures()[ 0 ] );
+ }
+
+ public void testParsePackagerConfigurationFolder() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ Assert.assertEquals( new File( "/home/help" ), //$NON-NLS-1$
+ config.getPackagerConfigurationFolder() );
+ }
+
+ public void testParseInstallerConfigurationFolder() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ Assert.assertEquals( "/home/installer", //$NON-NLS-1$
+ config.getInstallerConfigurationFolder() );
+ }
+
+ public void testParseRelativeExtensionSite() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ Assert.assertEquals( new File( org.eclipse.core.runtime.Platform.getLocation()
+ .toFile(),
+ "site" ), //$NON-NLS-1$
+ config.getExtensionSite() );
+ }
+
+ public void testParseTargetPlatformWithoutFormat() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ IPlatform platform = config.getTargetPlatforms()[ 0 ];
+ Assert.assertEquals( new Platform( "linux", "gtk", "x86" ), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ platform );
+ Assert.assertEquals( ArchiveFormat.antZip, platform.getArchiveFormat() );
+ }
+
+ public void testParsePlatformWithFormat() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ IPlatform platform = config.getTargetPlatforms()[ 1 ];
+ Assert.assertEquals( new Platform( "win32", "win32", "x86" ), platform ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Assert.assertEquals( ArchiveFormat.tar, platform.getArchiveFormat() );
+ }
+
+ public void testParseRcpVersion() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ String basename = config.getRootFileBaseName();
+ Assert.assertEquals( "eclipse-RCP-3.2-", basename ); //$NON-NLS-1$
+ }
+
+ public void testParseRootFiles() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ File folder = config.getRootFileFolder();
+ Assert.assertEquals( new File( "/home/root" ), folder ); //$NON-NLS-1$
+ }
+
+ public void testParseConfigFile() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ File configIni = config.getConfigIni();
+ Assert.assertEquals( new File( "/home/urs/config.ini" ), configIni ); //$NON-NLS-1$
+ }
+
+ public void testParseProductName() throws Exception {
+ IPackagerConfiguration config = new ConfigurationParser().parseConfiguration( xml );
+ Assert.assertEquals( "EPPBuild", config.getProductName() ); //$NON-NLS-1$
+ }
+} \ No newline at end of file
diff --git a/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/download/SiteCreator_PdeTest.java b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/download/SiteCreator_PdeTest.java
new file mode 100644
index 00000000..4e8e5644
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/download/SiteCreator_PdeTest.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * 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:
+ * Innoopract - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.epp.packaging.core.download;
+
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.epp.packaging.core.download.SiteCreator;
+import org.eclipse.update.configuration.IConfiguredSite;
+import org.eclipse.update.core.SiteManager;
+
+/** Test class */
+public class SiteCreator_PdeTest extends TestCase {
+
+ private static final String SITE = "./site"; //$NON-NLS-1$
+
+ public void testFilesAreCreated() throws IOException, CoreException {
+ SiteCreator.createInstallationSite( new File( SITE ) );
+ Assert.assertTrue( new File( SITE ).exists() );
+ }
+
+ public void testExtensionSiteIsCreated() throws IOException, CoreException {
+ IConfiguredSite site = SiteCreator.createInstallationSite( new File( SITE ) );
+ Assert.assertTrue( site.isExtensionSite() );
+ Assert.assertTrue( site.isEnabled() );
+ Assert.assertTrue( site.isUpdatable() );
+ }
+
+ public void testClearExtensionSite() throws CoreException, IOException {
+ SiteCreator.createInstallationSite( new File( SITE ) );
+ SiteCreator.removeInstallationSite( SITE );
+ IConfiguredSite[] configuredSites = SiteManager.getLocalSite()
+ .getCurrentConfiguration()
+ .getConfiguredSites();
+ File file = new File( SITE );
+ String fileUrl = file.toURL().toExternalForm() + "eclipse/"; //$NON-NLS-1$
+ for( IConfiguredSite site : configuredSites ) {
+ Assert.assertFalse( site.getSite()
+ .getURL()
+ .toExternalForm()
+ .equals( fileUrl ) );
+ }
+ Assert.assertFalse( file.exists() );
+ }
+
+ @Override
+ public void tearDown() throws CoreException, MalformedURLException
+ {
+ SiteCreator.removeInstallationSite( SITE );
+ }
+}
diff --git a/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/download/UpdateSiteManager_PdeTest.java b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/download/UpdateSiteManager_PdeTest.java
new file mode 100644
index 00000000..118f380f
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/download/UpdateSiteManager_PdeTest.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * 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:
+ * Innoopract - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.epp.packaging.core.download;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.epp.packaging.core.DummyPackagerConfiguration;
+import org.eclipse.epp.packaging.core.download.UpdateSiteManager;
+import org.eclipse.update.core.IFeature;
+import org.eclipse.update.core.VersionedIdentifier;
+
+/** Test class*/
+public class UpdateSiteManager_PdeTest extends TestCase {
+
+ private static final String BUCKMINSTER_UPDATESITE_URL
+ = "http://download.eclipse.org/technology/buckminster/updates/"; //$NON-NLS-1$
+ private static final VersionedIdentifier BUCKMINSTERIDENTIFIER
+ = new VersionedIdentifier( "org.eclipse.buckminster.core.feature", //$NON-NLS-1$
+ "1.0.0.v20070220" ); //$NON-NLS-1$
+ private static final VersionedIdentifier HEADLESSIDENTIFIER
+ = new VersionedIdentifier( "org.eclipse.buckminster.svn.headless.feature", //$NON-NLS-1$
+ "1.0.0.v20070207" ); //$NON-NLS-1$
+ private DummyPackagerConfiguration configuration;
+ private UpdateSiteManager manager;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ this.configuration = new DummyPackagerConfiguration();
+ this.configuration.setUpdateSite( BUCKMINSTER_UPDATESITE_URL );
+ this.configuration.addRequiredFeature( BUCKMINSTERIDENTIFIER );
+ this.configuration.addRequiredFeature( HEADLESSIDENTIFIER );
+ this.manager = new UpdateSiteManager( this.configuration );
+ }
+
+ // For some reason, this fails with the local update site.
+ public void testGetFeature()
+ throws CoreException, MalformedURLException, IOException
+ {
+ IFeature[] feature = this.manager.getFeatures();
+ Assert.assertEquals( 2, feature.length );
+ }
+
+ public void testAllFeaturesPresent()
+ throws MalformedURLException, IOException, CoreException
+ {
+ this.manager = new UpdateSiteManager( this.configuration );
+ Assert.assertTrue( this.manager.areFeaturesPresent( new VersionedIdentifier[]{
+ BUCKMINSTERIDENTIFIER, HEADLESSIDENTIFIER
+ } ) );
+ }
+}
diff --git a/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/io/FileUtils_Test.java b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/io/FileUtils_Test.java
new file mode 100644
index 00000000..f0755d93
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/io/FileUtils_Test.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * 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:
+ * Innoopract - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.epp.packaging.core.io;
+
+import java.io.File;
+
+import org.eclipse.epp.packaging.core.io.FileUtils;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+/** Test class */
+public class FileUtils_Test extends TestCase {
+
+ public void testFileIsCopied() throws Exception {
+ FileUtils.copy( "./resources/test/singleentryfile", //$NON-NLS-1$
+ "./resources/test/copy" ); //$NON-NLS-1$
+ Assert.assertTrue( new File( "./resources/test/copy" ).exists() ); //$NON-NLS-1$
+ }
+
+ public void testCopyFileDirectly() throws Exception {
+ FileUtils.copy( new File( "./resources/test/singleentryfile" ), //$NON-NLS-1$
+ new File( "./resources/test/copy" ) ); //$NON-NLS-1$
+ Assert.assertTrue( new File( "./resources/test/copy" ).exists() ); //$NON-NLS-1$
+ }
+
+ public void testDirectoryIsCreated() throws Exception {
+ FileUtils.copy( "./resources/test/singleentryfile", //$NON-NLS-1$
+ "./resources/test/copy/copy" ); //$NON-NLS-1$
+ Assert.assertTrue( new File( "./resources/test/copy/copy" ).exists() ); //$NON-NLS-1$
+ new File( "./resources/test/copy/copy" ).delete(); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ new File( "./resources/test/copy" ).delete(); //$NON-NLS-1$
+ }
+}
diff --git a/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/io/Zip_Test.java b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/io/Zip_Test.java
new file mode 100644
index 00000000..4f1ff4df
--- /dev/null
+++ b/test/org.eclipse.epp.packaging.core.test/src/org/eclipse/epp/packaging/core/io/Zip_Test.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Innoopract Informationssysteme GmbH
+ * 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:
+ * Innoopract - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.epp.packaging.core.io;
+
+import java.io.File;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.epp.packaging.core.io.Zip;
+
+/** Test class */
+public class Zip_Test extends TestCase {
+
+ private static final String TEST_ZIP_PATH
+ = "./resources/test/test.zip"; //$NON-NLS-1$
+ private Zip zip = null;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ this.zip = new Zip( new File( TEST_ZIP_PATH ) );
+ }
+
+ public void testCreateZipFile() throws Exception {
+ this.zip.addFile( "./resources/test/singleentryfile" ); //$NON-NLS-1$
+ this.zip.close();
+ Assert.assertTrue( new File( TEST_ZIP_PATH ).exists() );
+ }
+
+ public void testAddFile() throws Exception {
+ this.zip.addFile( "./resources/test/singleentryfile" ); //$NON-NLS-1$
+ this.zip.close();
+ ZipFile zipFile = new ZipFile( TEST_ZIP_PATH );
+ ZipEntry entry = zipFile.getEntry( "resources/test/singleentryfile" ); //$NON-NLS-1$
+ Assert.assertNotNull( entry );
+ }
+
+ // TODO test fails sometimes when not in debug mode... timing problem?
+ public void testAddFolder() throws Exception {
+ this.zip.addFolder( new File( "./resources/test/updatesite/features" ) ); //$NON-NLS-1$
+ this.zip.close();
+ ZipFile zipFile = new ZipFile( TEST_ZIP_PATH );
+ ZipEntry entry = zipFile.getEntry( "org.eclipse.buckminster.core.feature_1.0.0.v20070205.jar" ); //$NON-NLS-1$
+ Assert.assertNotNull( entry );
+ }
+
+ // TODO test fails sometimes when not in debug mode... timing problem?
+ public void testAddFileAs() throws Exception {
+ File testFile = new File( "./resources/test/singleentryfile" ); //$NON-NLS-1$
+ this.zip.addFileAs( testFile, "eclipse/configuration/config.ini" ); //$NON-NLS-1$
+ this.zip.close();
+ ZipEntry entry = new ZipFile( TEST_ZIP_PATH ).getEntry( "eclipse/configuration/config.ini" ); //$NON-NLS-1$
+ Assert.assertNotNull( entry );
+ }
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ new File( TEST_ZIP_PATH ).delete();
+ }
+}

Back to the top