Skip to content

Commit 65f9523

Browse files
committed
Refactor BaseRpcTest and all child classes
1 parent 8196cfa commit 65f9523

150 files changed

Lines changed: 1313 additions & 121 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/BaseRpcTests.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,27 @@
11
package com.smartdevicelink.test;
22

3-
import com.smartdevicelink.AndroidTestCase2;
3+
import android.support.test.runner.AndroidJUnit4;
4+
45
import com.smartdevicelink.proxy.RPCMessage;
56
import com.smartdevicelink.proxy.RPCRequest;
67
import com.smartdevicelink.proxy.RPCResponse;
78

89
import org.json.JSONArray;
910
import org.json.JSONException;
1011
import org.json.JSONObject;
12+
import org.junit.Before;
13+
import org.junit.Test;
14+
import org.junit.runner.RunWith;
1115

1216
import java.util.Iterator;
1317

14-
public abstract class BaseRpcTests extends AndroidTestCase2 {
18+
import static junit.framework.TestCase.assertEquals;
19+
import static junit.framework.TestCase.assertNotNull;
20+
import static junit.framework.TestCase.assertNull;
21+
import static junit.framework.TestCase.assertTrue;
22+
23+
@RunWith(AndroidJUnit4.class)
24+
public abstract class BaseRpcTests {
1525

1626
public static final int SDL_VERSION_UNDER_TEST = Config.SDL_VERSION_UNDER_TEST;
1727

@@ -39,7 +49,7 @@ public abstract class BaseRpcTests extends AndroidTestCase2 {
3949
*/
4050
protected abstract JSONObject getExpectedParameters(int sdlVersion);
4151

42-
@Override
52+
@Before
4353
public void setUp(){
4454
this.msg = createMessage();
4555
if (msg instanceof RPCRequest) {
@@ -51,10 +61,12 @@ else if (msg instanceof RPCResponse) {
5161

5262
}
5363

64+
@Test
5465
public void testCreation(){
5566
assertNotNull("Object creation failed.", msg);
5667
}
5768

69+
@Test
5870
public void testCorrelationId(){
5971
int correlationId;
6072
if (msg instanceof RPCRequest) {
@@ -68,13 +80,15 @@ else if (msg instanceof RPCResponse) {
6880

6981
}
7082

83+
@Test
7184
public void testMessageType(){
7285
String messageType = msg.getMessageType();
7386

7487
assertNotNull("Message type was null.", messageType);
7588
assertEquals("Message type was not REQUEST.", getMessageType(), messageType);
7689
}
7790

91+
@Test
7892
public void testCommandType(){
7993
String command = msg.getFunctionName();
8094

@@ -83,13 +97,15 @@ public void testCommandType(){
8397
}
8498

8599

100+
@Test
86101
public void testFunctionName(){
87102
String funcName = msg.getFunctionName();
88103

89104
assertNotNull("Function name was null.", funcName);
90105
assertEquals("Function name did not match expected name.", getCommandType(), funcName);
91106
}
92107

108+
@Test
93109
public void testJson(){
94110
try{
95111
JSONObject reference = buildJsonStore();

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnAppInterfaceUnregisteredTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
import org.json.JSONException;
1111
import org.json.JSONObject;
12+
import org.junit.Test;
13+
14+
import static junit.framework.TestCase.assertEquals;
15+
import static junit.framework.TestCase.assertNotNull;
16+
import static junit.framework.TestCase.assertNull;
17+
import static junit.framework.TestCase.fail;
1218

1319
/**
1420
* This is a unit test class for the SmartDeviceLink library project class :
@@ -51,6 +57,7 @@ protected JSONObject getExpectedParameters(int sdlVersion){
5157
/**
5258
* Tests the expected values of the RPC message.
5359
*/
60+
@Test
5461
public void testRpcValues () {
5562
// Test Values
5663
AppInterfaceUnregisteredReason reason = ( (OnAppInterfaceUnregistered) msg ).getReason();

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnAppServiceDataTests.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@
99

1010
import org.json.JSONException;
1111
import org.json.JSONObject;
12+
import org.junit.Test;
13+
14+
import static junit.framework.TestCase.assertEquals;
15+
import static junit.framework.TestCase.assertNotNull;
16+
import static junit.framework.TestCase.assertNull;
17+
import static junit.framework.TestCase.fail;
18+
1219

1320
/**
1421
* This is a unit test class for the SmartDeviceLink library project class :
@@ -51,6 +58,7 @@ protected JSONObject getExpectedParameters(int sdlVersion){
5158
/**
5259
* Tests the expected values of the RPC message.
5360
*/
61+
@Test
5462
public void testRpcValues () {
5563
// Test Values
5664
AppServiceData cmdId = ( (OnAppServiceData) msg ).getServiceData();

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnAudioPassThruTests.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import com.smartdevicelink.test.TestValues;
88

99
import org.json.JSONObject;
10+
import org.junit.Test;
11+
12+
import static junit.framework.TestCase.assertNotNull;
1013

1114
/**
1215
* This is a unit test class for the SmartDeviceLink library project class :
@@ -37,6 +40,7 @@ protected JSONObject getExpectedParameters(int sdlVersion){
3740
/**
3841
* Tests the expected values of the RPC message.
3942
*/
43+
@Test
4044
public void testRpcValues () {
4145
// Invalid/Null Tests
4246
OnAudioPassThru msg = new OnAudioPassThru();

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnButtonEventTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
import org.json.JSONException;
1212
import org.json.JSONObject;
13+
import org.junit.Test;
14+
15+
import static junit.framework.TestCase.assertEquals;
16+
import static junit.framework.TestCase.assertNotNull;
17+
import static junit.framework.TestCase.assertNull;
18+
import static junit.framework.TestCase.fail;
1319

1420
/**
1521
* This is a unit test class for the SmartDeviceLink library project class :
@@ -56,6 +62,7 @@ protected JSONObject getExpectedParameters(int sdlVersion){
5662
/**
5763
* Tests the expected values of the RPC message.
5864
*/
65+
@Test
5966
public void testRpcValues () {
6067
// Test Values
6168
int cmdId = ( (OnButtonEvent) msg ).getCustomButtonID();

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnButtonPressTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,12 @@
1010

1111
import org.json.JSONException;
1212
import org.json.JSONObject;
13+
import org.junit.Test;
14+
15+
import static junit.framework.TestCase.assertEquals;
16+
import static junit.framework.TestCase.assertNotNull;
17+
import static junit.framework.TestCase.assertNull;
18+
import static junit.framework.TestCase.fail;
1319

1420
/**
1521
* This is a unit test class for the SmartDeviceLink library project class :
@@ -56,6 +62,7 @@ protected JSONObject getExpectedParameters(int sdlVersion){
5662
/**
5763
* Tests the expected values of the RPC message.
5864
*/
65+
@Test
5966
public void testRpcValues () {
6067
// Test Values
6168
int customName = ( (OnButtonPress) msg ).getCustomButtonID();

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnCommandTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
import org.json.JSONException;
1111
import org.json.JSONObject;
12+
import org.junit.Test;
13+
14+
import static junit.framework.TestCase.assertEquals;
15+
import static junit.framework.TestCase.assertNotNull;
16+
import static junit.framework.TestCase.assertNull;
17+
import static junit.framework.TestCase.fail;
1218

1319
/**
1420
* This is a unit test class for the SmartDeviceLink library project class :
@@ -53,6 +59,7 @@ protected JSONObject getExpectedParameters(int sdlVersion){
5359
/**
5460
* Tests the expected values of the RPC message.
5561
*/
62+
@Test
5663
public void testRpcValues () {
5764
// Test Values
5865
int cmdId = ( (OnCommand) msg ).getCmdID();

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnDriverDistractionTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
import org.json.JSONException;
1111
import org.json.JSONObject;
12+
import org.junit.Test;
13+
14+
import static junit.framework.TestCase.assertEquals;
15+
import static junit.framework.TestCase.assertNotNull;
16+
import static junit.framework.TestCase.assertNull;
17+
import static junit.framework.TestCase.fail;
1218

1319
/**
1420
* This is a unit test class for the SmartDeviceLink library project class :
@@ -53,6 +59,7 @@ protected JSONObject getExpectedParameters(int sdlVersion){
5359
/**
5460
* Tests the expected values of the RPC message.
5561
*/
62+
@Test
5663
public void testRpcValues () {
5764
// Test Values
5865
DriverDistractionState cmdId = ( (OnDriverDistraction) msg ).getState();

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnErrorTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import junit.framework.TestCase;
88

9+
import org.junit.Test;
10+
911
/**
1012
* This is a unit test class for the SmartDeviceLink library project class :
1113
* {@link com.smartdevicelink.proxy.callbacks.OnError}
@@ -17,6 +19,7 @@ public class OnErrorTests extends TestCase {
1719
* {@link com.smartdevicelink.proxy.callbacks.OnError#OnError()}
1820
* {@link com.smartdevicelink.proxy.callbacks.OnError#OnError(String, Exception)}
1921
*/
22+
@Test
2023
public void testValues () {
2124
// Valid Tests
2225
OnError testOnError = new OnError();

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/rpc/notifications/OnHMIStatusTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414
import org.json.JSONException;
1515
import org.json.JSONObject;
16+
import org.junit.Test;
17+
18+
import static junit.framework.TestCase.assertEquals;
19+
import static junit.framework.TestCase.assertNotNull;
20+
import static junit.framework.TestCase.assertNull;
21+
import static junit.framework.TestCase.fail;
1622

1723
/**
1824
* This is a unit test class for the SmartDeviceLink library project class :
@@ -64,6 +70,7 @@ protected JSONObject getExpectedParameters(int sdlVersion){
6470
/**
6571
* Tests the expected values of the RPC message.
6672
*/
73+
@Test
6774
public void testRpcValues () {
6875
// Test Values
6976
AudioStreamingState audioStreamingState = ( (OnHMIStatus) msg ).getAudioStreamingState();

0 commit comments

Comments
 (0)