This commit is contained in:
Phillip Webb
2015-12-10 13:25:27 +00:00
parent ce2346b087
commit 2694605a4d
10 changed files with 41 additions and 55 deletions

View File

@@ -319,11 +319,12 @@ public class ConfigurationMetadataAnnotationProcessorTests {
assertThat(metadata, containsProperty("config.second.bar.name"));
assertThat(metadata, containsGroup("config.third").ofType(SimpleLombokPojo.class)
.fromSource(LombokInnerClassProperties.class));
// For some reason the annotation processor resolves a type for SimpleLombokPojo that
// is resolved (compiled) and the source annotations are gone. Because we don't see the
// @Data annotation anymore, no field is harvested. What is crazy is that a sample project
// works fine so this seem to be related to the unit test environment for some reason.
//assertThat(metadata, containsProperty("config.third.value"));
// For some reason the annotation processor resolves a type for SimpleLombokPojo
// that is resolved (compiled) and the source annotations are gone. Because we
// don't see the @Data annotation anymore, no field is harvested. What is crazy is
// that a sample project works fine so this seem to be related to the unit test
// environment for some reason. assertThat(metadata,
// containsProperty("config.third.value"));
assertThat(metadata, containsProperty("config.fourth"));
assertThat(metadata, not(containsGroup("config.fourth")));
}
@@ -335,7 +336,6 @@ public class ConfigurationMetadataAnnotationProcessorTests {
File additionalMetadataFile = new File(metaInfFolder,
"additional-spring-configuration-metadata.json");
additionalMetadataFile.createNewFile();
JSONObject property = new JSONObject();
property.put("name", "foo");
property.put("type", "java.lang.String");
@@ -347,11 +347,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
FileWriter writer = new FileWriter(additionalMetadataFile);
additionalMetadata.write(writer);
writer.flush();
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata, containsProperty("simple.comparator"));
assertThat(metadata, containsProperty("foo", String.class)
.fromSource(AdditionalMetadata.class));
}
@@ -361,29 +358,23 @@ public class ConfigurationMetadataAnnotationProcessorTests {
TestProject project = new TestProject(this.temporaryFolder, FooProperties.class,
BarProperties.class);
assertFalse(project.getOutputFile(METADATA_PATH).exists());
ConfigurationMetadata metadata = project.fullBuild();
assertTrue(project.getOutputFile(METADATA_PATH).exists());
assertThat(metadata,
containsProperty("foo.counter").fromSource(FooProperties.class));
assertThat(metadata,
containsProperty("bar.counter").fromSource(BarProperties.class));
metadata = project.incrementalBuild(BarProperties.class);
assertThat(metadata,
containsProperty("foo.counter").fromSource(FooProperties.class));
assertThat(metadata,
containsProperty("bar.counter").fromSource(BarProperties.class));
project.addSourceCode(BarProperties.class,
BarProperties.class.getResourceAsStream("BarProperties.snippet"));
metadata = project.incrementalBuild(BarProperties.class);
assertThat(metadata, containsProperty("bar.extra"));
assertThat(metadata, containsProperty("foo.counter"));
assertThat(metadata, containsProperty("bar.counter"));
project.revert(BarProperties.class);
metadata = project.incrementalBuild(BarProperties.class);
assertThat(metadata, not(containsProperty("bar.extra")));
@@ -398,7 +389,6 @@ public class ConfigurationMetadataAnnotationProcessorTests {
ConfigurationMetadata metadata = project.fullBuild();
assertThat(metadata, containsProperty("foo.counter"));
assertThat(metadata, containsProperty("bar.counter"));
project.replaceText(BarProperties.class, "@ConfigurationProperties",
"//@ConfigurationProperties");
metadata = project.incrementalBuild(BarProperties.class);
@@ -417,7 +407,6 @@ public class ConfigurationMetadataAnnotationProcessorTests {
containsProperty("bar.counter").fromSource(BarProperties.class));
assertThat(metadata, not(
containsProperty("bar.counter").fromSource(RenamedBarProperties.class)));
project.delete(BarProperties.class);
project.add(RenamedBarProperties.class);
metadata = project.incrementalBuild(RenamedBarProperties.class);

View File

@@ -161,7 +161,7 @@ public class TestProject {
/**
* Restore source code of given class to its original contents.
* @param type the class to revert
* @throws IOException
* @throws IOException on IO error
*/
public void revert(Class<?> type) throws IOException {
Assert.assertTrue(getSourceFile(type).exists());
@@ -171,7 +171,7 @@ public class TestProject {
/**
* Add source code of given class to this project.
* @param type the class to add
* @throws IOException
* @throws IOException on IO error
*/
public void add(Class<?> type) throws IOException {
Assert.assertFalse(getSourceFile(type).exists());

View File

@@ -28,6 +28,7 @@ import org.springframework.boot.configurationsample.NestedConfigurationProperty;
*/
@Data
@ConfigurationProperties(prefix = "config")
@SuppressWarnings("unused")
public class LombokInnerClassProperties {
private final Foo first = new Foo();
@@ -58,4 +59,5 @@ public class LombokInnerClassProperties {
public enum Fourth {
YES, NO
}
}

View File

@@ -30,6 +30,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties;
*/
@Data
@ConfigurationProperties(prefix = "data")
@SuppressWarnings("unused")
public class LombokSimpleDataProperties {
private final String id = "super-id";

View File

@@ -32,6 +32,7 @@ import org.springframework.boot.configurationsample.ConfigurationProperties;
@Getter
@Setter
@ConfigurationProperties(prefix = "simple")
@SuppressWarnings("unused")
public class LombokSimpleProperties {
private final String id = "super-id";

View File

@@ -24,6 +24,7 @@ import lombok.Data;
* @author Stephane Nicoll
*/
@Data
@SuppressWarnings("unused")
public class SimpleLombokPojo {
private int value;