提交 | 用户 | 时间
|
58d006
|
1 |
package com.mandi.fendan.test; |
A |
2 |
|
|
3 |
import java.lang.reflect.ParameterizedType; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.HashMap; |
|
6 |
import java.util.List; |
|
7 |
import java.util.Map; |
|
8 |
import java.util.Map.Entry; |
|
9 |
|
|
10 |
import org.apache.commons.lang3.StringUtils; |
|
11 |
import org.junit.Test; |
|
12 |
import org.springframework.context.ApplicationContext; |
|
13 |
|
|
14 |
import com.google.gson.JsonArray; |
|
15 |
import com.google.gson.JsonElement; |
|
16 |
import com.google.gson.JsonObject; |
|
17 |
import com.google.gson.JsonParser; |
|
18 |
import com.mandi.common.JSONobj; |
|
19 |
import com.mandi.common.Jacksonmethod; |
|
20 |
import com.mandi.common.SpringContext; |
|
21 |
import com.mandi.common.Wxhtmethod; |
|
22 |
import com.mandi.dao.common.ObjectResult; |
|
23 |
|
|
24 |
|
|
25 |
public class Test1 { |
|
26 |
|
|
27 |
|
|
28 |
@Test |
|
29 |
public void test_rrd(){ |
|
30 |
String fhdqNo="120200"; |
|
31 |
String str=StringUtils.substring(fhdqNo,0, fhdqNo.length()-2); |
|
32 |
System.err.println(str); |
|
33 |
} |
|
34 |
|
|
35 |
@Test |
|
36 |
public void test_htt(){ |
|
37 |
String url="http://10.1.10.101:8089/ws/api/prefix"; |
|
38 |
Map<String, Object> params=new HashMap<String, Object>(); |
|
39 |
params.put("action", "123"); |
|
40 |
List<Map<String, Object>> r=new ArrayList<Map<String,Object>>(); |
|
41 |
Map<String, Object> mm=new HashMap<String, Object>(); |
|
42 |
mm.put("abc", 1); |
|
43 |
mm.put("bcd", "123"); |
|
44 |
r.add(mm); |
|
45 |
params.put("data", mm); |
|
46 |
|
|
47 |
JsonObject jo=Wxhtmethod.postJsonStr(url,"abc"); |
|
48 |
System.err.println("jo::::"+jo.toString()); |
|
49 |
} |
|
50 |
|
|
51 |
@Test |
|
52 |
public void test_jp(){ |
|
53 |
|
|
54 |
// list: ["GFTD-18121682","GFTD-18121693","GFTD-18121695"] |
|
55 |
String list="[\"GFTD-18121682\",\"GFTD-18121693\",\"GFTD-18121695\"]"; |
|
56 |
JsonParser jp=new JsonParser(); |
|
57 |
JsonArray ja=jp.parse(list).getAsJsonArray(); |
|
58 |
for (JsonElement je : ja) { |
|
59 |
String jes=je.getAsString(); |
|
60 |
System.err.println("jes::::::::"+jes); |
|
61 |
} |
|
62 |
} |
|
63 |
@Test |
|
64 |
public void test_getjsobj(){ |
|
65 |
|
|
66 |
// list: ["GFTD-18121682","GFTD-18121693","GFTD-18121695"] |
|
67 |
// {"code":1,"hint":null,"errmsg":null,"item":"XS201812290003"} |
|
68 |
JsonObject jo=new JsonObject(); |
|
69 |
jo.addProperty("code", 0); |
|
70 |
jo.addProperty("item", "XS201812290003"); |
|
71 |
for (Entry<String, JsonElement> ey : jo.entrySet()) { |
|
72 |
System.err.println(ey.getKey()+"::::::::"+ey.getValue().getAsString()); |
|
73 |
} |
|
74 |
ObjectResult<String> ors=new ObjectResult<String>(); |
|
75 |
ors=JSONobj.getobj(jo, ors); |
|
76 |
System.err.println("aaaaaaaaaaa"); |
|
77 |
// ors=JSONobj.getobj(jo, ors); |
|
78 |
// System.err.println("a::::::::"+jo); |
|
79 |
// System.err.println("j::::::::"+Jacksonmethod.tojson(ors, false)); |
|
80 |
} |
|
81 |
|
|
82 |
|
|
83 |
@Test |
|
84 |
public void test_getccr(){ |
|
85 |
|
|
86 |
} |
|
87 |
|
|
88 |
} |