Fixed Test
This commit is contained in:
parent
d986457fbe
commit
ede317ca8c
|
@ -6,6 +6,7 @@ import java.security.SecureRandom;
|
|||
import javax.crypto.KeyGenerator;
|
||||
|
||||
import org.gcube.informationsystem.ContextTest;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.model.impl.properties.EncryptedImpl;
|
||||
import org.gcube.informationsystem.model.reference.properties.Encrypted;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
|
@ -81,8 +82,13 @@ public class EncryptedTest extends ContextTest {
|
|||
|
||||
@Test
|
||||
public void testEncryptedSpecilization() throws Exception {
|
||||
String marshalled = "{\"@class\":\"MyEncrypted\",\"@superClasses\":[\"Encrypted\", \"Property\"],\"value\":\"Encrypted\"}";
|
||||
String value = "myValue";
|
||||
String encryptedValue = EncryptedImpl.encrypt(value);
|
||||
String marshalled = "{\"" + Element.CLASS_PROPERTY + "\":\"MyEncrypted\",\"" + Element.SUPERCLASSES_PROPERTY + "\":[\"" + Encrypted.NAME + "\", \"" + Property.NAME + "\"],\"" + Encrypted.VALUE + "\":\""+ encryptedValue + "\"}";
|
||||
Property property = ElementMapper.unmarshal(Property.class, marshalled);
|
||||
Assert.assertTrue(property instanceof Encrypted);
|
||||
Encrypted encrypted = (Encrypted) property;
|
||||
Assert.assertTrue(encrypted.getEncryptedValue().compareTo(encryptedValue)==0);
|
||||
logger.debug(ElementMapper.marshal(property));
|
||||
}
|
||||
|
||||
|
@ -94,6 +100,5 @@ public class EncryptedTest extends ContextTest {
|
|||
logger.debug("Encrypted Value is : '{}' which decrypted is : '{}'", encryptedValue, decryptedValue);
|
||||
String reEncryptedValue = EncryptedImpl.encrypt(decryptedValue);
|
||||
Assert.assertTrue(encryptedValue.compareTo(reEncryptedValue)==0);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue