Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml7
-rw-r--r--tycho-core/pom.xml4
-rw-r--r--tycho-core/src/test/java/org/eclipse/tycho/core/maven/TychoInterpolatorTest.java40
-rw-r--r--tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/BuildPropertiesParserImplTest.java40
-rw-r--r--tycho-core/src/test/java/org/eclipse/tycho/core/resolver/DefaultTychoResolverTest.java11
-rw-r--r--tycho-surefire/tycho-surefire-plugin/pom.xml4
-rw-r--r--tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/TestMojoToolchainTests.java30
7 files changed, 56 insertions, 80 deletions
diff --git a/pom.xml b/pom.xml
index c85feb1d5..092576070 100644
--- a/pom.xml
+++ b/pom.xml
@@ -76,7 +76,6 @@
<!-- copy&paste from maven/pom.xml file. I wish import scope worked in 3.0 -->
<classWorldsVersion>2.2.3</classWorldsVersion>
<commonsCliVersion>1.2</commonsCliVersion>
- <easyMockVersion>1.2_Java1.3</easyMockVersion>
<junitVersion>3.8.2</junitVersion>
<plexusVersion>1.5.5</plexusVersion>
<plexusInterpolationVersion>1.14</plexusInterpolationVersion>
@@ -307,12 +306,6 @@
<artifactId>maven-verifier</artifactId>
<version>1.3</version>
</dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <version>3.0</version>
- <scope>test</scope>
- </dependency>
</dependencies>
</dependencyManagement>
diff --git a/tycho-core/pom.xml b/tycho-core/pom.xml
index 1c64e06be..cbf85653a 100644
--- a/tycho-core/pom.xml
+++ b/tycho-core/pom.xml
@@ -159,8 +159,8 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
</dependency>
</dependencies>
diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/maven/TychoInterpolatorTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/maven/TychoInterpolatorTest.java
index 69c08cdce..9f4f871f7 100644
--- a/tycho-core/src/test/java/org/eclipse/tycho/core/maven/TychoInterpolatorTest.java
+++ b/tycho-core/src/test/java/org/eclipse/tycho/core/maven/TychoInterpolatorTest.java
@@ -10,12 +10,10 @@
*******************************************************************************/
package org.eclipse.tycho.core.maven;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.util.Properties;
@@ -35,10 +33,10 @@ public class TychoInterpolatorTest {
@Before
public void setUp() {
- MavenSession session = createMock(MavenSession.class);
- project = createMock(MavenProject.class);
- settings = createMock(Settings.class);
- File baseDir = createMock(File.class);
+ MavenSession session = mock(MavenSession.class);
+ project = mock(MavenProject.class);
+ settings = mock(Settings.class);
+ File baseDir = mock(File.class);
Properties projectProperties = new Properties();
projectProperties.put("myProjectPropertyKey", "myProjectPropertyValue");
@@ -49,16 +47,14 @@ public class TychoInterpolatorTest {
Properties systemProperties = new Properties();
systemProperties.put("mySystemPropertyKey", "mySystemPropertyValue");
- expect(project.getProperties()).andReturn(projectProperties);
- expect(session.getSystemProperties()).andReturn(systemProperties);
- expect(session.getUserProperties()).andReturn(userProperties);
- expect(session.getSettings()).andReturn(settings);
- expect(settings.getLocalRepository()).andReturn("myLocalRepo");
- expect(project.getBasedir()).andReturn(baseDir);
- expect(project.getVersion()).andReturn("1.0.0");
- expect(baseDir.getAbsolutePath()).andReturn("absolutePathToBaseDir");
-
- replay(session, project, settings, baseDir);
+ when(project.getProperties()).thenReturn(projectProperties);
+ when(session.getSystemProperties()).thenReturn(systemProperties);
+ when(session.getUserProperties()).thenReturn(userProperties);
+ when(session.getSettings()).thenReturn(settings);
+ when(settings.getLocalRepository()).thenReturn("myLocalRepo");
+ when(project.getBasedir()).thenReturn(baseDir);
+ when(project.getVersion()).thenReturn("1.0.0");
+ when(baseDir.getAbsolutePath()).thenReturn("absolutePathToBaseDir");
interpolator = new TychoInterpolator(session, project);
}
@@ -101,18 +97,14 @@ public class TychoInterpolatorTest {
@Test
public void testProjectMembersGetInterpolated() {
- reset(project);
- expect(project.getArtifactId()).andReturn("myArtifactId");
- replay(project);
+ when(project.getArtifactId()).thenReturn("myArtifactId");
String interpolated = interpolator.interpolate("${project.artifactId}");
Assert.assertEquals("myArtifactId", interpolated);
}
@Test
public void testSettingsMembersGetInterpolated() {
- reset(settings);
- expect(settings.getSourceLevel()).andReturn("mySourceLevel");
- replay(settings);
+ when(settings.getSourceLevel()).thenReturn("mySourceLevel");
String interpolated = interpolator.interpolate("${settings.sourceLevel}");
Assert.assertEquals("mySourceLevel", interpolated);
}
diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/BuildPropertiesParserImplTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/BuildPropertiesParserImplTest.java
index cc26cac5b..98501c058 100644
--- a/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/BuildPropertiesParserImplTest.java
+++ b/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/BuildPropertiesParserImplTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Bachmann electronic and others.
+ * Copyright (c) 2014, 2015 Bachmann electronic 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
@@ -10,13 +10,11 @@
*******************************************************************************/
package org.eclipse.tycho.core.osgitools;
-import static org.easymock.EasyMock.anyObject;
-import static org.easymock.EasyMock.createMock;
-import static org.easymock.EasyMock.expect;
-import static org.easymock.EasyMock.expectLastCall;
-import static org.easymock.EasyMock.replay;
-import static org.easymock.EasyMock.reset;
-import static org.easymock.EasyMock.verify;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
import java.io.File;
import java.io.IOException;
@@ -43,19 +41,17 @@ public class BuildPropertiesParserImplTest {
@Before
public void setup() throws IllegalArgumentException, IllegalAccessException {
- legacySupport = createMock(LegacySupport.class);
- mavenSession = createMock(MavenSession.class);
- project1 = createMock(MavenProject.class);
- project2 = createMock(MavenProject.class);
- logger = createMock(Logger.class);
+ legacySupport = mock(LegacySupport.class);
+ mavenSession = mock(MavenSession.class);
+ project1 = mock(MavenProject.class);
+ project2 = mock(MavenProject.class);
+ logger = mock(Logger.class);
- expect(legacySupport.getSession()).andReturn(mavenSession);
- expect(mavenSession.getProjects()).andReturn(Arrays.asList(project1, project2)).anyTimes();
+ when(legacySupport.getSession()).thenReturn(mavenSession);
+ when(mavenSession.getProjects()).thenReturn(Arrays.asList(project1, project2));
- expect(project1.getBasedir()).andReturn(new File("/bathToProject1")).anyTimes();
- expect(project2.getBasedir()).andReturn(new File("/bathToProject2")).anyTimes();
-
- replay(legacySupport, mavenSession, project1, project2);
+ when(project1.getBasedir()).thenReturn(new File("/bathToProject1"));
+ when(project2.getBasedir()).thenReturn(new File("/bathToProject2"));
parser = new BuildPropertiesParserImpl(legacySupport, logger);
}
@@ -75,14 +71,10 @@ public class BuildPropertiesParserImplTest {
@Test
public void testInterpolateWithABaseDirThatsNotPartOfTheSessionsProjects() {
- reset(logger);
- logger.warn(anyObject(String.class));
- expectLastCall().once();
- replay(logger);
Properties props = new Properties();
props.put("key", "value");
parser.interpolate(props, new File("/bathToSomeProjectThatsNotPartOfTheSessionProjects"));
- verify(logger);
+ verify(logger, times(1)).warn(anyString());
}
@Test
diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/resolver/DefaultTychoResolverTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/resolver/DefaultTychoResolverTest.java
index b7eb24dc1..83a4d4e0e 100644
--- a/tycho-core/src/test/java/org/eclipse/tycho/core/resolver/DefaultTychoResolverTest.java
+++ b/tycho-core/src/test/java/org/eclipse/tycho/core/resolver/DefaultTychoResolverTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Bachmann electronic GmbH and others.
+ * Copyright (c) 2014, 2015 Bachmann electronic GmbH 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
@@ -10,10 +10,12 @@
*******************************************************************************/
package org.eclipse.tycho.core.resolver;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import java.util.Properties;
import org.apache.maven.project.MavenProject;
-import org.easymock.EasyMock;
import org.eclipse.tycho.core.resolver.shared.PlatformPropertiesUtils;
import org.junit.Assert;
import org.junit.Before;
@@ -34,11 +36,10 @@ public class DefaultTychoResolverTest {
System.setProperty("os.name", PlatformPropertiesUtils.INTERNAL_OS_LINUX);
System.setProperty("os.arch", PlatformPropertiesUtils.INTERNAL_AMD64);
- MavenProject project = EasyMock.createMock(MavenProject.class);
+ MavenProject project = mock(MavenProject.class);
Properties mergedProperties = new Properties();
Properties projectProperties = new Properties();
- EasyMock.expect(project.getProperties()).andReturn(projectProperties).anyTimes();
- EasyMock.replay(project);
+ when(project.getProperties()).thenReturn(projectProperties);
defaultTychoResolver.setTychoEnvironmentProperties(mergedProperties, project);
diff --git a/tycho-surefire/tycho-surefire-plugin/pom.xml b/tycho-surefire/tycho-surefire-plugin/pom.xml
index f68f240e4..404a4b924 100644
--- a/tycho-surefire/tycho-surefire-plugin/pom.xml
+++ b/tycho-surefire/tycho-surefire-plugin/pom.xml
@@ -111,8 +111,8 @@
<version>${surefire-version}</version>
</dependency>
<dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-core</artifactId>
</dependency>
</dependencies>
</project>
diff --git a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/TestMojoToolchainTests.java b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/TestMojoToolchainTests.java
index 0fdea670a..a9866f285 100644
--- a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/TestMojoToolchainTests.java
+++ b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/TestMojoToolchainTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014 Bachmann electronics GmbH and others.
+ * Copyright (c) 2014, 2015 Bachmann electronics GmbH 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
@@ -10,6 +10,9 @@
*******************************************************************************/
package org.eclipse.tycho.surefire;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
import java.lang.reflect.Field;
import junit.framework.TestCase;
@@ -21,7 +24,6 @@ import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainManager;
import org.apache.maven.toolchain.java.DefaultJavaToolChain;
import org.codehaus.plexus.util.ReflectionUtils;
-import org.easymock.EasyMock;
import org.eclipse.tycho.core.TychoConstants;
import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration;
import org.eclipse.tycho.core.maven.ToolchainProvider;
@@ -40,11 +42,11 @@ public class TestMojoToolchainTests extends TestCase {
@Override
public void setUp() throws Exception {
- toolchainManager = EasyMock.createMock(ToolchainManager.class);
- session = EasyMock.createMock(MavenSession.class);
- breeToolchain = EasyMock.createMock(DefaultJavaToolChain.class);
- systemToolchain = EasyMock.createMock(Toolchain.class);
- toolchainProvider = EasyMock.createMock(ToolchainProvider.class);
+ toolchainManager = mock(ToolchainManager.class);
+ session = mock(MavenSession.class);
+ breeToolchain = mock(DefaultJavaToolChain.class);
+ systemToolchain = mock(Toolchain.class);
+ toolchainProvider = mock(ToolchainProvider.class);
project = new MavenProject();
testMojo = new TestMojo();
setParameter(testMojo, "useJDK", JDKUsage.SYSTEM);
@@ -60,24 +62,21 @@ public class TestMojoToolchainTests extends TestCase {
}
public void testGetToolchainWithUseJDKSetToSystemWithToolchainManager() throws Exception {
- EasyMock.expect(toolchainManager.getToolchainFromBuildContext("jdk", session)).andReturn(systemToolchain);
- EasyMock.replay(toolchainManager);
+ when(toolchainManager.getToolchainFromBuildContext("jdk", session)).thenReturn(systemToolchain);
Toolchain tc = testMojo.getToolchain();
Assert.assertEquals(systemToolchain, tc);
}
public void testGetToolchainWithUseJDKSetToBREE() throws Exception {
setupWithBree();
- EasyMock.expect(toolchainProvider.findMatchingJavaToolChain(session, "myId")).andReturn(breeToolchain);
- EasyMock.replay(toolchainProvider);
+ when(toolchainProvider.findMatchingJavaToolChain(session, "myId")).thenReturn(breeToolchain);
Toolchain tc = testMojo.getToolchain();
Assert.assertEquals(breeToolchain, tc);
}
public void testGetToolchainWithUseJDKSetToBREEToolchainNotFound() throws Exception {
setupWithBree();
- EasyMock.expect(toolchainProvider.findMatchingJavaToolChain(session, "myId")).andReturn(null);
- EasyMock.replay(toolchainProvider);
+ when(toolchainProvider.findMatchingJavaToolChain(session, "myId")).thenReturn(null);
try {
testMojo.getToolchain();
fail("MojoExcecutionException expected since Toolchain could not be found!");
@@ -89,9 +88,8 @@ public class TestMojoToolchainTests extends TestCase {
public void setupWithBree() throws Exception {
setParameter(testMojo, "useJDK", JDKUsage.BREE);
- ExecutionEnvironmentConfiguration envConf = EasyMock.createMock(ExecutionEnvironmentConfiguration.class);
- EasyMock.expect(envConf.getProfileName()).andReturn("myId");
- EasyMock.replay(envConf);
+ ExecutionEnvironmentConfiguration envConf = mock(ExecutionEnvironmentConfiguration.class);
+ when(envConf.getProfileName()).thenReturn("myId");
project.setContextValue(TychoConstants.CTX_EXECUTION_ENVIRONMENT_CONFIGURATION, envConf);
}

Back to the top