Skip to content

Commit

Permalink
Adding an integration test for the compiler source and target synonyms
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrien authored and ifedorenko committed Aug 4, 2011
1 parent 72c7a1b commit 24e62f6
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
22 changes: 22 additions & 0 deletions org.eclipse.m2e.tests/projects/compilersynonym/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<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>

<groupId>org.eclipse.m2e.projects</groupId>
<artifactId>compilersynonym</artifactId>
<version>1.0.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>6</source>
<target>5</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

package org.eclipse.m2e.tests.project;

import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;

import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.MojoExecution;

import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.internal.MavenPluginActivator;
import org.eclipse.m2e.core.internal.project.registry.ProjectRegistryManager;
import org.eclipse.m2e.core.project.IMavenProjectFacade;
import org.eclipse.m2e.core.project.MavenUpdateRequest;
import org.eclipse.m2e.core.project.configurator.AbstractProjectConfigurator;
import org.eclipse.m2e.core.project.configurator.ILifecycleMapping;
import org.eclipse.m2e.core.project.configurator.MojoExecutionKey;
import org.eclipse.m2e.tests.common.AbstractMavenProjectTestCase;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;


public class CompilerSynonymTest extends AbstractMavenProjectTestCase {

public void testSynonym() throws Exception {
IProject project = importProject("projects/compilersynonym/pom.xml");
assertNoErrors(project);
waitForJobsToComplete();

IJavaProject javaProject = JavaCore.create(project);
assertEquals("1.6", javaProject.getOption(JavaCore.COMPILER_SOURCE, true));
assertEquals("1.5", javaProject.getOption(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, true));


}

private void deserialize(IMavenProjectFacade facade) throws IllegalArgumentException, IllegalAccessException {
// pretend it was deserialized from workspace state
for(Field field : facade.getClass().getDeclaredFields()) {
if(Modifier.isTransient(field.getModifiers())) {
field.setAccessible(true);
field.set(facade, null);
}
}
}
}

0 comments on commit 24e62f6

Please sign in to comment.