Skip to content

Commit

Permalink
Tests to reproduce issue #16: Maven plugin fails to set the classpath
Browse files Browse the repository at this point in the history
  • Loading branch information
luontola committed May 2, 2014
1 parent 1ff46fe commit b748fa6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 1 deletion.
1 change: 1 addition & 0 deletions end-to-end-tests/end-to-end-tests.iml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Maven: com.google.guava:guava:17.0" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-library:1.3" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
Expand Down
10 changes: 10 additions & 0 deletions end-to-end-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@
<artifactId>end-to-end-tests</artifactId>
<packaging>jar</packaging>

<dependencies>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>17.0</version>
</dependency>

</dependencies>

<build>
<plugins>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
// Copyright © 2013 Esko Luontola <www.orfjackal.net>
// Copyright © 2013-2014 Esko Luontola <www.orfjackal.net>
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package net.orfjackal.retrolambda.test;

import com.google.common.collect.Lists;

import java.util.List;
import java.util.concurrent.Callable;

public class InMainSources {
Expand All @@ -12,4 +15,8 @@ public static int callLambda() throws Exception {
Callable<Integer> lambda = () -> 42;
return lambda.call();
}

public static List<String> useLambdaOfImportedType(List<String> items) {
return Lists.transform(items, String::toUpperCase);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright © 2013-2014 Esko Luontola <www.orfjackal.net>
// This software is released under the Apache License 2.0.
// The license text is at http://www.apache.org/licenses/LICENSE-2.0

package net.orfjackal.retrolambda.test;

import org.hamcrest.*;
import org.junit.Test;

import java.util.Arrays;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;

public class ClasspathTest {

@Test
public void maven_plugin_sets_classpath_for_main_dependencies() {
assertThat(InMainSources.useLambdaOfImportedType(Arrays.asList("a", "b")), is(Arrays.asList("A", "B")));
}

@Test
public void maven_plugin_sets_classpath_for_test_dependencies() {
SelfDescribing lambda = (desc) -> desc.appendText("foo");

StringDescription result = new StringDescription();
lambda.describeTo(result);
assertThat(result.toString(), is("foo"));
}
}

0 comments on commit b748fa6

Please sign in to comment.