From 0e5320a6e524dd46179d5f7f1e86794b7b41092f Mon Sep 17 00:00:00 2001 From: Andreas Fitzek Date: Tue, 4 Nov 2014 09:12:37 +0100 Subject: Catch old SL Error Responses --- .../pdfas/lib/test/mains/LegacySLExtractor.java | 74 ++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/LegacySLExtractor.java (limited to 'pdf-as-lib/src/test') diff --git a/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/LegacySLExtractor.java b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/LegacySLExtractor.java new file mode 100644 index 00000000..d31d6b1e --- /dev/null +++ b/pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/LegacySLExtractor.java @@ -0,0 +1,74 @@ +package at.gv.egiz.pdfas.lib.test.mains; + +import static org.junit.Assert.*; + +import org.junit.Test; + +import at.gv.egiz.pdfas.common.exceptions.SLPdfAsException; +import at.gv.egiz.sl.util.BKUSLConnector; + +public class LegacySLExtractor { + + public static final String TEST_LEGACY_RESPONSE = "" + + "" + + "1501" + + "Fehler in XML-Struktur der Anfrage. (Element content is invalid according to the DTD/Schema.)" + + ""; + + public static final String TEST_LEGACY_RESPONSE_NOINFO = "" + + "" + + "1501" + + ""; + + public static final String TEST_LEGACY_RESPONSE_PLAIN = "" + + "" + + ""; + + public static final String TEST_LEGACY_SOMETHING_ELSE = "" + + "" + + "1501" + + "Fehler in XML-Struktur der Anfrage. (Element content is invalid according to the DTD/Schema.)" + + ""; + + @Test + public void test() { + SLPdfAsException e = BKUSLConnector.generateLegacySLException(TEST_LEGACY_RESPONSE); + + if(e == null) { + fail("Failed to extract SL Error"); + } + + if(e.getCode() != 1501 || !e.getInfo().equals("Fehler in XML-Struktur der Anfrage. (Element content is invalid according to the DTD/Schema.)")) { + fail("Failed to extract SL Error"); + } + + SLPdfAsException e1 = BKUSLConnector.generateLegacySLException(TEST_LEGACY_RESPONSE_NOINFO); + + if(e1 == null) { + fail("Failed to extract SL Error"); + } + + if(e1.getCode() != 1501 || e1.getInfo() != null) { + fail("Failed to extract SL Error"); + } + + SLPdfAsException e2 = BKUSLConnector.generateLegacySLException(TEST_LEGACY_RESPONSE_PLAIN); + + if(e2 != null) { + fail("Extracted invalid error info"); + } + + SLPdfAsException e3 = BKUSLConnector.generateLegacySLException(TEST_LEGACY_SOMETHING_ELSE); + + if(e3 != null) { + fail("Extracted invalid error info"); + } + + SLPdfAsException e4 = BKUSLConnector.generateLegacySLException(null); + + if(e4 != null) { + fail("Extracted invalid error info"); + } + } + +} -- cgit v1.2.3