隨筆 - 23  文章 - 11  trackbacks - 0
          <2011年6月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

          常用鏈接

          留言簿(3)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          在WebWork2.2中和Spring的結合變得簡單了,WebWork的Action的也可以由Spring來管理。但是如何進行測試了,在google上搜了一下,其代碼都是如下形式:
           1        Map params = new HashMap();
           2        params.put("a""test");
           3               Map paramCtx = new HashMap();
           4        paramCtx.put(ActionContext.PARAMETERS, params);
           5                ActionProxy proxy = ActionProxyFactory.getFactory().createActionProxy("/organiz""new_depart", paramCtx, falsefalse);
           6        proxy.setExecuteResult(false);
           7        assertEquals(proxy.execute(), "success");
           8
           9        MyTestAction action = (MyTestAction) proxy.getAction();
          10        assertEquals(action.getA(), "test");

          該代碼執行時會報錯誤,查看了一下源代碼應該加入
          1paramCtx.put(ActionContext.DEV_MODE, Boolean.FALSE);

          其次需要加載spring的applicationContext,代碼如下:
          1SpringObjectFactory objectFactory = new SpringObjectFactory();
          2        ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");
          3        objectFactory.setApplicationContext(appContext);
          4        ObjectFactory.setObjectFactory(objectFactory);


          posted @ 2012-02-28 22:53 小小~咖啡豆 閱讀(186) | 評論 (0)編輯 收藏
          1.編譯亂碼,設置編譯的字符集編碼和環境編碼
          <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-compiler-plugin</artifactId>
                          <version>2.3.2</version>
                          <configuration>
                              <source>1.4</source>
                              <target>1.4</target>
                              <encoding>UTF-8</encoding>
                          </configuration>
                      </plugin>
          設置環境變量MAVEN_OPTS=-Xms64m -Xmx128m -Dfile.encoding=UTF-8
          2.運行mvn test時亂碼(IDE上運行TestCase時OK,但是運行maven test亂碼,結果測試不通過)修改pom.xml增加如下內容即可
          <plugin>
                          <groupId>org.apache.maven.plugins</groupId>
                          <artifactId>maven-surefire-plugin</artifactId>
                          <version>2.7.2</version>
                          <configuration>
                              <forkMode>once</forkMode>
                              <argLine>-Dfile.encoding=UTF-8</argLine>
                              <systemProperties>
                                  <property>
                                      <name>net.sourceforge.cobertura.datafile</name>
                                      <value>target/cobertura/cobertura.ser</value>
                                  </property>
                              </systemProperties>
                          </configuration>
                      </plugin>
          posted @ 2011-06-30 02:15 小小~咖啡豆 閱讀(1526) | 評論 (1)編輯 收藏
          主站蜘蛛池模板: 五峰| 广河县| 西青区| 蓬莱市| 望都县| 电白县| 高碑店市| 五大连池市| 丰台区| 洪洞县| 清镇市| 贵州省| 乌苏市| 观塘区| 通道| 西乡县| 武定县| 弥勒县| 三亚市| 东台市| 本溪市| 包头市| 惠来县| 宜春市| 昌平区| 绥德县| 武穴市| 卢龙县| 松潘县| 绥中县| 临澧县| 香港| 阳春市| 卢龙县| 婺源县| 湟中县| 靖宇县| 永川市| 天等县| 水城县| 尚义县|