weixin-java-tools/src/test/java/chanjarster/weixin/api/ApiTestModule.java

30 lines
807 B
Java
Raw Normal View History

2014-08-25 14:10:18 +08:00
package chanjarster.weixin.api;
import java.io.InputStream;
import javax.xml.bind.JAXBException;
import chanjarster.weixin.api.WxBaseAPITest.WxXmlConfigStorage;
import chanjarster.weixin.util.xml.XmlTransformer;
import com.google.inject.Binder;
import com.google.inject.Module;
public class ApiTestModule implements Module {
@Override
public void configure(Binder binder) {
try {
InputStream is1 = ClassLoader.getSystemResourceAsStream("test-config.xml");
WxXmlConfigStorage config = XmlTransformer.fromXml(WxXmlConfigStorage.class, is1);
WxServiceImpl wxService = new WxServiceImpl();
wxService.setWxConfigStorage(config);
binder.bind(WxServiceImpl.class).toInstance(wxService);
} catch (JAXBException e) {
throw new RuntimeException(e);
}
}
}