33import java .io .IOException ;
44import java .io .InputStream ;
55
6- import me .chanjar .weixin .mp .api .impl .WxMpServiceImpl ;
7- import org .apache .commons .lang3 .builder .ToStringBuilder ;
8-
96import com .google .inject .Binder ;
107import com .google .inject .Module ;
118import com .thoughtworks .xstream .XStream ;
12- import com .thoughtworks .xstream .annotations .XStreamAlias ;
139
1410import me .chanjar .weixin .common .util .xml .XStreamInitializer ;
11+ import me .chanjar .weixin .mp .api .impl .WxMpServiceImpl ;
1512
1613public class ApiTestModule implements Module {
1714
1815 @ Override
1916 public void configure (Binder binder ) {
2017 try (InputStream is1 = ClassLoader
2118 .getSystemResourceAsStream ("test-config.xml" )) {
22- WxXmlMpInMemoryConfigStorage config = fromXml (
23- WxXmlMpInMemoryConfigStorage .class , is1 );
19+ WxXmlMpInMemoryConfigStorage config = this
20+ . fromXml ( WxXmlMpInMemoryConfigStorage .class , is1 );
2421 WxMpServiceImpl wxService = new WxMpServiceImpl ();
2522 wxService .setWxMpConfigStorage (config );
2623
@@ -32,50 +29,11 @@ public void configure(Binder binder) {
3229 }
3330
3431 @ SuppressWarnings ("unchecked" )
35- public static <T > T fromXml (Class <T > clazz , InputStream is ) {
32+ private <T > T fromXml (Class <T > clazz , InputStream is ) {
3633 XStream xstream = XStreamInitializer .getInstance ();
3734 xstream .alias ("xml" , clazz );
3835 xstream .processAnnotations (clazz );
3936 return (T ) xstream .fromXML (is );
4037 }
4138
42- @ XStreamAlias ("xml" )
43- public static class WxXmlMpInMemoryConfigStorage
44- extends WxMpInMemoryConfigStorage {
45-
46- private String openid ;
47- private String kfAccount ;
48- private String qrconnectRedirectUrl ;
49-
50- public String getOpenid () {
51- return this .openid ;
52- }
53-
54- public void setOpenid (String openid ) {
55- this .openid = openid ;
56- }
57-
58- @ Override
59- public String toString () {
60- return ToStringBuilder .reflectionToString (this );
61- }
62-
63- public String getKfAccount () {
64- return this .kfAccount ;
65- }
66-
67- public void setKfAccount (String kfAccount ) {
68- this .kfAccount = kfAccount ;
69- }
70-
71- public String getQrconnectRedirectUrl () {
72- return this .qrconnectRedirectUrl ;
73- }
74-
75- public void setQrconnectRedirectUrl (String qrconnectRedirectUrl ) {
76- this .qrconnectRedirectUrl = qrconnectRedirectUrl ;
77- }
78-
79- }
80-
8139}
0 commit comments