----------------------------------------------
License
----------------------------------------------
Copyright (c) 2012 Intel Corporation.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of works must retain the original copyright notice, this list
  of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the original copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
  may be used to endorse or promote products derived from this work without
  specific prior written permission.

THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Authors:
        Lin, Wanming <wanmingx.lin@intel.com>



----------------------------------------------
Introduction
----------------------------------------------
These tests are for checking compliance with W3C WebSocket API specification:
http://www.w3.org/TR/2012/CR-websockets-20120920


----------------------------------------------
Test Environment
----------------------------------------------
1. Pre-install Testkit-Lite package.
2. Run these cases as "normal" user.


----------------------------------------------
Pre-conditions
----------------------------------------------
1. Make sure the device under testing (DUT) is connected to network.

For Websocket Test Cases:
1. Please install Apache server and start Websocket server before testing.
2. Java Running Environment: JDK 1.6
3. Make sure your device connected to a good network which can access the server machine.
(Note: If you have installed Apache2 and configured the virtual host, you can skip to step 3.)

Steps:
1. Install Apache server:
   open terminal and type in this command: sudo apt-get install apache2;
2. Create the web project directory:
   open terminal and type in this command: mkdir -p /var/www/opt/tct-websocket-w3c-tests;
3. Properly organize the web resources:
   opt/tct-websocket-w3c-tests/resources  -->  /var/www/opt/tct-websocket-w3c-tests
   opt/tct-websocket-w3c-tests/websocket  -->  /var/www/opt/tct-websocket-w3c-tests
4. Access /var/www/opt/tct-websocket-w3c-tests/websocket/support/jetty
5. Start Websocket server:
   open terminal and type in this command: java -jar ws-server.jar 8081 8443
   If 8081 or 8443 has been used by other service, you can change to other unused port.
6. Update /var/www/opt/tct-websocket-w3c-tests/websocket/support/websocket.js:
   change SERVER_NAME from "127.0.0.1" to "192.168.13.28"(If the server IP address is 192.168.13.28)
   change WSS_SERVER_NAME from "127.0.0.1" to "192.168.13.28"(If the server IP address is 192.168.13.28)
   If you have changed the server port in step 3:
   change _PORT from "8081" to the frist port you changed
   change WSS_PORT from "8443" to the second port you changed
   Update /var/www/opt/tct-websocket-w3c-tests/websocket/w3c/websocket.js:
   change __SERVER__NAME from "127.0.0.1" to "192.168.13.28"(If the server IP address is 192.168.13.28)
   If you have changed the server port in step 3:
   change __PORT from "8081" to the frist port you changed
   change __SECURE__PORT from "8443" to the second port you changed
7. Restart Apache:
   open terminal and type in this command: sudo /etc/init.d/apache2 restart;

Notes:
If you run the testing on browser, before the testing, please add your server ip to Security Exception:
you can put "https://192.168.13.28:8443" (If the server IP address is 192.168.13.28 and the server port has not been changed) in browser to complete this setting.


----------------------------------------------
Build and Run
----------------------------------------------
(Suppose you only get the source code and Testkit-Lite has been set up on your test machine.
 If you have obtained tct-websocket-w3c-tests ZIP packages, you can directly go to step 3 on the test machine;
 if you have not installed Testkit-Lite, you need to install the latest version.)

Steps:
1. Prepare for building by running the following command:
   cd tct-websocket-w3c-tests

2. Modify tct-websocket-w3c-tests/tests.xml to change the est_script_entry node from 'http://127.0.0.1:8080'
   to 'http://192.168.13.28:8080'(If the server IP address is 192.168.13.28);

3. Build ZIP package by running the following command:
   ./pack.sh

4. Unzip the package on the test machine by running the following command:
   unzip -o tct-websocket-w3c-tests-<version>.zip -d /opt/usr/media/tct

5. Install the package on the test machine by running the following command:
   /opt/usr/media/tct/opt/tct-websocket-w3c-tests/inst.sh

6. Run test cases by running the following command on host:
   testkit-lite -f device:/opt/usr/media/tct/opt/tct-websocket-w3c-tests/tests.xml -e "WRTLauncher" -o tct-websocket-w3c-tests.results.xml
