Fail the build if the meta-data are invalid
Make sure to fail the build with a proper compilation error message if the user-defined meta-data are invalid. For now, this takes care of the JSON format but other checks may be added in the future. Closes gh-3329
This commit is contained in:
@@ -27,6 +27,7 @@ import org.json.JSONObject;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
import org.springframework.boot.configurationprocessor.metadata.ConfigurationMetadata;
|
||||
import org.springframework.boot.configurationprocessor.metadata.ItemHint;
|
||||
@@ -52,6 +53,7 @@ import org.springframework.boot.configurationsample.specific.InnerClassAnnotated
|
||||
import org.springframework.boot.configurationsample.specific.InnerClassProperties;
|
||||
import org.springframework.boot.configurationsample.specific.InnerClassRootConfig;
|
||||
import org.springframework.boot.configurationsample.specific.SimplePojo;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
@@ -78,6 +80,9 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
@Rule
|
||||
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||
|
||||
@Rule
|
||||
public ExpectedException thrown = ExpectedException.none();
|
||||
|
||||
private TestCompiler compiler;
|
||||
|
||||
@Before
|
||||
@@ -346,6 +351,16 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
.fromSource(AdditionalMetadata.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mergeOfInvalidAdditionalMetadata() throws IOException {
|
||||
File additionalMetadataFile = createAdditionalMetadataFile();
|
||||
FileCopyUtils.copy("Hello World", new FileWriter(additionalMetadataFile));
|
||||
|
||||
thrown.expect(IllegalStateException.class);
|
||||
thrown.expectMessage("Compilation failed");
|
||||
compile(SimpleProperties.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mergingOfSimpleHint() throws Exception {
|
||||
writeAdditionalHints(ItemHint.newHint("simple.the-name", new ItemHint.ValueHint(
|
||||
|
||||
Reference in New Issue
Block a user