Migrate to android-json
Migrate from `org.json:json` to the clean room Apache 2.0 licensed version that was developed for Android. Fixes gh-5929
This commit is contained in:
@@ -34,6 +34,7 @@ import org.springframework.boot.configurationprocessor.metadata.ConfigurationMet
|
||||
import org.springframework.boot.configurationprocessor.metadata.ItemDeprecation;
|
||||
import org.springframework.boot.configurationprocessor.metadata.ItemHint;
|
||||
import org.springframework.boot.configurationprocessor.metadata.ItemMetadata;
|
||||
import org.springframework.boot.configurationprocessor.metadata.TestJsonConverter;
|
||||
import org.springframework.boot.configurationsample.incremental.BarProperties;
|
||||
import org.springframework.boot.configurationsample.incremental.FooProperties;
|
||||
import org.springframework.boot.configurationsample.incremental.RenamedBarProperties;
|
||||
@@ -630,8 +631,9 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
JSONObject additionalMetadata = new JSONObject();
|
||||
additionalMetadata.put("properties", properties);
|
||||
FileWriter writer = new FileWriter(additionalMetadataFile);
|
||||
additionalMetadata.write(writer);
|
||||
writer.append(additionalMetadata.toString(2));
|
||||
writer.flush();
|
||||
writer.close();
|
||||
ConfigurationMetadata metadata = compile(SimpleProperties.class);
|
||||
assertThat(metadata).has(Metadata.withProperty("simple.comparator"));
|
||||
assertThat(metadata).has(Metadata.withProperty("foo", String.class)
|
||||
@@ -724,23 +726,28 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
return processor.getMetadata();
|
||||
}
|
||||
|
||||
private void writeAdditionalMetadata(ItemMetadata... metadata) throws IOException {
|
||||
private void writeAdditionalMetadata(ItemMetadata... metadata) throws Exception {
|
||||
TestJsonConverter converter = new TestJsonConverter();
|
||||
File additionalMetadataFile = createAdditionalMetadataFile();
|
||||
JSONObject additionalMetadata = new JSONObject();
|
||||
additionalMetadata.put("properties", metadata);
|
||||
JSONArray properties = new JSONArray();
|
||||
for (ItemMetadata itemMetadata : metadata) {
|
||||
properties.put(converter.toJsonObject(itemMetadata));
|
||||
}
|
||||
additionalMetadata.put("properties", properties);
|
||||
writeMetadata(additionalMetadataFile, additionalMetadata);
|
||||
}
|
||||
|
||||
private void writeAdditionalHints(ItemHint... hints) throws IOException {
|
||||
private void writeAdditionalHints(ItemHint... hints) throws Exception {
|
||||
TestJsonConverter converter = new TestJsonConverter();
|
||||
File additionalMetadataFile = createAdditionalMetadataFile();
|
||||
JSONObject additionalMetadata = new JSONObject();
|
||||
additionalMetadata.put("hints", hints);
|
||||
additionalMetadata.put("hints", converter.toJsonArray(Arrays.asList(hints)));
|
||||
writeMetadata(additionalMetadataFile, additionalMetadata);
|
||||
}
|
||||
|
||||
private void writePropertyDeprecation(ItemMetadata... items) throws IOException {
|
||||
private void writePropertyDeprecation(ItemMetadata... items) throws Exception {
|
||||
File additionalMetadataFile = createAdditionalMetadataFile();
|
||||
|
||||
JSONArray propertiesArray = new JSONArray();
|
||||
for (ItemMetadata item : items) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
@@ -776,11 +783,10 @@ public class ConfigurationMetadataAnnotationProcessorTests {
|
||||
return additionalMetadataFile;
|
||||
}
|
||||
|
||||
private void writeMetadata(File metadataFile, JSONObject metadata)
|
||||
throws IOException {
|
||||
private void writeMetadata(File metadataFile, JSONObject metadata) throws Exception {
|
||||
FileWriter writer = new FileWriter(metadataFile);
|
||||
try {
|
||||
metadata.write(writer);
|
||||
writer.append(metadata.toString(2));
|
||||
}
|
||||
finally {
|
||||
writer.close();
|
||||
|
||||
@@ -70,7 +70,7 @@ public class TestConfigurationMetadataAnnotationProcessor
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ConfigurationMetadata writeMetaData() {
|
||||
protected ConfigurationMetadata writeMetaData() throws Exception {
|
||||
super.writeMetaData();
|
||||
try {
|
||||
File metadataFile = new File(this.outputLocation,
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.boot.configurationprocessor.metadata;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -38,7 +37,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
public class JsonMarshallerTests {
|
||||
|
||||
@Test
|
||||
public void marshallAndUnmarshal() throws IOException {
|
||||
public void marshallAndUnmarshal() throws Exception {
|
||||
ConfigurationMetadata metadata = new ConfigurationMetadata();
|
||||
metadata.add(ItemMetadata.newProperty("a", "b", StringBuffer.class.getName(),
|
||||
InputStream.class.getName(), "sourceMethod", "desc", "x",
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.configurationprocessor.metadata;
|
||||
|
||||
/**
|
||||
* {@link JsonConverter} for use in tests.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class TestJsonConverter extends JsonConverter {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user