diff options
author | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-11-04 09:12:37 +0100 |
---|---|---|
committer | Andreas Fitzek <andreas.fitzek@iaik.tugraz.at> | 2014-11-04 09:12:37 +0100 |
commit | 0e5320a6e524dd46179d5f7f1e86794b7b41092f (patch) | |
tree | c51267e835c2745689b6f5680c421a2a92856ecd /pdf-as-lib/src/test/java/at/gv/egiz | |
parent | fed2e4a84d0d7e3ffa714e7c0685247be76715fb (diff) | |
download | pdf-as-4-0e5320a6e524dd46179d5f7f1e86794b7b41092f.tar.gz pdf-as-4-0e5320a6e524dd46179d5f7f1e86794b7b41092f.tar.bz2 pdf-as-4-0e5320a6e524dd46179d5f7f1e86794b7b41092f.zip |
Catch old SL Error Responses
Diffstat (limited to 'pdf-as-lib/src/test/java/at/gv/egiz')
-rw-r--r-- | pdf-as-lib/src/test/java/at/gv/egiz/pdfas/lib/test/mains/LegacySLExtractor.java | 74 |
1 files changed, 74 insertions, 0 deletions
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 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<sl10:ErrorResponse xmlns:sl10=\"http://www.buergerkarte.at/namespaces/securitylayer/20020225#\">" + + "<sl10:ErrorCode>1501</sl10:ErrorCode>" + + "<sl10:Info>Fehler in XML-Struktur der Anfrage. (Element content is invalid according to the DTD/Schema.)</sl10:Info>" + + "</sl10:ErrorResponse>"; + + public static final String TEST_LEGACY_RESPONSE_NOINFO = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<sl10:ErrorResponse xmlns:sl10=\"http://www.buergerkarte.at/namespaces/securitylayer/20020225#\">" + + "<sl10:ErrorCode>1501</sl10:ErrorCode>" + + "</sl10:ErrorResponse>"; + + public static final String TEST_LEGACY_RESPONSE_PLAIN = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<sl10:ErrorResponse xmlns:sl10=\"http://www.buergerkarte.at/namespaces/securitylayer/20020225#\">" + + "</sl10:ErrorResponse>"; + + public static final String TEST_LEGACY_SOMETHING_ELSE = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + + "<sl10:Errorresponse xmlns:sl10=\"http://www.buergerkarte.at/namespaces/securitylayer/20020225#\">" + + "<sl10:ErrorCode>1501</sl10:ErrorCode>" + + "<sl10:Info>Fehler in XML-Struktur der Anfrage. (Element content is invalid according to the DTD/Schema.)</sl10:Info>" + + "</sl10:Errorresponse>"; + + @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"); + } + } + +} |