Relocate projects to spring-boot-project
Move projects to better reflect the way that Spring Boot is released. The following projects are under `spring-boot-project`: - `spring-boot` - `spring-boot-autoconfigure` - `spring-boot-tools` - `spring-boot-starters` - `spring-boot-actuator` - `spring-boot-actuator-autoconfigure` - `spring-boot-test` - `spring-boot-test-autoconfigure` - `spring-boot-devtools` - `spring-boot-cli` - `spring-boot-docs` See gh-9316
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.handler.ArtifactHandler;
|
||||
import org.apache.maven.model.Dependency;
|
||||
import org.apache.maven.plugin.logging.Log;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Captor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
import org.springframework.boot.loader.tools.Library;
|
||||
import org.springframework.boot.loader.tools.LibraryCallback;
|
||||
import org.springframework.boot.loader.tools.LibraryScope;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
/**
|
||||
* Tests for {@link ArtifactsLibraries}.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class ArtifactsLibrariesTests {
|
||||
|
||||
@Mock
|
||||
private Artifact artifact;
|
||||
|
||||
@Mock
|
||||
private ArtifactHandler artifactHandler;
|
||||
|
||||
private Set<Artifact> artifacts;
|
||||
|
||||
private File file = new File(".");
|
||||
|
||||
private ArtifactsLibraries libs;
|
||||
|
||||
@Mock
|
||||
private LibraryCallback callback;
|
||||
|
||||
@Captor
|
||||
private ArgumentCaptor<Library> libraryCaptor;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
this.artifacts = Collections.singleton(this.artifact);
|
||||
this.libs = new ArtifactsLibraries(this.artifacts, null, mock(Log.class));
|
||||
given(this.artifact.getFile()).willReturn(this.file);
|
||||
given(this.artifactHandler.getExtension()).willReturn("jar");
|
||||
given(this.artifact.getArtifactHandler()).willReturn(this.artifactHandler);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callbackForJars() throws Exception {
|
||||
given(this.artifact.getType()).willReturn("jar");
|
||||
given(this.artifact.getScope()).willReturn("compile");
|
||||
this.libs.doWithLibraries(this.callback);
|
||||
verify(this.callback).library(this.libraryCaptor.capture());
|
||||
Library library = this.libraryCaptor.getValue();
|
||||
assertThat(library.getFile()).isEqualTo(this.file);
|
||||
assertThat(library.getScope()).isEqualTo(LibraryScope.COMPILE);
|
||||
assertThat(library.isUnpackRequired()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callbackWithUnpack() throws Exception {
|
||||
given(this.artifact.getGroupId()).willReturn("gid");
|
||||
given(this.artifact.getArtifactId()).willReturn("aid");
|
||||
given(this.artifact.getType()).willReturn("jar");
|
||||
given(this.artifact.getScope()).willReturn("compile");
|
||||
Dependency unpack = new Dependency();
|
||||
unpack.setGroupId("gid");
|
||||
unpack.setArtifactId("aid");
|
||||
this.libs = new ArtifactsLibraries(this.artifacts, Collections.singleton(unpack),
|
||||
mock(Log.class));
|
||||
this.libs.doWithLibraries(this.callback);
|
||||
verify(this.callback).library(this.libraryCaptor.capture());
|
||||
assertThat(this.libraryCaptor.getValue().isUnpackRequired()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renamesDuplicates() throws Exception {
|
||||
Artifact artifact1 = mock(Artifact.class);
|
||||
Artifact artifact2 = mock(Artifact.class);
|
||||
given(artifact1.getType()).willReturn("jar");
|
||||
given(artifact1.getScope()).willReturn("compile");
|
||||
given(artifact1.getGroupId()).willReturn("g1");
|
||||
given(artifact1.getArtifactId()).willReturn("artifact");
|
||||
given(artifact1.getBaseVersion()).willReturn("1.0");
|
||||
given(artifact1.getFile()).willReturn(new File("a"));
|
||||
given(artifact1.getArtifactHandler()).willReturn(this.artifactHandler);
|
||||
given(artifact2.getType()).willReturn("jar");
|
||||
given(artifact2.getScope()).willReturn("compile");
|
||||
given(artifact2.getGroupId()).willReturn("g2");
|
||||
given(artifact2.getArtifactId()).willReturn("artifact");
|
||||
given(artifact2.getBaseVersion()).willReturn("1.0");
|
||||
given(artifact2.getFile()).willReturn(new File("a"));
|
||||
given(artifact2.getArtifactHandler()).willReturn(this.artifactHandler);
|
||||
this.artifacts = new LinkedHashSet<>(Arrays.asList(artifact1, artifact2));
|
||||
this.libs = new ArtifactsLibraries(this.artifacts, null, mock(Log.class));
|
||||
this.libs.doWithLibraries(this.callback);
|
||||
verify(this.callback, times(2)).library(this.libraryCaptor.capture());
|
||||
assertThat(this.libraryCaptor.getAllValues().get(0).getName())
|
||||
.isEqualTo("g1-artifact-1.0.jar");
|
||||
assertThat(this.libraryCaptor.getAllValues().get(1).getName())
|
||||
.isEqualTo("g2-artifact-1.0.jar");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.apache.maven.shared.artifact.filter.collection.ArtifactsFilter;
|
||||
import org.apache.maven.shared.artifact.filter.collection.ScopeFilter;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link AbstractDependencyFilterMojo}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class DependencyFilterMojoTests {
|
||||
|
||||
@Test
|
||||
public void filterDependencies() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.<Exclude>emptyList(), "com.foo", "exclude-id");
|
||||
|
||||
Artifact artifact = createArtifact("com.bar", "one");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(
|
||||
createArtifact("com.foo", "one"), createArtifact("com.foo", "two"),
|
||||
createArtifact("com.bar", "exclude-id"), artifact);
|
||||
assertThat(artifacts).hasSize(1);
|
||||
assertThat(artifacts.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterGroupIdExactMatch() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.<Exclude>emptyList(), "com.foo", "");
|
||||
|
||||
Artifact artifact = createArtifact("com.foo.bar", "one");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(
|
||||
createArtifact("com.foo", "one"), createArtifact("com.foo", "two"),
|
||||
artifact);
|
||||
assertThat(artifacts).hasSize(1);
|
||||
assertThat(artifacts.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterScopeKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.<Exclude>emptyList(), "", "",
|
||||
new ScopeFilter(null, Artifact.SCOPE_SYSTEM));
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.foo", "two", Artifact.SCOPE_SYSTEM);
|
||||
Artifact three = createArtifact("com.foo", "three", Artifact.SCOPE_RUNTIME);
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(one, two, three);
|
||||
assertThat(artifacts).containsExactly(one, three);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterArtifactIdKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.<Exclude>emptyList(), "", "one,three");
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.foo", "two");
|
||||
Artifact three = createArtifact("com.foo", "three");
|
||||
Artifact four = createArtifact("com.foo", "four");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(one, two, three, four);
|
||||
assertThat(artifacts).containsExactly(two, four);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterGroupIdKeepOrder() throws MojoExecutionException {
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.<Exclude>emptyList(), "com.foo", "");
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.bar", "two");
|
||||
Artifact three = createArtifact("com.bar", "three");
|
||||
Artifact four = createArtifact("com.foo", "four");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(one, two, three, four);
|
||||
assertThat(artifacts).containsExactly(two, three);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void filterExcludeKeepOrder() throws MojoExecutionException {
|
||||
Exclude exclude = new Exclude();
|
||||
exclude.setGroupId("com.bar");
|
||||
exclude.setArtifactId("two");
|
||||
TestableDependencyFilterMojo mojo = new TestableDependencyFilterMojo(
|
||||
Collections.singletonList(exclude), "", "");
|
||||
Artifact one = createArtifact("com.foo", "one");
|
||||
Artifact two = createArtifact("com.bar", "two");
|
||||
Artifact three = createArtifact("com.bar", "three");
|
||||
Artifact four = createArtifact("com.foo", "four");
|
||||
Set<Artifact> artifacts = mojo.filterDependencies(one, two, three, four);
|
||||
assertThat(artifacts).containsExactly(one, three, four);
|
||||
}
|
||||
|
||||
private static Artifact createArtifact(String groupId, String artifactId) {
|
||||
return createArtifact(groupId, artifactId, null);
|
||||
}
|
||||
|
||||
private static Artifact createArtifact(String groupId, String artifactId,
|
||||
String scope) {
|
||||
Artifact a = mock(Artifact.class);
|
||||
given(a.getGroupId()).willReturn(groupId);
|
||||
given(a.getArtifactId()).willReturn(artifactId);
|
||||
if (scope != null) {
|
||||
given(a.getScope()).willReturn(scope);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
||||
private static final class TestableDependencyFilterMojo
|
||||
extends AbstractDependencyFilterMojo {
|
||||
|
||||
private final ArtifactsFilter[] additionalFilters;
|
||||
|
||||
private TestableDependencyFilterMojo(List<Exclude> excludes,
|
||||
String excludeGroupIds, String excludeArtifactIds,
|
||||
ArtifactsFilter... additionalFilters) {
|
||||
setExcludes(excludes);
|
||||
setExcludeGroupIds(excludeGroupIds);
|
||||
setExcludeArtifactIds(excludeArtifactIds);
|
||||
this.additionalFilters = additionalFilters;
|
||||
}
|
||||
|
||||
public Set<Artifact> filterDependencies(Artifact... artifacts)
|
||||
throws MojoExecutionException {
|
||||
Set<Artifact> input = new LinkedHashSet<>(Arrays.asList(artifacts));
|
||||
return filterDependencies(input, getFilters(this.additionalFilters));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() throws MojoExecutionException, MojoFailureException {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link ExcludeFilter}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
* @author David Turanski
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
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")));
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeGroupIdNoMatch() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(
|
||||
Arrays.asList(createExclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.baz", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeArtifactIdNoMatch() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(
|
||||
Arrays.asList(createExclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.foo", "biz");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@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")));
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeClassifierNoTargetClassifier() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(
|
||||
Arrays.asList(createExclude("com.foo", "bar", "jdk5")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeClassifierNoMatch() throws ArtifactFilterException {
|
||||
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));
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void excludeMulti() throws ArtifactFilterException {
|
||||
ExcludeFilter filter = new ExcludeFilter(Arrays.asList(
|
||||
createExclude("com.foo", "bar"), createExclude("com.foo", "bar2"),
|
||||
createExclude("org.acme", "app")));
|
||||
Set<Artifact> artifacts = new HashSet<>();
|
||||
artifacts.add(createArtifact("com.foo", "bar"));
|
||||
artifacts.add(createArtifact("com.foo", "bar"));
|
||||
Artifact anotherAcme = createArtifact("org.acme", "another-app");
|
||||
artifacts.add(anotherAcme);
|
||||
Set result = filter.filter(artifacts);
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.iterator().next()).isSameAs(anotherAcme);
|
||||
}
|
||||
|
||||
private Exclude createExclude(String groupId, String artifactId) {
|
||||
return createExclude(groupId, artifactId, null);
|
||||
}
|
||||
|
||||
private Exclude createExclude(String groupId, String artifactId, String classifier) {
|
||||
Exclude exclude = new Exclude();
|
||||
exclude.setGroupId(groupId);
|
||||
exclude.setArtifactId(artifactId);
|
||||
if (classifier != null) {
|
||||
exclude.setClassifier(classifier);
|
||||
}
|
||||
return exclude;
|
||||
}
|
||||
|
||||
private Artifact createArtifact(String groupId, String artifactId,
|
||||
String classifier) {
|
||||
Artifact a = mock(Artifact.class);
|
||||
given(a.getGroupId()).willReturn(groupId);
|
||||
given(a.getArtifactId()).willReturn(artifactId);
|
||||
given(a.getClassifier()).willReturn(classifier);
|
||||
return a;
|
||||
}
|
||||
|
||||
private Artifact createArtifact(String groupId, String artifactId) {
|
||||
return createArtifact(groupId, artifactId, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* Tests for {@link org.springframework.boot.maven.IncludeFilter}.
|
||||
*
|
||||
* @author David Turanski
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public class IncludeFilterTests {
|
||||
|
||||
@Test
|
||||
public void includeSimple() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeGroupIdNoMatch() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.baz", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeArtifactIdNoMatch() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar")));
|
||||
Artifact artifact = createArtifact("com.foo", "biz");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeClassifier() throws ArtifactFilterException {
|
||||
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));
|
||||
assertThat(result).hasSize(1);
|
||||
assertThat(result.iterator().next()).isSameAs(artifact);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeClassifierNoTargetClassifier() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(
|
||||
Arrays.asList(createInclude("com.foo", "bar", "jdk5")));
|
||||
Artifact artifact = createArtifact("com.foo", "bar");
|
||||
Set result = filter.filter(Collections.singleton(artifact));
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeClassifierNoMatch() throws ArtifactFilterException {
|
||||
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));
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void includeMulti() throws ArtifactFilterException {
|
||||
IncludeFilter filter = new IncludeFilter(Arrays.asList(
|
||||
createInclude("com.foo", "bar"), createInclude("com.foo", "bar2"),
|
||||
createInclude("org.acme", "app")));
|
||||
Set<Artifact> artifacts = new HashSet<>();
|
||||
artifacts.add(createArtifact("com.foo", "bar"));
|
||||
artifacts.add(createArtifact("com.foo", "bar"));
|
||||
Artifact anotherAcme = createArtifact("org.acme", "another-app");
|
||||
artifacts.add(anotherAcme);
|
||||
Set result = filter.filter(artifacts);
|
||||
assertThat(result).hasSize(2);
|
||||
}
|
||||
|
||||
private Include createInclude(String groupId, String artifactId) {
|
||||
return createInclude(groupId, artifactId, null);
|
||||
}
|
||||
|
||||
private Include createInclude(String groupId, String artifactId, String classifier) {
|
||||
Include include = new Include();
|
||||
include.setGroupId(groupId);
|
||||
include.setArtifactId(artifactId);
|
||||
if (classifier != null) {
|
||||
include.setClassifier(classifier);
|
||||
}
|
||||
return include;
|
||||
}
|
||||
|
||||
private Artifact createArtifact(String groupId, String artifactId,
|
||||
String classifier) {
|
||||
Artifact a = mock(Artifact.class);
|
||||
given(a.getGroupId()).willReturn(groupId);
|
||||
given(a.getArtifactId()).willReturn(artifactId);
|
||||
given(a.getClassifier()).willReturn(classifier);
|
||||
return a;
|
||||
}
|
||||
|
||||
private Artifact createArtifact(String groupId, String artifactId) {
|
||||
return createArtifact(groupId, artifactId, null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.util.jar.JarOutputStream;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link PropertiesMergingResourceTransformer}.
|
||||
*
|
||||
* @author Dave Syer
|
||||
*/
|
||||
public class PropertiesMergingResourceTransformerTests {
|
||||
|
||||
private final PropertiesMergingResourceTransformer transformer = new PropertiesMergingResourceTransformer();
|
||||
|
||||
@Test
|
||||
public void testProcess() throws Exception {
|
||||
assertThat(this.transformer.hasTransformedResource()).isFalse();
|
||||
this.transformer.processResource("foo",
|
||||
new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
assertThat(this.transformer.hasTransformedResource()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMerge() throws Exception {
|
||||
this.transformer.processResource("foo",
|
||||
new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
this.transformer.processResource("bar",
|
||||
new ByteArrayInputStream("foo=spam".getBytes()), null);
|
||||
assertThat(this.transformer.getData().getProperty("foo")).isEqualTo("bar,spam");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOutput() throws Exception {
|
||||
this.transformer.setResource("foo");
|
||||
this.transformer.processResource("foo",
|
||||
new ByteArrayInputStream("foo=bar".getBytes()), null);
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
JarOutputStream os = new JarOutputStream(out);
|
||||
this.transformer.modifyOutputStream(os);
|
||||
os.flush();
|
||||
os.close();
|
||||
assertThat(out.toByteArray()).isNotNull();
|
||||
assertThat(out.toByteArray().length > 0).isTrue();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests for {@link RunArguments}.
|
||||
*
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class RunArgumentsTests {
|
||||
|
||||
@Test
|
||||
public void parseNull() {
|
||||
String[] args = parseArgs(null);
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseNullArray() {
|
||||
String[] args = new RunArguments((String[]) null).asArray();
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseArrayContainingNullValue() {
|
||||
String[] args = new RunArguments(new String[]{"foo", null, "bar"}).asArray();
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args).containsOnly("foo", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseArrayContainingEmptyValue() {
|
||||
String[] args = new RunArguments(new String[]{"foo", "", "bar"}).asArray();
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args).containsOnly("foo", "", "bar");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseEmpty() {
|
||||
String[] args = parseArgs(" ");
|
||||
assertThat(args).isNotNull();
|
||||
assertThat(args.length).isEqualTo(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseDebugFlags() {
|
||||
String[] args = parseArgs(
|
||||
"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isEqualTo("-Xdebug");
|
||||
assertThat(args[1]).isEqualTo(
|
||||
"-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithExtraSpaces() {
|
||||
String[] args = parseArgs(" -Dfoo=bar -Dfoo2=bar2 ");
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isEqualTo("-Dfoo=bar");
|
||||
assertThat(args[1]).isEqualTo("-Dfoo2=bar2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseWithNewLinesAndTabs() {
|
||||
String[] args = parseArgs(" -Dfoo=bar \n" + "\t\t -Dfoo2=bar2 ");
|
||||
assertThat(args.length).isEqualTo(2);
|
||||
assertThat(args[0]).isEqualTo("-Dfoo=bar");
|
||||
assertThat(args[1]).isEqualTo("-Dfoo2=bar2");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void quoteHandledProperly() {
|
||||
String[] args = parseArgs("-Dvalue=\"My Value\" ");
|
||||
assertThat(args.length).isEqualTo(1);
|
||||
assertThat(args[0]).isEqualTo("-Dvalue=My Value");
|
||||
}
|
||||
|
||||
private String[] parseArgs(String args) {
|
||||
return new RunArguments(args).asArray();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,333 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.maven;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.jar.Manifest;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
import org.springframework.core.io.support.PropertiesLoaderUtils;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Verification utility for use with maven-invoker-plugin verification scripts.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public final class Verify {
|
||||
|
||||
public static final String SAMPLE_APP = "org.test.SampleApplication";
|
||||
|
||||
private Verify() {
|
||||
}
|
||||
|
||||
public static void verifyJar(File file) throws Exception {
|
||||
new JarArchiveVerification(file, SAMPLE_APP).verify();
|
||||
}
|
||||
|
||||
public static void verifyJar(File file, String main, String... scriptContents)
|
||||
throws Exception {
|
||||
verifyJar(file, main, true, scriptContents);
|
||||
}
|
||||
|
||||
public static void verifyJar(File file, String main, boolean executable,
|
||||
String... scriptContents) throws Exception {
|
||||
new JarArchiveVerification(file, main).verify(executable, scriptContents);
|
||||
}
|
||||
|
||||
public static void verifyWar(File file) throws Exception {
|
||||
new WarArchiveVerification(file).verify();
|
||||
}
|
||||
|
||||
public static void verifyZip(File file) throws Exception {
|
||||
new ZipArchiveVerification(file).verify();
|
||||
}
|
||||
|
||||
public static void verifyModule(File file) throws Exception {
|
||||
new ModuleArchiveVerification(file).verify();
|
||||
}
|
||||
|
||||
public static Properties verifyBuildInfo(File file, String group, String artifact,
|
||||
String name, String version) throws IOException {
|
||||
FileSystemResource resource = new FileSystemResource(file);
|
||||
Properties properties = PropertiesLoaderUtils.loadProperties(resource);
|
||||
assertThat(properties.get("build.group")).isEqualTo(group);
|
||||
assertThat(properties.get("build.artifact")).isEqualTo(artifact);
|
||||
assertThat(properties.get("build.name")).isEqualTo(name);
|
||||
assertThat(properties.get("build.version")).isEqualTo(version);
|
||||
return properties;
|
||||
}
|
||||
|
||||
public static class ArchiveVerifier {
|
||||
|
||||
private final ZipFile zipFile;
|
||||
|
||||
private final Map<String, ZipEntry> content;
|
||||
|
||||
public ArchiveVerifier(ZipFile zipFile) {
|
||||
this.zipFile = zipFile;
|
||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||
this.content = new HashMap<>();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry zipEntry = entries.nextElement();
|
||||
this.content.put(zipEntry.getName(), zipEntry);
|
||||
}
|
||||
}
|
||||
|
||||
public void assertHasEntryNameStartingWith(String entry) {
|
||||
for (String name : this.content.keySet()) {
|
||||
if (name.startsWith(entry)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("Expected entry starting with " + entry);
|
||||
}
|
||||
|
||||
public void assertHasNoEntryNameStartingWith(String entry) {
|
||||
for (String name : this.content.keySet()) {
|
||||
if (name.startsWith(entry)) {
|
||||
throw new IllegalStateException("Entry starting with " + entry
|
||||
+ " should not have been found");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void assertHasNonUnpackEntry(String entryName) {
|
||||
assertThat(hasNonUnpackEntry(entryName))
|
||||
.as("Entry starting with " + entryName + " was an UNPACK entry")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
public void assertHasUnpackEntry(String entryName) {
|
||||
assertThat(hasUnpackEntry(entryName))
|
||||
.as("Entry starting with " + entryName + " was not an UNPACK entry")
|
||||
.isTrue();
|
||||
}
|
||||
|
||||
private boolean hasNonUnpackEntry(String entryName) {
|
||||
return !hasUnpackEntry(entryName);
|
||||
}
|
||||
|
||||
private boolean hasUnpackEntry(String entryName) {
|
||||
String comment = getEntryStartingWith(entryName).getComment();
|
||||
return comment != null && comment.startsWith("UNPACK:");
|
||||
}
|
||||
|
||||
private ZipEntry getEntryStartingWith(String entryName) {
|
||||
for (Map.Entry<String, ZipEntry> entry : this.content.entrySet()) {
|
||||
if (entry.getKey().startsWith(entryName)) {
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException(
|
||||
"Unable to find entry starting with " + entryName);
|
||||
}
|
||||
|
||||
public boolean hasEntry(String entry) {
|
||||
return this.content.containsKey(entry);
|
||||
}
|
||||
|
||||
public ZipEntry getEntry(String entry) {
|
||||
return this.content.get(entry);
|
||||
}
|
||||
|
||||
public InputStream getEntryContent(String entry) throws IOException {
|
||||
ZipEntry zipEntry = getEntry(entry);
|
||||
if (zipEntry == null) {
|
||||
throw new IllegalArgumentException("No entry with name [" + entry + "]");
|
||||
}
|
||||
return this.zipFile.getInputStream(zipEntry);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static abstract class AbstractArchiveVerification {
|
||||
|
||||
private final File file;
|
||||
|
||||
AbstractArchiveVerification(File file) {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public void verify() throws Exception {
|
||||
verify(true);
|
||||
}
|
||||
|
||||
public void verify(boolean executable, String... scriptContents)
|
||||
throws Exception {
|
||||
assertThat(this.file).exists().isFile();
|
||||
|
||||
if (scriptContents.length > 0 && executable) {
|
||||
String contents = new String(FileCopyUtils.copyToByteArray(this.file));
|
||||
contents = contents.substring(0, contents
|
||||
.indexOf(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 })));
|
||||
for (String content : scriptContents) {
|
||||
assertThat(contents).contains(content);
|
||||
}
|
||||
}
|
||||
|
||||
if (!executable) {
|
||||
String contents = new String(FileCopyUtils.copyToByteArray(this.file));
|
||||
assertThat(contents).as("Is executable")
|
||||
.startsWith(new String(new byte[] { 0x50, 0x4b, 0x03, 0x04 }));
|
||||
}
|
||||
|
||||
try (ZipFile zipFile = new ZipFile(this.file)) {
|
||||
ArchiveVerifier verifier = new ArchiveVerifier(zipFile);
|
||||
verifyZipEntries(verifier);
|
||||
}
|
||||
}
|
||||
|
||||
protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
|
||||
verifyManifest(verifier);
|
||||
}
|
||||
|
||||
private void verifyManifest(ArchiveVerifier verifier) throws Exception {
|
||||
Manifest manifest = new Manifest(
|
||||
verifier.getEntryContent("META-INF/MANIFEST.MF"));
|
||||
verifyManifest(manifest);
|
||||
}
|
||||
|
||||
protected abstract void verifyManifest(Manifest manifest) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
public static class JarArchiveVerification extends AbstractArchiveVerification {
|
||||
|
||||
private final String main;
|
||||
|
||||
public JarArchiveVerification(File file, String main) {
|
||||
super(file);
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
|
||||
super.verifyZipEntries(verifier);
|
||||
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/spring-context");
|
||||
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/spring-core");
|
||||
verifier.assertHasEntryNameStartingWith("BOOT-INF/lib/javax.servlet-api-3");
|
||||
assertThat(verifier
|
||||
.hasEntry("org/springframework/boot/loader/JarLauncher.class"))
|
||||
.as("Unpacked launcher classes").isTrue();
|
||||
assertThat(verifier
|
||||
.hasEntry("BOOT-INF/classes/org/test/SampleApplication.class"))
|
||||
.as("Own classes").isTrue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyManifest(Manifest manifest) throws Exception {
|
||||
assertThat(manifest.getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("org.springframework.boot.loader.JarLauncher");
|
||||
assertThat(manifest.getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo(this.main);
|
||||
assertThat(manifest.getMainAttributes().getValue("Not-Used"))
|
||||
.isEqualTo("Foo");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class WarArchiveVerification extends AbstractArchiveVerification {
|
||||
|
||||
public WarArchiveVerification(File file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
|
||||
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");
|
||||
assertThat(verifier
|
||||
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
|
||||
.as("Unpacked launcher classes").isTrue();
|
||||
assertThat(verifier
|
||||
.hasEntry("WEB-INF/classes/org/" + "test/SampleApplication.class"))
|
||||
.as("Own classes").isTrue();
|
||||
assertThat(verifier.hasEntry("index.html")).as("Web content").isTrue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyManifest(Manifest manifest) throws Exception {
|
||||
assertThat(manifest.getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("org.springframework.boot.loader.WarLauncher");
|
||||
assertThat(manifest.getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("org.test.SampleApplication");
|
||||
assertThat(manifest.getMainAttributes().getValue("Not-Used"))
|
||||
.isEqualTo("Foo");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ZipArchiveVerification extends AbstractArchiveVerification {
|
||||
|
||||
ZipArchiveVerification(File file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyManifest(Manifest manifest) throws Exception {
|
||||
assertThat(manifest.getMainAttributes().getValue("Main-Class"))
|
||||
.isEqualTo("org.springframework.boot.loader.PropertiesLauncher");
|
||||
assertThat(manifest.getMainAttributes().getValue("Start-Class"))
|
||||
.isEqualTo("org.test.SampleApplication");
|
||||
assertThat(manifest.getMainAttributes().getValue("Not-Used"))
|
||||
.isEqualTo("Foo");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class ModuleArchiveVerification extends AbstractArchiveVerification {
|
||||
|
||||
ModuleArchiveVerification(File file) {
|
||||
super(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyZipEntries(ArchiveVerifier verifier) throws Exception {
|
||||
super.verifyZipEntries(verifier);
|
||||
verifier.assertHasEntryNameStartingWith("lib/spring-context");
|
||||
verifier.assertHasEntryNameStartingWith("lib/spring-core");
|
||||
verifier.assertHasNoEntryNameStartingWith("lib/javax.servlet-api-3");
|
||||
assertThat(verifier
|
||||
.hasEntry("org/" + "springframework/boot/loader/JarLauncher.class"))
|
||||
.as("Unpacked launcher classes").isFalse();
|
||||
assertThat(verifier.hasEntry("org/" + "test/SampleModule.class"))
|
||||
.as("Own classes").isTrue();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void verifyManifest(Manifest manifest) throws Exception {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.maven.sample;
|
||||
|
||||
/**
|
||||
* Sample class with a main method.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class ClassWithMainMethod {
|
||||
|
||||
public void run() {
|
||||
System.out.println("Hello World");
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
new ClassWithMainMethod().run();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2012-2013 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.boot.maven.sample;
|
||||
|
||||
/**
|
||||
* Sample class without a main method.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
public class ClassWithoutMainMethod {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user