Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core')
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/RPMCoreInternalTestSuite.java23
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/RPMProjectTest.java301
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/SpecFileParserTest.java100
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/AllTests.java21
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMCoreTestSuite.java23
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMCoreTestsPlugin.java76
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectFactoryTest.java62
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectNatureTest.java21
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectTest.java176
9 files changed, 198 insertions, 605 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/RPMCoreInternalTestSuite.java b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/RPMCoreInternalTestSuite.java
deleted file mode 100644
index 6a21d28da6..0000000000
--- a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/RPMCoreInternalTestSuite.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * (c) 2005 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-package org.eclipse.linuxtools.rpm.core.internal.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class RPMCoreInternalTestSuite extends TestSuite {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.eclipse.linuxtools.rpm.core.internal.tests");
- //$JUnit-BEGIN$
- suite.addTest(RPMProjectTest.suite());
- suite.addTest(SpecFileParserTest.suite());
- //$JUnit-END$
- return suite;
- }
-}
diff --git a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/RPMProjectTest.java b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/RPMProjectTest.java
deleted file mode 100644
index 4c75083b81..0000000000
--- a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/RPMProjectTest.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
- * (c) 2007 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-package org.eclipse.linuxtools.rpm.core.internal.tests;
-
-import java.io.File;
-import java.io.StringBufferInputStream;
-import java.net.URL;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.linuxtools.rpm.core.IRPMConstants;
-import org.eclipse.linuxtools.rpm.core.IRPMProject;
-import org.eclipse.linuxtools.rpm.core.ISpecFile;
-import org.eclipse.linuxtools.rpm.core.RPMCorePlugin;
-import org.eclipse.linuxtools.rpm.core.RPMExportDelta;
-import org.eclipse.linuxtools.rpm.core.RPMProjectFactory;
-import org.eclipse.linuxtools.rpm.core.RPMProjectNature;
-import org.eclipse.linuxtools.rpm.core.tests.RPMCoreTestsPlugin;
-
-public class RPMProjectTest extends TestCase {
-
- IWorkspace workspace;
- IWorkspaceRoot root;
- NullProgressMonitor monitor;
- String pluginRoot;
-
- final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
- private final String line_sep = System.getProperty("line.separator"); //$NON-NLS-1$
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- IWorkspaceDescription desc;
- workspace = ResourcesPlugin.getWorkspace();
- root = workspace.getRoot();
- monitor = new NullProgressMonitor();
- if(workspace == null) {
- fail("Workspace was not setup");
- }
- if(root == null) {
- fail("Workspace root was not setup");
- }
- desc = workspace.getDescription();
- desc.setAutoBuilding(false);
- workspace.setDescription(desc);
- }
-
- public static TestSuite suite() {
- return new TestSuite(RPMProjectTest.class);
- }
-
- public void testImportHelloWorld() throws Exception {
- // Create a project for the test
- IProject testProject = root.getProject("testHelloWorld");
- testProject.create(monitor);
- testProject.open(monitor);
- if(testProject == null) {
- fail("Unable to create test project");
- }
-
- // Instantiate an RPMProject
- IRPMProject rpmProject = RPMProjectFactory.getRPMProject(testProject);
-
- // Find the test SRPM and install it
- URL url = RPMCoreTestsPlugin.getDefault().find(new Path("resources" + file_sep + "srpms" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "helloworld-2-2.src.rpm"));
- if (url == null) {
- fail("Unable to find resource" + file_sep + "srpms" + file_sep +
- "helloworld-2-2.src.rpm");
- }
- File foo = new File(Platform.asLocalURL(url).getPath());
- rpmProject.importSourceRPM(foo);
-
- // Make sure the original SRPM got copied into the workspace
- IFile srpm = rpmProject.getConfiguration().getSrpmsFolder().getFile("helloworld-2-2.src.rpm");
- assertTrue(srpm.exists());
- assertNotNull(rpmProject.getProject().getPersistentProperty(new QualifiedName(RPMCorePlugin.ID,
- IRPMConstants.SRPM_PROPERTY)));
-
- // Make sure everything got installed properly
- IFile spec = rpmProject.getConfiguration().getSpecsFolder().getFile("helloworld.spec");
- assertTrue(spec.exists());
- IFile sourceBall = rpmProject.getConfiguration().getSourcesFolder().getFile("helloworld-2.tar.bz2");
- assertTrue(sourceBall.exists());
-
- // Make sure we got the spec file
- ISpecFile specFile = rpmProject.getSpecFile();
- assertTrue(specFile != null);
- assertNotNull(rpmProject.getProject().getPersistentProperty(new QualifiedName(RPMCorePlugin.ID,
- IRPMConstants.SPEC_FILE_PROPERTY)));
-
- // Make sure the sources got copied from BUILD to the project root
- IResource[] sources = rpmProject.getConfiguration().getBuildFolder().members();
- // If there is one folder, assume it contains all the sources
- if(sources.length == 1 && sources[0].getType() == IResource.FOLDER) {
- IFolder foo1 = rpmProject.getProject().getFolder(sources[0].getProjectRelativePath());
- sources = foo1.members();
- }
- for(int i=0; i < sources.length; i++) {
- if(sources[i].getType() == IResource.FILE) {
- assertTrue(testProject.getFile(sources[i].getName()).exists());
- }
- else if(sources[i].getType() == IResource.FOLDER) {
- assertTrue(testProject.getFolder(sources[i].getName()).exists());
- }
- }
-
- // Make sure the checksum was stored
- assertNotNull(rpmProject.getProject().getPersistentProperty(new QualifiedName(RPMCorePlugin.ID,
- IRPMConstants.CHECKSUM_PROPERTY)));
-
- // Make sure the RPM nature was added
- assertTrue(rpmProject.getProject().hasNature(RPMProjectNature.RPM_NATURE_ID));
-
- // Clean up
- testProject.delete(true, false, monitor);
- }
-
- public void testBuildPrepHelloWorld() throws Exception {
- // Create a project for the test
- IProject testProject = root.getProject("testBuildPrepHelloWorld");
- testProject.create(monitor);
- testProject.open(monitor);
- if(testProject == null) {
- fail("Unable to create test project");
- }
-
- // Instantiate an RPMProject
- IRPMProject rpmProject = RPMProjectFactory.getRPMProject(testProject);
-
- // Find the test SRPM, install, and build-prep it
- URL url = RPMCoreTestsPlugin.getDefault().find(new Path("resources" + file_sep + "srpms" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "helloworld-2-2.src.rpm"));
- if (url == null) {
- fail("Unable to find resource" + file_sep + "srpms" + file_sep +
- "helloworld-2-2.src.rpm");
- }
- File foo = new File(Platform.asLocalURL(url).getPath());
- rpmProject.importSourceRPM(foo);
- rpmProject.buildPrep();
-
- // Make sure we got everything in the build directory
- IFolder builddir = rpmProject.getConfiguration().getBuildFolder();
- IFolder helloworldFolder = builddir.getFolder("helloworld-2");
- assertTrue(helloworldFolder.exists());
-
- // Clean up
- testProject.delete(true, false, monitor);
- }
-
- public void testIsChangedHelloWorld() throws Exception {
- // Create a project for the test
- IProject testProject = root.getProject("testIsChangedHelloWorld");
- testProject.create(monitor);
- testProject.open(monitor);
- if(testProject == null) {
- fail("Unable to create test project");
- }
-
- // Instantiate an RPMProject
- IRPMProject rpmProject = RPMProjectFactory.getRPMProject(testProject);
-
- // Find the test SRPM and install it
- URL url = RPMCoreTestsPlugin.getDefault().find(new Path("resources" + file_sep + "srpms" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "helloworld-2-2.src.rpm"));
- if (url == null) {
- fail("Unable to find resource" + file_sep + "srpms" + file_sep +
- "helloworld-2-2.src.rpm");
- }
- File foo = new File(Platform.asLocalURL(url).getPath());
- rpmProject.importSourceRPM(foo);
- assertFalse(rpmProject.isChanged());
-
- testProject.delete(true, false, null);
- }
-
- public void testIsChangedHelloWorld1() throws Exception {
- // Create a project for the test
- IProject testProject = root.getProject("testIsChangedHelloWorld1");
- testProject.create(monitor);
- testProject.open(monitor);
- if(testProject == null) {
- fail("Unable to create test project");
- }
-
- // Instantiate an RPMProject
- IRPMProject rpmProject = RPMProjectFactory.getRPMProject(testProject);
-
- // Find the test SRPM and install it
- URL url = RPMCoreTestsPlugin.getDefault().find(new Path("resources" + file_sep + "srpms" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "helloworld-2-2.src.rpm"));
- if (url == null) {
- fail("Unable to find resource" + file_sep + "srpms" + file_sep +
- "helloworld-2-2.src.rpm");
- }
- File foo = new File(Platform.asLocalURL(url).getPath());
- rpmProject.importSourceRPM(foo);
- IFile sourceFile = rpmProject.getProject().getFile("helloworld.cpp");
- StringBufferInputStream foo1 = new StringBufferInputStream("/* */");
- sourceFile.appendContents(foo1, false, false, null);
- assertTrue(rpmProject.isChanged());
-
- testProject.delete(true, false, null);
- }
-
- public void testBuildSourceRPMHelloWorld() throws Exception {
- // Create a project for the test
- IProject testProject = root.getProject("testBuildSourceRPMHelloWorld1");
- testProject.create(monitor);
- testProject.open(monitor);
- if(testProject == null) {
- fail("Unable to create test project");
- }
-
- // Instantiate an RPMProject
- IRPMProject rpmProject = RPMProjectFactory.getRPMProject(testProject);
-
- // Find the test SRPM and install it
- URL url = RPMCoreTestsPlugin.getDefault().find(new Path("resources" + file_sep + "srpms" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "helloworld-2-2.src.rpm"));
- if (url == null) {
- fail("Unable to find resource" + file_sep + "srpms" + file_sep +
- "helloworld-2-2.src.rpm");
- }
- File foo = new File(Platform.asLocalURL(url).getPath());
- rpmProject.importSourceRPM(foo);
- RPMExportDelta export = new RPMExportDelta();
- export.setSpecFile(rpmProject.getSpecFile().getFile());
- export.setVersion("2");
- export.setRelease("3");
- rpmProject.buildSourceRPM(export);
-
- IFile foo2 = rpmProject.getConfiguration().getSrpmsFolder().getFile("helloworld-2-3.src.rpm");
- assertTrue(foo2.exists());
-
- testProject.delete(true, false, null);
- }
-
- public void testBuildSourceRPMHelloWorld1() throws Exception {
- // Create a project for the test
- IProject testProject = root.getProject("testBuildSourceRPMHelloWorld");
- testProject.create(monitor);
- testProject.open(monitor);
- if(testProject == null) {
- fail("Unable to create test project");
- }
-
- // Instantiate an RPMProject
- IRPMProject rpmProject = RPMProjectFactory.getRPMProject(testProject);
-
- // Find the test SRPM and install it
- URL url = RPMCoreTestsPlugin.getDefault().find(new Path("resources" + file_sep + "srpms" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "helloworld-2-2.src.rpm"));
- if (url == null) {
- fail("Unable to find resource" + file_sep + "srpms" + file_sep +
- "helloworld-2-2.src.rpm");
- }
- File foo = new File(Platform.asLocalURL(url).getPath());
- rpmProject.importSourceRPM(foo);
- IFile sourceFile = rpmProject.getProject().getFile("helloworld.cpp");
- StringBufferInputStream foo1 = new StringBufferInputStream("/* */");
- sourceFile.appendContents(foo1, false, false, null);
- RPMExportDelta export = new RPMExportDelta();
- export.setSpecFile(rpmProject.getSpecFile().getFile());
- export.setVersion("2");
- export.setRelease("4");
- export.setPatchName("myPatchFFFFF.patch");
- Date today = new Date();
- SimpleDateFormat df = new SimpleDateFormat("E MMM dd yyyy"); //$NON-NLS-1$
- export.setChangelogEntry("* " + df.format(today) + " Foo Bot <bot@foo.bar> 2-4" + line_sep +
- "- Made test change" + line_sep);
- rpmProject.buildSourceRPM(export);
-
- // Make sure patch was created
- assertTrue(rpmProject.getConfiguration().getSourcesFolder().getFile(export.getPatchName()).exists());
-
- IFile foo2 = rpmProject.getConfiguration().getSrpmsFolder().getFile("helloworld-2-4.src.rpm");
- assertTrue(foo2.exists());
- }
-}
diff --git a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/SpecFileParserTest.java b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/SpecFileParserTest.java
deleted file mode 100644
index b84c0616bb..0000000000
--- a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/internal/tests/SpecFileParserTest.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * (c) 2007 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-package org.eclipse.linuxtools.rpm.core.internal.tests;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.net.URL;
-
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.linuxtools.rpm.core.internal.SpecFileParser;
-import org.eclipse.linuxtools.rpm.core.tests.RPMCoreTestsPlugin;
-
-public class SpecFileParserTest extends TestCase {
-
- IWorkspace workspace;
- IWorkspaceRoot root;
- NullProgressMonitor monitor;
- String pluginRoot;
- final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
-
- public static TestSuite suite() {
- return new TestSuite(SpecFileParserTest.class);
- }
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- IWorkspaceDescription desc;
- workspace = ResourcesPlugin.getWorkspace();
- root = workspace.getRoot();
- monitor = new NullProgressMonitor();
- if(workspace == null) {
- fail("Workspace was not setup");
- }
- if(root == null) {
- fail("Workspace root was not setup");
- }
- desc = workspace.getDescription();
- desc.setAutoBuilding(false);
- workspace.setDescription(desc);
- }
-
- public void testParseHelloWorld() throws Exception {
- // Create a project for the test
- IProject testProject = root.getProject("testHelloWorldSpec");
- testProject.create(monitor);
- testProject.open(monitor);
- if(testProject == null) {
- fail("Unable to create test project");
- }
-
- // Find the spec
- URL url = RPMCoreTestsPlugin.getDefault().find(new Path("resources" + file_sep + "specs" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
- "helloworld.spec"));
- if (url == null) {
- fail("Unable to find resource" + file_sep + "srpms" + file_sep +
- "helloworld.spec");
- }
- File foo = new File(Platform.asLocalURL(url).getPath());
-
- // Copy the spec into workspace
- IFile specFile = testProject.getFile("helloworld.spec");
- specFile.create(new FileInputStream(foo), false, null);
- assertTrue(specFile.exists());
-
- // Try parsing it
- SpecFileParser parser = new SpecFileParser(specFile);
- parser.parse();
-
- // Make sure we parsed the spec correctly
- String name = parser.getName();
- assertTrue(name.equals("helloworld"));
- String version = parser.getVersion();
- assertTrue(version.equals("2"));
- String release = parser.getRelease();
- assertTrue(release.equals("2"));
- assertTrue(parser.getConfigureArgs() == null);
-
- // Clean up
- testProject.delete(true, false, monitor);
- }
-
-}
diff --git a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/AllTests.java b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/AllTests.java
index 6358be9ad6..ca5f48edd2 100644
--- a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/AllTests.java
+++ b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/AllTests.java
@@ -1,14 +1,15 @@
-/*
- * (c) 2004, 2005 Red Hat, Inc.
+/*******************************************************************************
+ * Copyright (c) 2004, 2005, 2009 Red Hat, Inc.
+ * 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
*
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
package org.eclipse.linuxtools.rpm.core.tests;
-
-import org.eclipse.linuxtools.rpm.core.internal.tests.RPMCoreInternalTestSuite;
-
import junit.framework.Test;
import junit.framework.TestSuite;
@@ -17,8 +18,8 @@ public class AllTests extends TestSuite{
public static Test suite() {
TestSuite suite = new TestSuite("Test for org.eclipse.linuxtools.rpm.core.tests");
//$JUnit-BEGIN$
- suite.addTest(RPMCoreInternalTestSuite.suite());
- suite.addTest(RPMCoreTestSuite.suite());
+ suite.addTestSuite(RPMProjectTest.class);
+ suite.addTestSuite(RPMProjectNatureTest.class);
//$JUnit-END$
return suite;
}
diff --git a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMCoreTestSuite.java b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMCoreTestSuite.java
deleted file mode 100644
index 895b90a4f4..0000000000
--- a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMCoreTestSuite.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * (c) 2004, 2005 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-package org.eclipse.linuxtools.rpm.core.tests;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-public class RPMCoreTestSuite extends TestSuite {
-
- public static Test suite() {
- TestSuite suite = new TestSuite(
- "Test for org.eclipse.linuxtools.rpm.core.tests");
- //$JUnit-BEGIN$
- suite.addTestSuite(RPMProjectNatureTest.class);
- suite.addTestSuite(RPMProjectFactoryTest.class);
- //$JUnit-END$
- return suite;
- }
-}
diff --git a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMCoreTestsPlugin.java b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMCoreTestsPlugin.java
deleted file mode 100644
index 45e9c7d54a..0000000000
--- a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMCoreTestsPlugin.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * (c) 2004, 2005 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-
-package org.eclipse.linuxtools.rpm.core.tests;
-
-import org.eclipse.ui.plugin.*;
-import org.osgi.framework.BundleContext;
-import java.util.*;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class RPMCoreTestsPlugin extends AbstractUIPlugin {
- //The shared instance.
- private static RPMCoreTestsPlugin plugin;
- //Resource bundle.
- private ResourceBundle resourceBundle;
-
- /**
- * The constructor.
- */
- public RPMCoreTestsPlugin() {
- super();
- plugin = this;
- try {
- resourceBundle = ResourceBundle.getBundle("org.eclipse.linuxtools.rpm.core.tests.TestsPluginResources");
- } catch (MissingResourceException x) {
- resourceBundle = null;
- }
- }
-
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- }
-
- /**
- * Returns the shared instance.
- */
- public static RPMCoreTestsPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle = RPMCoreTestsPlugin.getDefault().getResourceBundle();
- try {
- return (bundle != null) ? bundle.getString(key) : key;
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
- }
-}
diff --git a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectFactoryTest.java b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectFactoryTest.java
deleted file mode 100644
index 8ff147f334..0000000000
--- a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectFactoryTest.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * (c) 2007 Red Hat, Inc.
- *
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-
-package org.eclipse.linuxtools.rpm.core.tests;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceDescription;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.linuxtools.rpm.core.IRPMProject;
-import org.eclipse.linuxtools.rpm.core.RPMProjectFactory;
-
-public class RPMProjectFactoryTest extends TestCase {
-
- IWorkspace workspace;
- IWorkspaceRoot root;
- NullProgressMonitor monitor;
- String pluginRoot;
- final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
-
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- super.setUp();
- IWorkspaceDescription desc;
- workspace = ResourcesPlugin.getWorkspace();
- root = workspace.getRoot();
- monitor = new NullProgressMonitor();
- if(workspace == null) {
- fail("Workspace was not setup");
- }
- if(root == null) {
- fail("Workspace root was not setup");
- }
- desc = workspace.getDescription();
- desc.setAutoBuilding(false);
- workspace.setDescription(desc);
- }
-
- public void testGetNewProject() throws Exception {
- // Create a project for the test
- IProject testProject = root.getProject("testHelloWorld");
- testProject.create(monitor);
- testProject.open(monitor);
- if(testProject == null) {
- fail("Unable to create test project");
- }
-
- IRPMProject rpmProject = RPMProjectFactory.getRPMProject(testProject);
- assertNotNull(rpmProject);
- testProject.delete(true, false, monitor);
- }
-}
diff --git a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectNatureTest.java b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectNatureTest.java
index c3bd064409..c4b007cd2a 100644
--- a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectNatureTest.java
+++ b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectNatureTest.java
@@ -1,10 +1,13 @@
-/*
- * (c) 2007 Red Hat, Inc.
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Red Hat, Inc.
+ * 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
*
- * This program is open source software licensed under the
- * Eclipse Public License ver. 1
- */
-
+ * Contributors:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
package org.eclipse.linuxtools.rpm.core.tests;
import junit.framework.TestCase;
@@ -27,7 +30,8 @@ public class RPMProjectNatureTest extends TestCase {
/*
* @see TestCase#setUp()
*/
- protected void setUp() throws Exception {
+ @Override
+ protected void setUp() throws Exception {
super.setUp();
IWorkspaceDescription desc;
workspace = ResourcesPlugin.getWorkspace();
@@ -48,9 +52,6 @@ public class RPMProjectNatureTest extends TestCase {
IProject testProject = root.getProject("testProject");
testProject.create(monitor);
testProject.open(monitor);
- if(testProject == null) {
- fail("Unable to create test project");
- }
RPMProjectNature.addRPMNature(testProject, monitor);
assertTrue(testProject.hasNature(RPMProjectNature.RPM_NATURE_ID));
testProject.delete(true, false, monitor);
diff --git a/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectTest.java b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectTest.java
new file mode 100644
index 0000000000..a31730ef30
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.core.tests/src/org/eclipse/linuxtools/rpm/core/tests/RPMProjectTest.java
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2009 Red Hat, Inc.
+ * 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:
+ * Red Hat - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.rpm.core.tests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.net.URL;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceDescription;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.linuxtools.rpm.core.IRPMConstants;
+import org.eclipse.linuxtools.rpm.core.RPMCorePlugin;
+import org.eclipse.linuxtools.rpm.core.RPMProject;
+import org.eclipse.linuxtools.rpm.core.RPMProjectNature;
+import org.osgi.framework.FrameworkUtil;
+
+public class RPMProjectTest extends TestCase {
+
+ IWorkspace workspace;
+ IWorkspaceRoot root;
+ NullProgressMonitor monitor;
+ String pluginRoot;
+
+ final String file_sep = System.getProperty("file.separator"); //$NON-NLS-1$
+
+ /*
+ * @see TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ IWorkspaceDescription desc;
+ workspace = ResourcesPlugin.getWorkspace();
+ root = workspace.getRoot();
+ monitor = new NullProgressMonitor();
+ if (workspace == null) {
+ fail("Workspace was not setup");
+ }
+ if (root == null) {
+ fail("Workspace root was not setup");
+ }
+ desc = workspace.getDescription();
+ desc.setAutoBuilding(false);
+ workspace.setDescription(desc);
+ }
+
+ public void testImportHelloWorld() throws Exception {
+ // Create a project for the test
+ IProject testProject = root.getProject("testHelloWorld");
+ testProject.create(monitor);
+ testProject.open(monitor);
+
+ // Instantiate an RPMProject
+ RPMProject rpmProject = new RPMProject(testProject);
+
+ // Find the test SRPM and install it
+ URL url = FileLocator.find(FrameworkUtil.getBundle(RPMProjectTest.class), new Path(
+ "resources" + file_sep + "srpms" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
+ "helloworld-2-2.src.rpm"), null);
+ if (url == null) {
+ fail("Unable to find resource" + file_sep + "srpms" + file_sep
+ + "helloworld-2-2.src.rpm");
+ }
+ File foo = new File(FileLocator.toFileURL(url).getPath());
+ rpmProject.importSourceRPM(foo);
+
+ // Make sure the original SRPM got copied into the workspace
+ IFile srpm = rpmProject.getConfiguration().getSrpmsFolder().getFile(
+ "helloworld-2-2.src.rpm");
+ assertTrue(srpm.exists());
+ assertNotNull(rpmProject.getProject()
+ .getPersistentProperty(
+ new QualifiedName(RPMCorePlugin.ID,
+ IRPMConstants.SRPM_PROPERTY)));
+
+ // Make sure everything got installed properly
+ IFile spec = rpmProject.getConfiguration().getSpecsFolder().getFile(
+ "helloworld.spec");
+ assertTrue(spec.exists());
+ IFile sourceBall = rpmProject.getConfiguration().getSourcesFolder()
+ .getFile("helloworld-2.tar.bz2");
+ assertTrue(sourceBall.exists());
+
+ // Make sure we got the spec file
+ IFile specFile = rpmProject.getSpecFile();
+ assertTrue(specFile != null);
+ assertNotNull(rpmProject.getProject().getPersistentProperty(
+ new QualifiedName(RPMCorePlugin.ID,
+ IRPMConstants.SPEC_FILE_PROPERTY)));
+
+ // Make sure the RPM nature was added
+ assertTrue(rpmProject.getProject().hasNature(
+ RPMProjectNature.RPM_NATURE_ID));
+
+ // Clean up
+ testProject.delete(true, false, monitor);
+ }
+
+ public void testBuildPrepHelloWorld() throws Exception {
+ // Create a project for the test
+ IProject testProject = root.getProject("testBuildPrepHelloWorld");
+ testProject.create(monitor);
+ testProject.open(monitor);
+
+ // Instantiate an RPMProject
+ RPMProject rpmProject = new RPMProject(testProject);
+
+ // Find the test SRPM, install, and build-prep it
+ URL url = FileLocator.find(FrameworkUtil.getBundle(RPMProjectTest.class), new Path(
+ "resources" + file_sep + "srpms" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
+ "helloworld-2-2.src.rpm"), null);
+ if (url == null) {
+ fail("Unable to find resource" + file_sep + "srpms" + file_sep
+ + "helloworld-2-2.src.rpm");
+ }
+ File foo = new File(FileLocator.toFileURL(url).getPath());
+ rpmProject.importSourceRPM(foo);
+ rpmProject.buildPrep();
+
+ // Make sure we got everything in the build directory
+ IFolder builddir = rpmProject.getConfiguration().getBuildFolder();
+ IFolder helloworldFolder = builddir.getFolder("helloworld-2");
+ assertTrue(helloworldFolder.exists());
+
+ // Clean up
+ testProject.delete(true, false, monitor);
+ }
+
+ public void testBuildSourceRPMHelloWorld() throws Exception {
+ // Create a project for the test
+ IProject testProject = root.getProject("testBuildSourceRPMHelloWorld1");
+ testProject.create(monitor);
+ testProject.open(monitor);
+
+ // Instantiate an RPMProject
+ RPMProject rpmProject = new RPMProject(testProject);
+
+ // Find the test SRPM and install it
+ URL url = FileLocator.find(FrameworkUtil.getBundle(RPMProjectTest.class), new Path(
+ "resources" + file_sep + "srpms" + file_sep + //$NON-NLS-1$ //$NON-NLS-2$
+ "helloworld-2-2.src.rpm"), null);
+ if (url == null) {
+ fail("Unable to find resource" + file_sep + "srpms" + file_sep
+ + "helloworld-2-2.src.rpm");
+ }
+ File foo = new File(FileLocator.toFileURL(url).getPath());
+ rpmProject.importSourceRPM(foo);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ rpmProject.buildSourceRPM(bos);
+
+ IFile foo2 = rpmProject.getConfiguration().getSrpmsFolder().getFile(
+ "helloworld-2-2.src.rpm");
+ assertTrue(foo2.exists());
+
+ testProject.delete(true, false, null);
+ }
+}

Back to the top