package eu.europa.ec.markt.dss.validation102853.tsl;

import org.junit.Assert;
import org.junit.Test;

import eu.europa.ec.markt.dss.validation102853.https.CommonsDataLoader;

public class TrustedListCertificateSourceTest {
	
	@Test
	public void test1() throws Exception {
		
		TrustedListsCertificateSource source = new TrustedListsCertificateSource();
		source.setDataLoader(new CommonsDataLoader());
		source.setLotlCertificate("classpath://ec.europa.eu.crt");
		source.setLotlUrl("https://ec.europa.eu/information_society/policy/esignature/trusted-list/tl-mp.xml");
		source.setTslRefreshPolicy(TSLRefreshPolicy.NEVER);
		source.setCheckSignature(false);
		source.init();
		
		Assert.assertTrue(source.getCertificates().size() > 0);

	}
	
}

@@ -47,16 +47,55 @@
 3.tsl;%0A%0A
+import java.net.UnknownHostException;%0A%0A
 import o
@@ -111,16 +111,16 @@
 Assert;%0A
-
 import o
@@ -256,18 +256,17 @@
 eTest %7B%0A
-%09
 %0A
+
 %09@Test%0A%09
@@ -304,21 +304,28 @@
 ption %7B%0A
+%0A
 %09%09
+try %7B
 %0A%09%09
+%09
 TrustedL
@@ -390,24 +390,25 @@
 Source();%0A%09%09
+%09
 source.setDa
@@ -442,16 +442,17 @@
 der());%0A
+%09
 %09%09source
@@ -502,24 +502,25 @@
 eu.crt%22);%0A%09%09
+%09
 source.setLo
@@ -611,16 +611,17 @@
 .xml%22);%0A
+%09
 %09%09source
@@ -664,24 +664,25 @@
 y.NEVER);%0A%09%09
+%09
 source.setCh
@@ -704,16 +704,17 @@
 lse);%0A%09%09
+%09
 source.i
@@ -724,11 +724,10 @@
 ();%0A
-%09%09
 %0A
+%09
 %09%09As
@@ -783,13 +783,160 @@
  0);
+%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09if(!(e.getCause() instanceof UnknownHostException)) %7B%0A%09%09%09%09throw e;%0A%09%09%09%7D%0A%09%09%09// Internet failure is not test failure%0A%09%09%7D
 %0A%0A%09%7D%0A
-%09
 %0A%7D%0A

Test should not break when no internet connection