Example #1
0
  @Before
  public void init() {
    String[] resource = {
      "classpath:spring-db.xml", "classpath:spring-dao.xml", "classpath:spring-service.xml"
    };
    acx = new ClassPathXmlApplicationContext(resource);
    api = acx.getBean(WeiXinAPI.class);
    customerMapper = acx.getBean(CustomerMapper.class);
    wxConfigMapper = acx.getBean(WXConfigMapper.class);
    assertNotNull(api);
    assertNotNull(customerMapper);
    assertNotNull(wxConfigMapper);

    Customer cust = customerMapper.getCustomer(cust_id);
    if (cust == null) {
      cust = new Customer();
      cust.setCust_id(cust_id);
      cust.setCust_name("Test");
      cust.setMemo("");
      cust.setStatus(Status.AVAILABLE);
      customerMapper.addCustomer(cust);
      assertNotEquals(cust.getCust_id(), 0);
    }

    // add WeiXin configure
    WeiXinConfig cfg = wxConfigMapper.get(cust_id);
    if (null == cfg) {
      cfg = new WeiXinConfig();
      cfg.setCust_id(cust_id);
      cfg.setToken(TOKEN);
      cfg.setApi_url(MMT_TOKEN);
      cfg.setWx_account("lemon_test");
      cfg.setAppid("");
      cfg.setSecret("");
      cfg.setBiz_class(bizClass);
      cfg.setSubscribe_msg(Subscribe_msg);
      cfg.setWelcome_msg(Welcome_msg);
      wxConfigMapper.save(cfg);
      assertNotEquals(cfg.getCust_id(), 0);
    }
    WeiXin.init();
    WeiXin.setConfig(cfg);
  }
Example #2
0
 @Test
 @Ignore
 public void getAcessToken() {
   String ss = api.getAcessToken(wxConfigMapper.get(cust_id));
   System.out.println(ss);
 }