aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Guzman2013-12-04 17:14:03 (EST)
committerAlexander Kurtakov2013-12-05 07:09:05 (EST)
commit1fcb48b34b727a64b1624de0f8cf6657eebddf29 (patch)
tree139030842f1b6be97ec8e4a0c58c0409d749e12a
parentc4a213de41202de04e04d84aebaf03e579844fbc (diff)
downloadorg.eclipse.linuxtools-1fcb48b34b727a64b1624de0f8cf6657eebddf29.zip
org.eclipse.linuxtools-1fcb48b34b727a64b1624de0f8cf6657eebddf29.tar.gz
org.eclipse.linuxtools-1fcb48b34b727a64b1624de0f8cf6657eebddf29.tar.bz2
RPM: createrepo fragment test + simple test caserefs/changes/43/19343/3
New fragment for createrepo that handles test cases. First test case is a simple 1 that just checks if the project creator correctly creates a project with an empty content folder and uninitialized .repo file (due to not going through wizard initialization). Change-Id: Ib95eec9f25b98c9564a4eb7718c81ab9bd2191bd Signed-off-by: Neil Guzman <nguzman@redhat.com> Reviewed-on: https://git.eclipse.org/r/19343 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/.classpath7
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.gitignore6
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.project28
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.settings/org.eclipse.jdt.core.prefs11
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/META-INF/MANIFEST.MF9
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/build.properties5
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/plugin.properties12
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/pom.xml41
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/AllTests.java20
-rw-r--r--rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/CreaterepoProjectCreatorTest.java108
10 files changed, 247 insertions, 0 deletions
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.classpath b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.classpath
new file mode 100644
index 0000000..ad32c83
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.gitignore b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.gitignore
new file mode 100644
index 0000000..b3198b7
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.gitignore
@@ -0,0 +1,6 @@
+bin
+@dot
+javaCompiler...args
+build.xml
+target
+/target
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.project b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.project
new file mode 100644
index 0000000..b0f593e
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.eclipse.linuxtools.rpm.createrepo.tests</name>
+ <comment></comment>
+ <projects>
+ </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/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.settings/org.eclipse.jdt.core.prefs b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..8000cd6
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,11 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/META-INF/MANIFEST.MF b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..06a7509
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/META-INF/MANIFEST.MF
@@ -0,0 +1,9 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %Bundle-Name
+Bundle-SymbolicName: org.eclipse.linuxtools.rpm.createrepo.tests
+Bundle-Version: 1.0.0.qualifier
+Fragment-Host: org.eclipse.linuxtools.rpm.createrepo;bundle-version="1.0.0"
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: %Bundle-Vendor
+Require-Bundle: org.junit;bundle-version="4.8.1"
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/build.properties b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/build.properties
new file mode 100644
index 0000000..aa1a008
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/build.properties
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.properties
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/plugin.properties b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/plugin.properties
new file mode 100644
index 0000000..7f665ff
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/plugin.properties
@@ -0,0 +1,12 @@
+###############################################################################
+# Copyright (c) 2013 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:
+# Neil Guzman - initial API and implementation
+###############################################################################
+Bundle-Name = RPM Createrepo Plug-in
+Bundle-Vendor = Eclipse Linux Tools
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/pom.xml b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/pom.xml
new file mode 100644
index 0000000..2a391f2
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/pom.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (C) 2013 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
+-->
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <artifactId>linuxtools-rpm-parent</artifactId>
+ <groupId>org.eclipse.linuxtools.rpm</groupId>
+ <version>3.0.0-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>org.eclipse.linuxtools.rpm.createrepo.tests</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>eclipse-test-plugin</packaging>
+
+ <name>Linux Tools RPM Createrepo Tests Plug-in</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tycho-version}</version>
+ <configuration>
+ <useUIHarness>true</useUIHarness>
+ <useUIThread>true</useUIThread>
+ <product>org.eclipse.platform.ide</product>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
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
new file mode 100644
index 0000000..fb0524b
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/AllTests.java
@@ -0,0 +1,20 @@
+/*******************************************************************************
+ * 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.rpm.createrepo.tests;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+@RunWith(Suite.class)
+@SuiteClasses({CreaterepoProjectCreatorTest.class})
+public class AllTests {
+}
diff --git a/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/CreaterepoProjectCreatorTest.java b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/CreaterepoProjectCreatorTest.java
new file mode 100644
index 0000000..c9082b5
--- /dev/null
+++ b/rpm/org.eclipse.linuxtools.rpm.createrepo.tests/src/org/eclipse/linuxtools/rpm/createrepo/tests/CreaterepoProjectCreatorTest.java
@@ -0,0 +1,108 @@
+/*******************************************************************************
+ * 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.rpm.createrepo.tests;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.linuxtools.rpm.createrepo.CreaterepoProjectCreator;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test case for project creation with CreaterepoProjectCreatorTest class.
+ * This checks if the project creator is working and creating a project with
+ * an empty content folder and un-initialized .repo file.
+ */
+public class CreaterepoProjectCreatorTest {
+
+ private static final String PROJECT_NAME = "createrepo-test-project"; //$NON-NLS-1$
+ private static final String REPO_NAME = "createrepo-test-repo.repo"; //$NON-NLS-1$
+ private static final String CONTENT_FOLDER = "content"; //$NON-NLS-1$
+
+ private static IWorkspaceRoot root;
+ private static NullProgressMonitor monitor;
+ private IProject project;
+
+ /**
+ * Initialize workspace root and progress monitor.
+ *
+ * @throws Exception
+ */
+ @BeforeClass
+ public static void setUpBeforeClass() throws Exception {
+ root = ResourcesPlugin.getWorkspace().getRoot();
+ monitor = new NullProgressMonitor();
+ }
+
+ /**
+ * Create the project using CreaterepoProjectCreator.
+ *
+ * @throws Exception
+ */
+ @Before
+ public void setUp() throws Exception {
+ if (project == null || !project.exists()) {
+ project = CreaterepoProjectCreator.create(PROJECT_NAME, root.getLocation(), REPO_NAME, monitor);
+ }
+ }
+
+ /**
+ * Forcefully delete the project if it exists.
+ *
+ * @throws Exception
+ */
+ @After
+ public void tearDown() throws Exception {
+ if (project != null && project.exists()) {
+ project.delete(true, monitor);
+ }
+ }
+
+ /**
+ * Test to see if the project has been properly created and the contents
+ * initialized.
+ *
+ * @throws CoreException
+ * @throws IOException
+ */
+ @Test
+ public void testProjectContents() throws CoreException, IOException {
+ assertTrue(project.exists());
+ // 3 = .project + content folder + .repo file
+ assertEquals(3, project.members().length);
+
+ // contains content folder and repo file
+ assertTrue(project.findMember(CONTENT_FOLDER).exists());
+ assertTrue(project.findMember(REPO_NAME).exists());
+
+ IFolder contentFolder = (IFolder) project.findMember(CONTENT_FOLDER);
+ // content folder should be empty
+ assertEquals(0, contentFolder.members().length);
+
+ IFile repoFile = (IFile) project.findMember(REPO_NAME);
+ // repo file should be empty because test did not go through project creation
+ // to initialize .repo contents
+ assertEquals(repoFile.getContents().available(), 0);
+ }
+
+}