赞
踩
package junit; import java.util.List; import nc.bs.framework.common.InvocationInfoProxy; import nc.bs.framework.common.NCLocator; import nc.bs.framework.core.service.IFwLogin; import nc.bs.framework.test.AbstractTestCase; import nc.itf.uap.IUAPQueryBS; import nc.pub.smart.context.SmartContext; import nc.pub.smart.exception.SmartException; import nc.pub.smart.model.SmartModel; import nc.pub.smart.model.descriptor.Descriptor; import nc.pub.smart.provider.Provider; import nc.vo.pub.BusinessException; import nc.vo.smart.SmartDefVO; public class Test extends AbstractTestCase{ public void test(){ try { IUAPQueryBS lookup = NCLocator.getInstance().lookup(IUAPQueryBS .class); List<SmartDefVO> defvo = (List<SmartDefVO>) lookup.retrieveByClause(SmartDefVO.class," defcode='test_fei'" ); SmartModel smartmodel = defvo.get(0).getSmartmodel(); SmartContext context = smartmodel.getInitialContext(); Descriptor[] descriptors = smartmodel.getDescriptors(); String provideSQL = smartmodel.provideSQL(context, descriptors); Provider[] providers = smartmodel.getProviders(); for (Provider provider : providers) { String tableSql = provider.provideScript(context); System.out.println("初始sql:"+tableSql); } System.out.println("解析sql:"+provideSQL); } catch (SmartException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } catch (BusinessException e) { // TODO 自动生成的 catch 块 e.printStackTrace(); } } @Override public void setUp() throws Exception{ super.setUp(); InvocationInfoProxy.getInstance().setUserCode("feifei");//模拟客户端设置用户,否则报invalid secrity token NCLocator.getInstance().lookup(IFwLogin.class).login("feifei","1234qwer" , null);//模拟后台设置token,否则报invalid secrity token(null) } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。