How to Write AllSeen Alliance Self- Certification Test Cases September 25, 2014



Similar documents
Getting Started with the AllJoyn Lighting Service Framework 14.12

Author: Sascha Wolski Sebastian Hennebrueder Tutorials for Struts, EJB, xdoclet and eclipse.

Getting Started Android + Linux. February 27 th, 2014

Unit Testing. and. JUnit

AllJoyn Analytics Service Framework 1.0 Interface Definition

Appium mobile test automation

Listeners. Formats. Free Form. Formatted

Present and Act Upon. Register. Consume. Stream Analytics. Event Hubs. Field Gateway. Applications Cloud Gateway. Legacy IoT (custom protocols)

IoT Cloud, All Seen Alliance. Masanari Arai 荒 井 真 成 CEO, Kii Corpora0on

Open Sourcing the Internet of Things

ID TECH UniMag Android SDK User Manual

WebSphere Business Monitor

bbc Developing Service Providers Adobe Flash Media Rights Management Server November 2008 Version 1.5

Asynchronous Provisioning Platform (APP)

Hands on exercise for

Skynax. Mobility Management System. System Manual

EMC Documentum Repository Services for Microsoft SharePoint

Android Developer Fundamental 1

Application Interface Services Server for Mobile Enterprise Applications Configuration Guide Tools Release 9.2

SnapLogic Salesforce Snap Reference

ODROID Multithreading in Android

AT&T VERIFY CONNECT (V3.2.0) GETTING STARTED GUIDE FOR MOBILE SDK

Generating Automated Test Scripts for AltioLive using QF Test

