WO2017012218A1 - 利用tck测试安卓系统j2me标准接口实现的方法 - Google Patents

利用tck测试安卓系统j2me标准接口实现的方法 Download PDF

Info

Publication number
WO2017012218A1
WO2017012218A1 PCT/CN2015/093263 CN2015093263W WO2017012218A1 WO 2017012218 A1 WO2017012218 A1 WO 2017012218A1 CN 2015093263 W CN2015093263 W CN 2015093263W WO 2017012218 A1 WO2017012218 A1 WO 2017012218A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
android
package
jar
parameter information
Prior art date
Application number
PCT/CN2015/093263
Other languages
English (en)
French (fr)
Inventor
朱田田
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2017012218A1 publication Critical patent/WO2017012218A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software

Definitions

  • the present invention relates to the field of communication technologies, and in particular, to a method for testing a standard interface of a Java 2 Platform Micro Edition (J2ME) using a Technology Compatibility Kit (TCK) to test an Android (Android) system. .
  • J2ME Java 2 Platform Micro Edition
  • TK Technology Compatibility Kit
  • the Android system can support the running of J2ME applications, but it is necessary to test the completeness and compatibility of the J2ME standard interface implementation on the Android system.
  • TCK is a toolkit that integrates tools, inspections, and documentation. TCK is set to demonstrate whether a particular Sun technology implementation is compatible with the application specification or is compatible with Sun's reference implementations. Only systems that pass the TCK test are Will be considered in line with Java's relevant standards and specifications. Therefore, with the TCK test platform, the completeness and compatibility of the J2ME standard interface implementation of the Android system can be tested.
  • the embodiment of the present invention provides a method for testing an Android (Android) system J2ME standard interface by using TCK, so as to at least solve the problem that in the related art, without Java source code and only Jar file package, Jar conversion cannot be performed.
  • the problem for Apk is not limited to, but not limited to, but not limited to, but not Java source code and only Jar file package, Jar conversion cannot be performed.
  • An embodiment of the present invention provides a method for testing an Android system J2ME standard interface by using TCK, including: extracting parameter information in a Jar file package; and putting the parameter information into a preset Android Android engineering model to form Android project; based on the Android project, generate an Android package Apk file; wherein the Apk file is run in the Android system to test the implementation of the Android system J2ME standard interface.
  • the parameter information is put into the preset Android Android engineering model, including: detecting, according to the parameter information, a type of the Jar file package by using a Java reflection mechanism; in a preset plurality of Android engineering models Obtaining an Android engineering model corresponding to the type of the Jar file package; and inserting the parameter information into an Android engineering model corresponding to the type of the Jar file package.
  • the parameter information is extracted in the Jar file package, and the parameter information is extracted in the Manifest.mf manifest file of the Jar file package.
  • the parameter information includes: a main class MainClass and a package name package.
  • the Android engineering model includes: a source code model file, an AndroidManifest.xml model file; the Android project includes: a source code file, an AndroidMainfest.xml file, and a resource file; and the parameter information is put into a preset Android Android engineering model,
  • AndroidManifest.xml file the file other than the .class file in the Jar file package is used as the resource file of the Android project.
  • the generating, according to the Android project, the Apk file includes: compiling the source code file into a .class file; generating a .dex file based on the compiled .class file and the .class file in the Jar file package; Generating an .ap file based on the AndroidManifest.xml file and the resource file; generating an Apk file based on the .dex file and the .ap file.
  • the embodiment of the invention further provides an apparatus for testing an Android system J2ME standard interface by using TCK, comprising: an extracting module, configured to extract parameter information in a Jar file package; and a packaging module configured to put the parameter information into a preset Android Android project model to form an Android project; a conversion module configured to generate an Android package Apk file based on the Android project; wherein the Apk file is run in an Android system to test the Android system J2ME Implementation of standard interfaces.
  • the encapsulation module is configured to: detect, according to the parameter information, a type of the Jar file package by using a Java reflection mechanism; and obtain a type corresponding to the type of the Jar file package in a preset plurality of Android engineering models The Android engineering model; the parameter information is placed in the Android engineering model corresponding to the type of the Jar file package.
  • the extraction module is specifically configured to extract parameter information in a Manifest.mf manifest file of the Jar file package, where the parameter information includes: a main class MainClass and a package name package.
  • the Android project model includes: a source code model file, an AndroidManifest.xml model file; the Android project includes: a source code file, an AndroidMainfest.xml file, and a resource file; the package module is specifically configured to: put the MainClass and the Package, In the source code model file, the source code file of the Android project is formed; the MainClass and the Package are placed in the AndroidManifest.xml model file to form an AndroidManifest.xml file of the Android project; the class of the Jar file is divided by .class Files outside the file are used as resource files for Android projects.
  • the conversion module is specifically configured to: compile the source code file into a .class file; generate a .dex file based on the compiled .class file and the .class file in the Jar file package; based on the AndroidManifest .xml file and The resource file generates an .ap file; and generates an Apk file based on the .dex file and the .ap file.
  • the embodiment of the invention improves on the basis of the TCK test.
  • the information in the Jar file package and the preset Android engineering model are used to convert the Jar file package into Apk file. This method can automatically test the completeness and compatibility of the Android system J2ME standard interface implementation.
  • FIG. 1 is a flowchart of an interaction process between a server and a client when testing an implementation of a J2ME standard interface of an Android system according to an embodiment of the present invention
  • FIG. 2 is a flowchart of a method for testing an Android system J2ME standard interface using TCK according to an embodiment of the present invention
  • FIG. 3 is a specific flowchart of a method for testing an Android system J2ME standard interface by using TCK according to an embodiment of the present invention
  • FIG. 4 is a structural diagram of an apparatus for implementing an Android system J2ME standard interface using TCK according to an embodiment of the present invention.
  • the embodiment of the invention utilizes the TCK test system to test the completeness and compatibility of the implementation of the J2ME standard interface of the Android system.
  • the TCK test system includes: a server and a client.
  • the server is set up to provide testing services.
  • the client is set to accept the test from the server.
  • the client runs on the Android system.
  • step S110 the server deploys the test case according to the test requirements.
  • the test case is set to test the completeness and compatibility of the Android system J2ME standard interface implementation.
  • step S120 the server establishes a HyperText Transfer Protocol (HTTP) connection with the client.
  • HTTP HyperText Transfer Protocol
  • Step S130 After receiving the test request sent by the client, the server converts the test case test.jar that the client needs to execute into test1.Apk, and then sends the test case to the client.
  • test case test.jar includes source code set to test the implementation of the Android system J2ME standard interface.
  • the test case test.jar can be a Jar package.
  • the Jar package is obtained after the Java source code is compiled and packaged.
  • step S140 the client executes the test case test.Apk and sends the test result to the server.
  • step S150 the server determines whether there are still test cases to be tested. If yes, go to step S130; if no, go to step S160.
  • step S160 the final test result is output.
  • test results can reflect the completeness and compatibility of the Android system J2ME standard interface implementation.
  • An embodiment of the present invention provides a method for testing an Android system J2ME standard interface by using TCK.
  • FIG. 2 it is a flowchart of a method for testing an Android system J2ME standard interface by using TCK according to an embodiment of the present invention. The steps of this embodiment are performed at the server.
  • Step S210 extracting parameter information in the Jar file package.
  • the parameter information includes but is not limited to: main class MainClass, package name package configuration item information.
  • Step S220 the parameter information is put into a preset Android Android engineering model to form an Android project.
  • the Java reflection mechanism can be used to detect the type of the Jar file package; in a plurality of preset Android engineering models, the Android project model corresponding to the type of the Jar file package is obtained; Go to the Android project model corresponding to the type of the Jar file package; package the Android project model into which the parameter information is placed to form an Android project.
  • the Java reflection mechanism means that in the running state, all the properties and methods of any class can be known; any method and property of any object can be called; the function of dynamically acquiring information and dynamically calling the object is called The reflection mechanism of the Java language.
  • the types of Jar package include: MIDlet type, Xlet type, Main type.
  • the types of Android engineering models also include: MIDlet type, Xlet type, Main type.
  • Step S230 generating an Android package Apk file based on the Android project; wherein the Apk file is run in the Android system to test the implementation of the Android system J2ME standard interface.
  • the converted Apk file is sent to a client running on the Android system to test the implementation of the Android system J2ME standard interface.
  • the client feedback test results, the test results can reflect the completeness and compatibility of the Android system J2ME standard interface implementation.
  • Android projects include: source code files, AndroidMainfest.xml files, and resource files.
  • the AndroidMainfest.xml file is the configuration information list file of Apk. In order to make the invention more apparent, the invention is further described below.
  • FIG. 3 it is a specific flowchart of a method for testing an Android system J2ME standard interface by using TCK according to an embodiment of the present invention.
  • Step S310 detecting the type of the Jar file package by using the Java reflection mechanism based on the extracted MainClass and the Package.
  • the Java reflection mechanism can be used to detect whether there is a class that inherits the MIDlet in the Jar package, and if so, the Jar package is determined to be of the MIDlet type; if not, the detection is performed. Whether there is a class that implements the Xlet interface in the Jar package, and if so, it determines that the Jar package is an Xlet application; if not, it determines that the Jar package is of the Main type.
  • Step S320 Obtain an Android engineering model corresponding to the type of the Jar file package in the preset multiple Android engineering models; wherein the Android engineering model includes: a source code model file, and an AndroidManifest.xml model file.
  • the MIDlet type Android engineering model includes general information of the MIDlet type application
  • the Xlet type Android engineering model includes general information of the Xlet type application
  • the Main type Android engineering model includes the general information of the Main type application.
  • Non-generic information for this type of application is also included in each Android engineering model. It is necessary to fill in the non-general information part from the parameter information extracted from each Jar file package, so that the information in the Android engineering model is complete.
  • step S330 the MainClass and the Package are placed in the source code model file to form a source code file of the Android project.
  • the Java reflection mechanism is used to call the corresponding interface in the Jar file package in the callback interface of the Android Activity life cycle.
  • the StartApp() interface in the Jar file of the MIDlet type corresponds to the onCreate() interface of the Android Activity;
  • the initXlet() interface in the Jar file of the Xlet type corresponds to the onCreate() interface of the Android Activity;
  • in the Jar file of the Main type MainClass corresponds to the Android Activity's onCreate() interface.
  • step S340 the MainClass and the Package are placed in the AndroidManifest.xml model file to form an AndroidManifest.xml file of the Android project.
  • Step S350 the file other than the .class file in the Jar file package is used as the resource file of the Android project.
  • Step S360 the source code file, the AndroidManifest.xml file, and the resource file are packaged to form an Apk. file.
  • Step 1 Compile the source code file into a .class file.
  • Step 2 Generate a .dex file based on the compiled .class file and the .class file in the Jar file package. Further, using the dx tool, the compiled .class file and the .class file in the Jar file package are packaged to generate a .dex file.
  • Step 3 Generate an .ap file based on the AndroidManifest.xml file and the resource file. Further, using the aapt tool, the AndroidManifest.xml file and the resource file are packaged to be generated as an .ap file.
  • the resource files include: files in the assets directory and files in the res directory.
  • Step 4 Generate an Apk file based on the .dex file and the .ap file. Further, the .jar file and the .ap file are packaged into an Apk file using the Jar packaging tool.
  • the Apk file after converting the Jar file package into the Apk file, can be signed with the private key and the public key file by using the signApk tool provided by Android to obtain the signed Apk file. Further, the zipalign tool provided by Android can be used to optimize the signed Apk file, and finally the optimized Apk file is obtained.
  • the embodiment of the invention further provides an apparatus for testing the Android system J2ME standard interface by using TCK.
  • FIG. 4 it is a structural diagram of an apparatus implemented by the TCK test Android system J2ME standard interface according to an embodiment of the present invention.
  • the device includes:
  • the extraction module 410 is configured to extract parameter information in the Jar file package.
  • the encapsulation module 420 is configured to put the parameter information into a preset Android Android engineering model to form an Android project.
  • the conversion module 430 is configured to generate an Android package Apk file based on the Android project; wherein the Apk file is run in the Android system to test the implementation of the Android system J2ME standard interface.
  • the extraction module 410 is specifically configured to extract parameter information in a Manifest.mf manifest file of the Jar file package, where the parameter information includes: a main class MainClass and a package name Package.
  • the encapsulation module 420 is further configured to: detect, according to the parameter information, a type of the Jar file package by using a Java reflection mechanism; and obtain a type corresponding to the type of the Jar file package in a preset plurality of Android engineering models The Android engineering model; the parameter information is placed in the Android engineering model corresponding to the type of the Jar file package.
  • Android engineering model includes: source code model file, AndroidManifest.xml model file;
  • the encapsulation module 420 is specifically configured to: put the MainClass and the Package into a source code model file to form a source code file of the Android project; and put the MainClass and the Package into the AndroidManifest.xml mode.
  • the type file an AndroidManifest.xml file of the Android project is formed; a file other than the .class file in the Jar file package is used as a resource file of the Android project.
  • the conversion module 430 is specifically configured to: compile the source code file into a .class file; generate a .dex file based on the compiled .class file and the .class file in the Jar file package; based on the AndroidManifest.
  • the xml file and the resource file generate an .ap file; and generate an Apk file based on the .dex file and the .ap file.
  • the method for implementing the T2 test Android system J2ME standard interface provided by the embodiment of the present invention has the following beneficial effects: it is improved on the basis of the TCK test, and in the TCK test, there is no Java source code.
  • the Jar file package is converted into an Apk file by using the information in the Jar file package and the default Android project model. This method can automatically test the completeness and compatibility of the Android system J2ME standard interface implementation.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明公开了一种利用TCK测试Android系统J2ME标准接口实现的方法,包括:在Jar文件包中,提取参数信息;将参数信息放入预设的安卓Android工程模型中,以便形成Android工程;基于Android工程,生成安卓包Apk文件;其中,在Android系统中运行Apk文件,以测试Android系统J2ME标准接口的实现。本发明在TCK测试的基础上对其加以改进,在TCK测试中,在没有Java源代码的情况下,利用Jar文件包中的信息和预设的Android工程模型,将Jar文件包转换为Apk文件。通过该方法可以自动对Android系统J2ME标准接口实现的完备性和兼容性进行测试。

