开发高可移植性J2ME的软件测试篇(下)

发表于:2009-3-26 13:45

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:饶荣庆    来源:IT168

  简单的Demo

  下面是简单的测试环境的代码,有经验的朋友可以很容易就就跑起来。

  代码片段

  /**

     * getSysInfo

     */

    private void getSysInfo() {

        addInfo("Microedition Configuration: ",

              getInfo(System.getProperty("microedition.configuration")));


      addInfo("Microedition Profiles: ",

              getInfo(System.getProperty("microedition.profiles")));


      addInfo("microedition.jtwi.version:",

              getInfo(System.getProperty("microedition.jtwi.version")));


      addInfo("microedition.platform:",

              getInfo(System.getProperty("microedition.platform")));


      addInfo("microedition.locale:",

              getInfo(System.getProperty("microedition.locale")));


      addInfo("default encoding:",

              getInfo(System.getProperty("microedition.encoding")));


      addInfo("microedition.commports",

            getInfo(System.getProperty("microedition.commports")));


      addInfo("microedition.hostname",

            getInfo(System.getProperty("microedition.hostname")));


    //  microedition.smartcardslots

              addInfo(" microedition.smartcardslots",

            getInfo(System.getProperty(" microedition.smartcardslots")));


      addInfo("com.nokia.network.access",

                      getInfo(System.getProperty("com.nokia.network.access"))); 


      addInfo("com.nokia.mid.dateformat",

              getInfo(System.getProperty("com.nokia.mid.dateformat")));


      addInfo("com.nokia.mid.timeformat",

              getInfo(System.getProperty("com.nokia.mid.timeformat")));

 

      addInfo("com.nokia.memoryramfree",

              getInfo(System.getProperty("com.nokia.memoryramfree")));


      addInfo("com.nokia.mid.batterylevel",

              getInfo(System.getProperty("com.nokia.mid.batterylevel")));


      addInfo("com.nokia.mid.countrycode",

              getInfo(System.getProperty("com.nokia.mid.countrycode")));


      addInfo("com.nokia.mid.networkstatus",

              getInfo(System.getProperty("com.nokia.mid.networkstatus")));


      addInfo("com.nokia.mid.networksignal",

              getInfo(System.getProperty("com.nokia.mid.networksignal")));

      addInfo("com.nokia.mid.networkid",

              getInfo(System.getProperty("com.nokia.mid.networkid")));

      addInfo("com.nokia.mid.networkavailability",

              getInfo(System.getProperty("com.nokia.mid.networkavailability")));

      addInfo("com.nokia.mid.cellid",

              getInfo(System.getProperty("com.nokia.mid.cellid")));

      addInfo("com.nokia.mid.imei",

              getInfo(System.getProperty("com.nokia.mid.imei")));

      addInfo("com.nokia.mid.imsi",

              getInfo(System.getProperty("com.nokia.mid.imsi")));


      String[] timeZoneIDs = java.util.TimeZone.getAvailableIDs();

      StringBuffer timeZonesBuffer = new StringBuffer();

      for (int i = 0; i < timeZoneIDs.length; i++) {

          timeZonesBuffer.append(timeZoneIDs[i]).append('\n');

      }


      addInfo("Total memory:",

              Long.toString(Runtime.getRuntime().totalMemory()) + " bytes");


      addInfo("Free memory:",

              Long.toString(Runtime.getRuntime().freeMemory()) + " bytes");

      addInfo("Available TimeZones:", timeZonesBuffer.toString());


      addInfo("Default TimeZone:", java.util.TimeZone.getDefault().getID());

      addInfo("com.siemens.mp.lcdui.Image", hasClassExit("com.siemens.mp.lcdui.Image") + "");

      addInfo("com.motorola.phonebook.PhoneBookRecord",        hasClassExit("com.motorola.phonebook.PhoneBookRecord") + "");

      addInfo("com.motorola.Dialer", hasClassExit("com.motorola.Dialer") + "");

      addInfo("com.jblend.util.Case", hasClassExit("com.jblend.util.Case") + "");

      addInfo("com.samsung.util.AudioClip", hasClassExit("com.samsung.util.AudioClip") + "");

      addInfo("com.mot.iden.multimedia.Lighting",     hasClassExit("com.mot.iden.multimedia.Lighting") + "");

    }

    private boolean hasClassExit(String aClassName) {

        try {

            Class.forName(aClassName);

            return true;

        } catch (Exception e) {

            return false;

        }

    }


   public String getInfo(String info) {

       if (info == null) {

           return "<unknown>";

       } else {

           return info;

       }

   }

    public void addInfo(String name, String value) {

        iForm.append(new StringItem(name, value));

}

42/4<1234>
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号