1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.giraph.examples;
20
21 import static org.junit.Assert.assertEquals;
22
23 import org.apache.giraph.combiner.MessageCombiner;
24 import org.apache.giraph.combiner.MinimumIntMessageCombiner;
25 import org.apache.hadoop.io.IntWritable;
26 import org.apache.hadoop.io.WritableComparable;
27 import org.junit.Test;
28
29 public class MinimumIntCombinerTest {
30
31 @Test
32 public void testCombiner() throws Exception {
33 MessageCombiner<WritableComparable, IntWritable>
34 messageCombiner =
35 new MinimumIntMessageCombiner();
36
37 IntWritable vertexId = new IntWritable(1);
38 IntWritable result = messageCombiner.createInitialMessage();
39 messageCombiner.combine(vertexId, result, new IntWritable(39947466));
40 messageCombiner.combine(vertexId, result, new IntWritable(199));
41 messageCombiner.combine(vertexId, result, new IntWritable(42));
42 messageCombiner.combine(vertexId, result, new IntWritable(19998888));
43 assertEquals(42, result.get());
44 }
45 }