Description

利用TCK测试安卓系统J2ME标准接口实现的方法 技术领域
本发明涉及通信技术领域,特别是涉及一种利用技术兼容包(Technology Compatibility Kit,简称TCK)测试安卓(Android)系统Java 2平台微型版(Java 2 Platform Micro Edition,简称J2ME)标准接口实现的方法。
背景技术
目前Android系统可以实现支持J2ME应用程序运行,但是,需要在Android系统上测试J2ME标准接口实现的完备性和兼容性。
基于预先准备的大量J2ME应用程序,在Android系统上逐个执行J2ME测试,并不能完整地测试出Android系统对J2ME标准接口的完备性和兼容性,并且因为J2ME标准接口并不是Android系统自有接口,所以Android系统的测试工具中没有对J2ME标准接口的测试方法。
TCK是一套集工具、检测及文档于一体的工具包,TCK设置为证明一个特定的Sun技术实现是否和应用程序规范兼容、或者是否和Sun设计的参考实现兼容,只有通过TCK测试的系统才会被认为符合Java的相关标准和规范。因此,借助TCK测试平台,可以测试出Android系统的J2ME标准接口实现的完备性和兼容性。
因为Android系统能够运行安卓包(Android Package,简称Apk),而不能直接运行Java归档文件(Java Archive,简称Jar),所以,如果借助TCK测试平台测试Android系统的J2ME标准接口实现的完备性和兼容性,需要将Jar转换为Apk,通过在Android系统中运行Apk,来测试J2ME标准接口实现的完备性和兼容性,但是,在相关技术中,只能在具有Java源代码的情况下转换出Apk,而在没有Java源代码、只有Jar文件包的情况下,无法将Jar转换为Apk。
发明内容
本发明实施例提供了一种利用TCK测试安卓(Android)系统J2ME标准接口实现的方法,用以至少解决在相关技术中,在没有Java源代码、只有Jar文件包的情况下,无法将Jar转换为Apk的问题。
基于上述技术问题,本发明实施例是通过以下技术方案来解决的。
本发明实施例提供了一种利用TCK测试Android系统J2ME标准接口实现的方法,包括:在Jar文件包中,提取参数信息;将所述参数信息放入预设的安卓Android工程模型中,以便形成Android工程;基于所述Android工程,生成安卓包Apk文件;其中,在Android系统中运行所述Apk文件,以测试所述Android系统J2ME标准接口的实现。
其中,将所述参数信息放入预设的安卓Android工程模型中,包括:基于所述参数信息,利用Java反射机制检测出所述Jar文件包的类型;在预设的多种Android工程模型中,获取所述Jar文件包的类型对应的Android工程模型;将所述参数信息放入所述Jar文件包的类型对应的Android工程模型中。
其中,在Jar文件包中,提取参数信息,包括:在Jar文件包的Manifest.mf清单文件中,提取参数信息;其中,所述参数信息包括:主类MainClass、包名Package。
其中,Android工程模型包括:源代码模型文件、AndroidManifest.xml模型文件;Android工程包括:源代码文件、AndroidMainfest.xml文件和资源文件;将所述参数信息放入预设的安卓Android工程模型中,以便形成Android工程,包括:将所述MainClass和Package,放入源代码模型文件中,形成Android工程的源代码文件;将所述MainClass和Package,放入AndroidManifest.xml模型文件中,形成Android工程的AndroidManifest.xml文件;将所述Jar文件包中除.class文件外的文件作为Android工程的资源文件。
其中,基于所述Android工程,生成Apk文件,包括:将所述源代码文件编译成.class文件;基于编译成的.class文件和所述Jar文件包中的.class文件,生成.dex文件;基于所述AndroidManifest.xml文件和所述资源文件,生成.ap文件;基于所述.dex文件和所述.ap文件,生成Apk文件。
本发明实施例还提供了一种利用TCK测试Android系统J2ME标准接口实现的装置,包括:提取模块,设置为在Jar文件包中,提取参数信息;封装模块,设置为将所述参数信息放入预设的安卓Android工程模型中,以便形成Android工程;转换模块,设置为基于所述Android工程,生成安卓包Apk文件;其中,在Android系统中运行所述Apk文件,以测试所述Android系统J2ME标准接口的实现。
其中,所述封装模块设置为:基于所述参数信息,利用Java反射机制检测出所述Jar文件包的类型;在预设的多种Android工程模型中,获取所述Jar文件包的类型对应的Android工程模型;将所述参数信息放入所述Jar文件包的类型对应的Android工程模型中。
其中,所述提取模块具体设置为:在Jar文件包的Manifest.mf清单文件中,提取参数信息;其中,所述参数信息包括:主类MainClass、包名Package。
其中,Android工程模型包括:源代码模型文件、AndroidManifest.xml模型文件;Android工程包括:源代码文件、AndroidMainfest.xml文件和资源文件;所述封装模块具体设置为:将所述MainClass和Package,放入源代码模型文件中,形成Android工程的源代码文件;将所述MainClass和Package,放入AndroidManifest.xml模型文件中,形成Android工程的AndroidManifest.xml文件;将所述Jar文件包中除.class文件外的文件作为Android工程的资源文件。
其中,所述转换模块具体设置为:将所述源代码文件编译成.class文件;基于编译成的.class文件和所述Jar文件包中的.class文件,生成.dex文件;基于所述AndroidManifest.xml文件和 所述资源文件,生成.ap文件;基于所述.dex文件和所述.ap文件,生成Apk文件。
本发明实施例有益效果如下:
本发明实施例在TCK测试的基础上对其加以改进,在TCK测试中,在没有Java源代码的情况下,利用Jar文件包中的信息和预设的Android工程模型,将Jar文件包转换为Apk文件。通过该方法可以自动对Android系统J2ME标准接口实现的完备性和兼容性进行测试。
附图说明
图1是根据本发明一实施例的测试Android系统J2ME标准接口实现时服务端和客户端的交互过程流程图;
图2是根据本发明一实施例的利用TCK测试Android系统J2ME标准接口实现的方法的流程图;
图3是根据本发明一实施例的利用TCK测试Android系统J2ME标准接口实现的方法的具体流程图;
图4是根据本发明一实施例的利用TCK测试Android系统J2ME标准接口实现的装置的结构图。
具体实施方式
以下结合附图以及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不限定本发明。
本发明实施例利用TCK测试系统,来测试Android系统J2ME标准接口实现的完备性和兼容性。TCK测试系统包括:服务端和客户端。服务端设置为提供测试服务。客户端设置为接受服务端的测试。该客户端运行在Android系统中。
利用TCK测试系统,测试Android系统J2ME标准接口实现的完备性和兼容性时,服务端和客户端的交互过程如图1所示。
步骤S110,服务端按照测试要求部署测试用例。
测试用例设置为测试Android系统J2ME标准接口实现的完备性和兼容性。
步骤S120,服务端与客户端建立超文本传输协议(HyperText Transfer Protocol,简称HTTP)连接。
步骤S130,服务端在接收到客户端发送的测试请求之后,将客户端需要执行的测试用例test.jar转换为test1.Apk之后,发送给客户端。
测试用例test.jar包括设置为测试Android系统J2ME标准接口实现的源代码。
测试用例test.jar可以是Jar包。Jar包是Java源代码经编译打包后得到的。
步骤S140,客户端执行测试用例test.Apk,并将测试结果发送给服务端。
步骤S150,服务端判断是否还有待测试的测试用例。若是,则执行步骤S130;若否,则执行步骤S160。
步骤S160,输出最终的测试结果。
测试结果可以反映出Android系统J2ME标准接口实现的完备性和兼容性是否达标。
本发明实施例提供了一种利用TCK测试Android系统J2ME标准接口实现的方法,如图2所示,为根据本发明一实施例的利用TCK测试Android系统J2ME标准接口实现的方法的流程图。本实施例的步骤在服务端执行。
步骤S210,在Jar文件包中,提取参数信息。
读取Manifest.mf清单文件中的配置项;在Jar文件包的Manifest.mf清单文件中,提取参数信息。参数信息包括但不限于:主类MainClass、包名Package配置项信息。
步骤S220,将所述参数信息放入预设的安卓Android工程模型中,以便形成Android工程。
基于提取出的参数信息,利用Java反射机制,可以检测出Jar文件包的类型;在预设的多种Android工程模型中,获取Jar文件包的类型对应的Android工程模型;将所述参数信息放到所述Jar文件包的类型对应的Android工程模型中;对放入参数信息的Android工程模型打包,形成Android工程。
Java反射机制是指:在运行状态中,能够得知任意一个类的所有属性和方法;能够调用任意一个对象的任意一个方法和属性;这种动态获取信息以及动态调用对象的方法的功能称为Java语言的反射机制。
Jar文件包的类型包括:MIDlet类型、Xlet类型、Main类型。为了与Jar文件包的类型对应,Android工程模型的类型也包括:MIDlet类型、Xlet类型、Main类型。
步骤S230,基于所述Android工程,生成安卓包Apk文件;其中,在Android系统中运行所述Apk文件,以测试所述Android系统J2ME标准接口的实现。
将转换出的Apk文件向运行在Android系统的客户端发送,以便测试所述Android系统J2ME标准接口的实现。客户端反馈测试结果,该测试结果可以反映出Android系统J2ME标准接口实现的完备性和兼容性。
Android工程包括:源代码文件、AndroidMainfest.xml文件和资源文件。 AndroidMainfest.xml文件是Apk的配置信息清单文件。为了使本发明更加清楚,下面对本发明进行进一步地描述。
如图3所示,为根据本发明一实施例的利用TCK测试Android系统J2ME标准接口实现的方法的具体流程图。
步骤S310,基于提取出的MainClass和Package,利用Java反射机制检测出Jar文件包的类型。
由于Jar文件包是J2ME应用,因此在提取出MainClass和Package之后,可以利用Java反射机制,可以检测Jar包中是否存在继承MIDlet的类,若是,则判定Jar包为MIDlet类型;若否,则检测Jar包中是否存在实现Xlet接口的类,若是,则判定Jar包为Xlet应用;若否,则判定Jar包为Main类型。
步骤S320,在预设的多种Android工程模型中,获取Jar文件包的类型对应的Android工程模型;其中,Android工程模型包括:源代码模型文件、AndroidManifest.xml模型文件。
根据Jar文件包的类型,在预设的多种Android工程模型中,选择对应类型的Android工程模型。
每种Android工程模型中包括该种类应用的通用信息。只要是该种类型的Jar文件包,在转换Apk的过程时,都可以使用该类型Android工程模型的通用信息。例如:MIDlet类型的Android工程模型中包括MIDlet类型应用的通用信息;Xlet类型的Android工程模型中包括Xlet类型应用的通用信息;Main类型的Android工程模型中包括Main类型应用的通用信息。
每种Android工程模型中还包括该种类应用的非通用信息。需要将从每个Jar文件包中提取出的参数信息填入非通用信息部分,使Android工程模型中的信息完整。
步骤S330,将MainClass和Package,放到源代码模型文件中,形成Android工程的源代码文件。
在形成源代码文件时,利用Java反射机制,在Android的Activity生命周期的回调接口中调用Jar文件包中的对应接口。
接口的对应关系如下:
MIDlet类型的Jar文件包中的StartApp()接口对应Android Activity的onCreate()接口;Xlet类型的Jar文件包中的initXlet()接口对应Android Activity的onCreate()接口;Main类型的Jar文件包中的MainClass对应Android Activity的onCreate()接口。
步骤S340,将MainClass和Package,放到AndroidManifest.xml模型文件中,形成Android工程的AndroidManifest.xml文件。
步骤S350,将所述Jar文件包中除.class文件外的文件作为Android工程的资源文件。
步骤S360,将源代码文件、AndroidManifest.xml文件和资源文件进行打包处理,形成Apk 文件。
步骤1,将所述源代码文件编译成.class文件。
步骤2,基于编译成的所述.class文件和Jar文件包中的.class文件,生成.dex文件。进一步地,利用dx工具,将编译的.class文件和Jar文件包中的.class文件打包,以生成.dex文件。
步骤3,基于AndroidManifest.xml文件和资源文件,生成.ap文件。进一步地,利用aapt工具,将AndroidManifest.xml文件和资源文件打包,以生成为.ap文件。该资源文件包括:assets目录下的文件和res目录下的文件。
步骤4,基于所述.dex文件和所述.ap文件,生成Apk文件。进一步地,利用Jar打包工具,将.dex文件和.ap文件打包成Apk文件。
在一个实施例中,在将Jar文件包转换成Apk文件之后,可以利用Android提供的signApk工具用私钥和公钥文件对Apk文件进行签名,得到签名后的Apk文件。进一步地,还可以使用Android提供的zipalign的工具,对签名后的Apk文件进行优化,最终得到优化后的Apk文件。
本发明实施例还提供了一种利用TCK测试Android系统J2ME标准接口实现的装置。如图4所示,为根据本发明一实施例的利用TCK测试Android系统J2ME标准接口实现的装置的结构图。
该装置包括:
提取模块410,设置为在Jar文件包中,提取参数信息。
封装模块420,设置为将所述参数信息放入预设的安卓Android工程模型中,以便形成Android工程。
转换模块430,设置为基于所述Android工程,生成安卓包Apk文件;其中,在所述Android系统中运行所述Apk文件,以测试所述Android系统J2ME标准接口的实现。
所述提取模块410具体设置为:在Jar文件包的Manifest.mf清单文件中,提取参数信息;其中,所述参数信息包括:主类MainClass、包名Package。
所述封装模块420还设置为:基于所述参数信息,利用Java反射机制检测出所述Jar文件包的类型;在预设的多种Android工程模型中,获取所述Jar文件包的类型对应的Android工程模型;将所述参数信息放入所述Jar文件包的类型对应的Android工程模型中。
Android工程模型包括:源代码模型文件、AndroidManifest.xml模型文件;
所述封装模块420具体设置为:将所述MainClass和Package,放入源代码模型文件中,形成Android工程的源代码文件;将所述MainClass和Package,放入AndroidManifest.xml模 型文件中,形成Android工程的AndroidManifest.xml文件;将所述Jar文件包中除.class文件外的文件作为Android工程的资源文件。
所述转换模块430具体设置为:将所述源代码文件编译成.class文件;基于编译成的.class文件和所述Jar文件包中的.class文件,生成.dex文件;基于所述AndroidManifest.xml文件和所述资源文件,生成.ap文件;基于所述.dex文件和所述.ap文件,生成Apk文件。
本发明实施例所述的装置的功能已经在图1-图3所示的方法实施例中进行了描述,故本实施例的描述中未详尽之处,可以参见前述实施例中的相关说明,在此不做赘述。
尽管为示例目的,已经公开了本发明的优选实施例,本领域的技术人员将意识到各种改进、增加和取代也是可能的,因此,本发明的范围应当不限于上述实施例。
工业实用性
如上所述,本发明实施例提供的一种利用TCK测试安卓系统J2ME标准接口实现的方法,具有以下有益效果:在TCK测试的基础上对其加以改进,在TCK测试中,在没有Java源代码的情况下,利用Jar文件包中的信息和预设的Android工程模型,将Jar文件包转换为Apk文件。通过该方法可以自动对Android系统J2ME标准接口实现的完备性和兼容性进行测试。

