package com.googlecode.jmxtrans;

import java.util.TreeMap;

import org.junit.Assert;
import org.junit.Test;

import com.googlecode.jmxtrans.util.PropertyResolver;

public class PropertyResolverTests {

    @Test
    public void testProps() {
        System.setProperty("myhost", "w2");
        System.setProperty("myport", "1099");

        String s1 = "${xxx} : ${yyy}";
        String s2 = PropertyResolver.resolveProps(s1);
        Assert.assertEquals(s1, s2);

        s1 = "${myhost} : ${myport}";
        s2 = PropertyResolver.resolveProps(s1);
        Assert.assertEquals("w2 : 1099", s2);

        s1 = "${myhost} : ${myaltport:2099}";
        s2 = PropertyResolver.resolveProps(s1);
        Assert.assertEquals("w2 : 2099", s2);
    }

    @Test
    public void testMap() {
        TreeMap<String, Object> map = new TreeMap<String, Object>();
        map.put("host", "${myhost}");
        map.put("port", "${myport}");
        map.put("count", new Integer(10));

        PropertyResolver.resolveMap(map);
        Assert.assertEquals("w2", map.get("host"));
        Assert.assertEquals("1099", map.get("port"));
        Assert.assertEquals(new Integer(10), map.get("count"));
    }
}

@@ -27,16 +27,67 @@
 trans;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.List;%0A
 import j
@@ -1235,10 +1235,393 @@
 ;%0A    %7D%0A
+%0A    @Test%0A    public void testList() %7B%0A        List%3CString%3E list = new ArrayList%3CString%3E();%0A        list.add(%22$%7Bmyhost%7D%22);%0A        list.add(%22$%7Bmyport%7D%22);%0A        list.add(%22count%22);%0A%0A        PropertyResolver.resolveList(list);%0A        Assert.assertEquals(%22w2%22, list.get(0));%0A        Assert.assertEquals(%221099%22, list.get(1));%0A        Assert.assertEquals(%22count%22, list.get(2));%0A    %7D%0A%0A
 %7D%0A

Add Resolver for list of String