From b9eb1329a6dbec7b75c21d8e0eb13134121db6bb Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Sat, 19 Mar 2016 02:05:33 -0700 Subject: Initial commit for the CCB API Client. The client currently supports the following APIs: * individual_profiles * individual_profile_from_id * individual_profile_from_login_password * individual_profile_from_micr * custom_field_labels --- .../p4square/ccbapi/model/XmlBinderTestBase.java | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/test/java/com/p4square/ccbapi/model/XmlBinderTestBase.java (limited to 'src/test/java/com/p4square/ccbapi/model/XmlBinderTestBase.java') diff --git a/src/test/java/com/p4square/ccbapi/model/XmlBinderTestBase.java b/src/test/java/com/p4square/ccbapi/model/XmlBinderTestBase.java new file mode 100644 index 0000000..2422d39 --- /dev/null +++ b/src/test/java/com/p4square/ccbapi/model/XmlBinderTestBase.java @@ -0,0 +1,39 @@ +package com.p4square.ccbapi.model; + +import java.io.InputStream; +import com.p4square.ccbapi.CCBXmlBinder; +import org.junit.Before; + +/** + * Created by jesterpm on 3/14/16. + */ +public class XmlBinderTestBase { + + private CCBXmlBinder binder; + + @Before + public void setUp() { + binder = new CCBXmlBinder(); + } + + /** + * Helper to test the response stored in a file. + * + * @param filename The name of the xml file containing the response. + * @param clazz The class to bind to. + * @param The type of the return value. + * @return The parsed response. + * @throws Exception If something fails. + */ + protected T parseFile(final String filename, final Class clazz) throws Exception { + InputStream in = getClass().getResourceAsStream(filename); + if (in == null) { + throw new AssertionError("Could not find file " + filename); + } + try { + return binder.bindResponseXML(in, clazz); + } finally { + in.close(); + } + } +} -- cgit v1.2.3