Java Web???????????????1??
???????????? ???????[ 2013/12/4 11:59:25 ] ????????
/**
* ????????????????????????????????????????????????????и????????????????????
*
* @author xiaoli
*
*/
public class CreateMultiTaskReportTest3 extends TestCase {
private UserManager userManager;
private UserService userService;
@Override
protected void setUp() throws Exception {
super.setUp();
String[] paths = { "classpath:applicationContext.xml" };
ApplicationContext ctx = new ClassPathXmlApplicationContext(paths);
SpringContextListener.setApplicationContext(ctx);
// ############???servlet???????????????????????·??
Constant.CURRENT_PROJECT_PATH = "src/";
// ############????????л??bean
userManager = (UserManager) ctx.getBean("userManager");
userService = (UserService) ctx.getBean("userService");
}
@Override
protected void tearDown() throws Exception {
super.tearDown();
}
@Test
public void test(){
// ###########?????????????????
List<String> bbqs = new ArrayList<String>();
UnitTestUtils.imitateCreateMultiBbq(bbqs?? 2?? "2048"?? "5");
// ???????
TestRunnable[] tr = new TestRunnable[bbqs.size()];
int processCount = 0;
// ##########????Щ?????????
for (String bbq : bbqs) {
// ??????????
String reportMap = "{taskID:"402880ee425a92f501425aa75ad50002"??bbq_:""
+ bbq
+ """
+ "??bbhid:"402855b942099b1b014209b1177e03f5"??approvalFlag:2??reportFlag:False??auditFlag:False??sheetMap:"
+ "[{id:"402880ee425a92f501425aa75ad60004"??sheetType:"BASIC"??values:{}}]}";
// ????????user
UserVO user = null;
try {
user = checkUser("xl1"?? "1");
} catch (BaseAppException e) {
e.printStackTrace();
} // ???????checkUser
String sessionInfo = "{institutionname:"???????"??institutioncode:"A01NC"??username:"Ф??1"
+ "1"??usercode:"xl1"??rolecode:"null"??bbhId:"402855b942099b1b014209b1177e03f5"??bbhcode:"B01b"??btype:"BASIC"??taskid:"402880ee425a92f501425a"
+ "a75ad50002"??bbhname:"???????b"??bbq:"" + bbq
+ ""??frequency:"MONTH"??SESSIONDIMENSION:{}}";
try {
userService.updateSession(sessionInfo?? user);
} catch (BaseAppException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} // ???????updateSession
// ???????????
InvokeSource invokeSource = InvokeSource.WSCALL;
CreateMulltiTaskReportGroboThread reportThread = new CreateMulltiTaskReportGroboThread(reportMap??user?? invokeSource??bbq);
tr[processCount] = reportThread;
processCount++;
}
System.out.println("#######################################??????########################");
long startTime = System.currentTimeMillis();
// ????????????????
MultiThreadedTestRunner mttr = new MultiThreadedTestRunner(tr);
// ???в??????
try {
mttr.runTestRunnables();
} catch (Throwable e) {
e.printStackTrace();
}
System.out.println("#######################????????"
+ String.valueOf((System.currentTimeMillis() - startTime) / 1000) + "??");
}
/**
* xl1 1
* */
public UserVO checkUser(String userid??
String password) throws BaseAppException {
Map<String?? String> paramMap = new HashMap<String?? String>();
paramMap.put("UserName"?? userid);
paramMap.put("Password"?? password);
List<User> users = userManager.findByCodeCache(userid);
List<User> needUsers = new ArrayList<User>();
if (users != null && users.size() > 0) {
for (User user : users) {
if (user.getState() && user.getCode().equals(userid)
&& user.getPassword().equals(Encryption.encryption(password))) {
needUsers.add(user);
}
}
}
// ??????
if (needUsers != null && needUsers.size() > 0) {
User user = needUsers.get(0);
// ?????????????????session??
// UserVO userVO = userManager.getUserPermission(user.getId());
String ipAddress = "0.0.0.0";
UserVO userVO = new UserVO();
BeanUtil2.copyProperties(user?? userVO);
userVO.setIpAddress(ipAddress);
return userVO; // ??????
} else {
return null;
}
}
}
|
?????????????????????????????????????????????????????????????????????Щ?????????ú????á?
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????