package com.ctrip.ops.sysdev;

import com.ctrip.ops.sysdev.filters.GeoIP2;
import org.json.simple.JSONValue;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.HashMap;
import java.util.Map;

public class TestGeoIP2 {
	@Test
	public void testGsub() throws UnsupportedEncodingException {
		String s = "61.240.136.69";
		HashMap config = new HashMap() {
			{
				put("source", "clientip");
			}
		};

		GeoIP2 geoip2Filter = new GeoIP2(config);

		Map event = new HashMap();
		event.put("clientip", s);
		event = geoip2Filter.process(event);
		System.out.println(event);
	}
}

@@ -317,16 +317,22 @@
 2 %7B%0A
-%09
+    
 @Test%0A
-%09
+    
 publ
@@ -388,18 +388,24 @@
 ption %7B%0A
-%09%09
+        
 String s
@@ -424,18 +424,24 @@
 36.69%22;%0A
-%09%09
+        
 HashMap 
@@ -469,57 +469,180 @@
 ) %7B%0A
-%09%09%09%7B%0A%09%09%09%09put(%22source%22, %22clientip%22);%0A%09%09%09%7D%0A%09%09%7D;%0A%0A%09%09
+            %7B%0A                put(%22source%22, %22clientip%22);%0A                put(%22database%22, %22/Users/liujia/Desktop/es/mydata4vipday2.datx%22);%0A            %7D%0A        %7D;%0A%0A        
 GeoI
@@ -680,18 +680,24 @@
 nfig);%0A%0A
-%09%09
+        
 Map even
@@ -715,18 +715,24 @@
 hMap();%0A
-%09%09
+        
 event.pu
@@ -749,18 +749,24 @@
 p%22, s);%0A
-%09%09
+        
 event = 
@@ -798,10 +798,16 @@
 t);%0A
-%09%09
+        
 Syst
@@ -833,9 +833,12 @@
 t);%0A
-%09
+    
 %7D%0A%7D%0A

add datbase in testcase