mirror of
https://github.com/querydsl/querydsl.git
synced 2026-06-19 21:00:53 +08:00
#733215 : added tests
This commit is contained in:
parent
99af30b236
commit
d4951f431d
@ -46,7 +46,17 @@
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.6.1</version>
|
||||
</dependency>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
|
||||
<dependency>
|
||||
<groupId>com.h2database</groupId>
|
||||
<artifactId>h2</artifactId>
|
||||
<version>1.2.133</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
package com.mysema.query.maven;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MetadataExportMojoTest {
|
||||
|
||||
private final String url = "jdbc:h2:mem:testdb" + System.currentTimeMillis();
|
||||
|
||||
@Test
|
||||
public void Execute() throws SecurityException, NoSuchFieldException, IllegalAccessException, MojoExecutionException, MojoFailureException {
|
||||
MavenProject project = new MavenProject();
|
||||
MetadataExportMojo mojo = new MetadataExportMojo();
|
||||
set(mojo, "project", project);
|
||||
set(mojo, "jdbcDriver", "org.h2.Driver");
|
||||
set(mojo, "jdbcUrl", url);
|
||||
set(mojo, "jdbcUser", "sa");
|
||||
set(mojo, "namePrefix", "Q"); // default value
|
||||
set(mojo, "packageName", "com.example");
|
||||
set(mojo, "targetFolder", "target/export");
|
||||
|
||||
mojo.execute();
|
||||
|
||||
assertEquals(Collections.singletonList("target/export"), project.getCompileSourceRoots());
|
||||
assertTrue(new File("target/export").exists());
|
||||
|
||||
}
|
||||
|
||||
private void set(Object obj, String fieldName, Object value) throws SecurityException, NoSuchFieldException, IllegalAccessException{
|
||||
Field field = AbstractMetaDataExportMojo.class.getDeclaredField(fieldName);
|
||||
field.setAccessible(true);
|
||||
field.set(obj, value);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user