写文档时看着不好的随手改。

This commit is contained in:
Calvin
2013-07-01 23:57:42 +08:00
parent 63b3510f08
commit adb5a06eb9
12 changed files with 29 additions and 18 deletions
@@ -33,7 +33,7 @@ import org.springside.modules.beanvalidator.BeanValidators;
@RequestMapping(value = "/api/v1/task")
public class TaskRestController {
Logger logger = LoggerFactory.getLogger(TaskRestController.class);
private static Logger logger = LoggerFactory.getLogger(TaskRestController.class);
@Autowired
private TaskService taskService;
@@ -15,7 +15,7 @@
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<!-- 将StringHttpMessageCOnverter的默认编码设为UTF-8 -->
<!-- 将StringHttpMessageConverter的默认编码设为UTF-8 -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8" />
</bean>
@@ -35,7 +35,7 @@ public class BaseFunctionalTestCase {
private static Logger logger = LoggerFactory.getLogger(BaseFunctionalTestCase.class);
@BeforeClass
public static void beforeClass() throws Exception {
public static void initFunctionalTestEnv() throws Exception {
baseUrl = propertiesLoader.getProperty("baseUrl");
// 如果是目标地址是localhost,则启动嵌入式jetty。如果指向远程地址,则不需要启动Jetty.
@@ -20,12 +20,12 @@ public class BaseSeleniumTestCase extends BaseFunctionalTestCase {
protected static Selenium2 s;
//出错时截屏的规则
// 出错时截屏的规则
@Rule
public TestRule snapshotrule = new SeleniumSnapshotRule(s);
public TestRule snapshotRule = new SeleniumSnapshotRule(s);
@BeforeClass
public static void init() throws Exception {
public static void initSelenium() throws Exception {
createSeleniumOnce();
loginAsUserIfNecessary();
}
@@ -35,7 +35,7 @@ public class BaseSeleniumTestCase extends BaseFunctionalTestCase {
*/
protected static void createSeleniumOnce() throws Exception {
if (s == null) {
//根据配置创建Selenium driver.
// 根据配置创建Selenium driver.
String driverName = propertiesLoader.getProperty("selenium.driver");
WebDriver driver = WebDriverFactory.createDriver(driverName);
@@ -59,5 +59,4 @@ public class BaseSeleniumTestCase extends BaseFunctionalTestCase {
s.waitForTitleContains("任务管理");
}
}
}
@@ -26,8 +26,8 @@ public class QuickStartServer {
try {
server.start();
System.out.println("Server running at http://localhost:" + PORT + CONTEXT);
System.out.println("Hit Enter to reload the application quickly");
System.out.println("[INFO] Server running at http://localhost:" + PORT + CONTEXT);
System.out.println("[Hint] Hit Enter to reload the application quickly");
// 等待用户输入回车重载应用.
while (true) {
@@ -19,7 +19,7 @@ public class MashupServerController {
private static final String DEFAULT_JQUERY_JSONP_CALLBACK_PARM_NAME = "callback";
private final JsonMapper mapper = new JsonMapper();
private JsonMapper mapper = new JsonMapper();
@RequestMapping(value = "/web/mashup", produces = "applicaiton/javascript")
@ResponseBody
@@ -15,7 +15,7 @@
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager">
<mvc:message-converters register-defaults="true">
<!-- 将StringHttpMessageCOnverter的默认编码设为UTF-8 -->
<!-- 将StringHttpMessageConverter的默认编码设为UTF-8 -->
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8" />
</bean>
@@ -33,7 +33,10 @@ public class BaseFunctionalTestCase {
private static Logger logger = LoggerFactory.getLogger(BaseFunctionalTestCase.class);
@BeforeClass
public static void beforeClass() throws Exception {
public static void initFunctionalTestEnv() throws Exception {
System.out.println("[Hint] Don't forget to set -XX:MaxPermSize=128m");
baseUrl = propertiesLoader.getProperty("baseUrl");
Boolean isEmbedded = new URL(baseUrl).getHost().equals("localhost")
@@ -52,7 +55,7 @@ public class BaseFunctionalTestCase {
*/
protected static void startJettyOnce() throws Exception {
if (jettyServer == null) {
//设定Spring的profile
// 设定Spring的profile
System.setProperty("spring.profiles.active", "functional");
jettyServer = JettyFactory.createServerInSource(new URL(baseUrl).getPort(), ShowcaseServer.CONTEXT);
@@ -21,7 +21,7 @@ public class BaseSeleniumTestCase extends BaseFunctionalTestCase {
//出错时截屏的规则
@Rule
public TestRule snapshotrule = new SeleniumSnapshotRule(s);
public TestRule snapshotRule = new SeleniumSnapshotRule(s);
@BeforeClass
public static void createSeleniumOnce() throws Exception {
@@ -91,6 +91,11 @@ public class UserRestFT extends BaseFunctionalTestCase {
assertEquals("admin", response.getBody().getLoginName());
assertEquals("管理员", response.getBody().getName());
assertEquals(new Long(1), response.getBody().getTeamId());
// 直接取出XML串
HttpEntity<String> xml = jdkTemplate.exchange(resoureUrl + "/{id}.xml", HttpMethod.GET, requestEntity,
String.class, 1L);
System.out.println("xml output is " + xml.getBody());
}
/**
@@ -104,6 +109,10 @@ public class UserRestFT extends BaseFunctionalTestCase {
assertEquals("admin", user.getLoginName());
assertEquals("管理员", user.getName());
assertEquals(new Long(1), user.getTeamId());
// 直接取出JSON串
String json = httpClientRestTemplate.getForObject(resoureUrl + "/{id}.json", String.class, 1L);
System.out.println("json output is " + json);
}
/**
@@ -26,7 +26,7 @@ public class ShowcaseServer {
server.start();
System.out.println("Server running at http://localhost:" + PORT + CONTEXT);
System.out.println("Hit Enter to reload the application quickly");
System.out.println("[Hint] Hit Enter to reload the application quickly");
// 等待用户输入回车重载应用.
while (true) {
@@ -70,7 +70,7 @@ public class JettyFactory {
public static void reloadContext(Server server) throws Exception {
WebAppContext context = (WebAppContext) server.getHandler();
System.out.println("Application reloading");
System.out.println("[INFO] Application reloading");
context.stop();
WebAppClassLoader classLoader = new WebAppClassLoader(context);
@@ -80,6 +80,6 @@ public class JettyFactory {
context.start();
System.out.println("Application reloaded");
System.out.println("[INFO] Application reloaded");
}
}