### Question:
BceConfigDataHandler extends SimpleChannelHandler { public static BceConfigDataHandler getInstance() { return instance; } private  BceConfigDataHandler(); static BceConfigDataHandler getInstance(); @Override void messageProcess(IoSession session, Object message, SessionKey sessionKey);  }### Answer:
@Test public void testUserLoginVip() throws Exception { String userName = "test001"; UserManager manager = UserManager.getInstance(); manager.removeUser("test001"); User user = manager.createDefaultUser(); user.set_id(new UserId(userName)); user.setUsername("test001"); UserManager.getInstance().saveUser(user, true); List<Message> list = loginUser(userName, user); ShopData shopData = (ShopData)list.get(0); ChargeData chargeData = null; for ( Message msg : list ) { if ( msg != null ) { if ( msg instanceof ChargeData ) { chargeData = (ChargeData)msg; } else if ( msg instanceof ShopData ) { shopData = (ShopData)msg; } } } int shopPrice = shopData.getBuyPrices(0).getPrice(); int shopDiscount = shopData.getDiscount(); System.out.println("shopPrice = " + shopPrice+", shopDiscount = " + shopDiscount); int chargePrice = chargeData.getPrice(); int chargeDiscount = chargeData.getDiscount(); int yuanbao = chargeData.getYuanbao(); System.out.println("chargePrice = " + chargePrice + ", chargeDiscount="+chargeDiscount+", yuanbao="+yuanbao); user = UserManager.getInstance().queryUser(userName); user.setIsvip(true); user.setVipedate(new Date(System.currentTimeMillis()+86400)); UserManager.getInstance().saveUser(user, false); list = loginUser(userName, user); shopData = (ShopData)list.get(0); chargeData = (ChargeData)list.get(1); int newShopPrice = shopData.getBuyPrices(0).getPrice(); int newShopDiscount = shopData.getDiscount(); System.out.println("shopPrice = " + newShopPrice+", shopDiscount = " + newShopDiscount); assertEquals( shopPrice, newShopPrice); assertTrue( newShopDiscount < shopDiscount ); int newChargePrice = chargeData.getPrice(); int newChargeDiscount = chargeData.getDiscount(); int newYuanbao = chargeData.getYuanbao(); System.out.println("chargePrice = " + newChargePrice + ", chargeDiscount="+newChargeDiscount+", yuanbao="+newYuanbao); assertEquals(chargePrice, newChargePrice); assertTrue(newChargeDiscount < 100); assertTrue(newYuanbao > yuanbao); }
@Test public void testUserLoginVipExpire() throws Exception { String userName = "test001"; UserManager manager = UserManager.getInstance(); manager.removeUser(userName); User user = manager.createDefaultUser(); user.set_id(new UserId(userName)); user.setUsername(userName); UserManager.getInstance().saveUser(user, true); user = UserManager.getInstance().queryUser(userName); user.setIsvip(true); user.setVipedate(new Date(System.currentTimeMillis()-86400)); manager.saveUser(user, true); List<Message> list = loginUser(userName, user); ShopData shopData = (ShopData)list.get(0); ChargeData chargeData = (ChargeData)list.get(1); int shopPrice = shopData.getBuyPrices(0).getPrice(); int shopDiscount = shopData.getDiscount(); System.out.println("shopPrice = " + shopPrice+", shopDiscount = " + shopDiscount); int chargePrice = chargeData.getPrice(); int chargeDiscount = chargeData.getDiscount(); int yuanbao = chargeData.getYuanbao(); System.out.println("chargePrice = " + chargePrice + ", chargeDiscount="+chargeDiscount+", yuanbao="+yuanbao); assertEquals(100, shopDiscount); assertEquals(0, chargeDiscount); }