Skip to content

Commit d022320

Browse files
author
Marcelo Vanzin
committed
Fix some tests.
- JavaAPISuite was trying to compare a bare path with a URI. Fix by extracting the path from the URI, since we know it should be a local path anyway/ - b9be160 excluded the ASM dependency everywhere, but easymock needs it (because cglib needs it). So re-add the dependency, with test scope this time. The second one above actually uncovered a weird situation: the maven test target works, even though I can't find the class sbt complains about in its classpath. sbt complains with: [error] Uncaught exception when running org.apache.spark.util .random.RandomSamplerSuite: java.lang.NoClassDefFoundError: org/objectweb/asm/Type To avoid more weirdness caused by that, I explicitly added the asm dependency to both maven and sbt (for tests only), and verified the classes don't end up in the final assembly.
1 parent 67fca18 commit d022320

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

core/pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@
244244
<artifactId>easymockclassextension</artifactId>
245245
<scope>test</scope>
246246
</dependency>
247+
<dependency>
248+
<groupId>asm</groupId>
249+
<artifactId>asm</artifactId>
250+
<scope>test</scope>
251+
</dependency>
247252
<dependency>
248253
<groupId>com.novocode</groupId>
249254
<artifactId>junit-interface</artifactId>

core/src/test/java/org/apache/spark/JavaAPISuite.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.apache.spark;
1919

2020
import java.io.*;
21+
import java.net.URI;
2122
import java.util.*;
2223

2324
import scala.Tuple2;
@@ -705,7 +706,7 @@ public void textFiles() throws IOException {
705706
}
706707

707708
@Test
708-
public void wholeTextFiles() throws IOException {
709+
public void wholeTextFiles() throws Exception {
709710
byte[] content1 = "spark is easy to use.\n".getBytes("utf-8");
710711
byte[] content2 = "spark is also easy to use.\n".getBytes("utf-8");
711712

@@ -721,7 +722,7 @@ public void wholeTextFiles() throws IOException {
721722
List<Tuple2<String, String>> result = readRDD.collect();
722723

723724
for (Tuple2<String, String> res : result) {
724-
Assert.assertEquals(res._2(), container.get(res._1()));
725+
Assert.assertEquals(res._2(), container.get(new URI(res._1()).getPath()));
725726
}
726727
}
727728

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,13 @@
468468
<version>3.1</version>
469469
<scope>test</scope>
470470
</dependency>
471+
<!-- Needed by cglib which is needed by easymock. -->
472+
<dependency>
473+
<groupId>asm</groupId>
474+
<artifactId>asm</artifactId>
475+
<version>3.3.1</version>
476+
<scope>test</scope>
477+
</dependency>
471478
<dependency>
472479
<groupId>org.mockito</groupId>
473480
<artifactId>mockito-all</artifactId>

project/SparkBuild.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,9 @@ object SparkBuild extends Build {
293293
"com.novocode" % "junit-interface" % "0.10" % "test",
294294
"org.easymock" % "easymockclassextension" % "3.1" % "test",
295295
"org.mockito" % "mockito-all" % "1.9.0" % "test",
296-
"junit" % "junit" % "4.10" % "test"
296+
"junit" % "junit" % "4.10" % "test",
297+
// Needed by cglib which is needed by easymock.
298+
"asm" % "asm" % "3.3.1" % "test"
297299
),
298300

299301
testOptions += Tests.Argument(TestFrameworks.JUnit, "-v", "-a"),
@@ -461,7 +463,7 @@ object SparkBuild extends Build {
461463

462464
def toolsSettings = sharedSettings ++ Seq(
463465
name := "spark-tools",
464-
libraryDependencies <+= scalaVersion(v => "org.scala-lang" % "scala-compiler" % v ),
466+
libraryDependencies <+= scalaVersion(v => "org.scala-lang" % "scala-compiler" % v),
465467
libraryDependencies <+= scalaVersion(v => "org.scala-lang" % "scala-reflect" % v )
466468
) ++ assemblySettings ++ extraAssemblySettings
467469

@@ -630,9 +632,9 @@ object SparkBuild extends Build {
630632
scalaVersion := "2.10.4",
631633
retrieveManaged := true,
632634
retrievePattern := "[type]s/[artifact](-[revision])(-[classifier]).[ext]",
633-
libraryDependencies := Seq("spark-streaming-mqtt", "spark-streaming-zeromq",
635+
libraryDependencies := Seq("spark-streaming-mqtt", "spark-streaming-zeromq",
634636
"spark-streaming-flume", "spark-streaming-kafka", "spark-streaming-twitter",
635-
"spark-streaming", "spark-mllib", "spark-bagel", "spark-graphx",
637+
"spark-streaming", "spark-mllib", "spark-bagel", "spark-graphx",
636638
"spark-core").map(sparkPreviousArtifact(_).get intransitive())
637639
)
638640

0 commit comments

Comments
 (0)