Skip to content

Testing on Windows Guide

stankovski edited this page Oct 6, 2014 · 31 revisions

Install Pre-Requisites

  1. Install latest Java SDK (e.g. 1.7) at http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html and add env variable for the Java SDK, e.g. JAVA_HOME=C:\Program Files\Java\jdk1.7.0_09\
  2. Install Eclipse IDE for Java EE Developer at http://www.eclipse.org/downloads/ (need to download and extract zip files)
  3. Install and add env variable for Maven on Windows, as instruction from http://www.mkyong.com/maven/how-to-install-maven-in-windows/
  4. Install Maven Eclipse Integration from Eclipse Market Place. Start Eclipse, go to Help - Eclipse Marketplace, search "maven integration for eclipse" and install the "Maven Integration for Eclipse"
  5. Remove 128 bit encryption key limitation. Download Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 7 at http://www.oracle.com/technetwork/java/javase/downloads/jce-7-download-432124.html, unzip the file and copy all the files to JRE/lib/security directory to replace the existed files, and do this for all the /JRE/lib/security/ folders including the jre folder under jdk (if you have multiple JRE, JDK on the machine)
  6. Install Git for Window from here http://git-scm.com/downloads

Get Azure SDK for Java via Git

  1. Create test folder and from the test folder, launch Git Bash, type the following command:
git clone https://github.com/Azure/azure-sdk-for-java.git
cd ./azure-sdk-for-java/microsoft-azure-api/ 
  1. Type command for the branch you like to run (below is for dev branch here, if run on master branch, no need to run "git checkout dev" cmd below, default is master branch. if for release branch, should run git checkout release)
git checkout dev 

Setup Project in Eclipse

  1. Launch Eclipse from admin cmd prompt at where the Eclipse is installed.
  2. From Eclipse, File - Import, select Maven - Existing Maven Project, click Next.
  3. Browse to Azure SDK for Java folder created from step above (e.g. c:\test\azure-sdk-for-java\microsoft-azure-api), make sure the checkbox under projects is checked (if not, click the Advanced arrow, and type in new profiles and name template, then check the checkbox above), click Next, Click Finish.
  4. Add Azure SDK jar to the project if project has built error. If the loaded project have build errors, (red icon on the some nodes), one step to fix the build error (there are some files only generated by built) is to include existed azure sdk jar file as external reference. At Eclipse java project, right click project – Build Path – Add external Archive, then add the Jar file.
  5. Close Eclipse.

Setup for Azure Account

  1. Setup the Windows Azure Account. Login https://manage.windowsazure.com with your own credential, create a storage account, a Service Bus account,a media service account.
  2. Setup the following env variables. Please create new account for each machine that is running the unit test to avoid unit tests from different machine to confront each other.
set JAVA_OPTS="-Dhttp.proxyHost=localhost -Dhttp.proxyPort=8888"
set blob.accountName=yourstorageaccount
set blob.accountKey=lhURaXGhNOOV8Tq0PSaxsn7pxjh7Y3WfUVaDqRdyHjkQNXqUqbZb4M46sn18E...
set blob.uri=http://yourstorageaccount.blob.core.windows.net 
set queue.accountName=yourstorageaccount
set queue.accountKey=lhURaXGhNOOV8Tq0PSaxsn7pxjh7Y3WfUVaDqRdyHjkQNXqUqbZb4M46sn18E...
set queue.uri=http://yourstorageaccount.queue.core.windows.net
set table.accountName=yourstorageaccount
set table.accountKey=lhURaXGhNOOV8Tq0PSaxsn7pxjh7Y3WfUVaDqRdyHjkQNXqUqbZb4M46sn18E...
set table.uri=http://yourstorageaccount.table.core.windows.net 
set serviceBus.uri=https://yourservicebusnamespace.servicebus.windows.net/
set serviceBus.wrap.uri=https://yourservicebusnamespace-sb.accesscontrol.windows.net/WRAPv0.9
set serviceBus.wrap.name=owner
set serviceBus.wrap.password=IxZSJvtYItrIHJIBuCzlqjbd....
set serviceBus.connection.string=<connection string from portal containing SAS token>
set wrapTest.serviceBus.connection.string=<connection string from portal containing WRAP token>
set management.uri=https://management.core.windows.net/ 
set management.subscription.id=[Windows Azure subscription ID]
set management.keystore.path=[The path to the keystore]
set management.keystore.password=[The password of the keystore]
set management.keystore.type=[The type of the keystore, such as jks]
set media.uri=https://wamsbluclus001rest-hs.cloudapp.net/
set media.oauth.uri=https://wamsprodglobal001acs.accesscontrol.windows.net/v2/OAuth2-13
set media.oauth.client.id=[media service account name]
set media.oauth.client.secret=[media service account secret]
set media.oauth.scope=urn:WindowsAzureMediaServices
set media.queue.account.name=[storagequeuename]
set media.queue.account.key=lhURaXGhNOOV8Tq0PSaxs......
set media.queue.uri=http://[storagequeuename].queue.core.windows.net

Run Unit Test

  1. Launch the Eclipse.exe from the same admin console where the env setup done, make sure the Java SDK project created from the above step can be built without errors.
  2. To run all the JUnit test, right click src/test/java and choose "Debug As - JUnit Test".
  3. To run one of the JUnit test, right click the component you want to run under src/test/java and choose "Debug As - JUnit Test".
  4. Status of pass or fail for unit test should show in the JUnit console (green is pass, red is fail)