Claims (10)

  1. 一种利用TCK测试安卓Android系统J2ME标准接口实现的方法,包括:
    在Jar文件包中,提取参数信息;
    将所述参数信息放入预设的Android工程模型中,以便形成Android工程;
    基于所述Android工程,生成安卓包Apk文件;其中,在Android系统中运行所述Apk文件,以测试所述Android系统J2ME标准接口的实现。
  2. 如权利要求1所述的方法,其中,将所述参数信息放入预设的安卓Android工程模型中,包括:
    基于所述参数信息,利用Java反射机制检测出所述Jar文件包的类型;
    在预设的多种Android工程模型中,获取所述Jar文件包的类型对应的Android工程模型;
    将所述参数信息放入所述Jar文件包的类型对应的Android工程模型中。
  3. 如权利要求1或2所述的方法,其中,在Jar文件包中,提取参数信息,包括:
    在Jar文件包的Manifest.mf清单文件中,提取参数信息;其中,所述参数信息包括:主类MainClass、包名Package。
  4. 如权利要求3所述的方法,其中,
    Android工程模型包括:源代码模型文件、AndroidManifest.xml模型文件;
    Android工程包括:源代码文件、AndroidMainfest.xml文件和资源文件;
    将所述参数信息放入预设的安卓Android工程模型中,以便形成Android工程,包括:
    将所述MainClass和Package,放入源代码模型文件中,形成Android工程的源代码文件;
    将所述MainClass和Package,放入AndroidManifest.xml模型文件中,形成Android工程的AndroidManifest.xml文件;
    将所述Jar文件包中除.class文件外的文件作为Android工程的资源文件。
  5. 如权利要求4所述的方法,其中,基于所述Android工程,生成Apk文件,包括:
    将所述源代码文件编译成.class文件;
    基于编译成的.class文件和所述Jar文件包中的.class文件,生成.dex文件;
    基于所述AndroidManifest.xml文件和所述资源文件,生成.ap文件;
    基于所述.dex文件和所述.ap文件,生成Apk文件。
  6. 一种利用TCK测试安卓Android系统J2ME标准接口实现的装置,包括:
    提取模块,设置为在Jar文件包中,提取参数信息;
    封装模块,设置为将所述参数信息放入预设的Android工程模型中,以便形成Android工程;
    转换模块,设置为基于所述Android工程,生成安卓包Apk文件;其中,在Android系统中运行所述Apk文件,以测试所述Android系统J2ME标准接口的实现。
  7. 如权利要求6所述的装置,其中,所述封装模块设置为:
    基于所述参数信息,利用Java反射机制检测出所述Jar文件包的类型;
    在预设的多种Android工程模型中,获取所述Jar文件包的类型对应的Android工程模型;
    将所述参数信息放入所述Jar文件包的类型对应的Android工程模型中。
  8. 如权利要求6或7所述的装置,其中,所述提取模块具体设置为:
    在Jar文件包的Manifest.mf清单文件中,提取参数信息;其中,所述参数信息包括:主类MainClass、包名Package。
  9. 如权利要求8所述的装置,其中,
    Android工程模型包括:源代码模型文件、AndroidManifest.xml模型文件;
    Android工程包括:源代码文件、AndroidMainfest.xml文件和资源文件;
    所述封装模块具体设置为:
    将所述MainClass和Package,放入源代码模型文件中,形成Android工程的源代码文件;
    将所述MainClass和Package,放入AndroidManifest.xml模型文件中,形成Android工程的AndroidManifest.xml文件;
    将所述Jar文件包中除.class文件外的文件作为Android工程的资源文件。
  10. 如权利要求9所述的装置,其中,所述转换模块具体设置为:
    将所述源代码文件编译成.class文件;
    基于编译成的.class文件和所述Jar文件包中的.class文件,生成.dex文件;
    基于所述AndroidManifest.xml文件和所述资源文件,生成.ap文件;
    基于所述.dex文件和所述.ap文件,生成Apk文件。
