mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-03 21:07:49 +08:00
added tests
This commit is contained in:
parent
aeef332601
commit
3323375125
@ -33,6 +33,8 @@ import org.apache.commons.lang.StringUtils;
|
||||
*/
|
||||
public final class JavaWriter implements Appendable, CodeWriter{
|
||||
|
||||
private static final int INDENT_SPACES = 4;
|
||||
|
||||
private static final String EXTENDS = " extends ";
|
||||
|
||||
private static final String IMPLEMENTS = " implements ";
|
||||
@ -41,8 +43,6 @@ public final class JavaWriter implements Appendable, CodeWriter{
|
||||
|
||||
private static final String IMPORT_STATIC = "import static ";
|
||||
|
||||
private static final int INDENT_SPACES = 4;
|
||||
|
||||
private static final String PACKAGE = "package ";
|
||||
|
||||
private static final String PRIVATE = "private ";
|
||||
|
||||
@ -7,18 +7,27 @@ import java.io.StringWriter;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@TestAnnotation(prop2 = false)
|
||||
@TestAnnotation(prop2 = false, clazz = AnnotationTest.class)
|
||||
@TestAnnotation2("Hello")
|
||||
public class AnnotationTest {
|
||||
|
||||
|
||||
private StringWriter w = new StringWriter();
|
||||
private CodeWriter writer = new JavaWriter(w);
|
||||
|
||||
@Test
|
||||
public void testClassAnnotation() throws IOException{
|
||||
writer.annotation(getClass().getAnnotation(TestAnnotation.class));
|
||||
assertEquals("@com.mysema.codegen.TestAnnotation(prop2=false)", w.toString().trim());
|
||||
assertEquals("@com.mysema.codegen.TestAnnotation(clazz=com.mysema.codegen.AnnotationTest.class, prop2=false)", w.toString().trim());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClassAnnotation2() throws IOException{
|
||||
writer.annotation(getClass().getAnnotation(TestAnnotation2.class));
|
||||
assertEquals("@com.mysema.codegen.TestAnnotation2(\"Hello\")", w.toString().trim());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testMethodAnnotation() throws IOException, SecurityException, NoSuchMethodException {
|
||||
writer.annotation(getClass().getMethod("testMethodAnnotation").getAnnotation(Test.class));
|
||||
|
||||
@ -7,7 +7,6 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Documented
|
||||
@Target( { TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TestAnnotation {
|
||||
@ -15,5 +14,7 @@ public @interface TestAnnotation {
|
||||
boolean prop1() default false;
|
||||
|
||||
boolean prop2();
|
||||
|
||||
Class<?> clazz();
|
||||
|
||||
}
|
||||
|
||||
18
src/test/java/com/mysema/codegen/TestAnnotation2.java
Normal file
18
src/test/java/com/mysema/codegen/TestAnnotation2.java
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package com.mysema.codegen;
|
||||
|
||||
import static java.lang.annotation.ElementType.TYPE;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Target( { TYPE })
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TestAnnotation2 {
|
||||
|
||||
String value();
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user