@Test
public void testStoreCredential(){

	SoftwareSmartcard s = setupSmartcard();
	
	Random r = new Random(1234);
	
	URI longURI1 = URI.create(new BigInteger(2048*3, r).toString());
	URI longURI2 = URI.create(new BigInteger(2048*2, r).toString());
	URI longURI3 = URI.create(new BigInteger(2048*2, r).toString());
	System.out.println("credUID: " + longURI3);
	
	byte[] loongByteArr = new byte[2048*2+256];
	
	Credential cred = new Credential();
	CryptoParams cryptoParam = new CryptoParams();
	
	CredentialDescription credDesc = new CredentialDescription();
	credDesc.setImageReference(ImagePathBuilder.TEST_IMAGE_JPG);
    credDesc.setIssuerParametersUID(longURI2);
    credDesc.setCredentialSpecificationUID(longURI2);
	credDesc.setCredentialUID(longURI3);
	cred.setCredentialDescription(credDesc);
	cred.setCryptoParams(cryptoParam);
	URI credentialId =  URI.create("credUri");
	s.storeCredential(pin, credentialId, cred, serializer);
	
	Credential credPrime = s.getCredential(pin, credentialId, serializer);
	CredentialDescription credDescriptionPrime = credPrime.getCredentialDescription();
	System.out.println("from read credential - credUID: "+credDescriptionPrime.getCredentialUID().toString());
	assertEquals(credDesc.getCredentialUID(), credDescriptionPrime.getCredentialUID());
	
	byte[] origCredSerialized = serializer.serializeCredential(cred);
	byte[] newCredSerialized = serializer.serializeCredential(credPrime);
	System.out.println("orig: " + origCredSerialized.length+", new: " + newCredSerialized.length);
	assertTrue(Arrays.equals(origCredSerialized, newCredSerialized));
	
	
	//Now test pseudonym storage
	PseudonymWithMetadata pseudonym = new PseudonymWithMetadata();
	Pseudonym pseu = new Pseudonym();
	pseu.setExclusive(true);
	URI pseudonymUID = URI.create("pseudonymUri");
	pseu.setPseudonymUID(pseudonymUID);
	pseu.setPseudonymValue(loongByteArr);
	pseu.setScope("testScope");
	pseu.setSecretReference(deviceURI);
	pseudonym.setPseudonym(pseu);    	
	pseudonym.setCryptoParams(cryptoParam);
	    	
	CardStorage cardStorage = new CardStorage();
	cardStorage.addSmartcard(s, pin);    	
	PseudonymSerializer pseudonymSerializer = new PseudonymSerializerGzipXml(cardStorage);
	System.out.println("After this line");
	s.storePseudonym(pin, pseudonymUID, pseudonym, pseudonymSerializer);
	
	PseudonymWithMetadata pseudonymPrime = s.getPseudonym(pin, pseu.getPseudonymUID(), pseudonymSerializer);
	byte[] first = pseudonymSerializer.serializePseudonym(pseudonym);
	byte[] second = pseudonymSerializer.serializePseudonym(pseudonymPrime);
	assertTrue(Arrays.equals(first, second));
}