PCT/CN2015/093263 2015-07-17 2015-10-29 利用tck测试安卓系统j2me标准接口实现的方法 WO2017012218A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510420719.5 2015-07-17
CN201510420719.5A CN106339311A (zh) 2015-07-17 2015-07-17 一种利用TCK测试Android系统J2ME标准接口实现的方法和装置

Publications (1)

Publication Number Publication Date
WO2017012218A1 true WO2017012218A1 (zh) 2017-01-26

Family

ID=57826782

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/093263 WO2017012218A1 (zh) 2015-07-17 2015-10-29 利用tck测试安卓系统j2me标准接口实现的方法

Country Status (2)

Country Link
CN (1) CN106339311A (zh)
WO (1) WO2017012218A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108762806A (zh) * 2018-05-09 2018-11-06 成都市极米科技有限公司 一种Android系统定制包分离系统、定制升级包生成系统及其实现方法

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103514069A (zh) * 2012-11-22 2014-01-15 Tcl集团股份有限公司 测试Android系统HAL层API的方法及系统
CN103885873A (zh) * 2012-12-20 2014-06-25 上海明想电子科技有限公司 一种自动化集成测试的方法
US20150058826A1 (en) * 2013-08-26 2015-02-26 The Trustees Of Columbia University In The City Of New York Systems and methods for efficiently and effectively detecting mobile app bugs
CN104699604A (zh) * 2015-02-28 2015-06-10 百度在线网络技术(北京)有限公司 用于测试基于定制浏览内核的安卓应用的方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103514069A (zh) * 2012-11-22 2014-01-15 Tcl集团股份有限公司 测试Android系统HAL层API的方法及系统
CN103885873A (zh) * 2012-12-20 2014-06-25 上海明想电子科技有限公司 一种自动化集成测试的方法
US20150058826A1 (en) * 2013-08-26 2015-02-26 The Trustees Of Columbia University In The City Of New York Systems and methods for efficiently and effectively detecting mobile app bugs
CN104699604A (zh) * 2015-02-28 2015-06-10 百度在线网络技术(北京)有限公司 用于测试基于定制浏览内核的安卓应用的方法及装置

