Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: b17567066b28ccb16e9727d60cdf2c39a90968e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
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$    
  }
}

Back to the top