/**
 * TestLog.java
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 * 
 * Copyright (C) Wouter Lueks, Radboud University Nijmegen, March 2013.
 */

package org.irmacard.idemix.tests;

import java.util.List;

import javax.smartcardio.CardException;
import javax.smartcardio.CardTerminal;
import javax.smartcardio.TerminalFactory;

import net.sourceforge.scuba.smartcards.CardServiceException;
import net.sourceforge.scuba.smartcards.TerminalCardService;

import org.irmacard.idemix.IdemixService;
import org.irmacard.idemix.util.IdemixLogEntry;
import org.junit.Test;

public class TestLog {
    public static final byte[] DEFAULT_CARD_PIN = {0x30, 0x30, 0x30, 0x30, 0x30, 0x30};
	
	@Test
	public void testRetrieveLog() throws CardException, CardServiceException {
        CardTerminal terminal = TerminalFactory.getDefault().terminals().list().get(0);            
        IdemixService is = new IdemixService(new TerminalCardService(terminal));
        
        is.open();
        is.sendCardPin(DEFAULT_CARD_PIN);
        List<IdemixLogEntry> list = is.getLogEntries();
        for(IdemixLogEntry l : list) {
        	l.print();
        }
	}

}

@@ -781,16 +781,128 @@
 tests;%0A%0A
+import static org.junit.Assert.assertEquals;%0Aimport static org.junit.Assert.assertTrue;%0A%0Aimport java.util.Date;%0A
 import j
@@ -916,16 +916,16 @@
 l.List;%0A
-
 %0Aimport 
@@ -1162,17 +1162,16 @@
 ervice;%0A
-%0A
 import o
@@ -1387,17 +1387,522 @@
  0x30%7D;%0A
-%09
+%0A%09public static final byte%5B%5D test_input = %7B 0x51, 0x39, (byte) 0x8b, (byte) 0xb6, 0x00,%0A%09%09%090x00, 0x00, 0x00, 0x02, 0x00, 0x0A, 0x00, 0x3E, 0x00, 0x00, 0x00 %7D;%0A%0A    @Test%0A    public void parseLog() %7B%0A    %09IdemixLogEntry log = new IdemixLogEntry(test_input);%0A    %09assertTrue((log.getAction() == IdemixLogEntry.Action.VERIFY));%0A    %09assertEquals(log.getTimestamp().getTime(), (new Date(1362725814000l)).getTime());%0A    %09assertEquals(log.getCredential(), 10);%0A    %09assertEquals(log.getDisclose(), 0x3E);%0A    %7D%0A
 %0A%09@Test%0A
@@ -2357,10 +2357,9 @@
   %7D%0A
+
 %09%7D%0A
-%0A
 %7D%0A

Test vector for parsing