File: TupleTest.java

package info (click to toggle)
libjgroups-java 2.12.2.Final-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 8,724 kB
  • sloc: java: 109,098; xml: 9,423; sh: 174; makefile: 4
file content (43 lines) | stat: -rw-r--r-- 1,465 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package org.jgroups.tests;

import org.jgroups.util.Tuple;
import org.jgroups.Global;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Bela Ban
 */
@Test(groups=Global.FUNCTIONAL)
public class TupleTest {

    public static void testCreation() {
        Tuple<String,Integer> tuple=new Tuple<String,Integer>("Bela", 322649);
        System.out.println("tuple: " + tuple);
        Assert.assertEquals("Bela", tuple.getVal1());
        Assert.assertEquals(322649, tuple.getVal2().intValue());
    }

    public static void testSet() {
        Tuple<String,Integer> tuple=new Tuple<String,Integer>("Bela", 322649);
        System.out.println("tuple: " + tuple);
        tuple.setVal1("Michelle");
        tuple.setVal2(7);
        Assert.assertEquals("Michelle", tuple.getVal1());
        Assert.assertEquals(7, tuple.getVal2().intValue());
    }

    public static void testHashMap() {
        Map<Integer,Tuple<String,Integer>> map=new HashMap<Integer,Tuple<String,Integer>>();
        map.put(1, new Tuple<String,Integer>("one",1));
        map.put(2, new Tuple<String,Integer>("two", 2));
        System.out.println("map: " + map);
        Assert.assertEquals("one", map.get(1).getVal1());
        Assert.assertEquals(1, map.get(1).getVal2().intValue());
        Assert.assertEquals("two", map.get(2).getVal1());
        Assert.assertEquals(2, map.get(2).getVal2().intValue());
    }
}