How To Write A File Station In Android.Com (For Free) On A Microsoft Macbook Or Ipad (For A Limited Time) On An Ubuntu 8.1 (For Ubuntu) On Your Computer Or Ipa (For

EVALUATION. WA1844 WebSphere Process Server 7.0 Programming Using WebSphere Integration COPY. Developer

Drupal CMS for marketing sites

Getting Started Guide

UI Performance Monitoring

Mocean Android SDK Developer Guide

Database Applications Recitation 10. Project 3: CMUQFlix CMUQ s Movies Recommendation System

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

ITG Software Engineering

Getting Started with the Ed-Fi ODS and Ed-Fi ODS API

SOFTWARE DEVELOPMENT BASICS SED

How To Use Titanium Studio

HP Operations Orchestration Software

JUnit Howto. Blaine Simpson

CS 111 Classes I 1. Software Organization View to this point:

Using vcenter Orchestrator AMQP Plug-in

Virtuozzo Virtualization SDK

Egnyte for Salesforce v2.1 Administrator s Guide

Unicenter NSM Integration for Remedy (v 1.0.5)

Iotivity Programmer s Guide Soft Sensor Manager for Android

TESTING TOOLS COMP220/285 University of Liverpool slide 1

Boardies IT Solutions Tel:

White Paper March 1, Integrating AR System with Single Sign-On (SSO) authentication systems

AllJoyn Device System Bridge

Affinegy 1705 S. Capital of Texas Hwy, Ste. 310, Austin, TX (512)

FioranoMQ 9. High Availability Guide

Programming the Internet of Things

Sophos Mobile Control Web service guide

Overview of Web Services API

MarkLogic Server. Reference Application Architecture Guide. MarkLogic 8 February, Copyright 2015 MarkLogic Corporation. All rights reserved.

Requirements for building a Connector in CloudAnywhere

XMLVend Protocol Message Validation Suite

Software project management. and. Maven

Jemmy tutorial. Introduction to Jemmy testing framework. Pawel Prokop. March 14,

Deadlock Victim. dimanche 6 mai 12

Building and Using Web Services With JDeveloper 11g

Threads & Tasks: Executor Framework

HP Operations Orchestration Software

Applets, RMI, JDBC Exam Review

Basic Android Setup Windows Version

CI/CD Cheatsheet. Lars Fabian Tuchel Date: 18.March 2014 DOC:

Setting Up Resources in VMware Identity Manager

Cid Santos Luis Matos. Introduction to AllJoyn

Policy Guide Access Manager 3.1 SP5 January 2013

Quick Actions Implementation Guide

Using the VMRC Plug-In: Startup, Invoking Methods, and Shutdown on page 4

Oracle FLEXCUBE Universal Banking 12.0 RAD Notification Development. Release 1.0

Amazon Glacier. Developer Guide API Version

Instrumentation for Linux Event Log Analysis

MIDDLEWARE AUTOMATION

Transactionality and Fault Handling in WebSphere Process Server Web Service Invocations. version Feb 2011

IBM Tivoli Workload Scheduler Integration Workbench V8.6.: How to customize your automation environment by creating a custom Job Type plug-in

Kentico CMS 7.0 E-commerce Guide

Finally, an agile test strategy (that works)! AS OW Test Model, Objectware

IOIO for Android Beginners Guide Introduction

How To Develop An Open Play Context Framework For Android (For Android)

q for Gods Whitepaper Series (Edition 7) Common Design Principles for kdb+ Gateways

TIBCO Spotfire Statistics Services Installation and Administration Guide. Software Release 5.0 November 2012

Open XML Court Interface (OXCI) Architecture Proposal

AllJoyn Framework System Overview

Jet Data Manager 2012 User Guide

Working with Motorola RFID

Capabilities of a Java Test Execution Framework by Erick Griffin

Plugin JUnit. Contents. Mikaël Marche. November 18, 2005

Copyright 2013 EMC Corporation. All Rights Reserved.

EMC Documentum Composer

STORM. Simulation TOol for Real-time Multiprocessor scheduling. Designer Guide V3.3.1 September 2009

Leveraging Cloud Storage Through Mobile Applications Using Mezeo Cloud Storage Platform REST API. John Eastman Mezeo

Title Release Notes PC SDK Date Dealt with by, telephone. Table of Content GENERAL Corrected Issues PDD...

3.5. cmsg Developer s Guide. Data Acquisition Group JEFFERSON LAB. Version

Web Publisher Administration Guide

<Insert Picture Here> TDD on a Coherence project

IBM SPSS Collaboration and Deployment Services Version 6 Release 0. Single Sign-On Services Developer's Guide

Course Summary. Prerequisites

HTTPS hg clone plugin library SSH hg clone plugin library

If you wanted multiple screens, there was no way for data to be accumulated or stored

Dragan Juričić, PBZ May 2015

Transcription:

How to Write AllSeen Alliance Self- Certification Test Cases September 25, 2014 This work is licensed under a Creative Commons Attribution 4.0 International License. http://creativecommons.org/licenses/by/4.0/ Any and all source code included in this work is licensed under the ISC License per the AllSeen Alliance IP Policy. https://allseenalliance.org/allseen/ip-policy

Contents 1 Introduction... 3 1.1 Purpose... 3 1.2 Scope... 3 1.3 References... 3 1.4 Acronyms and terms... 3 2 Overview... 4 2.1 AllJoyn validation framework... 4 2.1.1 ValidationTestCase/ValidationBaseTestCase classes... 4 2.1.2 ValidationSuite/ValidationTest annotations... 4 2.1.3 ValidationTestContext class... 4 3 Adding a new test suite... 5 3.1 Prepare for your new test suite... 5 3.2 Modify POM files... 5 3.3 New test case class... 7 3.4 New test suite class... 9 3.5 Compiling your new test classes... 10 3.6 Running your new test cases... 10 4 Useful techniques... 11 4.1 Handling asynchronous events... 11 4.1.1 Create a handler class that will handle the event... 11 4.2 Determine if an AllJoyn service/interface is implemented... 12 ii AllSeen Alliance

1 Introduction 1.1 Purpose This guide helps you write tests to verify that a device/application functionally behaves according to AllJoyn service framework interface definitions. It details each step in the process to write a validation test using the AllJoyn validation framework and JUnit 3 framework. 1.2 Scope This document is intended for software engineers and assumes familiarity with the AllJoyn SDK and Java programming language. 1.3 References The following documents are available on the AllSeen Alliance wiki. Test Case Specification Template AllSeen Alliance Self-Certification User Guide AllSeen Alliance Self-Certification Developer Guide 1.4 Acronyms and terms Term AllJoyn service frameworks AllJoyn base services DUT POM file Test device Definition A collection of full-feature implementations using the AllJoyn framework that provides specific functionality. These are building blocks that can be combined together to build interoperable devices and applications. This includes the Config, Control Panel, Notification, and Onboarding interfaces that support the relevant service frameworks. Device Under Test. The device, typically embedded, that runs the service to be validated. Project Object Module file. Maven uses a POM XML file to compile and link your Validation Test app. It uses another to deploy your Validation Test to the test device, and to execute your Validation Test. Android device, typically phone or tablet, which runs the Validation Tests against the service running on the DUT. 3 AllSeen Alliance

2 Overview The AllJoyn framework is open-source software that allows for proximity peer to peer over various transports. The AllJoyn service frameworks are a collection of full-feature implementations using the AllJoyn framework that provide specific functionality. These are building blocks that can be combined together to build interoperable devices and applications. The AllJoyn service framework implementations must conform to the published service framework interface specifications. This document goes over the steps to write tests to verify that an implementation behaves according to AllJoyn service framework interface specifications and the steps involved in executing the tests. 2.1 AllJoyn validation framework The AllJoyn validation framework provides the set of Java interface definitions and classes required to write a test which can verify an AllJoyn service/interface implementation. It defines the API for plugging in the test cases/suites. 2.1.1 ValidationTestCase/ValidationBaseTestCase classes A class containing a test must extend junit.framework.testcase and also implement org.alljoyn.validation.framework.validationtestcase. Optionally, the test case class can extend org.alljoyn.validation.framework.validationbasetestcase. ValidationBaseTestCase provides an implementation of methods specified in ValidationTestCase. 2.1.2 ValidationSuite/ValidationTest annotations The test case class must be annotated with org.alljoyn.validation.framework.annotation.validationsuite annotation to indicate that it s a test case class. The methods implementing the tests must be annotated with org.alljoyn.validation.framework.annotation.validationtest annotation. The annotations provide the mapping from a particular test case class and method to the test suite name and test case name. 2.1.3 ValidationTestContext class The org.alljoyn.validation.framework.validationtestcontext class facilitates communication between a test case and the validation framework. A test case can retrieve test parameters from the ValidationTestContext as well as provide information about the test case to the ValidationTestContext. 4 AllSeen Alliance

3 Adding a new test suite This section details the steps for writing a sample test case class and adding the test to a sample test suite. This section assumes that the compliance tests repository has been cloned under $VAL_DIR. 3.1 Prepare for your new test suite 1. From the $VAL_DIR\tests\java\components\validation-tests\HEAD folder, copy the validation-tests-suites folder and paste to a new folder. Rename it to represent your service, e.g., validation-tests-suites-lighting. This path will be referred to as $SVC_DIR in this document. 2. Delete the test folder from $SVC_DIR\src. 3. Delete all existing folders from $VAL_DIR\tests\java\components\validationtests\HEAD\$SVC_DIR \src\main\java\org\alljoyn\validation\testing\suites. 4. Create a new folder in $SVC_DIR \src\main\java\org\alljoyn\validation\testing\suites, e.g., lamp In section 3.3, this new folder will be where you place your new class files. 5. Delete all existing folders and files from $VAL_DIR\tests\java\components\validationtests\HEAD\$SVC_DIR \src\main\resources\introspection-xml. 6. Place the XML file for your new service in this folder (introspection-xml). 3.2 Modify POM files Complete the following steps to modify the POM files to build the modules. 1. Locate the POM XML file in $SVC_DIR. 2. Modify the second <artifactid> tag, which is currently validation-tests-suites, to be $SVC_DIR. For example: <parent> <groupid>org.alljoyn.validation.validation-tests</groupid> <artifactid>validation-tests-suites-lighting</artifactid> <version>1.0.0.09-snapshot</version> </parent> <artifactid>validation-tests-suites-lighting</artifactid>.. 3. Locate the POM XML file in the \validation-tests\head folder. 4. Modify the modules section in it to include the new module you built, for example: <modules> <module>validation-tests-simulator</module> <module>validation-tests-suites</module> 5 AllSeen Alliance

How to Write AllSeen Alliance Self-Certification Test Cases Adding a new test suite <module>validation-tests-suites-lighting</module> <module>validation-tests-utils</module> <module>validation-tests-utils-android</module> <module>validation-tests-it</module> </modules> 5. Locate the POM XML file in the \validation-tests\head\validation-tests-it folder. 6. Modify the maven-remote-resources-plugin section in it to add a new resource bundle for your service: <plugin> <groupid>org.apache.maven.plugins</groupid> <artifactid>maven-remote-resources-plugin</artifactid> <version>1.5</version> <configuration> <resourcebundles> <resourcebundle>org.alljoyn.validation.validationtests:validation-tests-suites:$project.version</resourcebundle> <resourcebundle>org.alljoyn.validation.validationtests:validation-tests-suiteslighting:$project.version</resourcebundle> </resourcebundles> <attached>false</attached> <outputdirectory>$project.basedir/target/shared</outputdirectory > </configuration> <executions><execution><goals><goal>process</goal></goals></execut ion></executions> </plugin> 7. Add a dependency tag for your new module, for example: <dependency> <groupid>junit</groupid> <artifactid>junit</artifactid> <scope>provided</scope> </dependency> <dependency> <groupid>org.alljoyn.validation.validation-tests</groupid> <artifactid>validation-tests-suites-lighting</artifactid> <version>$project.version</version> </dependency> <dependency> <groupid>org.alljoyn.validation.validation-tests</groupid> <artifactid>validation-tests-suites</artifactid> <version>$project.version</version> </dependency> 6 AllSeen Alliance

How to Write AllSeen Alliance Self-Certification Test Cases Adding a new test suite 3.3 New test case class 1. In the folder you created in section 3.1, step 4, create a class that extends org.alljoyn.validation.framework.validationbasetestcase and annotate the class with org.alljoyn.validation.framework.annotation.validationsuite annotation. 2. Specify a name for the testgroupid to be used when creating an org.alljoyn.validation.framework.validationtestgroup object. @ValidationSuite(name = "Sample-v1") public class SampleTestSuite extends ValidationBaseTestCase The expected naming convention for testgroupid includes the name of the service framework and its version (for example, Config-v1). This value must uniquely identify the test suite that includes one or more test cases. The test cases for a test suite can also be contained in multiple Java classes. In that case, all the classes for the test suite must contain this annotation and the same name. 3. Implement a setup() method in which the parameters passed in to the test are read. Any steps that are common to all tests in the class should also be implemented in this method. Since JUnit 3 framework is used, the setup() method is invoked before executing each test method. @Override protected void setup() super.setup(); testparametervalue = getvalidationtestcontext().gettestparameter(testparametername);...... 4. Create a teardown() method to perform cleanup after a test completes execution. Since JUnit 3 framework is used, the teardown() method is called after executing each test method. @Override protected void teardown() super.teardown(); 5. Implement the test method and annotate it with the org.alljoyn.validation.framework.annotation.validationtest annotation. 6. Specify a test method name to be used later when creating an org.alljoyn.validation.framework.validationtestitem object. 7 AllSeen Alliance

How to Write AllSeen Alliance Self-Certification Test Cases Adding a new test suite The expected naming convention for test method name is the name of the service framework, its version, and a test case ID (for example, Config-v1-01). This must uniquely identify the test. @ValidationTest(name = "Sample-v1-01") public void testsample_v1_01_sample()... If some information about the test execution needs to be captured, use org.alljoyn.validation.framework.validationtestcontext to add a note in the test. The ValidationTestContext interface extends org.alljoyn.validation.framework.testcasenotelistener interface which defines the addnote() method. getvalidationtestcontext().addnote("information to be captured"); If the test requires some user interaction, use the org.alljoyn.validation.framework.validationtestcontext object to wait for user input. The ValidationTestContext interface extends org.alljoyn.validation.framework.userinputhandler interface which defines the waitforuserinput() method. The org.alljoyn.validation.framework.userinputdetails class is used to interact with the user and the org.alljoyn.validation.framework.userresponse object will contain results of the user operation. @ValidationTest(name = "Sample-v1-01") public void testsample_v1_01_sample() UserResponse userresponse = getuserresponse(getvalidationtestcontext()); private UserResponse getuserresponse(userinputhandler userinputhandler) String[] messagearray = "Test Msg 1", "Test Msg 2", "Test Msg 3" ; UserInputDetails userinputdetails = new UserInputDetails("Select the message(s) received", messagearray); return userinputhandler.waitforuserinput(userinputdetails); 8 AllSeen Alliance

How to Write AllSeen Alliance Self-Certification Test Cases Adding a new test suite 3.4 New test suite class 1. In the folder you created in section 3.1, step 4, create a class that implements org.alljoyn.validation.framework.validationtestsuite. This class serves the following purposes: It determines if the test cases present in a ValidationSuite should be run against a device based on the received About announcements. It determines the set of test cases to be executed. One test suite class must be created for each ValidationSuite. public class SampleTestSuiteManager implements ValidationTestSuite 2. Implement the getapplicabletests() method. This method has to iterate over the About announcements from the device and return applicable test groups. @Override public List<ValidationTestGroup> getapplicabletests(alljoynannounceddevice alljoynannounceddevice) for (AboutAnnouncement aboutannouncement : alljoynannounceddevice.getannouncements()) if (addtestgroupforapplication(aboutannouncement)) testgroups.add(createtestgroup(aboutannouncement)); return testgroups; The addtestgroupforapplication() method should have the logic to determine if the test suite is applicable based on the About announcement details. The createtestgroup() method should have the logic to create an org.alljoyn.validation.framework.validationtestgroup object. private ValidationTestGroup createtestgroup(aboutannouncement aboutannouncement) Class<? extends ValidationTestCase> validationtestcaseclass = SampleTestSuite.class; ValidationSuite validationsuite = validationtestcaseclass.getannotation(validationsuite.class ); String testgroupid = validationsuite.name(); ValidationTestGroup testgroup = new ValidationTestGroup(testGroupId, aboutannouncement); addtestitemstogroupfromannotations(testgroup, validationtestcaseclass); return testgroup; 9 AllSeen Alliance

How to Write AllSeen Alliance Self-Certification Test Cases Adding a new test suite NOTE The addtestitemstogroupfromannotations() method should take care of creating org.alljoyn.validation.framework.validationtestitem objects and adding them to ValidationTestGroup object. private void addtestitemstogroupfromannotations(validationtestgroup testgroup, Class<? extends ValidationTestCase> validationtestcaseclass) Method[] methods = validationtestcaseclass.getmethods(); List<Method> testmethods = new ArrayList<Method>(); for (Method method : methods) ValidationTest validationtest = method.getannotation(validationtest.class); Disabled disabled = method.getannotation(disabled.class); if ((validationtest!= null) && (disabled == null)) testmethods.add(method); Collections.sort(testMethods, sampletestcomparator); for (Method testmethod : testmethods) ValidationTestItem testitem = new ValidationTestItem(validationTest.name(), validationtestcaseclass.getname(), testmethod.getname(), validationtest.timeout()); testgroup.addtestitem(testitem); The Collections.sort(testMethods, sampletestcomparator) sequences the tests as per the values specified in the order field of ValidationTest annotation. 3.5 Compiling your new test classes Refer to the AllSeen Alliance Self-Certification Developer Guide for instructions. 3.6 Running your new test cases Refer to the AllSeen Alliance Self-Certification User Guide for instructions. 10 AllSeen Alliance

4 Useful techniques This section provides helpful techniques for writing test cases. 4.1 Handling asynchronous events The test cases execute synchronously in a single thread. Sometimes a test case must wait for other events to occur before test execution can proceed. The following design provides a technique for waiting for something to happen, and retrieving details on what happened. 4.1.1 Create a handler class that will handle the event The handler class will maintain an internal optionally bounded blocking queue that holds the events. The handler class must expose a public method that is invoked by the event publisher. When an event is received from the publisher, the event is added to the queue. The handler class must also expose another method for event receivers to get the event. Whenever this method is invoked, the event is polled from the queue and returned to the receiver. The same instance of handler class is used by both the event publisher and event subscriber. public class EventHandler private LinkedBlockingDeque<Object> eventqueue = new LinkedBlockingDeque<Object>(); public void handleevent(object object) eventqueue.add(object); public Object waitfornextevent(long timeout, TimeUnit unit) throws InterruptedException return eventqueue.poll(timeout, unit); The waitfornextevent() method will time out if no event is received within the timeout duration specified in the call. The reason for waiting only a specific length of time is that it allows the test case to fail sooner if the expected event doesn t occur in the expected time (versus waiting for the test case to time out). If the expectation is that a particular event will happen within a particular time frame, the test case should be coded to wait only that long before having an assertion fail. 11 AllSeen Alliance

How to Write AllSeen Alliance Self-Certification Test Cases Useful techniques 4.2 Determine if an AllJoyn service/interface is implemented Create a utility method that will accept an AboutAnnouncement method and the AllJoyn feature interface name. public boolean supportsinterface(aboutannouncement aboutannouncement, String expectedinterfacename) boolean interfacesupported = false; for (BusObjectDescription busobjectdescription : aboutannouncement.getobjectdescriptions()) for (String interfacename : busobjectdescription.interfaces) if (interfacename.equals(expectedinterfacename)) interfacesupported = true; break; return interfacesupported; 12 AllSeen Alliance