aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-12-09 16:18:16 (EST)
committerAlexander Kurtakov2013-12-16 04:46:18 (EST)
commit56f7187e1f9656ad2731128ed4648043751c13ee (patch)
treeb6836efde5d03694a139dc48cad3cacfa7376a23
parent8d6723f1bfb9f1a2162c817d8022cc8f8a63058b (diff)
downloadorg.eclipse.linuxtools-56f7187e1f9656ad2731128ed4648043751c13ee.zip
org.eclipse.linuxtools-56f7187e1f9656ad2731128ed4648043751c13ee.tar.gz
org.eclipse.linuxtools-56f7187e1f9656ad2731128ed4648043751c13ee.tar.bz2
RPM: createrepo tests for simple executionrefs/changes/12/19612/6
Testing classes within: o org.eclipse.linuxtools.internal.rpm.createrepo Change-Id: I83d5d285f677a7d63bc4db4a80c6242730f6dbd2 Signed-off-by: Neil Guzman <nguzman@redhat.com> Reviewed-on: https://git.eclipse.org/r/19612 Tested-by: Hudson CI Reviewed-by: Alexander Kurtakov <akurtako@redhat.com> IP-Clean: Alexander Kurtakov <akurtako@redhat.com> Tested-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/internal/rpm/createrepo/tests/CreaterepoTest.java103
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/AllTests.java3
2 files changed, 105 insertions, 1 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/internal/rpm/createrepo/tests/CreaterepoTest.java b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/internal/rpm/createrepo/tests/CreaterepoTest.java
new file mode 100644
index 0000000..4f336d9
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/internal/rpm/createrepo/tests/CreaterepoTest.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat Inc. 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:
+ * Neil Guzman - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.internal.rpm.createrepo.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Createrepo;
+import org.eclipse.linuxtools.rpm.createrepo.CreaterepoProject;
+import org.eclipse.linuxtools.rpm.createrepo.tests.TestCreaterepoProject;
+import org.eclipse.ui.console.MessageConsole;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * Tests for Createrepo class and general createrepo command
+ * execution. Assumes system has "createrepo" command.
+ */
+public class CreaterepoTest {
+
+ private static TestCreaterepoProject testProject;
+ private CreaterepoProject project;
+ private MessageConsole console;
+
+ /**
+ * Initialize the test project.
+ *
+ * @throws CoreException
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws CoreException {
+ testProject = new TestCreaterepoProject();
+ }
+
+ /**
+ * Delete the project when tests are done.
+ *
+ * @throws CoreException
+ */
+ @AfterClass
+ public static void tearDownAfterClass() throws CoreException {
+ testProject.dispose();
+ }
+
+ /**
+ * Get the CreaterepoProject at the beginning of each test, as
+ * well as create the console.
+ *
+ * @throws CoreException
+ */
+ @Before
+ public void setUp() throws CoreException {
+ project = testProject.getCreaterepoProject();
+ console = new MessageConsole("testConsole", null, null, true); //$NON-NLS-1$
+ }
+
+ /**
+ * Clear the preferences after each test and destroy the console.
+ *
+ * @throws BackingStoreException
+ */
+ @After
+ public void tearDown() throws BackingStoreException {
+ IEclipsePreferences pref = project.getEclipsePreferences();
+ pref.clear();
+ pref.flush();
+ console.destroy();
+ }
+
+ /**
+ * Test a simple createrepo execution taking in no extra commands.
+ *
+ * @throws CoreException
+ */
+ @Test
+ public void testSimpleCreaterepoExecution() throws CoreException {
+ Createrepo command = new Createrepo();
+ IStatus status = command.execute(console.newMessageStream(),
+ project, new ArrayList<String>());
+ if (status.getCode() == IStatus.ERROR) {
+ fail("Possibly failed due to system not having the 'createrepo' command, or it cannot be found."); //$NON-NLS-1$
+ }
+ assertEquals(IStatus.OK, status.getCode());
+ }
+
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/AllTests.java b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/AllTests.java
index 14b7dc7..6a656f3 100644
--- a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/AllTests.java
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/AllTests.java
@@ -10,6 +10,7 @@
*******************************************************************************/
package org.eclipse.linuxtools.rpm.createrepo.tests;
+import org.eclipse.linuxtools.internal.rpm.createrepo.tests.CreaterepoTest;
import org.eclipse.linuxtools.internal.rpm.createrepo.tree.tests.CreaterepoTreeCategoryTest;
import org.eclipse.linuxtools.internal.rpm.createrepo.tree.tests.CreaterepoTreeTest;
import org.eclipse.linuxtools.internal.rpm.createrepo.wizard.tests.CreaterepoWizardTest;
@@ -20,6 +21,6 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({CreaterepoProjectCreatorTest.class, CreaterepoUtilsTest.class,
CreaterepoProjectTest.class, CreaterepoTreeCategoryTest.class, CreaterepoTreeTest.class,
- CreaterepoWizardTest.class})
+ CreaterepoWizardTest.class, CreaterepoTest.class})
public class AllTests {
}