Reformat code use Eclipse Mars

This commit is contained in:
Phillip Webb
2015-10-07 23:32:31 -07:00
parent ba7c1fda72
commit 6ab376e2e8
652 changed files with 4151 additions and 3919 deletions

View File

@@ -160,13 +160,13 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private void processExecutableElement(String prefix, ExecutableElement element) {
if (element.getModifiers().contains(Modifier.PUBLIC)
&& (TypeKind.VOID != element.getReturnType().getKind())) {
Element returns = this.processingEnv.getTypeUtils().asElement(
element.getReturnType());
Element returns = this.processingEnv.getTypeUtils()
.asElement(element.getReturnType());
if (returns instanceof TypeElement) {
this.metadataCollector.add(ItemMetadata.newGroup(prefix,
this.typeUtils.getType(returns),
this.typeUtils.getType(element.getEnclosingElement()),
element.toString()));
this.metadataCollector.add(
ItemMetadata.newGroup(prefix, this.typeUtils.getType(returns),
this.typeUtils.getType(element.getEnclosingElement()),
element.toString()));
processTypeElement(prefix, (TypeElement) returns);
}
}
@@ -198,8 +198,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
ExecutableElement setter = members.getPublicSetters().get(name);
VariableElement field = members.getFields().get(name);
TypeMirror returnType = getter.getReturnType();
Element returnTypeElement = this.processingEnv.getTypeUtils().asElement(
returnType);
Element returnTypeElement = this.processingEnv.getTypeUtils()
.asElement(returnType);
boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
boolean isNested = isNested(returnTypeElement, field, element);
boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
@@ -211,9 +211,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
boolean deprecated = hasDeprecateAnnotation(getter)
|| hasDeprecateAnnotation(setter)
|| hasDeprecateAnnotation(element);
this.metadataCollector.add(ItemMetadata
.newProperty(prefix, name, dataType, sourceType, null,
description, defaultValue, deprecated));
this.metadataCollector
.add(ItemMetadata.newProperty(prefix, name, dataType, sourceType,
null, description, defaultValue, deprecated));
}
}
}
@@ -227,8 +227,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
continue;
}
TypeMirror returnType = field.asType();
Element returnTypeElement = this.processingEnv.getTypeUtils().asElement(
returnType);
Element returnTypeElement = this.processingEnv.getTypeUtils()
.asElement(returnType);
boolean isExcluded = this.typeExcludeFilter.isExcluded(returnType);
boolean isNested = isNested(returnTypeElement, field, element);
boolean isCollection = this.typeUtils.isCollectionOrMap(returnType);
@@ -240,9 +240,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
Object defaultValue = fieldValues.get(name);
boolean deprecated = hasDeprecateAnnotation(field)
|| hasDeprecateAnnotation(element);
this.metadataCollector.add(ItemMetadata
.newProperty(prefix, name, dataType, sourceType, null,
description, defaultValue, deprecated));
this.metadataCollector
.add(ItemMetadata.newProperty(prefix, name, dataType, sourceType,
null, description, defaultValue, deprecated));
}
}
}
@@ -256,8 +256,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private boolean hasLombokSetter(VariableElement field, TypeElement element) {
return !field.getModifiers().contains(Modifier.FINAL)
&& (hasAnnotation(field, LOMBOK_SETTER_ANNOTATION)
|| hasAnnotation(element, LOMBOK_SETTER_ANNOTATION) || hasAnnotation(
element, LOMBOK_DATA_ANNOTATION));
|| hasAnnotation(element, LOMBOK_SETTER_ANNOTATION)
|| hasAnnotation(element, LOMBOK_DATA_ANNOTATION));
}
private void processNestedTypes(String prefix, TypeElement element,
@@ -267,8 +267,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
String name = entry.getKey();
ExecutableElement getter = entry.getValue();
VariableElement field = members.getFields().get(name);
Element returnType = this.processingEnv.getTypeUtils().asElement(
getter.getReturnType());
Element returnType = this.processingEnv.getTypeUtils()
.asElement(getter.getReturnType());
AnnotationMirror annotation = getAnnotation(getter,
configurationPropertiesAnnotation());
boolean isNested = isNested(returnType, field, element);
@@ -328,8 +328,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
Map<String, Object> values = new LinkedHashMap<String, Object>();
for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry : annotation
.getElementValues().entrySet()) {
values.put(entry.getKey().getSimpleName().toString(), entry.getValue()
.getValue());
values.put(entry.getKey().getSimpleName().toString(),
entry.getValue().getValue());
}
return values;
}
@@ -349,7 +349,8 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
return null;
}
private ConfigurationMetadata mergeAdditionalMetadata(ConfigurationMetadata metadata) {
private ConfigurationMetadata mergeAdditionalMetadata(
ConfigurationMetadata metadata) {
try {
ConfigurationMetadata merged = new ConfigurationMetadata(metadata);
merged.addAll(this.metadataStore.readAdditionalMetadata());

View File

@@ -95,11 +95,13 @@ public class MetadataCollector {
private boolean shouldBeMerged(ItemMetadata itemMetadata) {
String sourceType = itemMetadata.getSourceType();
return (sourceType != null && !deletedInCurrentBuild(sourceType) && !processedInCurrentBuild(sourceType));
return (sourceType != null && !deletedInCurrentBuild(sourceType)
&& !processedInCurrentBuild(sourceType));
}
private boolean deletedInCurrentBuild(String sourceType) {
return this.processingEnvironment.getElementUtils().getTypeElement(sourceType) == null;
return this.processingEnvironment.getElementUtils()
.getTypeElement(sourceType) == null;
}
private boolean processedInCurrentBuild(String sourceType) {

View File

@@ -89,21 +89,21 @@ public class MetadataStore {
}
private FileObject getMetadataResource() throws IOException {
FileObject resource = this.environment.getFiler().getResource(
StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
FileObject resource = this.environment.getFiler()
.getResource(StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
return resource;
}
private FileObject createMetadataResource() throws IOException {
FileObject resource = this.environment.getFiler().createResource(
StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
FileObject resource = this.environment.getFiler()
.createResource(StandardLocation.CLASS_OUTPUT, "", METADATA_PATH);
return resource;
}
private InputStream getAdditionalMetadataStream() throws IOException {
// Most build systems will have copied the file to the class output location
FileObject fileObject = this.environment.getFiler().getResource(
StandardLocation.CLASS_OUTPUT, "", ADDITIONAL_METADATA_PATH);
FileObject fileObject = this.environment.getFiler()
.getResource(StandardLocation.CLASS_OUTPUT, "", ADDITIONAL_METADATA_PATH);
File file = new File(fileObject.toUri());
if (!file.exists()) {
// Gradle keeps things separate
@@ -115,8 +115,8 @@ public class MetadataStore {
file = new File(path);
}
}
return (file.exists() ? new FileInputStream(file) : fileObject.toUri().toURL()
.openStream());
return (file.exists() ? new FileInputStream(file)
: fileObject.toUri().toURL().openStream());
}
}

View File

@@ -54,8 +54,8 @@ class TypeElementMembers {
}
private void process(TypeElement element) {
for (ExecutableElement method : ElementFilter.methodsIn(element
.getEnclosedElements())) {
for (ExecutableElement method : ElementFilter
.methodsIn(element.getEnclosedElements())) {
processMethod(method);
}
for (VariableElement field : ElementFilter
@@ -95,14 +95,14 @@ class TypeElementMembers {
}
private boolean isSetterReturnType(ExecutableElement method) {
return (TypeKind.VOID == method.getReturnType().getKind() || this.env
.getTypeUtils().isSameType(method.getEnclosingElement().asType(),
method.getReturnType()));
return (TypeKind.VOID == method.getReturnType().getKind()
|| this.env.getTypeUtils().isSameType(
method.getEnclosingElement().asType(), method.getReturnType()));
}
private String getAccessorName(String methodName) {
String name = methodName.startsWith("is") ? methodName.substring(2) : methodName
.substring(3);
String name = methodName.startsWith("is") ? methodName.substring(2)
: methodName.substring(3);
name = Character.toLowerCase(name.charAt(0)) + name.substring(1);
return name;
}

View File

@@ -40,6 +40,7 @@ import javax.lang.model.util.Types;
class TypeUtils {
private static final Map<TypeKind, Class<?>> PRIMITIVE_WRAPPERS;
static {
Map<TypeKind, Class<?>> wrappers = new HashMap<TypeKind, Class<?>>();
wrappers.put(TypeKind.BOOLEAN, Boolean.class);
@@ -63,8 +64,9 @@ class TypeUtils {
this.env = env;
Types types = env.getTypeUtils();
WildcardType wc = types.getWildcardType(null, null);
this.collectionType = types.getDeclaredType(this.env.getElementUtils()
.getTypeElement(Collection.class.getName()), wc);
this.collectionType = types.getDeclaredType(
this.env.getElementUtils().getTypeElement(Collection.class.getName()),
wc);
this.mapType = types.getDeclaredType(
this.env.getElementUtils().getTypeElement(Map.class.getName()), wc, wc);
@@ -109,8 +111,8 @@ class TypeUtils {
}
public String getJavaDoc(Element element) {
String javadoc = (element == null ? null : this.env.getElementUtils()
.getDocComment(element));
String javadoc = (element == null ? null
: this.env.getElementUtils().getDocComment(element));
if (javadoc != null) {
javadoc = javadoc.trim();
}

View File

@@ -30,9 +30,11 @@ class ExpressionTree extends ReflectionWrapper {
private final Class<?> literalTreeType = findClass("com.sun.source.tree.LiteralTree");
private final Method literalValueMethod = findMethod(this.literalTreeType, "getValue");
private final Method literalValueMethod = findMethod(this.literalTreeType,
"getValue");
private final Class<?> newArrayTreeType = findClass("com.sun.source.tree.NewArrayTree");
private final Class<?> newArrayTreeType = findClass(
"com.sun.source.tree.NewArrayTree");
private final Method arrayValueMethod = findMethod(this.newArrayTreeType,
"getInitializers");

View File

@@ -56,6 +56,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
private static class FieldCollector implements TreeVisitor {
private static final Map<String, Class<?>> WRAPPER_TYPES;
static {
Map<String, Class<?>> types = new HashMap<String, Class<?>>();
types.put("boolean", Boolean.class);
@@ -72,6 +73,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
}
private static final Map<Class<?>, Object> DEFAULT_TYPE_VALUES;
static {
Map<Class<?>, Object> values = new HashMap<Class<?>, Object>();
values.put(Boolean.class, false);
@@ -83,6 +85,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser {
}
private static final Map<String, Object> WELL_KNOWN_STATIC_FINALS;
static {
Map<String, Object> values = new HashMap<String, Object>();
values.put("Boolean.TRUE", true);

View File

@@ -41,9 +41,11 @@ class Tree extends ReflectionWrapper {
}
public void accept(TreeVisitor visitor) throws Exception {
this.acceptMethod.invoke(getInstance(), Proxy.newProxyInstance(getInstance()
.getClass().getClassLoader(), new Class<?>[] { this.treeVisitorType },
new TreeVisitorInvocationHandler(visitor)), 0);
this.acceptMethod.invoke(getInstance(),
Proxy.newProxyInstance(getInstance().getClass().getClassLoader(),
new Class<?>[] { this.treeVisitorType },
new TreeVisitorInvocationHandler(visitor)),
0);
}
/**
@@ -59,7 +61,8 @@ class Tree extends ReflectionWrapper {
@Override
@SuppressWarnings("rawtypes")
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
public Object invoke(Object proxy, Method method, Object[] args)
throws Throwable {
if (method.getName().equals("visitClass")) {
if ((Integer) args[1] == 0) {
Iterable members = (Iterable) Tree.this.GET_CLASS_TREE_MEMBERS

View File

@@ -92,14 +92,12 @@ public class ConfigurationMetadataAnnotationProcessorTests {
public void simpleProperties() throws Exception {
ConfigurationMetadata metadata = compile(SimpleProperties.class);
assertThat(metadata, containsGroup("simple").fromSource(SimpleProperties.class));
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.the-name", String.class)
.fromSource(SimpleProperties.class)
.withDescription("The name of this simple properties.")
.withDefaultValue(is("boot")).withDeprecated());
assertThat(
metadata,
assertThat(metadata,
containsProperty("simple.flag", Boolean.class)
.fromSource(SimpleProperties.class)
.withDescription("A simple flag.").withDeprecated());
@@ -113,10 +111,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
ConfigurationMetadata metadata = compile(SimplePrefixValueProperties.class);
assertThat(metadata,
containsGroup("simple").fromSource(SimplePrefixValueProperties.class));
assertThat(
metadata,
containsProperty("simple.name", String.class).fromSource(
SimplePrefixValueProperties.class));
assertThat(metadata, containsProperty("simple.name", String.class)
.fromSource(SimplePrefixValueProperties.class));
}
@Test
@@ -181,69 +177,48 @@ public class ConfigurationMetadataAnnotationProcessorTests {
public void parseCollectionConfig() throws Exception {
ConfigurationMetadata metadata = compile(SimpleCollectionProperties.class);
// getter and setter
assertThat(
metadata,
containsProperty("collection.integers-to-names",
"java.util.Map<java.lang.Integer,java.lang.String>"));
assertThat(
metadata,
containsProperty("collection.longs",
"java.util.Collection<java.lang.Long>"));
assertThat(metadata, containsProperty("collection.integers-to-names",
"java.util.Map<java.lang.Integer,java.lang.String>"));
assertThat(metadata, containsProperty("collection.longs",
"java.util.Collection<java.lang.Long>"));
assertThat(metadata,
containsProperty("collection.floats", "java.util.List<java.lang.Float>"));
// getter only
assertThat(
metadata,
containsProperty("collection.names-to-integers",
"java.util.Map<java.lang.String,java.lang.Integer>"));
assertThat(
metadata,
containsProperty("collection.bytes",
"java.util.Collection<java.lang.Byte>"));
assertThat(
metadata,
containsProperty("collection.doubles", "java.util.List<java.lang.Double>"));
assertThat(metadata, containsProperty("collection.names-to-integers",
"java.util.Map<java.lang.String,java.lang.Integer>"));
assertThat(metadata, containsProperty("collection.bytes",
"java.util.Collection<java.lang.Byte>"));
assertThat(metadata, containsProperty("collection.doubles",
"java.util.List<java.lang.Double>"));
}
@Test
public void simpleMethodConfig() throws Exception {
ConfigurationMetadata metadata = compile(SimpleMethodConfig.class);
assertThat(metadata, containsGroup("foo").fromSource(SimpleMethodConfig.class));
assertThat(
metadata,
containsProperty("foo.name", String.class).fromSource(
SimpleMethodConfig.Foo.class));
assertThat(
metadata,
containsProperty("foo.flag", Boolean.class).fromSource(
SimpleMethodConfig.Foo.class));
assertThat(metadata, containsProperty("foo.name", String.class)
.fromSource(SimpleMethodConfig.Foo.class));
assertThat(metadata, containsProperty("foo.flag", Boolean.class)
.fromSource(SimpleMethodConfig.Foo.class));
}
@Test
public void invalidMethodConfig() throws Exception {
ConfigurationMetadata metadata = compile(InvalidMethodConfig.class);
assertThat(
metadata,
containsProperty("something.name", String.class).fromSource(
InvalidMethodConfig.class));
assertThat(metadata, containsProperty("something.name", String.class)
.fromSource(InvalidMethodConfig.class));
assertThat(metadata, not(containsProperty("invalid.name")));
}
@Test
public void methodAndClassConfig() throws Exception {
ConfigurationMetadata metadata = compile(MethodAndClassConfig.class);
assertThat(
metadata,
containsProperty("conflict.name", String.class).fromSource(
MethodAndClassConfig.Foo.class));
assertThat(
metadata,
containsProperty("conflict.flag", Boolean.class).fromSource(
MethodAndClassConfig.Foo.class));
assertThat(
metadata,
containsProperty("conflict.value", String.class).fromSource(
MethodAndClassConfig.class));
assertThat(metadata, containsProperty("conflict.name", String.class)
.fromSource(MethodAndClassConfig.Foo.class));
assertThat(metadata, containsProperty("conflict.flag", Boolean.class)
.fromSource(MethodAndClassConfig.Foo.class));
assertThat(metadata, containsProperty("conflict.value", String.class)
.fromSource(MethodAndClassConfig.class));
}
@Test
@@ -320,7 +295,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
@Test
public void lombokExplicitProperties() throws Exception {
ConfigurationMetadata metadata = compile(LombokExplicitProperties.class);
assertSimpleLombokProperties(metadata, LombokExplicitProperties.class, "explicit");
assertSimpleLombokProperties(metadata, LombokExplicitProperties.class,
"explicit");
}
@Test
@@ -347,9 +323,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
assertThat(metadata, containsProperty("simple.comparator"));
assertThat(metadata,
containsProperty("foo", String.class)
.fromSource(AdditionalMetadata.class));
assertThat(metadata, containsProperty("foo", String.class)
.fromSource(AdditionalMetadata.class));
}
@Test
@@ -411,9 +386,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
containsProperty("foo.counter").fromSource(FooProperties.class));
assertThat(metadata,
containsProperty("bar.counter").fromSource(BarProperties.class));
assertThat(metadata,
not(containsProperty("bar.counter")
.fromSource(RenamedBarProperties.class)));
assertThat(metadata, not(
containsProperty("bar.counter").fromSource(RenamedBarProperties.class)));
project.delete(BarProperties.class);
project.add(RenamedBarProperties.class);
@@ -430,9 +404,8 @@ public class ConfigurationMetadataAnnotationProcessorTests {
Class<?> source, String prefix) {
assertThat(metadata, containsGroup(prefix).fromSource(source));
assertThat(metadata, not(containsProperty(prefix + ".id")));
assertThat(metadata,
containsProperty(prefix + ".name", String.class).fromSource(source)
.withDescription("Name description."));
assertThat(metadata, containsProperty(prefix + ".name", String.class)
.fromSource(source).withDescription("Name description."));
assertThat(metadata, containsProperty(prefix + ".description"));
assertThat(metadata, containsProperty(prefix + ".counter"));
assertThat(metadata, containsProperty(prefix + ".number").fromSource(source)

View File

@@ -119,12 +119,12 @@ public class ConfigurationMetadataMatchers {
ConfigurationMetadata metadata = (ConfigurationMetadata) item;
ItemMetadata property = getFirstPropertyWithName(metadata, this.name);
if (property == null) {
description.appendText("missing "
+ this.itemType.toString().toLowerCase() + " " + this.name);
description.appendText("missing " + this.itemType.toString().toLowerCase()
+ " " + this.name);
}
else {
description.appendText(
"was " + this.itemType.toString().toLowerCase() + " ")
description
.appendText("was " + this.itemType.toString().toLowerCase() + " ")
.appendValue(property);
}
}
@@ -151,12 +151,14 @@ public class ConfigurationMetadataMatchers {
public ContainsItemMatcher ofType(Class<?> dataType) {
return new ContainsItemMatcher(this.itemType, this.name, dataType.getName(),
this.sourceType, this.description, this.defaultValue, this.deprecated);
this.sourceType, this.description, this.defaultValue,
this.deprecated);
}
public ContainsItemMatcher ofType(String dataType) {
return new ContainsItemMatcher(this.itemType, this.name, dataType,
this.sourceType, this.description, this.defaultValue, this.deprecated);
this.sourceType, this.description, this.defaultValue,
this.deprecated);
}
public ContainsItemMatcher fromSource(Class<?> sourceType) {

View File

@@ -73,9 +73,10 @@ public class TestCompiler {
return getTask(javaFileObjects);
}
private TestCompilationTask getTask(Iterable<? extends JavaFileObject> javaFileObjects) {
return new TestCompilationTask(this.compiler.getTask(null, this.fileManager,
null, null, null, javaFileObjects));
private TestCompilationTask getTask(
Iterable<? extends JavaFileObject> javaFileObjects) {
return new TestCompilationTask(this.compiler.getTask(null, this.fileManager, null,
null, null, javaFileObjects));
}
public File getOutputLocation() {

View File

@@ -34,8 +34,8 @@ import org.springframework.boot.configurationprocessor.metadata.JsonMarshaller;
*/
@SupportedAnnotationTypes({ "*" })
@SupportedSourceVersion(SourceVersion.RELEASE_6)
public class TestConfigurationMetadataAnnotationProcessor extends
ConfigurationMetadataAnnotationProcessor {
public class TestConfigurationMetadataAnnotationProcessor
extends ConfigurationMetadataAnnotationProcessor {
static final String CONFIGURATION_PROPERTIES_ANNOTATION = "org.springframework.boot.configurationsample.ConfigurationProperties";
@@ -66,8 +66,8 @@ public class TestConfigurationMetadataAnnotationProcessor extends
File metadataFile = new File(this.outputLocation,
"META-INF/spring-configuration-metadata.json");
if (metadataFile.isFile()) {
this.metadata = new JsonMarshaller().read(new FileInputStream(
metadataFile));
this.metadata = new JsonMarshaller()
.read(new FileInputStream(metadataFile));
}
else {
this.metadata = new ConfigurationMetadata();

View File

@@ -140,8 +140,8 @@ public class TestProject {
File targetFile = getSourceFile(target);
String contents = getContents(targetFile);
int insertAt = contents.lastIndexOf('}');
String additionalSource = FileCopyUtils.copyToString(new InputStreamReader(
snippetStream));
String additionalSource = FileCopyUtils
.copyToString(new InputStreamReader(snippetStream));
contents = contents.substring(0, insertAt) + additionalSource
+ contents.substring(insertAt);
putContents(targetFile, contents);

View File

@@ -82,8 +82,8 @@ public abstract class AbstractFieldValuesProcessorTests {
equalToObject(new Object[] { "FOO", "BAR" }));
assertThat(values.get("stringArrayNone"), nullValue());
assertThat(values.get("stringEmptyArray"), equalToObject(new Object[0]));
assertThat(values.get("stringArrayConst"), equalToObject(new Object[] { "OK",
"KO" }));
assertThat(values.get("stringArrayConst"),
equalToObject(new Object[] { "OK", "KO" }));
assertThat(values.get("stringArrayConstElements"),
equalToObject(new Object[] { "c" }));
assertThat(values.get("integerArray"), equalToObject(new Object[] { 42, 24 }));
@@ -94,7 +94,8 @@ public abstract class AbstractFieldValuesProcessorTests {
return equalTo(object);
}
@SupportedAnnotationTypes({ "org.springframework.boot.configurationsample.ConfigurationProperties" })
@SupportedAnnotationTypes({
"org.springframework.boot.configurationsample.ConfigurationProperties" })
@SupportedSourceVersion(SourceVersion.RELEASE_6)
private class TestProcessor extends AbstractProcessor {
@@ -114,8 +115,8 @@ public abstract class AbstractFieldValuesProcessorTests {
for (Element element : roundEnv.getElementsAnnotatedWith(annotation)) {
if (element instanceof TypeElement) {
try {
this.values.putAll(this.processor
.getFieldValues((TypeElement) element));
this.values.putAll(
this.processor.getFieldValues((TypeElement) element));
}
catch (Exception ex) {
throw new IllegalStateException(ex);

View File

@@ -28,8 +28,8 @@ import static org.junit.Assume.assumeNoException;
*
* @author Phillip Webb
*/
public class JavaCompilerFieldValuesProcessorTests extends
AbstractFieldValuesProcessorTests {
public class JavaCompilerFieldValuesProcessorTests
extends AbstractFieldValuesProcessorTests {
@Override
protected FieldValuesParser createProcessor(ProcessingEnvironment env) {

View File

@@ -40,7 +40,8 @@ public class ConfigurationMetadataTests {
@Test
public void toDashedCaseWordsSeveralUnderScores() {
assertThat(toDashedCase("Word___With__underscore"), is("word___with__underscore"));
assertThat(toDashedCase("Word___With__underscore"),
is("word___with__underscore"));
}
@Test

View File

@@ -41,12 +41,12 @@ public class JsonMarshallerTests {
ConfigurationMetadata metadata = new ConfigurationMetadata();
metadata.add(ItemMetadata.newProperty("a", "b", StringBuffer.class.getName(),
InputStream.class.getName(), "sourceMethod", "desc", "x", true));
metadata.add(ItemMetadata.newProperty("b.c.d", null, null, null, null, null,
null, false));
metadata.add(ItemMetadata.newProperty("c", null, null, null, null, null, 123,
false));
metadata.add(ItemMetadata.newProperty("d", null, null, null, null, null, true,
metadata.add(ItemMetadata.newProperty("b.c.d", null, null, null, null, null, null,
false));
metadata.add(
ItemMetadata.newProperty("c", null, null, null, null, null, 123, false));
metadata.add(
ItemMetadata.newProperty("d", null, null, null, null, null, true, false));
metadata.add(ItemMetadata.newProperty("e", null, null, null, null, null,
new String[] { "y", "n" }, false));
metadata.add(ItemMetadata.newProperty("f", null, null, null, null, null,
@@ -55,8 +55,8 @@ public class JsonMarshallerTests {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
JsonMarshaller marshaller = new JsonMarshaller();
marshaller.write(metadata, outputStream);
ConfigurationMetadata read = marshaller.read(new ByteArrayInputStream(
outputStream.toByteArray()));
ConfigurationMetadata read = marshaller
.read(new ByteArrayInputStream(outputStream.toByteArray()));
assertThat(read,
containsProperty("a.b", StringBuffer.class).fromSource(InputStream.class)
.withDescription("desc").withDefaultValue(is("x"))
@@ -66,8 +66,8 @@ public class JsonMarshallerTests {
assertThat(read, containsProperty("d").withDefaultValue(is(true)));
assertThat(read,
containsProperty("e").withDefaultValue(is(new String[] { "y", "n" })));
assertThat(read,
containsProperty("f").withDefaultValue(is(new boolean[] { true, false })));
assertThat(read, containsProperty("f")
.withDefaultValue(is(new boolean[] { true, false })));
assertThat(read, containsGroup("d"));
}

View File

@@ -21,8 +21,8 @@ package org.springframework.boot.configurationsample.simple;
*
* @author Stephane Nicoll
*/
public abstract class HierarchicalPropertiesParent extends
HierarchicalPropertiesGrandparent {
public abstract class HierarchicalPropertiesParent
extends HierarchicalPropertiesGrandparent {
private String second;

View File

@@ -105,8 +105,8 @@ public abstract class ManagedDependencies implements Dependencies {
*/
public static ManagedDependencies get(
Collection<Dependencies> versionManagedDependencies) {
return new ManagedDependencies(new ManagedDependenciesDelegate(
versionManagedDependencies)) {
return new ManagedDependencies(
new ManagedDependenciesDelegate(versionManagedDependencies)) {
};
}

View File

@@ -35,7 +35,8 @@ class ManagedDependenciesDelegate extends AbstractDependencies {
* @param versionManagedDependencies a collection of {@link Dependencies} that take
* precedence over the `spring-boot-dependencies`.
*/
public ManagedDependenciesDelegate(Collection<Dependencies> versionManagedDependencies) {
public ManagedDependenciesDelegate(
Collection<Dependencies> versionManagedDependencies) {
this(getSpringBootDependencies(), versionManagedDependencies);
}
@@ -57,7 +58,8 @@ class ManagedDependenciesDelegate extends AbstractDependencies {
private static Dependencies getSpringBootDependencies() {
if (springBootDependencies == null) {
springBootDependencies = new PomDependencies(getResource("effective-pom.xml"));
springBootDependencies = new PomDependencies(
getResource("effective-pom.xml"));
}
return springBootDependencies;
}

View File

@@ -91,8 +91,8 @@ public class PomDependencies extends AbstractDependencies {
String groupId = getTextContent(element, "groupId");
String artifactId = getTextContent(element, "artifactId");
String version = getTextContent(element, "version");
List<Exclusion> exclusions = createExclusions(element
.getElementsByTagName("exclusions"));
List<Exclusion> exclusions = createExclusions(
element.getElementsByTagName("exclusions"));
return new Dependency(groupId, artifactId, version, exclusions);
}

View File

@@ -36,10 +36,10 @@ public class ManagedDependenciesDelegateTests {
@Before
public void setup() throws Exception {
PropertiesFileDependencies root = new PropertiesFileDependencies(getClass()
.getResourceAsStream("external.properties"));
PropertiesFileDependencies extra = new PropertiesFileDependencies(getClass()
.getResourceAsStream("additional-external.properties"));
PropertiesFileDependencies root = new PropertiesFileDependencies(
getClass().getResourceAsStream("external.properties"));
PropertiesFileDependencies extra = new PropertiesFileDependencies(
getClass().getResourceAsStream("additional-external.properties"));
this.dependencies = new ManagedDependenciesDelegate(root,
Collections.<Dependencies>singleton(extra));
}

View File

@@ -36,8 +36,8 @@ public class PropertiesFileDependenciesTests {
@Before
public void setup() throws Exception {
this.dependencies = new PropertiesFileDependencies(getClass()
.getResourceAsStream("external.properties"));
this.dependencies = new PropertiesFileDependencies(
getClass().getResourceAsStream("external.properties"));
}
@Test

View File

@@ -64,8 +64,8 @@ public abstract class FileUtils {
*/
public static String sha1Hash(File file) throws IOException {
try {
DigestInputStream inputStream = new DigestInputStream(new FileInputStream(
file), MessageDigest.getInstance("SHA-1"));
DigestInputStream inputStream = new DigestInputStream(
new FileInputStream(file), MessageDigest.getInstance("SHA-1"));
try {
byte[] buffer = new byte[4098];
while (inputStream.read(buffer) != -1) {

View File

@@ -142,8 +142,8 @@ public class JarWriter {
*/
public void writeLoaderClasses() throws IOException {
URL loaderJar = getClass().getClassLoader().getResource(NESTED_LOADER_JAR);
JarInputStream inputStream = new JarInputStream(new BufferedInputStream(
loaderJar.openStream()));
JarInputStream inputStream = new JarInputStream(
new BufferedInputStream(loaderJar.openStream()));
JarEntry entry;
while ((entry = inputStream.getNextJarEntry()) != null) {
if (entry.getName().endsWith(".class")) {
@@ -267,8 +267,8 @@ public class JarWriter {
@Override
public int read(byte[] b, int off, int len) throws IOException {
int read = (this.headerStream == null ? -1 : this.headerStream.read(b, off,
len));
int read = (this.headerStream == null ? -1
: this.headerStream.read(b, off, len));
if (read != -1) {
this.headerStream = null;
return read;

View File

@@ -31,8 +31,8 @@ abstract class JvmUtils {
/**
* Various search locations for tools, including the odd Java 6 OSX jar
*/
private static final String[] TOOLS_LOCATIONS = { "lib/tools.jar",
"../lib/tools.jar", "../Classes/classes.jar" };
private static final String[] TOOLS_LOCATIONS = { "lib/tools.jar", "../lib/tools.jar",
"../Classes/classes.jar" };
public static ClassLoader getToolsClassLoader() {
ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();

View File

@@ -116,6 +116,7 @@ public class Layouts {
public static class War implements Layout {
private static final Map<LibraryScope, String> SCOPE_DESTINATIONS;
static {
Map<LibraryScope, String> map = new HashMap<LibraryScope, String>();
map.put(LibraryScope.COMPILE, "WEB-INF/lib/");

View File

@@ -113,7 +113,8 @@ public abstract class MainClassFinder {
return null; // nothing to do
}
if (!rootFolder.isDirectory()) {
throw new IllegalArgumentException("Invalid root folder '" + rootFolder + "'");
throw new IllegalArgumentException(
"Invalid root folder '" + rootFolder + "'");
}
String prefix = rootFolder.getAbsolutePath() + "/";
Deque<File> stack = new ArrayDeque<File>();
@@ -230,7 +231,8 @@ public abstract class MainClassFinder {
return name;
}
private static List<JarEntry> getClassEntries(JarFile source, String classesLocation) {
private static List<JarEntry> getClassEntries(JarFile source,
String classesLocation) {
classesLocation = (classesLocation != null ? classesLocation : "");
Enumeration<JarEntry> sourceEntries = source.entries();
List<JarEntry> classEntries = new ArrayList<JarEntry>();

View File

@@ -120,8 +120,8 @@ public class Repackager {
destination = destination.getAbsoluteFile();
File workingSource = this.source;
if (this.source.equals(destination)) {
workingSource = new File(this.source.getParentFile(), this.source.getName()
+ ".original");
workingSource = new File(this.source.getParentFile(),
this.source.getName() + ".original");
workingSource.delete();
renameFile(this.source, workingSource);
}
@@ -146,8 +146,8 @@ public class Repackager {
JarFile jarFile = new JarFile(this.source);
try {
Manifest manifest = jarFile.getManifest();
return (manifest != null && manifest.getMainAttributes().getValue(
BOOT_VERSION_ATTRIBUTE) != null);
return (manifest != null && manifest.getMainAttributes()
.getValue(BOOT_VERSION_ATTRIBUTE) != null);
}
finally {
jarFile.close();
@@ -196,12 +196,12 @@ public class Repackager {
private void writeNestedLibraries(List<Library> libraries, Set<String> alreadySeen,
JarWriter writer) throws IOException {
for (Library library : libraries) {
String destination = Repackager.this.layout.getLibraryDestination(
library.getName(), library.getScope());
String destination = Repackager.this.layout
.getLibraryDestination(library.getName(), library.getScope());
if (destination != null) {
if (!alreadySeen.add(destination + library.getName())) {
throw new IllegalStateException("Duplicate library "
+ library.getName());
throw new IllegalStateException(
"Duplicate library " + library.getName());
}
writer.writeNestedLibrary(destination, library);
}
@@ -248,8 +248,8 @@ public class Repackager {
}
String launcherClassName = this.layout.getLauncherClassName();
if (launcherClassName != null) {
manifest.getMainAttributes()
.putValue(MAIN_CLASS_ATTRIBUTE, launcherClassName);
manifest.getMainAttributes().putValue(MAIN_CLASS_ATTRIBUTE,
launcherClassName);
if (startClass == null) {
throw new IllegalStateException("Unable to find main class");
}
@@ -270,8 +270,8 @@ public class Repackager {
private void renameFile(File file, File dest) {
if (!file.renameTo(dest)) {
throw new IllegalStateException("Unable to rename '" + file + "' to '" + dest
+ "'");
throw new IllegalStateException(
"Unable to rename '" + file + "' to '" + dest + "'");
}
}

View File

@@ -35,8 +35,8 @@ import org.springframework.util.ReflectionUtils;
*/
public class RunProcess {
private static final Method INHERIT_IO_METHOD = ReflectionUtils.findMethod(
ProcessBuilder.class, "inheritIO");
private static final Method INHERIT_IO_METHOD = ReflectionUtils
.findMethod(ProcessBuilder.class, "inheritIO");
private static final long JUST_ENDED_LIMIT = 500;
@@ -125,8 +125,8 @@ public class RunProcess {
}
private void redirectOutput(Process process) {
final BufferedReader reader = new BufferedReader(new InputStreamReader(
process.getInputStream()));
final BufferedReader reader = new BufferedReader(
new InputStreamReader(process.getInputStream()));
new Thread() {
@Override

View File

@@ -91,8 +91,8 @@ public class MainClassFinderTests {
public void findMainClassInJarSubLocation() throws Exception {
this.testJarFile.addClass("a/B.class", ClassWithMainMethod.class);
this.testJarFile.addClass("a/b/c/E.class", ClassWithMainMethod.class);
String actual = MainClassFinder
.findMainClass(this.testJarFile.getJarFile(), "a/");
String actual = MainClassFinder.findMainClass(this.testJarFile.getJarFile(),
"a/");
assertThat(actual, equalTo("B"));
}

View File

@@ -288,8 +288,8 @@ public class RepackagerTests {
@Override
public void doWithLibraries(LibraryCallback callback) throws IOException {
callback.library(new Library(libJarFile, LibraryScope.COMPILE));
callback.library(new Library(libJarFileToUnpack, LibraryScope.COMPILE,
true));
callback.library(
new Library(libJarFileToUnpack, LibraryScope.COMPILE, true));
callback.library(new Library(libNonJarFile, LibraryScope.COMPILE));
}
});
@@ -351,9 +351,8 @@ public class RepackagerTests {
Repackager repackager = new Repackager(file);
repackager.repackage(NO_LIBRARIES);
Manifest actualManifest = getManifest(file);
assertThat(
actualManifest.getMainAttributes().containsKey(
new Attributes.Name("Spring-Boot-Version")), equalTo(true));
assertThat(actualManifest.getMainAttributes()
.containsKey(new Attributes.Name("Spring-Boot-Version")), equalTo(true));
}
@Test
@@ -394,7 +393,8 @@ public class RepackagerTests {
}
@Test
public void unpackLibrariesTakePrecedenceOverExistingSourceEntries() throws Exception {
public void unpackLibrariesTakePrecedenceOverExistingSourceEntries()
throws Exception {
TestJarFile nested = new TestJarFile(this.temporaryFolder);
nested.addClass("a/b/C.class", ClassWithoutMainMethod.class);
final File nestedFile = nested.getFile();

View File

@@ -212,7 +212,8 @@ public class LaunchedURLClassLoader extends URLClassLoader {
// manifest
if (jarFile.getJarEntryData(path) != null
&& jarFile.getManifest() != null) {
definePackage(packageName, jarFile.getManifest(), url);
definePackage(packageName, jarFile.getManifest(),
url);
return null;
}

View File

@@ -151,7 +151,8 @@ public abstract class Launcher {
throw new IllegalStateException(
"Unable to determine code source archive from " + root);
}
return (root.isDirectory() ? new ExplodedArchive(root) : new JarFileArchive(root));
return (root.isDirectory() ? new ExplodedArchive(root)
: new JarFileArchive(root));
}
}

View File

@@ -47,8 +47,8 @@ public class MainMethodRunner implements Runnable {
.loadClass(this.mainClassName);
Method mainMethod = mainClass.getDeclaredMethod("main", String[].class);
if (mainMethod == null) {
throw new IllegalStateException(this.mainClassName
+ " does not have a main method");
throw new IllegalStateException(
this.mainClassName + " does not have a main method");
}
mainMethod.invoke(null, new Object[] { this.args });
}

View File

@@ -170,16 +170,17 @@ public class PropertiesLauncher extends Launcher {
}
protected File getHomeDirectory() {
return new File(SystemPropertyUtils.resolvePlaceholders(System.getProperty(HOME,
"${user.dir}")));
return new File(SystemPropertyUtils
.resolvePlaceholders(System.getProperty(HOME, "${user.dir}")));
}
private void initializeProperties(File home) throws Exception, IOException {
String config = "classpath:"
+ SystemPropertyUtils.resolvePlaceholders(SystemPropertyUtils
.getProperty(CONFIG_NAME, "application")) + ".properties";
config = SystemPropertyUtils.resolvePlaceholders(SystemPropertyUtils.getProperty(
CONFIG_LOCATION, config));
+ SystemPropertyUtils.resolvePlaceholders(
SystemPropertyUtils.getProperty(CONFIG_NAME, "application"))
+ ".properties";
config = SystemPropertyUtils.resolvePlaceholders(
SystemPropertyUtils.getProperty(CONFIG_LOCATION, config));
InputStream resource = getResource(config);
if (resource != null) {
@@ -198,8 +199,9 @@ public class PropertiesLauncher extends Launcher {
this.properties.put(key, value);
}
}
if (SystemPropertyUtils.resolvePlaceholders(
"${" + SET_SYSTEM_PROPERTIES + ":false}").equals("true")) {
if (SystemPropertyUtils
.resolvePlaceholders("${" + SET_SYSTEM_PROPERTIES + ":false}")
.equals("true")) {
this.logger.info("Adding resolved properties to System properties");
for (Object key : Collections.list(this.properties.propertyNames())) {
String value = this.properties.getProperty((String) key);
@@ -278,8 +280,8 @@ public class PropertiesLauncher extends Launcher {
// Try a URL connection content-length header...
URLConnection connection = url.openConnection();
try {
connection.setUseCaches(connection.getClass().getSimpleName()
.startsWith("JNLP"));
connection.setUseCaches(
connection.getClass().getSimpleName().startsWith("JNLP"));
if (connection instanceof HttpURLConnection) {
HttpURLConnection httpConnection = (HttpURLConnection) connection;
httpConnection.setRequestMethod("HEAD");
@@ -306,7 +308,8 @@ public class PropertiesLauncher extends Launcher {
path = this.properties.getProperty(PATH);
}
if (path != null) {
this.paths = parsePathsProperty(SystemPropertyUtils.resolvePlaceholders(path));
this.paths = parsePathsProperty(
SystemPropertyUtils.resolvePlaceholders(path));
}
this.logger.info("Nested archive paths: " + this.paths);
}
@@ -344,8 +347,8 @@ public class PropertiesLauncher extends Launcher {
protected String getMainClass() throws Exception {
String mainClass = getProperty(MAIN, "Start-Class");
if (mainClass == null) {
throw new IllegalStateException("No '" + MAIN
+ "' or 'Start-Class' specified");
throw new IllegalStateException(
"No '" + MAIN + "' or 'Start-Class' specified");
}
return mainClass;
}
@@ -365,8 +368,8 @@ public class PropertiesLauncher extends Launcher {
private ClassLoader wrapWithCustomClassLoader(ClassLoader parent,
String loaderClassName) throws Exception {
Class<ClassLoader> loaderClass = (Class<ClassLoader>) Class.forName(
loaderClassName, true, parent);
Class<ClassLoader> loaderClass = (Class<ClassLoader>) Class
.forName(loaderClassName, true, parent);
try {
return loaderClass.getConstructor(ClassLoader.class).newInstance(parent);
@@ -404,8 +407,8 @@ public class PropertiesLauncher extends Launcher {
}
if (this.properties.containsKey(propertyKey)) {
String value = SystemPropertyUtils.resolvePlaceholders(this.properties
.getProperty(propertyKey));
String value = SystemPropertyUtils
.resolvePlaceholders(this.properties.getProperty(propertyKey));
this.logger.fine("Property '" + propertyKey + "' from properties: " + value);
return value;
}
@@ -429,8 +432,8 @@ public class PropertiesLauncher extends Launcher {
if (manifest != null) {
String value = manifest.getMainAttributes().getValue(manifestKey);
if (value != null) {
this.logger.fine("Property '" + manifestKey + "' from archive manifest: "
+ value);
this.logger.fine(
"Property '" + manifestKey + "' from archive manifest: " + value);
return value;
}
}
@@ -468,14 +471,14 @@ public class PropertiesLauncher extends Launcher {
}
Archive archive = getArchive(file);
if (archive != null) {
this.logger.info("Adding classpath entries from archive " + archive.getUrl()
+ root);
this.logger.info(
"Adding classpath entries from archive " + archive.getUrl() + root);
lib.add(archive);
}
Archive nested = getNestedArchive(root);
if (nested != null) {
this.logger.info("Adding classpath entries from nested " + nested.getUrl()
+ root);
this.logger.info(
"Adding classpath entries from nested " + nested.getUrl() + root);
lib.add(nested);
}
return lib;
@@ -509,8 +512,8 @@ public class PropertiesLauncher extends Launcher {
return new FilteredArchive(this.parent, filter);
}
private void addParentClassLoaderEntries(List<Archive> lib) throws IOException,
URISyntaxException {
private void addParentClassLoaderEntries(List<Archive> lib)
throws IOException, URISyntaxException {
ClassLoader parentClassLoader = getClass().getClassLoader();
List<Archive> urls = new ArrayList<Archive>();
for (URL url : getURLs(parentClassLoader)) {
@@ -521,8 +524,8 @@ public class PropertiesLauncher extends Launcher {
String name = url.getFile();
File dir = new File(name.substring(0, name.length() - 1));
if (dir.exists()) {
urls.add(new ExplodedArchive(new File(name.substring(0,
name.length() - 1)), false));
urls.add(new ExplodedArchive(
new File(name.substring(0, name.length() - 1)), false));
}
}
else {

View File

@@ -44,8 +44,8 @@ import org.springframework.boot.loader.util.AsciiBytes;
*/
public class ExplodedArchive extends Archive {
private static final Set<String> SKIPPED_NAMES = new HashSet<String>(Arrays.asList(
".", ".."));
private static final Set<String> SKIPPED_NAMES = new HashSet<String>(
Arrays.asList(".", ".."));
private static final AsciiBytes MANIFEST_ENTRY_NAME = new AsciiBytes(
"META-INF/MANIFEST.MF");
@@ -152,7 +152,8 @@ public class ExplodedArchive extends Archive {
protected Archive getNestedArchive(Entry entry) throws IOException {
File file = ((FileEntry) entry).getFile();
return (file.isDirectory() ? new ExplodedArchive(file) : new JarFileArchive(file));
return (file.isDirectory() ? new ExplodedArchive(file)
: new JarFileArchive(file));
}
@Override
@@ -204,8 +205,8 @@ public class ExplodedArchive extends Archive {
@Override
protected URLConnection openConnection(URL url) throws IOException {
String name = url.getPath().substring(
ExplodedArchive.this.root.toURI().getPath().length());
String name = url.getPath()
.substring(ExplodedArchive.this.root.toURI().getPath().length());
if (ExplodedArchive.this.entries.containsKey(new AsciiBytes(name))) {
return new URL(url.toString()).openConnection();
}

View File

@@ -85,8 +85,8 @@ public class FilteredArchive extends Archive {
return this.parent.getFilteredArchive(new EntryRenameFilter() {
@Override
public AsciiBytes apply(AsciiBytes entryName, Entry entry) {
return FilteredArchive.this.filter.matches(entry) ? filter.apply(
entryName, entry) : null;
return FilteredArchive.this.filter.matches(entry)
? filter.apply(entryName, entry) : null;
}
});
}

View File

@@ -247,8 +247,9 @@ public class RandomAccessDataFile implements RandomAccessData {
try {
this.available.acquire();
RandomAccessFile file = this.files.poll();
return (file == null ? new RandomAccessFile(
RandomAccessDataFile.this.file, "r") : file);
return (file == null
? new RandomAccessFile(RandomAccessDataFile.this.file, "r")
: file);
}
catch (InterruptedException ex) {
throw new IOException(ex);

View File

@@ -82,8 +82,8 @@ class CentralDirectoryEndRecord {
return false;
}
// Total size must be the structure size + comment
long commentLength = Bytes.littleEndianValue(this.block, this.offset
+ COMMENT_LENGTH_OFFSET, 2);
long commentLength = Bytes.littleEndianValue(this.block,
this.offset + COMMENT_LENGTH_OFFSET, 2);
return this.size == MINIMUM_SIZE + commentLength;
}

View File

@@ -45,14 +45,16 @@ public class Handler extends URLStreamHandler {
private static final String SEPARATOR = "!/";
private static final String[] FALLBACK_HANDLERS = { "sun.net.www.protocol.jar.Handler" };
private static final String[] FALLBACK_HANDLERS = {
"sun.net.www.protocol.jar.Handler" };
private static final Method OPEN_CONNECTION_METHOD;
static {
Method method = null;
try {
method = URLStreamHandler.class
.getDeclaredMethod("openConnection", URL.class);
method = URLStreamHandler.class.getDeclaredMethod("openConnection",
URL.class);
}
catch (Exception ex) {
}
@@ -60,6 +62,7 @@ public class Handler extends URLStreamHandler {
}
private static SoftReference<Map<File, JarFile>> rootFileCache;
static {
rootFileCache = new SoftReference<Map<File, JarFile>>(null);
}
@@ -186,7 +189,8 @@ public class Handler extends URLStreamHandler {
* which are then swallowed.
* @param useFastConnectionExceptions if fast connection exceptions can be used.
*/
public static void setUseFastConnectionExceptions(boolean useFastConnectionExceptions) {
public static void setUseFastConnectionExceptions(
boolean useFastConnectionExceptions) {
JarURLConnection.setUseFastExceptions(useFastConnectionExceptions);
}

View File

@@ -107,13 +107,13 @@ public final class JarEntryData {
// aspectjrt-1.7.4.jar has a different ext bytes length in the
// local directory to the central directory. We need to re-read
// here to skip them
byte[] localHeader = Bytes.get(this.source.getData().getSubsection(
this.localHeaderOffset, LOCAL_FILE_HEADER_SIZE));
byte[] localHeader = Bytes.get(this.source.getData()
.getSubsection(this.localHeaderOffset, LOCAL_FILE_HEADER_SIZE));
long nameLength = Bytes.littleEndianValue(localHeader, 26, 2);
long extraLength = Bytes.littleEndianValue(localHeader, 28, 2);
this.data = this.source.getData().getSubsection(
this.localHeaderOffset + LOCAL_FILE_HEADER_SIZE + nameLength
+ extraLength, getCompressedSize());
this.data = this.source.getData().getSubsection(this.localHeaderOffset
+ LOCAL_FILE_HEADER_SIZE + nameLength + extraLength,
getCompressedSize());
}
return this.data;
}
@@ -154,8 +154,8 @@ public final class JarEntryData {
}
/**
* Decode MSDOS Date Time details. See <a
* href="http://mindprod.com/jgloss/zip.html">mindprod.com/jgloss/zip.html</a> for
* Decode MSDOS Date Time details. See
* <a href="http://mindprod.com/jgloss/zip.html">mindprod.com/jgloss/zip.html</a> for
* more details of the format.
* @param date the date part
* @param time the time part

View File

@@ -124,7 +124,7 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
private JarFile(RandomAccessDataFile rootFile, String pathFromRoot,
RandomAccessData data, List<JarEntryData> entries, JarEntryFilter... filters)
throws IOException {
throws IOException {
super(rootFile.getFile());
this.rootFile = rootFile;
this.pathFromRoot = pathFromRoot;
@@ -167,7 +167,8 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
for (JarEntryData entry : entries) {
AsciiBytes name = entry.getName();
for (JarEntryFilter filter : filters) {
name = (filter == null || name == null ? name : filter.apply(name, entry));
name = (filter == null || name == null ? name
: filter.apply(name, entry));
}
if (name != null) {
JarEntryData filteredCopy = entry.createFilteredCopy(this, name);
@@ -291,8 +292,8 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
// Fallback to JarInputStream to obtain certificates, not fast but hopefully not
// happening that often.
try {
JarInputStream inputStream = new JarInputStream(getData().getInputStream(
ResourceAccess.ONCE));
JarInputStream inputStream = new JarInputStream(
getData().getInputStream(ResourceAccess.ONCE));
try {
java.util.jar.JarEntry entry = inputStream.getNextJarEntry();
while (entry != null) {
@@ -343,8 +344,8 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
return sourceEntry.nestedJar;
}
catch (IOException ex) {
throw new IOException("Unable to open nested jar file '"
+ sourceEntry.getName() + "'", ex);
throw new IOException(
"Unable to open nested jar file '" + sourceEntry.getName() + "'", ex);
}
}
@@ -367,9 +368,10 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
return null;
}
};
return new JarFile(this.rootFile, this.pathFromRoot + "!/"
+ sourceEntry.getName().substring(0, sourceName.length() - 1), this.data,
this.entries, filter);
return new JarFile(this.rootFile,
this.pathFromRoot + "!/"
+ sourceEntry.getName().substring(0, sourceName.length() - 1),
this.data, this.entries, filter);
}
private JarFile createJarFileFromFileEntry(JarEntryData sourceEntry)
@@ -380,8 +382,8 @@ public class JarFile extends java.util.jar.JarFile implements Iterable<JarEntryD
+ "jar files must be stored without compression. Please check the "
+ "mechanism used to create your executable jar file");
}
return new JarFile(this.rootFile, this.pathFromRoot + "!/"
+ sourceEntry.getName(), sourceEntry.getData());
return new JarFile(this.rootFile,
this.pathFromRoot + "!/" + sourceEntry.getName(), sourceEntry.getData());
}
/**

View File

@@ -101,8 +101,8 @@ class JarURLConnection extends java.net.JarURLConnection {
@Override
public void connect() throws IOException {
if (!this.jarEntryName.isEmpty()) {
this.jarEntryData = this.jarFile.getJarEntryData(this.jarEntryName
.asAsciiBytes());
this.jarEntryData = this.jarFile
.getJarEntryData(this.jarEntryName.asAsciiBytes());
if (this.jarEntryData == null) {
throwFileNotFound(this.jarEntryName, this.jarFile);
}
@@ -115,8 +115,8 @@ class JarURLConnection extends java.net.JarURLConnection {
if (Boolean.TRUE.equals(useFastExceptions.get())) {
throw FILE_NOT_FOUND_EXCEPTION;
}
throw new FileNotFoundException("JAR entry " + entry + " not found in "
+ jarFile.getName());
throw new FileNotFoundException(
"JAR entry " + entry + " not found in " + jarFile.getName());
}
@Override
@@ -247,8 +247,8 @@ class JarURLConnection extends java.net.JarURLConnection {
int hi = Character.digit(source.charAt(i + 1), 16);
int lo = Character.digit(source.charAt(i + 2), 16);
if (hi == -1 || lo == -1) {
throw new IllegalArgumentException("Invalid encoded sequence \""
+ source.substring(i) + "\"");
throw new IllegalArgumentException(
"Invalid encoded sequence \"" + source.substring(i) + "\"");
}
return ((char) ((hi << 4) + lo));
}

View File

@@ -101,8 +101,8 @@ public final class AsciiBytes {
return false;
}
for (int i = 0; i < postfix.length; i++) {
if (this.bytes[this.offset + (this.length - 1) - i] != postfix.bytes[postfix.offset
+ (postfix.length - 1) - i]) {
if (this.bytes[this.offset + (this.length - 1)
- i] != postfix.bytes[postfix.offset + (postfix.length - 1) - i]) {
return false;
}
}

View File

@@ -96,8 +96,8 @@ public abstract class SystemPropertyUtils {
while (startIndex != -1) {
int endIndex = findPlaceholderEndIndex(buf, startIndex);
if (endIndex != -1) {
String placeholder = buf.substring(
startIndex + PLACEHOLDER_PREFIX.length(), endIndex);
String placeholder = buf
.substring(startIndex + PLACEHOLDER_PREFIX.length(), endIndex);
String originalPlaceholder = placeholder;
if (!visitedPlaceholders.add(originalPlaceholder)) {
throw new IllegalArgumentException("Circular placeholder reference '"
@@ -115,9 +115,10 @@ public abstract class SystemPropertyUtils {
if (separatorIndex != -1) {
String actualPlaceholder = placeholder.substring(0,
separatorIndex);
String defaultValue = placeholder.substring(separatorIndex
+ VALUE_SEPARATOR.length());
propVal = resolvePlaceholder(properties, value, actualPlaceholder);
String defaultValue = placeholder
.substring(separatorIndex + VALUE_SEPARATOR.length());
propVal = resolvePlaceholder(properties, value,
actualPlaceholder);
if (propVal == null) {
propVal = defaultValue;
}
@@ -135,8 +136,8 @@ public abstract class SystemPropertyUtils {
}
else {
// Proceed with unprocessed value.
startIndex = buf.indexOf(PLACEHOLDER_PREFIX, endIndex
+ PLACEHOLDER_SUFFIX.length());
startIndex = buf.indexOf(PLACEHOLDER_PREFIX,
endIndex + PLACEHOLDER_SUFFIX.length());
}
visitedPlaceholders.remove(originalPlaceholder);
}

View File

@@ -90,8 +90,8 @@ public class ExecutableArchiveLauncherTests {
assertArrayEquals(urls, ((URLClassLoader) classLoader).getURLs());
}
private static final class UnitTestExecutableArchiveLauncher extends
ExecutableArchiveLauncher {
private static final class UnitTestExecutableArchiveLauncher
extends ExecutableArchiveLauncher {
public UnitTestExecutableArchiveLauncher(JavaAgentDetector javaAgentDetector) {
super(javaAgentDetector);
@@ -103,7 +103,8 @@ public class ExecutableArchiveLauncherTests {
}
}
private void doWithTccl(ClassLoader classLoader, Callable<?> action) throws Exception {
private void doWithTccl(ClassLoader classLoader, Callable<?> action)
throws Exception {
ClassLoader old = Thread.currentThread().getContextClassLoader();
try {
Thread.currentThread().setContextClassLoader(classLoader);

View File

@@ -34,38 +34,39 @@ import static org.junit.Assert.assertTrue;
public class InputArgumentsJavaAgentDetectorTests {
@Test
public void nonAgentJarsDoNotProduceFalsePositives() throws MalformedURLException,
IOException {
public void nonAgentJarsDoNotProduceFalsePositives()
throws MalformedURLException, IOException {
InputArgumentsJavaAgentDetector detector = new InputArgumentsJavaAgentDetector(
Arrays.asList("-javaagent:my-agent.jar"));
assertFalse(detector.isJavaAgentJar(new File("something-else.jar")
.getCanonicalFile().toURI().toURL()));
assertFalse(detector.isJavaAgentJar(
new File("something-else.jar").getCanonicalFile().toURI().toURL()));
}
@Test
public void singleJavaAgent() throws MalformedURLException, IOException {
InputArgumentsJavaAgentDetector detector = new InputArgumentsJavaAgentDetector(
Arrays.asList("-javaagent:my-agent.jar"));
assertTrue(detector.isJavaAgentJar(new File("my-agent.jar").getCanonicalFile()
.toURI().toURL()));
assertTrue(detector.isJavaAgentJar(
new File("my-agent.jar").getCanonicalFile().toURI().toURL()));
}
@Test
public void singleJavaAgentWithOptions() throws MalformedURLException, IOException {
InputArgumentsJavaAgentDetector detector = new InputArgumentsJavaAgentDetector(
Arrays.asList("-javaagent:my-agent.jar=a=alpha,b=bravo"));
assertTrue(detector.isJavaAgentJar(new File("my-agent.jar").getCanonicalFile()
.toURI().toURL()));
assertTrue(detector.isJavaAgentJar(
new File("my-agent.jar").getCanonicalFile().toURI().toURL()));
}
@Test
public void multipleJavaAgents() throws MalformedURLException, IOException {
InputArgumentsJavaAgentDetector detector = new InputArgumentsJavaAgentDetector(
Arrays.asList("-javaagent:my-agent.jar", "-javaagent:my-other-agent.jar"));
assertTrue(detector.isJavaAgentJar(new File("my-agent.jar").getCanonicalFile()
.toURI().toURL()));
assertTrue(detector.isJavaAgentJar(new File("my-other-agent.jar")
.getCanonicalFile().toURI().toURL()));
Arrays.asList("-javaagent:my-agent.jar",
"-javaagent:my-other-agent.jar"));
assertTrue(detector.isJavaAgentJar(
new File("my-agent.jar").getCanonicalFile().toURI().toURL()));
assertTrue(detector.isJavaAgentJar(
new File("my-other-agent.jar").getCanonicalFile().toURI().toURL()));
}
}

View File

@@ -46,44 +46,44 @@ public class LaunchedURLClassLoaderTests {
public void resolveResourceFromWindowsFilesystem() throws Exception {
// This path is invalid - it should return null even on Windows.
// A regular URLClassLoader will deal with it gracefully.
assertNull(getClass().getClassLoader().getResource(
"c:\\Users\\user\\bar.properties"));
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(new URL[] { new URL(
"jar:file:src/test/resources/jars/app.jar!/") }, getClass()
.getClassLoader());
assertNull(getClass().getClassLoader()
.getResource("c:\\Users\\user\\bar.properties"));
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(
new URL[] { new URL("jar:file:src/test/resources/jars/app.jar!/") },
getClass().getClassLoader());
// So we should too...
assertNull(loader.getResource("c:\\Users\\user\\bar.properties"));
}
@Test
public void resolveResourceFromArchive() throws Exception {
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(new URL[] { new URL(
"jar:file:src/test/resources/jars/app.jar!/") }, getClass()
.getClassLoader());
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(
new URL[] { new URL("jar:file:src/test/resources/jars/app.jar!/") },
getClass().getClassLoader());
assertNotNull(loader.getResource("demo/Application.java"));
}
@Test
public void resolveResourcesFromArchive() throws Exception {
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(new URL[] { new URL(
"jar:file:src/test/resources/jars/app.jar!/") }, getClass()
.getClassLoader());
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(
new URL[] { new URL("jar:file:src/test/resources/jars/app.jar!/") },
getClass().getClassLoader());
assertTrue(loader.getResources("demo/Application.java").hasMoreElements());
}
@Test
public void resolveRootPathFromArchive() throws Exception {
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(new URL[] { new URL(
"jar:file:src/test/resources/jars/app.jar!/") }, getClass()
.getClassLoader());
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(
new URL[] { new URL("jar:file:src/test/resources/jars/app.jar!/") },
getClass().getClassLoader());
assertNotNull(loader.getResource(""));
}
@Test
public void resolveRootResourcesFromArchive() throws Exception {
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(new URL[] { new URL(
"jar:file:src/test/resources/jars/app.jar!/") }, getClass()
.getClassLoader());
LaunchedURLClassLoader loader = new LaunchedURLClassLoader(
new URL[] { new URL("jar:file:src/test/resources/jars/app.jar!/") },
getClass().getClassLoader());
assertTrue(loader.getResources("").hasMoreElements());
}

View File

@@ -80,7 +80,8 @@ public class PropertiesLauncherTests {
System.setProperty("loader.config.name", "foo");
PropertiesLauncher launcher = new PropertiesLauncher();
assertEquals("my.Application", launcher.getMainClass());
assertEquals("[etc/]", ReflectionTestUtils.getField(launcher, "paths").toString());
assertEquals("[etc/]",
ReflectionTestUtils.getField(launcher, "paths").toString());
}
@Test
@@ -95,8 +96,8 @@ public class PropertiesLauncherTests {
System.setProperty("loader.path", "jars/*");
System.setProperty("loader.main", "demo.Application");
PropertiesLauncher launcher = new PropertiesLauncher();
assertEquals("[jars/]", ReflectionTestUtils.getField(launcher, "paths")
.toString());
assertEquals("[jars/]",
ReflectionTestUtils.getField(launcher, "paths").toString());
launcher.launch(new String[0]);
waitFor("Hello World");
}
@@ -106,8 +107,8 @@ public class PropertiesLauncherTests {
System.setProperty("loader.path", "jars/app.jar");
System.setProperty("loader.main", "demo.Application");
PropertiesLauncher launcher = new PropertiesLauncher();
assertEquals("[jars/app.jar]", ReflectionTestUtils.getField(launcher, "paths")
.toString());
assertEquals("[jars/app.jar]",
ReflectionTestUtils.getField(launcher, "paths").toString());
launcher.launch(new String[0]);
waitFor("Hello World");
}
@@ -117,8 +118,8 @@ public class PropertiesLauncherTests {
System.setProperty("loader.path", "./jars/app.jar");
System.setProperty("loader.main", "demo.Application");
PropertiesLauncher launcher = new PropertiesLauncher();
assertEquals("[jars/app.jar]", ReflectionTestUtils.getField(launcher, "paths")
.toString());
assertEquals("[jars/app.jar]",
ReflectionTestUtils.getField(launcher, "paths").toString());
launcher.launch(new String[0]);
waitFor("Hello World");
}
@@ -128,8 +129,8 @@ public class PropertiesLauncherTests {
System.setProperty("loader.path", "jars/app.jar");
System.setProperty("loader.classLoader", URLClassLoader.class.getName());
PropertiesLauncher launcher = new PropertiesLauncher();
assertEquals("[jars/app.jar]", ReflectionTestUtils.getField(launcher, "paths")
.toString());
assertEquals("[jars/app.jar]",
ReflectionTestUtils.getField(launcher, "paths").toString());
launcher.launch(new String[0]);
waitFor("Hello World");
}

View File

@@ -65,10 +65,8 @@ public class WarLauncherTests {
List<Archive> archives = launcher.getClassPathArchives();
assertEquals(2, archives.size());
assertThat(
getUrls(archives),
hasItems(webInfClasses.toURI().toURL(), new URL("jar:"
+ webInfLibFoo.toURI().toURL() + "!/")));
assertThat(getUrls(archives), hasItems(webInfClasses.toURI().toURL(),
new URL("jar:" + webInfLibFoo.toURI().toURL() + "!/")));
}
@Test
@@ -80,12 +78,10 @@ public class WarLauncherTests {
List<Archive> archives = launcher.getClassPathArchives();
assertEquals(2, archives.size());
assertThat(
getUrls(archives),
hasItems(
new URL("jar:" + warRoot.toURI().toURL() + "!/WEB-INF/classes!/"),
new URL("jar:" + warRoot.toURI().toURL()
+ "!/WEB-INF/lib/foo.jar!/")));
assertThat(getUrls(archives),
hasItems(new URL("jar:" + warRoot.toURI().toURL()
+ "!/WEB-INF/classes!/"),
new URL("jar:" + warRoot.toURI().toURL() + "!/WEB-INF/lib/foo.jar!/")));
}
private Set<URL> getUrls(List<Archive> archives) throws MalformedURLException {
@@ -100,8 +96,8 @@ public class WarLauncherTests {
File warRoot = new File("target/archive.war");
warRoot.delete();
JarOutputStream jarOutputStream = new JarOutputStream(new FileOutputStream(
warRoot));
JarOutputStream jarOutputStream = new JarOutputStream(
new FileOutputStream(warRoot));
jarOutputStream.putNextEntry(new JarEntry("WEB-INF/"));
jarOutputStream.putNextEntry(new JarEntry("WEB-INF/classes/"));

View File

@@ -69,8 +69,8 @@ public class ExplodedArchiveTests {
Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
File destination = new File(this.rootFolder.getAbsolutePath()
+ File.separator + entry.getName());
File destination = new File(
this.rootFolder.getAbsolutePath() + File.separator + entry.getName());
destination.getParentFile().mkdirs();
if (entry.isDirectory()) {
destination.mkdir();
@@ -115,8 +115,8 @@ public class ExplodedArchiveTests {
public void getNestedArchive() throws Exception {
Entry entry = getEntriesMap(this.archive).get("nested.jar");
Archive nested = this.archive.getNestedArchive(entry);
assertThat(nested.getUrl().toString(), equalTo("jar:" + this.rootFolder.toURI()
+ "nested.jar!/"));
assertThat(nested.getUrl().toString(),
equalTo("jar:" + this.rootFolder.toURI() + "nested.jar!/"));
}
@Test
@@ -125,8 +125,8 @@ public class ExplodedArchiveTests {
Archive nested = this.archive.getNestedArchive(entry);
Map<String, Entry> nestedEntries = getEntriesMap(nested);
assertThat(nestedEntries.size(), equalTo(1));
assertThat(nested.getUrl().toString(), equalTo("file:"
+ this.rootFolder.toURI().getPath() + "d/"));
assertThat(nested.getUrl().toString(),
equalTo("file:" + this.rootFolder.toURI().getPath() + "d/"));
}
@Test
@@ -159,7 +159,8 @@ public class ExplodedArchiveTests {
@Test
public void getNonRecursiveManifest() throws Exception {
ExplodedArchive archive = new ExplodedArchive(new File("src/test/resources/root"));
ExplodedArchive archive = new ExplodedArchive(
new File("src/test/resources/root"));
assertNotNull(archive.getManifest());
Map<String, Archive.Entry> entries = getEntriesMap(archive);
assertThat(entries.size(), equalTo(4));
@@ -167,8 +168,8 @@ public class ExplodedArchiveTests {
@Test
public void getNonRecursiveManifestEvenIfNonRecursive() throws Exception {
ExplodedArchive archive = new ExplodedArchive(
new File("src/test/resources/root"), false);
ExplodedArchive archive = new ExplodedArchive(new File("src/test/resources/root"),
false);
assertNotNull(archive.getManifest());
Map<String, Archive.Entry> entries = getEntriesMap(archive);
assertThat(entries.size(), equalTo(3));
@@ -176,7 +177,8 @@ public class ExplodedArchiveTests {
@Test
public void getResourceAsStream() throws Exception {
ExplodedArchive archive = new ExplodedArchive(new File("src/test/resources/root"));
ExplodedArchive archive = new ExplodedArchive(
new File("src/test/resources/root"));
assertNotNull(archive.getManifest());
URLClassLoader loader = new URLClassLoader(new URL[] { archive.getUrl() });
assertNotNull(loader.getResourceAsStream("META-INF/spring/application.xml"));
@@ -185,8 +187,8 @@ public class ExplodedArchiveTests {
@Test
public void getResourceAsStreamNonRecursive() throws Exception {
ExplodedArchive archive = new ExplodedArchive(
new File("src/test/resources/root"), false);
ExplodedArchive archive = new ExplodedArchive(new File("src/test/resources/root"),
false);
assertNotNull(archive.getManifest());
URLClassLoader loader = new URLClassLoader(new URL[] { archive.getUrl() });
assertNotNull(loader.getResourceAsStream("META-INF/spring/application.xml"));

View File

@@ -85,8 +85,8 @@ public class JarFileArchiveTests {
public void getNestedArchive() throws Exception {
Entry entry = getEntriesMap(this.archive).get("nested.jar");
Archive nested = this.archive.getNestedArchive(entry);
assertThat(nested.getUrl().toString(), equalTo("jar:" + this.rootJarFileUrl
+ "!/nested.jar!/"));
assertThat(nested.getUrl().toString(),
equalTo("jar:" + this.rootJarFileUrl + "!/nested.jar!/"));
}
@Test

View File

@@ -34,8 +34,8 @@ public class ByteArrayRandomAccessDataTests {
public void testGetInputStream() throws Exception {
byte[] bytes = new byte[] { 0, 1, 2, 3, 4, 5 };
RandomAccessData data = new ByteArrayRandomAccessData(bytes);
assertThat(FileCopyUtils.copyToByteArray(data
.getInputStream(ResourceAccess.PER_READ)), equalTo(bytes));
assertThat(FileCopyUtils.copyToByteArray(
data.getInputStream(ResourceAccess.PER_READ)), equalTo(bytes));
assertThat(data.getSize(), equalTo((long) bytes.length));
}
@@ -44,8 +44,10 @@ public class ByteArrayRandomAccessDataTests {
byte[] bytes = new byte[] { 0, 1, 2, 3, 4, 5 };
RandomAccessData data = new ByteArrayRandomAccessData(bytes);
data = data.getSubsection(1, 4).getSubsection(1, 2);
assertThat(FileCopyUtils.copyToByteArray(data
.getInputStream(ResourceAccess.PER_READ)), equalTo(new byte[] { 2, 3 }));
assertThat(
FileCopyUtils
.copyToByteArray(data.getInputStream(ResourceAccess.PER_READ)),
equalTo(new byte[] { 2, 3 }));
assertThat(data.getSize(), equalTo(2L));
}
}

View File

@@ -50,6 +50,7 @@ import static org.junit.Assert.assertThat;
public class RandomAccessDataFileTests {
private static final byte[] BYTES;
static {
BYTES = new byte[256];
for (int i = 0; i < BYTES.length; i++) {
@@ -212,7 +213,8 @@ public class RandomAccessDataFileTests {
@Test
public void subsectionZeroLength() throws Exception {
RandomAccessData subsection = this.file.getSubsection(0, 0);
assertThat(subsection.getInputStream(ResourceAccess.PER_READ).read(), equalTo(-1));
assertThat(subsection.getInputStream(ResourceAccess.PER_READ).read(),
equalTo(-1));
}
@Test

View File

@@ -152,8 +152,8 @@ public class JarFileTests {
@Test
public void getInputStream() throws Exception {
InputStream inputStream = this.jarFile.getInputStream(this.jarFile
.getEntry("1.dat"));
InputStream inputStream = this.jarFile
.getInputStream(this.jarFile.getEntry("1.dat"));
assertThat(inputStream.available(), equalTo(1));
assertThat(inputStream.read(), equalTo(1));
assertThat(inputStream.available(), equalTo(0));
@@ -180,8 +180,8 @@ public class JarFileTests {
@Test
public void close() throws Exception {
RandomAccessDataFile randomAccessDataFile = spy(new RandomAccessDataFile(
this.rootJarFile, 1));
RandomAccessDataFile randomAccessDataFile = spy(
new RandomAccessDataFile(this.rootJarFile, 1));
JarFile jarFile = new JarFile(randomAccessDataFile);
jarFile.close();
verify(randomAccessDataFile).close();
@@ -204,7 +204,8 @@ public class JarFileTests {
@Test
public void createEntryUrl() throws Exception {
URL url = new URL(this.jarFile.getUrl(), "1.dat");
assertThat(url.toString(), equalTo("jar:" + this.rootJarFile.toURI() + "!/1.dat"));
assertThat(url.toString(),
equalTo("jar:" + this.rootJarFile.toURI() + "!/1.dat"));
JarURLConnection jarURLConnection = (JarURLConnection) url.openConnection();
assertThat(jarURLConnection.getJarFile(), sameInstance(this.jarFile));
assertThat(jarURLConnection.getJarEntry(),
@@ -217,8 +218,8 @@ public class JarFileTests {
@Test
public void getMissingEntryUrl() throws Exception {
URL url = new URL(this.jarFile.getUrl(), "missing.dat");
assertThat(url.toString(), equalTo("jar:" + this.rootJarFile.toURI()
+ "!/missing.dat"));
assertThat(url.toString(),
equalTo("jar:" + this.rootJarFile.toURI() + "!/missing.dat"));
this.thrown.expect(FileNotFoundException.class);
((JarURLConnection) url.openConnection()).getJarEntry();
}
@@ -242,8 +243,8 @@ public class JarFileTests {
@Test
public void getNestedJarFile() throws Exception {
JarFile nestedJarFile = this.jarFile.getNestedJarFile(this.jarFile
.getEntry("nested.jar"));
JarFile nestedJarFile = this.jarFile
.getNestedJarFile(this.jarFile.getEntry("nested.jar"));
Enumeration<java.util.jar.JarEntry> entries = nestedJarFile.entries();
assertThat(entries.nextElement().getName(), equalTo("META-INF/"));
@@ -253,14 +254,14 @@ public class JarFileTests {
assertThat(entries.nextElement().getName(), equalTo("\u00E4.dat"));
assertThat(entries.hasMoreElements(), equalTo(false));
InputStream inputStream = nestedJarFile.getInputStream(nestedJarFile
.getEntry("3.dat"));
InputStream inputStream = nestedJarFile
.getInputStream(nestedJarFile.getEntry("3.dat"));
assertThat(inputStream.read(), equalTo(3));
assertThat(inputStream.read(), equalTo(-1));
URL url = nestedJarFile.getUrl();
assertThat(url.toString(), equalTo("jar:" + this.rootJarFile.toURI()
+ "!/nested.jar!/"));
assertThat(url.toString(),
equalTo("jar:" + this.rootJarFile.toURI() + "!/nested.jar!/"));
JarURLConnection conn = (JarURLConnection) url.openConnection();
assertThat(conn.getJarFile(), sameInstance(nestedJarFile));
assertThat(conn.getJarFileURL().toString(),
@@ -276,8 +277,8 @@ public class JarFileTests {
assertThat(entries.nextElement().getName(), equalTo("9.dat"));
assertThat(entries.hasMoreElements(), equalTo(false));
InputStream inputStream = nestedJarFile.getInputStream(nestedJarFile
.getEntry("9.dat"));
InputStream inputStream = nestedJarFile
.getInputStream(nestedJarFile.getEntry("9.dat"));
assertThat(inputStream.read(), equalTo(9));
assertThat(inputStream.read(), equalTo(-1));
@@ -289,11 +290,11 @@ public class JarFileTests {
@Test
public void getNestJarEntryUrl() throws Exception {
JarFile nestedJarFile = this.jarFile.getNestedJarFile(this.jarFile
.getEntry("nested.jar"));
JarFile nestedJarFile = this.jarFile
.getNestedJarFile(this.jarFile.getEntry("nested.jar"));
URL url = nestedJarFile.getJarEntry("3.dat").getUrl();
assertThat(url.toString(), equalTo("jar:" + this.rootJarFile.toURI()
+ "!/nested.jar!/3.dat"));
assertThat(url.toString(),
equalTo("jar:" + this.rootJarFile.toURI() + "!/nested.jar!/3.dat"));
InputStream inputStream = url.openStream();
assertThat(inputStream, notNullValue());
assertThat(inputStream.read(), equalTo(3));
@@ -310,8 +311,8 @@ public class JarFileTests {
assertThat(inputStream.read(), equalTo(3));
JarURLConnection connection = (JarURLConnection) url.openConnection();
assertThat(connection.getURL().toString(), equalTo(spec));
assertThat(connection.getJarFileURL().toString(), equalTo("jar:"
+ this.rootJarFile.toURI() + "!/nested.jar"));
assertThat(connection.getJarFileURL().toString(),
equalTo("jar:" + this.rootJarFile.toURI() + "!/nested.jar"));
assertThat(connection.getEntryName(), equalTo("3.dat"));
}
@@ -360,8 +361,8 @@ public class JarFileTests {
assertThat(entries.nextElement().getName(), equalTo("x.dat"));
assertThat(entries.hasMoreElements(), equalTo(false));
InputStream inputStream = filteredJarFile.getInputStream(filteredJarFile
.getEntry("x.dat"));
InputStream inputStream = filteredJarFile
.getInputStream(filteredJarFile.getEntry("x.dat"));
assertThat(inputStream.read(), equalTo(1));
assertThat(inputStream.read(), equalTo(-1));
}
@@ -369,8 +370,10 @@ public class JarFileTests {
@Test
public void sensibleToString() throws Exception {
assertThat(this.jarFile.toString(), equalTo(this.rootJarFile.getPath()));
assertThat(this.jarFile.getNestedJarFile(this.jarFile.getEntry("nested.jar"))
.toString(), equalTo(this.rootJarFile.getPath() + "!/nested.jar"));
assertThat(
this.jarFile.getNestedJarFile(this.jarFile.getEntry("nested.jar"))
.toString(),
equalTo(this.rootJarFile.getPath() + "!/nested.jar"));
}
@Test
@@ -418,8 +421,8 @@ public class JarFileTests {
@Test
public void cannotLoadMissingJar() throws Exception {
// relates to gh-1070
JarFile nestedJarFile = this.jarFile.getNestedJarFile(this.jarFile
.getEntry("nested.jar"));
JarFile nestedJarFile = this.jarFile
.getNestedJarFile(this.jarFile.getEntry("nested.jar"));
URL nestedUrl = nestedJarFile.getUrl();
URL url = new URL(nestedUrl, nestedJarFile.getUrl() + "missing.jar!/3.dat");
this.thrown.expect(FileNotFoundException.class);

View File

@@ -49,7 +49,8 @@ public class SystemPropertyUtilsTests {
@Test
public void testNestedPlaceholder() {
assertEquals("foo", SystemPropertyUtils.resolvePlaceholders("${bar:${spam:foo}}"));
assertEquals("foo",
SystemPropertyUtils.resolvePlaceholders("${bar:${spam:foo}}"));
}
@Test

View File

@@ -107,10 +107,10 @@ public abstract class AbstractDependencyFilterMojo extends AbstractMojo {
for (ArtifactsFilter additionalFilter : additionalFilters) {
filters.addFilter(additionalFilter);
}
filters.addFilter(new ArtifactIdFilter("",
cleanFilterConfig(this.excludeArtifactIds)));
filters.addFilter(new MatchingGroupIdFilter(
cleanFilterConfig(this.excludeGroupIds)));
filters.addFilter(
new ArtifactIdFilter("", cleanFilterConfig(this.excludeArtifactIds)));
filters.addFilter(
new MatchingGroupIdFilter(cleanFilterConfig(this.excludeGroupIds)));
if (this.includes != null && !this.includes.isEmpty()) {
filters.addFilter(new IncludeFilter(this.includes));
}

View File

@@ -41,6 +41,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
public class ArtifactsLibraries implements Libraries {
private static final Map<String, LibraryScope> SCOPES;
static {
Map<String, LibraryScope> scopes = new HashMap<String, LibraryScope>();
scopes.put(Artifact.SCOPE_COMPILE, LibraryScope.COMPILE);

View File

@@ -65,8 +65,8 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer
String name = (String) key;
String value = properties.getProperty(name);
String existing = this.data.getProperty(name);
this.data
.setProperty(name, existing == null ? value : existing + "," + value);
this.data.setProperty(name,
existing == null ? value : existing + "," + value);
}
}

View File

@@ -147,10 +147,9 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
finally {
long duration = System.currentTimeMillis() - startTime;
if (duration > FIND_WARNING_TIMEOUT) {
getLog().warn(
"Searching for the main-class is taking some time, "
+ "consider using the mainClass configuration "
+ "parameter");
getLog().warn("Searching for the main-class is taking some time, "
+ "consider using the mainClass configuration "
+ "parameter");
}
}
}
@@ -173,9 +172,8 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
throw new MojoExecutionException(ex.getMessage(), ex);
}
if (!source.equals(target)) {
getLog().info(
"Attaching archive: " + target + ", with classifier: "
+ this.classifier);
getLog().info("Attaching archive: " + target + ", with classifier: "
+ this.classifier);
this.projectHelper.attachArtifact(this.project, this.project.getPackaging(),
this.classifier, target);
}

View File

@@ -43,8 +43,8 @@ class RunArguments {
return CommandLineUtils.translateCommandline(arguments);
}
catch (Exception ex) {
throw new IllegalArgumentException("Failed to parse arguments [" + arguments
+ "]", ex);
throw new IllegalArgumentException(
"Failed to parse arguments [" + arguments + "]", ex);
}
}

View File

@@ -154,7 +154,8 @@ public class RunMojo extends AbstractDependencyFilterMojo {
}
CodeSource source = loaded.getProtectionDomain().getCodeSource();
if (source != null) {
this.agent = new File[] { new File(source.getLocation().getFile()) };
this.agent = new File[] {
new File(source.getLocation().getFile()) };
}
}
}
@@ -170,7 +171,8 @@ public class RunMojo extends AbstractDependencyFilterMojo {
private void run(String startClassName) throws MojoExecutionException {
findAgent();
boolean hasAgent = (this.agent != null && this.agent.length > 0);
boolean hasJvmArgs = (this.jvmArguments != null && this.jvmArguments.length() > 0);
boolean hasJvmArgs = (this.jvmArguments != null
&& this.jvmArguments.length() > 0);
if (Boolean.TRUE.equals(this.fork)
|| (this.fork == null && (hasAgent || hasJvmArgs))) {
runWithForkedJvm(startClassName);
@@ -180,9 +182,8 @@ public class RunMojo extends AbstractDependencyFilterMojo {
getLog().warn("Fork mode disabled, ignoring agent");
}
if (hasJvmArgs) {
getLog().warn(
"Fork mode disabled, ignoring JVM argument(s) ["
+ this.jvmArguments + "]");
getLog().warn("Fork mode disabled, ignoring JVM argument(s) ["
+ this.jvmArguments + "]");
}
runWithMavenJvm(startClassName);
}
@@ -196,8 +197,8 @@ public class RunMojo extends AbstractDependencyFilterMojo {
args.add(startClassName);
addArgs(args);
try {
new RunProcess(new JavaExecutable().toString()).run(args
.toArray(new String[args.size()]));
new RunProcess(new JavaExecutable().toString())
.run(args.toArray(new String[args.size()]));
}
catch (Exception ex) {
throw new MojoExecutionException("Could not exec java", ex);
@@ -206,8 +207,9 @@ public class RunMojo extends AbstractDependencyFilterMojo {
private void runWithMavenJvm(String startClassName) throws MojoExecutionException {
IsolatedThreadGroup threadGroup = new IsolatedThreadGroup(startClassName);
Thread launchThread = new Thread(threadGroup, new LaunchRunner(startClassName,
this.arguments), startClassName + ".main()");
Thread launchThread = new Thread(threadGroup,
new LaunchRunner(startClassName, this.arguments),
startClassName + ".main()");
launchThread.setContextClassLoader(new URLClassLoader(getClassPathUrls()));
launchThread.start();
join(threadGroup);
@@ -236,8 +238,9 @@ public class RunMojo extends AbstractDependencyFilterMojo {
try {
StringBuilder classpath = new StringBuilder();
for (URL ele : getClassPathUrls()) {
classpath = classpath.append((classpath.length() > 0 ? File.pathSeparator
: "") + new File(ele.toURI()));
classpath = classpath
.append((classpath.length() > 0 ? File.pathSeparator : "")
+ new File(ele.toURI()));
}
getLog().debug("Classpath for forked process: " + classpath);
args.add("-cp");
@@ -310,10 +313,11 @@ public class RunMojo extends AbstractDependencyFilterMojo {
urls.add(this.classesDirectory.toURI().toURL());
}
private void addDependencies(List<URL> urls) throws MalformedURLException,
MojoExecutionException {
private void addDependencies(List<URL> urls)
throws MalformedURLException, MojoExecutionException {
FilterArtifacts filters = getFilters(new TestArtifactFilter());
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(), filters);
Set<Artifact> artifacts = filterDependencies(this.project.getArtifacts(),
filters);
for (Artifact artifact : artifacts) {
if (artifact.getFile() != null) {
urls.add(artifact.getFile().toURI().toURL());
@@ -382,7 +386,8 @@ public class RunMojo extends AbstractDependencyFilterMojo {
}
}
public synchronized void rethrowUncaughtException() throws MojoExecutionException {
public synchronized void rethrowUncaughtException()
throws MojoExecutionException {
if (this.exception != null) {
throw new MojoExecutionException("An exception occured while running. "
+ this.exception.getMessage(), this.exception);
@@ -420,7 +425,8 @@ public class RunMojo extends AbstractDependencyFilterMojo {
catch (NoSuchMethodException ex) {
Exception wrappedEx = new Exception(
"The specified mainClass doesn't contain a "
+ "main method with appropriate signature.", ex);
+ "main method with appropriate signature.",
ex);
thread.getThreadGroup().uncaughtException(thread, wrappedEx);
}
catch (Exception ex) {

View File

@@ -72,8 +72,8 @@ public class DependencyFilterMojoTests {
return a;
}
private static class TestableDependencyFilterMojo extends
AbstractDependencyFilterMojo {
private static class TestableDependencyFilterMojo
extends AbstractDependencyFilterMojo {
private TestableDependencyFilterMojo(List<Exclude> excludes,
String excludeGroupIds, String excludeArtifactIds) {

View File

@@ -41,17 +41,17 @@ public class ExcludeFilterTests {
@Test
public void excludeSimple() throws ArtifactFilterException {
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo",
"bar")));
Set result = filter.filter(Collections
.singleton(createArtifact("com.foo", "bar")));
ExcludeFilter filter = new ExcludeFilter(
Arrays.asList(createExclude("com.foo", "bar")));
Set result = filter
.filter(Collections.singleton(createArtifact("com.foo", "bar")));
assertEquals("Should have been filtered", 0, result.size());
}
@Test
public void excludeGroupIdNoMatch() throws ArtifactFilterException {
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo",
"bar")));
ExcludeFilter filter = new ExcludeFilter(
Arrays.asList(createExclude("com.foo", "bar")));
Artifact artifact = createArtifact("com.baz", "bar");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should not have been filtered", 1, result.size());
@@ -60,8 +60,8 @@ public class ExcludeFilterTests {
@Test
public void excludeArtifactIdNoMatch() throws ArtifactFilterException {
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo",
"bar")));
ExcludeFilter filter = new ExcludeFilter(
Arrays.asList(createExclude("com.foo", "bar")));
Artifact artifact = createArtifact("com.foo", "biz");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should not have been filtered", 1, result.size());
@@ -70,17 +70,17 @@ public class ExcludeFilterTests {
@Test
public void excludeClassifier() throws ArtifactFilterException {
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo",
"bar", "jdk5")));
Set result = filter.filter(Collections.singleton(createArtifact("com.foo", "bar",
"jdk5")));
ExcludeFilter filter = new ExcludeFilter(
Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
Set result = filter
.filter(Collections.singleton(createArtifact("com.foo", "bar", "jdk5")));
assertEquals("Should have been filtered", 0, result.size());
}
@Test
public void excludeClassifierNoTargetClassifier() throws ArtifactFilterException {
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo",
"bar", "jdk5")));
ExcludeFilter filter = new ExcludeFilter(
Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
Artifact artifact = createArtifact("com.foo", "bar");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should not have been filtered", 1, result.size());
@@ -89,8 +89,8 @@ public class ExcludeFilterTests {
@Test
public void excludeClassifierNoMatch() throws ArtifactFilterException {
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(createExclude("com.foo",
"bar", "jdk5")));
ExcludeFilter filter = new ExcludeFilter(
Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
Artifact artifact = createArtifact("com.foo", "bar", "jdk6");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should not have been filtered", 1, result.size());
@@ -126,7 +126,8 @@ public class ExcludeFilterTests {
return exclude;
}
private Artifact createArtifact(String groupId, String artifactId, String classifier) {
private Artifact createArtifact(String groupId, String artifactId,
String classifier) {
Artifact a = mock(Artifact.class);
given(a.getGroupId()).willReturn(groupId);
given(a.getArtifactId()).willReturn(artifactId);

View File

@@ -39,8 +39,8 @@ public class IncludeFilterTests {
@Test
public void includeSimple() throws ArtifactFilterException {
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo",
"bar")));
IncludeFilter filter = new IncludeFilter(
Arrays.asList(createInclude("com.foo", "bar")));
Artifact artifact = createArtifact("com.foo", "bar");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should not have been filtered", 1, result.size());
@@ -49,8 +49,8 @@ public class IncludeFilterTests {
@Test
public void includeGroupIdNoMatch() throws ArtifactFilterException {
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo",
"bar")));
IncludeFilter filter = new IncludeFilter(
Arrays.asList(createInclude("com.foo", "bar")));
Artifact artifact = createArtifact("com.baz", "bar");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should have been filtered", 0, result.size());
@@ -58,8 +58,8 @@ public class IncludeFilterTests {
@Test
public void includeArtifactIdNoMatch() throws ArtifactFilterException {
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo",
"bar")));
IncludeFilter filter = new IncludeFilter(
Arrays.asList(createInclude("com.foo", "bar")));
Artifact artifact = createArtifact("com.foo", "biz");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should have been filtered", 0, result.size());
@@ -67,8 +67,8 @@ public class IncludeFilterTests {
@Test
public void includeClassifier() throws ArtifactFilterException {
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo",
"bar", "jdk5")));
IncludeFilter filter = new IncludeFilter(
Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
Artifact artifact = createArtifact("com.foo", "bar", "jdk5");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should not have been filtered", 1, result.size());
@@ -77,8 +77,8 @@ public class IncludeFilterTests {
@Test
public void includeClassifierNoTargetClassifier() throws ArtifactFilterException {
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo",
"bar", "jdk5")));
IncludeFilter filter = new IncludeFilter(
Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
Artifact artifact = createArtifact("com.foo", "bar");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should have been filtered", 0, result.size());
@@ -86,8 +86,8 @@ public class IncludeFilterTests {
@Test
public void includeClassifierNoMatch() throws ArtifactFilterException {
IncludeFilter filter = new IncludeFilter(Arrays.asList(createInclude("com.foo",
"bar", "jdk5")));
IncludeFilter filter = new IncludeFilter(
Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
Artifact artifact = createArtifact("com.foo", "bar", "jdk6");
Set result = filter.filter(Collections.singleton(artifact));
assertEquals("Should have been filtered", 0, result.size());
@@ -121,7 +121,8 @@ public class IncludeFilterTests {
return include;
}
private Artifact createArtifact(String groupId, String artifactId, String classifier) {
private Artifact createArtifact(String groupId, String artifactId,
String classifier) {
Artifact a = mock(Artifact.class);
given(a.getGroupId()).willReturn(groupId);
given(a.getArtifactId()).willReturn(artifactId);

View File

@@ -44,7 +44,8 @@ public class RunArgumentsTests {
@Test
public void parseDebugFlags() {
String[] args = parseArgs("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
String[] args = parseArgs(
"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
assertEquals(2, args.length);
assertEquals("-Xdebug", args[0]);
assertEquals("-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005",

View File

@@ -118,8 +118,8 @@ public class Verify {
return entry.getValue();
}
}
throw new IllegalStateException("Unable to find entry starting with "
+ entryName);
throw new IllegalStateException(
"Unable to find entry starting with " + entryName);
}
public boolean hasEntry(String entry) {
@@ -191,16 +191,16 @@ public class Verify {
verifier.assertHasEntryNameStartingWith("lib/spring-context");
verifier.assertHasEntryNameStartingWith("lib/spring-core");
verifier.assertHasEntryNameStartingWith("lib/javax.servlet-api-3");
assertTrue("Unpacked launcher classes", verifier.hasEntry("org/"
+ "springframework/boot/loader/JarLauncher.class"));
assertTrue("Own classes", verifier.hasEntry("org/"
+ "test/SampleApplication.class"));
assertTrue("Unpacked launcher classes", verifier
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"));
assertTrue("Own classes",
verifier.hasEntry("org/" + "test/SampleApplication.class"));
}
@Override
protected void verifyManifest(Manifest manifest) throws Exception {
assertEquals("org.springframework.boot.loader.JarLauncher", manifest
.getMainAttributes().getValue("Main-Class"));
assertEquals("org.springframework.boot.loader.JarLauncher",
manifest.getMainAttributes().getValue("Main-Class"));
assertEquals(this.main, manifest.getMainAttributes().getValue("Start-Class"));
assertEquals("Foo", manifest.getMainAttributes().getValue("Not-Used"));
}
@@ -217,20 +217,21 @@ public class Verify {
super.verifyZipEntries(verifier);
verifier.assertHasEntryNameStartingWith("WEB-INF/lib/spring-context");
verifier.assertHasEntryNameStartingWith("WEB-INF/lib/spring-core");
verifier.assertHasEntryNameStartingWith("WEB-INF/lib-provided/javax.servlet-api-3");
assertTrue("Unpacked launcher classes", verifier.hasEntry("org/"
+ "springframework/boot/loader/JarLauncher.class"));
assertTrue("Own classes", verifier.hasEntry("WEB-INF/classes/org/"
+ "test/SampleApplication.class"));
verifier.assertHasEntryNameStartingWith(
"WEB-INF/lib-provided/javax.servlet-api-3");
assertTrue("Unpacked launcher classes", verifier
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"));
assertTrue("Own classes", verifier
.hasEntry("WEB-INF/classes/org/" + "test/SampleApplication.class"));
assertTrue("Web content", verifier.hasEntry("index.html"));
}
@Override
protected void verifyManifest(Manifest manifest) throws Exception {
assertEquals("org.springframework.boot.loader.WarLauncher", manifest
.getMainAttributes().getValue("Main-Class"));
assertEquals("org.test.SampleApplication", manifest.getMainAttributes()
.getValue("Start-Class"));
assertEquals("org.springframework.boot.loader.WarLauncher",
manifest.getMainAttributes().getValue("Main-Class"));
assertEquals("org.test.SampleApplication",
manifest.getMainAttributes().getValue("Start-Class"));
assertEquals("Foo", manifest.getMainAttributes().getValue("Not-Used"));
}
}
@@ -243,10 +244,10 @@ public class Verify {
@Override
protected void verifyManifest(Manifest manifest) throws Exception {
assertEquals("org.springframework.boot.loader.PropertiesLauncher", manifest
.getMainAttributes().getValue("Main-Class"));
assertEquals("org.test.SampleApplication", manifest.getMainAttributes()
.getValue("Start-Class"));
assertEquals("org.springframework.boot.loader.PropertiesLauncher",
manifest.getMainAttributes().getValue("Main-Class"));
assertEquals("org.test.SampleApplication",
manifest.getMainAttributes().getValue("Start-Class"));
assertEquals("Foo", manifest.getMainAttributes().getValue("Not-Used"));
}
}
@@ -263,10 +264,10 @@ public class Verify {
verifier.assertHasEntryNameStartingWith("lib/spring-context");
verifier.assertHasEntryNameStartingWith("lib/spring-core");
verifier.assertHasNoEntryNameStartingWith("lib/javax.servlet-api-3");
assertFalse("Unpacked launcher classes", verifier.hasEntry("org/"
+ "springframework/boot/loader/JarLauncher.class"));
assertTrue("Own classes", verifier.hasEntry("org/"
+ "test/SampleModule.class"));
assertFalse("Unpacked launcher classes", verifier
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"));
assertTrue("Own classes",
verifier.hasEntry("org/" + "test/SampleModule.class"));
}
@Override