Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: NathanNeff/njn-hadoop
base: 762424a989
...
head fork: NathanNeff/njn-hadoop
compare: 839fa2e050
  • 4 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
9 README.org
@@ -0,0 +1,9 @@
+* njn-hadoop
+
+My hadoop stuff.
+
+Apologies in advance for junk commit descriptions, etc.
+
+* wordcount
+
+ - MRUnit example with gradle
View
9 wordcount/build.gradle
@@ -13,9 +13,18 @@ repositories {
dependencies {
compile 'org.apache.hadoop:hadoop-client:2.0.0-mr1-cdh4.1.1'
+ /* compile(group: 'org.apache.mrunit', name: 'mrunit', version: '0.9.0-incubating', ext: 'pom') */
+ testCompile fileTree(dir: 'lib', include: '*.jar')
+
}
task "create-dirs" << {
sourceSets*.java.srcDirs*.each { it.mkdirs() }
sourceSets*.resources.srcDirs*.each { it.mkdirs() }
}
+
+test {
+ onOutput { descriptor, event ->
+ logger.lifecycle("\n\nTest: " + descriptor + " produced standard out/err: " + event.message )
+ }
+}
View
BIN  wordcount/lib/mrunit-0.9.0-incubating-hadoop1.jar
Binary file not shown
View
14 wordcount/src/test/java/WordMapperTest.java
@@ -1,4 +1,3 @@
-import hadoop.dev.wordcount.mapred.WordMapper;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
@@ -6,19 +5,26 @@
import org.junit.Before;
import org.junit.Test;
-public class MRUnitHelloWorld {
+public class WordMapperTest {
MapDriver<LongWritable, Text, Text, IntWritable> mapDriver;
- @Before
+
+ @Before
public void setUp() {
WordMapper mapper = new WordMapper();
mapDriver = new MapDriver<LongWritable, Text, Text, IntWritable>();
mapDriver.setMapper(mapper);
}
- @Test
+ @Test
public void testMapper() {
mapDriver.withInput(new LongWritable(1), new Text("cat dog"));
mapDriver.withOutput(new Text("cat"), new IntWritable(1));
mapDriver.withOutput(new Text("dog"), new IntWritable(1));
mapDriver.runTest();
}
+
+ @Test
+ public void testNoOutput() {
+ mapDriver.withInput(new LongWritable(1), new Text(""));
+ mapDriver.runTest();
+ }
}

No commit comments for this range

Something went wrong with that request. Please try again.