package eu.europa.esig.dss.tsl.service;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.FileInputStream;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.Test;

import eu.europa.esig.dss.tsl.TSLParserResult;
import eu.europa.esig.dss.tsl.TSLPointer;

public class TSLParserTest {

	@Test
	public void parseLOTL() throws Exception {
		TSLParser parser = new TSLParser(new FileInputStream(new File("src/test/resources/LOTL.xml")));
		TSLParserResult model = parser.call();
		assertNotNull(model);
		assertNotNull(model.getNextUpdateDate());
		assertNotNull(model.getIssueDate());
		assertEquals("EU", model.getTerritory());
		assertEquals(115, model.getSequenceNumber());
		List<TSLPointer> pointers = model.getPointers();
		assertTrue(CollectionUtils.isNotEmpty(pointers));
		for (TSLPointer tslPointer : pointers) {
			assertTrue(StringUtils.isNotEmpty(tslPointer.getMimeType()));
			assertTrue(StringUtils.isNotEmpty(tslPointer.getTerritory()));
			assertTrue(StringUtils.isNotEmpty(tslPointer.getUrl()));
			assertTrue(CollectionUtils.isNotEmpty(tslPointer.getPotentialSigners()));
		}
		assertTrue(CollectionUtils.isNotEmpty(model.getDistributionPoints()));
	}

}

@@ -239,19 +239,67 @@
 va.util.
-Lis
+HashSet;%0Aimport java.util.List;%0Aimport java.util.Se
 t;%0A%0Aimpo
@@ -505,16 +505,157 @@
 Pointer;
+%0Aimport eu.europa.esig.dss.tsl.TSLService;%0Aimport eu.europa.esig.dss.tsl.TSLServiceProvider;%0Aimport eu.europa.esig.dss.x509.CertificateToken;
 %0A%0Apublic
@@ -1485,16 +1485,16 @@
 ));%0A%09%09%7D%0A
-
 %09%09assert
@@ -1562,10 +1562,1377 @@
 ));%0A%09%7D%0A%0A
+%09@Test%0A%09public void countCertificatesLT() throws Exception %7B%0A%09%09int oldResult = 35;%0A%09%09TSLParser parser = new TSLParser(new FileInputStream(new File(%22src/test/resources/tsls/621C7723265CA33AAD0607B3C612B313872E7514.xml%22)));%0A%09%09TSLParserResult model = parser.call();%0A%0A%09%09Set%3CCertificateToken%3E certs = new HashSet%3CCertificateToken%3E();%0A%09%09List%3CTSLServiceProvider%3E serviceProviders = model.getServiceProviders();%0A%09%09for (TSLServiceProvider tslServiceProvider : serviceProviders) %7B%0A%09%09%09List%3CTSLService%3E services = tslServiceProvider.getServices();%0A%09%09%09for (TSLService tslService : services) %7B%0A%09%09%09%09certs.addAll( tslService.getCertificates());%0A%09%09%09%7D%0A%09%09%7D%0A%09%09assertEquals(oldResult, certs.size());%0A%09%7D%0A%0A%09@Test%0A%09public void countCertificatesDE() throws Exception %7B%0A%09%09int oldResult = 413;%0A%09%09TSLParser parser = new TSLParser(new FileInputStream(new File(%22src/test/resources/tsls/59F95095730A1809A027655246D6524959B191A8.xml%22)));%0A%09%09TSLParserResult model = parser.call();%0A%0A%09%09Set%3CCertificateToken%3E certs = new HashSet%3CCertificateToken%3E();%0A%09%09List%3CTSLServiceProvider%3E serviceProviders = model.getServiceProviders();%0A%09%09for (TSLServiceProvider tslServiceProvider : serviceProviders) %7B%0A%09%09%09List%3CTSLService%3E services = tslServiceProvider.getServices();%0A%09%09%09for (TSLService tslService : services) %7B%0A%09%09%09%09certs.addAll( tslService.getCertificates());%0A%09%09%09%7D%0A%09%09%7D%0A%09%09assertEquals(oldResult, certs.size());%0A%09%7D%0A%0A
 %7D%0A

Add tests to be sure to retrieve all certificates