2
0

Initial Java JSON serialization/deserialization.

This commit is contained in:
Maarten Billemont
2018-05-08 22:40:48 -04:00
parent 1cb720da32
commit f0d523fb35
26 changed files with 330 additions and 287 deletions

View File

@@ -64,7 +64,7 @@ public class MPMasterKeyTest {
masterKey.getKeyID( testCase.getAlgorithm() );
fail( "[testMasterKey] invalidate ineffective: " + testCase );
}
catch (final MPInvalidatedException ignored) {
catch (final MPKeyUnavailableException ignored) {
}
assertNotEquals(
masterPassword,

View File

@@ -18,8 +18,11 @@
package com.lyndir.masterpassword;
import com.lyndir.masterpassword.model.MPJSONUnmarshaller;
import java.io.File;
import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import com.lyndir.masterpassword.model.*;
import java.io.*;
import org.testng.Assert;
import org.testng.annotations.Test;
@@ -31,7 +34,12 @@ public class MPModelTest {
@Test
public void testMasterKey()
throws Exception {
System.err.println( new MPJSONUnmarshaller().unmarshall(
new File( "/Users/lhunath/.mpw.d/Maarten Billemont.mpsites.json" ) ) );
File file = new File( "/Users/lhunath/.mpw.d/Maarten Billemont.mpsites.json" );
String orig = CharStreams.toString( new InputStreamReader( new FileInputStream( file ), Charsets.UTF_8 ) );
System.out.println(orig);
MPFileUser user = new MPJSONUnmarshaller().unmarshall( file, null );
String result = new MPJSONMarshaller().marshall( user );
System.out.println(result);
Assert.assertEquals( result, orig, "Marshalled sites do not match original sites." );
}
}