test_class.declarator: logoutAction
test_class.modifier: @Autowired
  	private
test_class.original_string: @Autowired
  	private LogoutAction logoutAction;
test_class.type: LogoutAction
test_class.var_name: logoutAction
test_class.file: ki4so-web/src/test/java/com/github/ebnew/ki4so/web/action/LogoutActionTest.java
test_class.identifier: LogoutActionTest
test_case.body: @Test
  	public void testGetAppList() throws UnsupportedEncodingException {
  		//测试准备。
  		MockHttpServletRequest request = new MockHttpServletRequest();
  		MockHttpServletResponse response = new MockHttpServletResponse();
  		CredentialResolver credentialResolver = Mockito.mock(CredentialResolver.class);
  		logoutAction.setCredentialResolver(credentialResolver);
  		
  		Ki4soService ki4soService = Mockito.mock(Ki4soService.class);
  		logoutAction.setKi4soService(ki4soService);
  		
  		Credential credential = Mockito.mock(Credential.class);
  		
  		//设置预期结果。
  		Mockito.when(credentialResolver.resolveCredential(request)).thenReturn(credential);
  		List<App> list = new ArrayList<App>();
  		App app = new App();
  		app.setAppId("1000");
  		app.setAppName("测试应用程序1");
  		app.setHost("app.com");
  		app.setLogoutUrl("http://app.com/logout.do");
  		list.add(app);
  		Mockito.when(ki4soService.getAppList(credential)).thenReturn(list);
  		
  		//执行查询。
  		logoutAction.getAppList(request, response);
  		
  		//检查结果。
  		Assert.assertEquals("application/x-javascript", response.getContentType());
  		Assert.assertEquals("UTF-8", response.getCharacterEncoding());
  		//检查输出的jsonp串是否正确。
  		String content = response.getContentAsString();
  		content = content.trim();
  		Assert.assertTrue(content.startsWith("fetchAppList("));
  		Assert.assertTrue(content.endsWith(");"));
  		String json = content.replaceFirst("fetchAppList\\(", "");
  		json = json.replaceFirst("\\);", "");
  		JSONArray data = (JSONArray)JSON.parse(json);
  		Assert.assertEquals(1, data.size());
  		@SuppressWarnings("unchecked")
  		Map<String, Object> map = (Map<String, Object>)data.get(0);
  		Assert.assertEquals("1000", map.get("appId"));
  		
  	}
test_case.class_method_signature: LogoutActionTest.testGetAppList()
test_case.full_signature: @Test public void testGetAppList()
test_case.identifier: testGetAppList
test_case.invocations: mock setCredentialResolver mock setKi4soService mock thenReturn when resolveCredential setAppId setAppName setHost setLogoutUrl add thenReturn when getAppList getAppList assertEquals getContentType assertEquals getCharacterEncoding getContentAsString trim assertTrue startsWith assertTrue endsWith replaceFirst replaceFirst parse assertEquals size get assertEquals get
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetAppList()
focal_class.declarator: credentialResolver
focal_class.modifier: @Autowired
  	protected
focal_class.original_string: @Autowired
  	protected CredentialResolver credentialResolver;
focal_class.type: CredentialResolver
focal_class.var_name: credentialResolver
focal_class.declarator: ki4soService
focal_class.modifier: @Autowired
  	protected
focal_class.original_string: @Autowired
  	protected Ki4soService ki4soService;
focal_class.type: Ki4soService
focal_class.var_name: ki4soService
focal_class.file: ki4so-web/src/main/java/com/github/ebnew/ki4so/web/action/LogoutAction.java
focal_class.identifier: LogoutAction
focal_class.class_method_signature: LogoutAction.setKi4soService(Ki4soService ki4soService)
focal_class.full_signature: public void setKi4soService(Ki4soService ki4soService)
focal_class.identifier: setKi4soService
focal_class.modifiers: public
focal_class.parameters: (Ki4soService ki4soService)
focal_class.return: void
focal_class.signature: void setKi4soService(Ki4soService ki4soService)
focal_class.class_method_signature: LogoutAction.setCredentialResolver(CredentialResolver credentialResolver)
focal_class.full_signature: public void setCredentialResolver(CredentialResolver credentialResolver)
focal_class.identifier: setCredentialResolver
focal_class.modifiers: public
focal_class.parameters: (CredentialResolver credentialResolver)
focal_class.return: void
focal_class.signature: void setCredentialResolver(CredentialResolver credentialResolver)
focal_class.class_method_signature: LogoutAction.getAppList(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.full_signature: @RequestMapping("/getAppList") public void getAppList(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.identifier: getAppList
focal_class.modifiers: @RequestMapping("/getAppList") public
focal_class.parameters: (HttpServletRequest request,
  			HttpServletResponse response)
focal_class.return: void
focal_class.signature: void getAppList(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.class_method_signature: LogoutAction.getCallbackName(String defalutCallbackName, HttpServletRequest request)
focal_class.full_signature: private String getCallbackName(String defalutCallbackName, HttpServletRequest request)
focal_class.identifier: getCallbackName
focal_class.modifiers: private
focal_class.parameters: (String defalutCallbackName, HttpServletRequest request)
focal_class.return: String
focal_class.signature: String getCallbackName(String defalutCallbackName, HttpServletRequest request)
focal_class.class_method_signature: LogoutAction.logout(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.full_signature: @RequestMapping("/logout") public void logout(HttpServletRequest request,
  			HttpServletResponse response)
focal_class.identifier: logout
focal_class.modifiers: @RequestMapping("/logout") public
focal_class.parameters: (HttpServletRequest request,
  			HttpServletResponse response)
focal_class.return: void
focal_class.signature: void logout(HttpServletRequest request,
  			HttpServletResponse response)
focal_method.body: @RequestMapping("/getAppList")
  	public void getAppList(HttpServletRequest request,
  			HttpServletResponse response){
  		//解析用户凭据。
  		Credential credential = credentialResolver.resolveCredential(request);
  		//实现输出为json串。
  		List<App> list =  this.ki4soService.getAppList(credential);
  		String json = JSON.toJSONString(list);
  		StringBuffer sb = new StringBuffer();
  		sb.append(getCallbackName("fetchAppList", request))
  		.append("(")
  		.append(json)
  		.append(");");
  		try {
  			response.setContentType("application/x-javascript");
  			response.setCharacterEncoding("UTF-8");
  			response.getWriter().println(sb.toString());
  		} catch (IOException e) {
  		}
  	}
focal_method.class_method_signature: LogoutAction.getAppList(HttpServletRequest request,
  			HttpServletResponse response)
focal_method.full_signature: @RequestMapping("/getAppList") public void getAppList(HttpServletRequest request,
  			HttpServletResponse response)
focal_method.identifier: getAppList
focal_method.invocations: resolveCredential getAppList toJSONString append append append append getCallbackName setContentType setCharacterEncoding println getWriter toString
focal_method.modifiers: @RequestMapping("/getAppList") public
focal_method.parameters: (HttpServletRequest request,
  			HttpServletResponse response)
focal_method.return: void
focal_method.signature: void getAppList(HttpServletRequest request,
  			HttpServletResponse response)