67 lines
1.9 KiB
Java
67 lines
1.9 KiB
Java
package monnethic.mobile.test;
|
|
|
|
import android.content.Context;
|
|
import android.support.test.InstrumentationRegistry;
|
|
import com.example.monnthic.monnethicmobile.R;
|
|
|
|
|
|
import org.hyperledger.fabric.sdk.NetworkConfig;
|
|
import org.json.JSONObject;
|
|
import org.junit.Test;
|
|
|
|
import java.io.BufferedReader;
|
|
import java.io.InputStream;
|
|
import java.io.InputStreamReader;
|
|
import java.io.Reader;
|
|
import java.io.StringWriter;
|
|
import java.io.Writer;
|
|
|
|
import javax.json.Json;
|
|
import javax.json.JsonObject;
|
|
import javax.json.JsonReader;
|
|
|
|
import io.grpc.internal.JsonParser;
|
|
|
|
|
|
public class LearningTest {
|
|
@Test
|
|
public void useAppContext() throws Exception {
|
|
// Context of the app under test.
|
|
Context appContext = InstrumentationRegistry.getTargetContext();
|
|
|
|
System.out.println(appContext.getFilesDir());
|
|
|
|
System.out.println(appContext.getPackageName());
|
|
|
|
InputStream is = appContext.getResources().openRawResource(R.raw.config);
|
|
/*
|
|
try (JsonReader reader = Json.createReader(is)) {
|
|
JsonObject jsonConfig = (JsonObject) reader.read();
|
|
System.out.println(jsonConfig);
|
|
System.out.println(jsonConfig.getClass());
|
|
NetworkConfig config;
|
|
config = NetworkConfig.fromJsonObject(jsonConfig);
|
|
//System.out.println(config!=null);
|
|
}*/
|
|
|
|
/*
|
|
Writer writer = new StringWriter();
|
|
char[] buffer = new char[1024];
|
|
try {
|
|
Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
|
int n;
|
|
while ((n = reader.read(buffer)) != -1) {
|
|
writer.write(buffer, 0, n);
|
|
}
|
|
} finally {
|
|
is.close();
|
|
}
|
|
|
|
String jsonString = writer.toString();
|
|
JSONObject jsonObject = new JSONObject(jsonString);
|
|
System.out.println(jsonObject.getString("name"));
|
|
System.out.println(jsonObject.getJSONObject("organizations"));
|
|
*/
|
|
}
|
|
}
|