Author: fbricon
Date: 2012-08-28 05:40:03 -0400 (Tue, 28 Aug 2012)
New Revision: 43262
Added:
trunk/maven/tests/org.jboss.tools.maven.common.test/
trunk/maven/tests/org.jboss.tools.maven.common.test/.classpath
trunk/maven/tests/org.jboss.tools.maven.common.test/.project
trunk/maven/tests/org.jboss.tools.maven.common.test/.settings/
trunk/maven/tests/org.jboss.tools.maven.common.test/.settings/org.eclipse.jdt.core.prefs
trunk/maven/tests/org.jboss.tools.maven.common.test/.settings/org.eclipse.m2e.core.prefs
trunk/maven/tests/org.jboss.tools.maven.common.test/META-INF/
trunk/maven/tests/org.jboss.tools.maven.common.test/META-INF/MANIFEST.MF
trunk/maven/tests/org.jboss.tools.maven.common.test/build.properties
trunk/maven/tests/org.jboss.tools.maven.common.test/plugin_customization.ini
trunk/maven/tests/org.jboss.tools.maven.common.test/pom.xml
trunk/maven/tests/org.jboss.tools.maven.common.test/resources/
trunk/maven/tests/org.jboss.tools.maven.common.test/resources/arquillian-core-spi.jar
trunk/maven/tests/org.jboss.tools.maven.common.test/resources/jansi-1.6.jar
trunk/maven/tests/org.jboss.tools.maven.common.test/resources/junit_4_10.jar
trunk/maven/tests/org.jboss.tools.maven.common.test/src/
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/AbstractIdentificationTest.java
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/FileIdentificationManagerTest.java
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/IdentificationUtilTest.java
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/MavenPropertiesIdentifierTest.java
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/NexusRepositoryIdentifierTest.java
Modified:
trunk/maven/tests/pom.xml
Log:
JBIDE-12314 : Add JUnit tests for the identification part
Added: trunk/maven/tests/org.jboss.tools.maven.common.test/.classpath
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.common.test/.classpath
(rev 0)
+++ trunk/maven/tests/org.jboss.tools.maven.common.test/.classpath 2012-08-28 09:40:03 UTC
(rev 43262)
@@ -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="target/classes"/>
+</classpath>
Added: trunk/maven/tests/org.jboss.tools.maven.common.test/.project
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.common.test/.project
(rev 0)
+++ trunk/maven/tests/org.jboss.tools.maven.common.test/.project 2012-08-28 09:40:03 UTC
(rev 43262)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.maven.common.test</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.m2e.core.maven2Builder</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.m2e.core.maven2Nature</nature>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added:
trunk/maven/tests/org.jboss.tools.maven.common.test/.settings/org.eclipse.jdt.core.prefs
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.common.test/.settings/org.eclipse.jdt.core.prefs
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.common.test/.settings/org.eclipse.jdt.core.prefs 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,7 @@
+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.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
Added:
trunk/maven/tests/org.jboss.tools.maven.common.test/.settings/org.eclipse.m2e.core.prefs
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.common.test/.settings/org.eclipse.m2e.core.prefs
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.common.test/.settings/org.eclipse.m2e.core.prefs 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
Added: trunk/maven/tests/org.jboss.tools.maven.common.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.common.test/META-INF/MANIFEST.MF
(rev 0)
+++ trunk/maven/tests/org.jboss.tools.maven.common.test/META-INF/MANIFEST.MF 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,20 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss Maven (Core+UI) Tests
+Bundle-SymbolicName: org.jboss.tools.maven.common.test;singleton:=true
+Bundle-Version: 1.4.0.qualifier
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.apache.log4j,
+ org.junit4,
+ org.jboss.tools.maven.core,
+ org.jboss.tools.common,
+ org.jboss.tools.tests,
+ org.eclipse.m2e.launching,
+ org.eclipse.m2e.tests.common,
+ org.eclipse.ui.ide
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Eclipse-RegisterBuddy: org.apache.log4j
+
Added: trunk/maven/tests/org.jboss.tools.maven.common.test/build.properties
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.common.test/build.properties
(rev 0)
+++ trunk/maven/tests/org.jboss.tools.maven.common.test/build.properties 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,4 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .
Added: trunk/maven/tests/org.jboss.tools.maven.common.test/plugin_customization.ini
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.common.test/plugin_customization.ini
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.common.test/plugin_customization.ini 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,2 @@
+org.eclipse.m2e.core/eclipse.m2.updateIndexes=false
+org.jboss.tools.central/showJBossCentralOnStartup=false
\ No newline at end of file
Added: trunk/maven/tests/org.jboss.tools.maven.common.test/pom.xml
===================================================================
--- trunk/maven/tests/org.jboss.tools.maven.common.test/pom.xml
(rev 0)
+++ trunk/maven/tests/org.jboss.tools.maven.common.test/pom.xml 2012-08-28 09:40:03 UTC
(rev 43262)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss.tools.maven</groupId>
+ <artifactId>tests</artifactId>
+ <version>1.4.0-SNAPSHOT</version>
+ </parent>
+ <groupId>org.jboss.tools.maven.tests</groupId>
+ <artifactId>org.jboss.tools.maven.common.test</artifactId>
+
+ <packaging>eclipse-test-plugin</packaging>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.eclipse.tycho</groupId>
+ <artifactId>tycho-surefire-plugin</artifactId>
+ <version>${tychoVersion}</version>
+ <configuration>
+ <useUIThread>false</useUIThread>
+ <useUIHarness>true</useUIHarness>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added:
trunk/maven/tests/org.jboss.tools.maven.common.test/resources/arquillian-core-spi.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/maven/tests/org.jboss.tools.maven.common.test/resources/arquillian-core-spi.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/maven/tests/org.jboss.tools.maven.common.test/resources/jansi-1.6.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/maven/tests/org.jboss.tools.maven.common.test/resources/jansi-1.6.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/maven/tests/org.jboss.tools.maven.common.test/resources/junit_4_10.jar
===================================================================
(Binary files differ)
Property changes on:
trunk/maven/tests/org.jboss.tools.maven.common.test/resources/junit_4_10.jar
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added:
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/AbstractIdentificationTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/AbstractIdentificationTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/AbstractIdentificationTest.java 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,29 @@
+package org.jboss.tools.maven.core.identification;
+
+import java.io.File;
+
+import org.junit.After;
+import org.junit.Before;
+
+public abstract class AbstractIdentificationTest {
+
+ protected File arquillian;//Has maven properties
+ protected File junit;//Has no maven properties
+ protected File jansi;//Has multiple maven properties
+
+ @Before
+ public void initFiles() {
+ junit = new File("resources/junit_4_10.jar");
+ arquillian = new File("resources/arquillian-core-spi.jar");
+ jansi = new File("resources/jansi-1.6.jar");
+ }
+
+ @After
+ public void disposeFiles() {
+ junit = null;
+ arquillian = null;
+ jansi = null;
+ }
+
+
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/FileIdentificationManagerTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/FileIdentificationManagerTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/FileIdentificationManagerTest.java 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,57 @@
+package org.jboss.tools.maven.core.identification;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.m2e.core.embedder.ArtifactKey;
+import org.jboss.tools.maven.core.internal.identification.FileIdentificationManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class FileIdentificationManagerTest extends AbstractIdentificationTest {
+
+ private FileIdentificationManager fileIdentificationManager;
+
+ private IProgressMonitor monitor;
+
+ @Before
+ public void setUp() {
+ ArtifactIdentifier identifier1 = new ArtifactIdentifier() {
+ @Override
+ public ArtifactKey identify(File file) throws CoreException {
+ return null;
+ }
+ };
+ monitor = new NullProgressMonitor();
+ fileIdentificationManager = new
FileIdentificationManager(Collections.singleton(identifier1));
+ }
+
+ @Test
+ public void testIdentify() throws Exception {
+
+ assertNull(fileIdentificationManager.identify(junit, monitor));
+
+ fileIdentificationManager.addArtifactIdentifier(
+ new ArtifactIdentifier() {
+ @Override
+ public ArtifactKey identify(File file) throws CoreException {
+ return new ArtifactKey("junit", "junit", "4.10",
null);
+ }
+ }
+ );
+ assertNotNull(fileIdentificationManager.identify(junit, monitor));
+
+ }
+
+ @After
+ public void tearDown() {
+ fileIdentificationManager = null;
+ }
+
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/IdentificationUtilTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/IdentificationUtilTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/IdentificationUtilTest.java 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,21 @@
+package org.jboss.tools.maven.core.identification;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.jboss.tools.maven.core.identification.IdentificationUtil.getSHA1;
+import java.io.File;
+
+import org.junit.Test;
+
+public class IdentificationUtilTest {
+
+ @Test
+ public void testSHA1() throws Exception {
+
+ assertNull(getSHA1(null));
+
+ assertEquals("e4f1766ce7404a08f45d859fb9c226fc9e41a861",
+ getSHA1(new File("resources/junit_4_10.jar")));
+ }
+
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/MavenPropertiesIdentifierTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/MavenPropertiesIdentifierTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/MavenPropertiesIdentifierTest.java 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,26 @@
+package org.jboss.tools.maven.core.identification;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import org.eclipse.m2e.core.embedder.ArtifactKey;
+import org.jboss.tools.maven.core.internal.identification.MavenPropertiesIdentifier;
+import org.junit.Test;
+
+public class MavenPropertiesIdentifierTest extends AbstractIdentificationTest {
+
+ @Test
+ public void testIdentify() throws Exception {
+ MavenPropertiesIdentifier identifier = new MavenPropertiesIdentifier();
+ //Has No Maven Properties
+ assertNull(identifier.identify(junit));
+
+ //Has Multiple Maven Properties
+ assertNull(identifier.identify(jansi));
+
+ ArtifactKey key = identifier.identify(arquillian);
+ assertEquals("arquillian-core-spi", key.getArtifactId());
+ assertEquals("1.0.1.Final", key.getVersion());
+ }
+
+}
Added:
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/NexusRepositoryIdentifierTest.java
===================================================================
---
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/NexusRepositoryIdentifierTest.java
(rev 0)
+++
trunk/maven/tests/org.jboss.tools.maven.common.test/src/org/jboss/tools/maven/core/identification/NexusRepositoryIdentifierTest.java 2012-08-28
09:40:03 UTC (rev 43262)
@@ -0,0 +1,60 @@
+package org.jboss.tools.maven.core.identification;
+
+import static org.junit.Assert.assertEquals;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.m2e.core.embedder.ArtifactKey;
+import org.jboss.tools.maven.core.MavenCoreActivator;
+import org.jboss.tools.maven.core.internal.identification.NexusRepositoryIdentifier;
+import org.jboss.tools.maven.core.repositories.NexusRepository;
+import org.jboss.tools.maven.core.repositories.RemoteRepositoryManager;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class NexusRepositoryIdentifierTest extends AbstractIdentificationTest {
+
+ Map<NexusRepository, Boolean> initialRepoState = new HashMap<NexusRepository,
Boolean>();
+
+ @Before
+ public void setupRepositories() {
+ RemoteRepositoryManager repoManager =
MavenCoreActivator.getDefault().getRepositoryManager();
+ for (NexusRepository repo : repoManager.getDefaultRepositories()) {
+ initialRepoState.put(repo, repo.isEnabled());
+ if (repo.getName().toLowerCase().contains("jboss")) {
+ repo.setEnabled(true);
+ }
+ else {
+ repo.setEnabled(false);
+ }
+ }
+ }
+
+ @After
+ public void restoreRepos() {
+ for (Map.Entry<NexusRepository, Boolean> entry : initialRepoState.entrySet()) {
+ entry.getKey().setEnabled(entry.getValue());
+ }
+ }
+
+ @Test
+ public void testIdentify() throws Exception {
+ NexusRepositoryIdentifier identifier = new NexusRepositoryIdentifier();
+ ArtifactKey key;
+ key= identifier.identify(junit);
+ assertEquals("junit", key.getArtifactId());
+ assertEquals("4.10", key.getVersion());
+
+ key= identifier.identify(jansi);
+ assertEquals("jansi", key.getArtifactId());
+ assertEquals("1.6", key.getVersion());
+
+ key = identifier.identify(arquillian);
+ assertEquals("arquillian-core-spi", key.getArtifactId());
+ assertEquals("1.0.1.Final", key.getVersion());
+ }
+
+
+}
Modified: trunk/maven/tests/pom.xml
===================================================================
--- trunk/maven/tests/pom.xml 2012-08-28 09:34:41 UTC (rev 43261)
+++ trunk/maven/tests/pom.xml 2012-08-28 09:40:03 UTC (rev 43262)
@@ -14,6 +14,7 @@
<packaging>pom</packaging>
<modules>
<module>org.jboss.tools.maven.configurators.tests</module>
+ <module>org.jboss.tools.maven.common.test</module>
<module>org.jboss.tools.maven.profiles.test</module>
<module>org.jboss.tools.maven.ui.bot.test</module>
</modules>