}
buildTypes {
+ debug {
+ debuggable true
+ }
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.flatbuffers:flatbuffers-java:2.0.0'
+
+ implementation project(path: ':android:modules:tcp')
implementation project(path: ':android:modules:webrtc')
+
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:2.25.0'
testImplementation 'org.powermock:powermock-core:2.0.0-beta.5'
testImplementation 'org.powermock:powermock-module-junit4:2.0.0-beta.5'
testImplementation 'org.powermock:powermock-api-mockito2:2.0.0-beta.5'
+
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
--- /dev/null
+plugins {
+ id 'com.android.library'
+}
+
+android {
+ compileSdkVersion 31
+
+ defaultConfig {
+ minSdkVersion 28
+ targetSdkVersion 31
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+ implementation 'androidx.appcompat:appcompat:1.4.1'
+ implementation 'com.google.android.material:material:1.4.0'
+
+ testImplementation 'junit:junit:4.13.2'
+
+ androidTestImplementation 'androidx.test.ext:junit:1.1.3'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
+ androidTestImplementation project(path: ':android:aitt')
+}
--- /dev/null
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
--- /dev/null
+package com.samsung.android.modules.tcp;
+
+import android.content.Context;
+import android.util.Log;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+import com.samsung.android.aitt.Aitt;
+
+@RunWith(AndroidJUnit4.class)
+public class TCPInstrumentedTest {
+
+ private static Context appContext;
+
+ private static final String TAG = "AITT-ANDROID";
+ private static final String aittId = "aitt";
+ private final String topic = "aitt/test";
+ private final String message = "test message";
+
+ @BeforeClass
+ public static void initialize() throws InstantiationException {
+ appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ }
+
+ @Test
+ public void testPublishWithTCP_P() {
+ try {
+ Aitt aitt = new Aitt(appContext, aittId);
+
+ assertNotNull("AITT instance is null.", aitt);
+ // TODO: aitt.connect(brokerIp, port);
+
+ byte[] payload = message.getBytes();
+ aitt.publish(topic, payload, Aitt.Protocol.TCP, Aitt.QoS.AT_LEAST_ONCE, false);
+
+ // TODO: aitt.disconnect();
+ } catch(Exception e) {
+ fail("Failed to execute testPublishWithTCP_P " + e);
+ }
+ }
+
+ @Test
+ public void testSubscribeWithTCP_P() {
+ try {
+ Aitt aitt = new Aitt(appContext, aittId);
+
+ assertNotNull("AITT instance is null.", aitt);
+ // TODO: aitt.connect(brokerIp, port);
+
+ aitt.subscribe(topic, message -> {
+ Log.i(TAG, "Subscription callback is called");
+ }, Aitt.Protocol.TCP, Aitt.QoS.AT_LEAST_ONCE);
+
+ // TODO: aitt.disconnect();
+ } catch(Exception e) {
+ fail("Failed testSubscribeWithTCP_P " + e);
+ }
+ }
+
+ @Test
+ public void testPublishSubscribeWithTCP_P() {
+ try {
+ Aitt aitt = new Aitt(appContext, aittId);
+
+ assertNotNull("AITT instance is null.", aitt);
+ // TODO: aitt.connect(brokerIp, port);
+
+ aitt.subscribe(topic, message -> {
+ String _topic = message.getTopic();
+ byte[] _payload = message.getPayload();
+ Log.i(TAG, "Topic = " + _topic + ", Payload = " + _payload);
+ }, Aitt.Protocol.TCP, Aitt.QoS.AT_LEAST_ONCE);
+
+ byte[] payload = message.getBytes();
+ aitt.publish(topic, payload, Aitt.Protocol.TCP, Aitt.QoS.AT_LEAST_ONCE, false);
+
+ // TODO: aitt.disconnect();
+ } catch(Exception e) {
+ fail("Failed testPublishSubscribeWithTCP_P " + e);
+ }
+ }
+}