aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-12-10 10:07:27 (EST)
committerAlexander Kurtakov2013-12-16 04:46:59 (EST)
commit6904ab702e46173a2f1f15b5393302fcf77bcf25 (patch)
tree904675df5b42327ce38571825c8fc9aa0a7396f1
parent56f7187e1f9656ad2731128ed4648043751c13ee (diff)
downloadorg.eclipse.linuxtools-6904ab702e46173a2f1f15b5393302fcf77bcf25.zip
org.eclipse.linuxtools-6904ab702e46173a2f1f15b5393302fcf77bcf25.tar.gz
org.eclipse.linuxtools-6904ab702e46173a2f1f15b5393302fcf77bcf25.tar.bz2
RPM: createrepo tests for preference initializationrefs/changes/13/19613/5
Testing classes: o CreaterepoPreferenceInitializer.java o CreaterepoPreferenceConstants.java Tests to check if the preferences are initializing properly. Change-Id: I180619fb7092ef1fe56d6919c346a077ba6687c0 Signed-off-by: Neil Guzman <nguzman@redhat.com> Reviewed-on: https://git.eclipse.org/r/19613 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/preference/tests/CreaterepoPreferenceInitializationTest.java79
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/internal/rpm/createrepo/tests/CreaterepoTest.java14
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/AllTests.java3
3 files changed, 93 insertions, 3 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/tests/CreaterepoPreferenceInitializationTest.java b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/tests/CreaterepoPreferenceInitializationTest.java
new file mode 100644
index 0000000..e10a7ff
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/internal/rpm/createrepo/preference/tests/CreaterepoPreferenceInitializationTest.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * 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.preference.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.linuxtools.internal.rpm.createrepo.Activator;
+import org.eclipse.linuxtools.rpm.createrepo.CreaterepoPreferenceConstants;
+import org.junit.Test;
+
+/**
+ * Tests for preferences if they are being initialized correctly.
+ */
+public class CreaterepoPreferenceInitializationTest {
+
+ /**
+ * Test for the initial preferences to be set for the plugin. Test
+ * that if the default value is what the return is, then it failed.
+ * The defaults are intentionally wrong to test if correct values are
+ * stored incorrectly on initialization.
+ */
+ @Test
+ public void testPreferenceInitialization() {
+ IEclipsePreferences node = DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID);
+ assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_UNIQUE_MD_NAME, node.getBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME,
+ !CreaterepoPreferenceConstants.DEFAULT_UNIQUE_MD_NAME));
+ assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_GENERATE_DB, node.getBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB,
+ !CreaterepoPreferenceConstants.DEFAULT_GENERATE_DB));
+ assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_IGNORE_SYMLINKS, node.getBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS,
+ !CreaterepoPreferenceConstants.DEFAULT_IGNORE_SYMLINKS));
+ assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_PRETTY, node.getBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML,
+ !CreaterepoPreferenceConstants.DEFAULT_PRETTY));
+ assertNotEquals(-1309, node.getInt(CreaterepoPreferenceConstants.PREF_WORKERS, -1309));
+ assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_CHECK_TS, node.getBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS,
+ !CreaterepoPreferenceConstants.DEFAULT_CHECK_TS));
+ assertNotEquals(-1309, node.getInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT, -1309));
+ assertNotEquals(CreaterepoPreferenceConstants.DEFAULT_CHECKSUM.concat("test"), node.get(CreaterepoPreferenceConstants.PREF_CHECKSUM, //$NON-NLS-1$
+ CreaterepoPreferenceConstants.DEFAULT_CHECKSUM.concat("test"))); //$NON-NLS-1$
+ assertNotEquals(CreaterepoPreferenceConstants.DEFAULT_COMPRESS_TYPE.concat("test"), node.get(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, //$NON-NLS-1$
+ CreaterepoPreferenceConstants.DEFAULT_COMPRESS_TYPE.concat("test"))); //$NON-NLS-1$
+ }
+
+ /**
+ * These should be what is stored in the default preferences and what
+ * the values should change to if "Restore Defaults" on a preference page
+ * is clicked. Make sure it tests are checking values declared in
+ * {@linkplain CreaterepoPreferenceConstants}
+ */
+ @Test
+ public void testPreferenceDefaults() {
+ IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_UNIQUE_MD_NAME, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_GENERATE_DB, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_IGNORE_SYMLINKS, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_PRETTY, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_NUM_WORKERS, prefStore.getDefaultInt(CreaterepoPreferenceConstants.PREF_WORKERS));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_CHECK_TS, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_CHANGELOG_LIMIT, prefStore.getDefaultInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_CHECKSUM, prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_CHECKSUM));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_COMPRESS_TYPE, prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_GENERAL_ENABLED, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_DELTA_ENABLE, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_NUM_DELTAS, prefStore.getDefaultInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS));
+ assertEquals(CreaterepoPreferenceConstants.DEFAULT_MAX_DELTA_SIZE, prefStore.getDefaultInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE));
+ }
+
+}
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
index 4f336d9..bd9ad23 100644
--- 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
@@ -13,12 +13,15 @@ package org.eclipse.linuxtools.internal.rpm.createrepo.tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
+import java.io.IOException;
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.core.utils.BufferedProcessInputStream;
+import org.eclipse.linuxtools.rpm.core.utils.Utils;
import org.eclipse.linuxtools.rpm.createrepo.CreaterepoProject;
import org.eclipse.linuxtools.rpm.createrepo.tests.TestCreaterepoProject;
import org.eclipse.ui.console.MessageConsole;
@@ -40,12 +43,19 @@ public class CreaterepoTest {
private MessageConsole console;
/**
- * Initialize the test project.
+ * Initialize the test project. Will fail immediately if it cannot find
+ * the createrepo command.
*
* @throws CoreException
+ * @throws IOException
+ * @throws InterruptedException
*/
@BeforeClass
- public static void setUpBeforeClass() throws CoreException {
+ public static void setUpBeforeClass() throws CoreException, IOException, InterruptedException {
+ BufferedProcessInputStream bpis = Utils.runCommandToInputStream("which", "createrepo"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (bpis.getExitValue() == 1) {
+ fail("Failed due to system not having the 'createrepo' command, or it cannot be found."); //$NON-NLS-1$
+ }
testProject = new TestCreaterepoProject();
}
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 6a656f3..0fd830e 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.preference.tests.CreaterepoPreferenceInitializationTest;
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;
@@ -21,6 +22,6 @@ import org.junit.runners.Suite.SuiteClasses;
@RunWith(Suite.class)
@SuiteClasses({CreaterepoProjectCreatorTest.class, CreaterepoUtilsTest.class,
CreaterepoProjectTest.class, CreaterepoTreeCategoryTest.class, CreaterepoTreeTest.class,
- CreaterepoWizardTest.class, CreaterepoTest.class})
+ CreaterepoWizardTest.class, CreaterepoTest.class, CreaterepoPreferenceInitializationTest.class})
public class AllTests {
}