Also Published As

Publication number Publication date
CN106339311A (zh) 2017-01-18

Similar Documents

Publication Publication Date Title
EP2972866B1 (en) Techniques for correlating vulnerabilities across an evolving codebase
US9582268B2 (en) Automatic communications graphing for a source application
CN110275831B (zh) 协议接口的mock数据校验方法和装置
US20180357154A1 (en) Automatically Running Tests Against WEB APIs Based on Specifications
US9547579B1 (en) Method and apparatus for automatically detecting defects
US9952855B2 (en) Software test automation
CN110058864B (zh) 微服务的部署方法及装置
CN107896244B (zh) 一种版本文件的分发方法、客户端及服务器
CN109376088B (zh) 一种自动化测试系统及自动化测试方法
WO2020015191A1 (zh) 业务规则的发布管理方法、电子装置及可读存储介质
CN108459850B (zh) 生成测试脚本的方法、装置及系统
CN112379969B (zh) 一种基于容器化应用的持续集成交付方法及相关设备
CN107632829A (zh) 一种基于iOS系统下的App自动化持续集成系统及方法
CN112486592B (zh) 分布式数据处理方法、装置、服务器及可读存储介质
US9477444B1 (en) Method and apparatus for validating and recommending software architectures
CN106972983B (zh) 网络接口的自动化测试装置及方法
WO2017012218A1 (zh) 利用tck测试安卓系统j2me标准接口实现的方法
CN108595656A (zh) 一种数据的处理方法及系统
CN110990833A (zh) 一种sdk安全检测方法及相关设备
Dietrich et al. Driver generation for java ee web applications
CN113127367B (zh) Android动态权限申请的缺陷检测方法
CN112073462B (zh) 定位方法及装置
CN110727601B (zh) 多平台程序的测试方法及相关装置
CN114115982A (zh) 代码发布方法、装置、设备及存储介质
CN115129329A (zh) 部署服务的方法及装置、计算机可存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15898774

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15898774

Country of ref document: EP

Kind code of ref document: A1