Android Open Source - latrobe-datacapture-dir Data Tester From Project Back to project page latrobe-datacapture-dir .
License The source code is released under:
MIT License
If you think the Android project latrobe-datacapture-dir listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
Java Source Code package com.example.DataCaptureApp.testing;
/ / w w w . j a v a 2 s . c o m
import com.example.DataCaptureApp.data.Data;
import com.example.DataCaptureApp.data.DataTransform;
import com.example.DataCaptureApp.data.IDataTransform;
/**
* Created by Tom on 6/09/2014.
*/
public class DataTester
{
public static void main(String[] args)
{
Data dp = new Data();
log("Test 1 - Setting String\n-----------------" );
String strKey = "string" ;
String strValue = "Test String!" ;
log("Setting '" + strKey + "' to '" + strValue + "'" );
dp.set(strKey, strValue);
log();
log("Test 2 - Retrieving String\n-----------------" );
log("Retrieving '" + strKey + "'" );
String retrieved = dp.get(strKey);
log(strKey + " = " + retrieved);
log();
log("Test 3 - Setting Integer\n-----------------" );
String intKey = "int" ;
int intValue = 100;
log("Setting '" + intKey + "' to '" + intValue + "'" );
dp.set(intKey, intValue);
log();
log("Test 4 - Retrieving Integer\n-----------------" );
log("Retrieving '" + intKey + "'" );
int retInt = dp.get(intKey);
log(intKey + " = " + retInt);
log();
log("Test 5 - Setting DataTransform\n------------------" );
String dptKey = "dpt" ;
DataTransform dptValue = new DataTransform();
log("Setting '" + dptKey + "' to DataTransform object" );
dp.set(dptKey, dptValue);
log();
log("Test 6 - Retrieving DataTransform as IDataTransform\n-----------------------" );
IDataTransform idpt = dp.get(dptKey);
log("Is IDataTransform? " + (idpt instanceof IDataTransform));
log("Is DataTransform? " + (idpt instanceof DataTransform));
log();
log("Test 7 - Deleting String\n----------------------" );
log("Deleting '" + strKey + "'" );
retrieved = dp.remove(strKey);
log("'" + strKey + "' was '" + retrieved + "'" );
log("'" + strKey + "' is '" + dp.get(strKey) + "'" );
log("Test 8 - Data to JSON String\n----------------------" );
Data test = new Data();
test.set("number" , 23.53);
test.set("integer" , 10000);
test.set("boolean" , true);
test.set("intArray" , new Integer [] {1,2,3,4});
test.set("intArray2" , new int [] {1,2,3,4});
test.set("stringArray" , new String[] {"Hello" , "World" , "Testing!" });
Data test2 = new Data();
test2.set("int" , 30);
test2.set("bool" , true);
test.set("data" , test2);
String json = test.toJson();
log("JSON: " + json);
log("Test 9 - JSON String to Data\n----------------------------" );
Data data = Data.fromJson(json);
log("Data: created" );
log();
log("TESTING COMPLETE" );
log();
}
public static void log()
{
log("" );
}
public static void log(String msg)
{
System.out.println(msg);
}
}
Java Source Code List com.example.DataCaptureApp.AdvConfigActivity.java com.example.DataCaptureApp.ConfigActivity.java com.example.DataCaptureApp.MasterActivity.java com.example.DataCaptureApp.MasterService.java com.example.DataCaptureApp.SlaveActivity.java com.example.DataCaptureApp.SlaveService.java com.example.DataCaptureApp.data.DataServiceConnection.java com.example.DataCaptureApp.data.DataService.java com.example.DataCaptureApp.data.DataTransform.java com.example.DataCaptureApp.data.Data.java com.example.DataCaptureApp.data.Event.java com.example.DataCaptureApp.data.FailedInitialisationException.java com.example.DataCaptureApp.data.IDataEventListener.java com.example.DataCaptureApp.data.IDataListener.java com.example.DataCaptureApp.data.IDataSource.java com.example.DataCaptureApp.data.IDataTransform.java com.example.DataCaptureApp.data.IEventListener.java com.example.DataCaptureApp.data.IEventSource.java com.example.DataCaptureApp.services.BluetoothConnectivityService.java com.example.DataCaptureApp.services.BluetoothThread.java com.example.DataCaptureApp.services.DataDbContract.java com.example.DataCaptureApp.services.DataDbHelper.java com.example.DataCaptureApp.services.DataStoreService.java com.example.DataCaptureApp.services.HttpThread.java com.example.DataCaptureApp.services.RemoteConnectivityService.java com.example.DataCaptureApp.services.SensorSampleService.java com.example.DataCaptureApp.services.SensorSampler.java com.example.DataCaptureApp.testing.BluetoothActivity.java com.example.DataCaptureApp.testing.DataStoreActivity.java com.example.DataCaptureApp.testing.DataTester.java com.example.DataCaptureApp.testing.IServiceListener.java com.example.DataCaptureApp.testing.MainService.java com.example.DataCaptureApp.testing.MasterTestActivity.java com.example.DataCaptureApp.testing.RandomService.java com.example.DataCaptureApp.testing.RemoteActivity.java com.example.DataCaptureApp.testing.SensorSampleActivity.java com.example.DataCaptureApp.testing.ServiceTestActivity.java com.example.DataCaptureApp.testing.SlaveTestActivity.java com.example.DataCaptureApp.testing.TestActivity.java com.example.DataCaptureApp.transforms.AggregatorDataTransform.java com.example.DataCaptureApp.transforms.ArithmeticDataTransform.java com.example.DataCaptureApp.transforms.ArrayCollectDataTransform.java com.example.DataCaptureApp.transforms.ArraySplitDataTransform.java com.example.DataCaptureApp.transforms.DeserialiseDataTransform.java com.example.DataCaptureApp.transforms.FieldCopyDataTransform.java com.example.DataCaptureApp.transforms.FieldModifyDataTransform.java com.example.DataCaptureApp.transforms.FieldRenameDataTransform.java com.example.DataCaptureApp.transforms.IntervalAggregatorDataTransform.java com.example.DataCaptureApp.transforms.PackDataTransform.java com.example.DataCaptureApp.transforms.QuaternionDifferenceDataTransform.java com.example.DataCaptureApp.transforms.RemoveDataTransform.java com.example.DataCaptureApp.transforms.SetDataTransform.java com.example.DataCaptureApp.transforms.UnpackDataTransform.java com.example.DataCaptureApp.utils.BroadcastDataSource.java com.example.DataCaptureApp.utils.ByteUtils.java com.example.DataCaptureApp.utils.DataEventHandler.java com.example.DataCaptureApp.utils.DataHandlerThread.java com.example.DataCaptureApp.utils.JSONReader.java com.example.DataCaptureApp.utils.Quaternion.java com.example.DataCaptureApp.utils.SerialisationUtils.java