diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2016-03-19 02:05:33 -0700 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2016-03-19 02:07:24 -0700 |
commit | b9eb1329a6dbec7b75c21d8e0eb13134121db6bb (patch) | |
tree | fec73ab32ff625c304513c24e864809845eede1a /src/test/java/com/p4square/ccbapi/model/XmlBinderTestBase.java |
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
Diffstat (limited to 'src/test/java/com/p4square/ccbapi/model/XmlBinderTestBase.java')
-rw-r--r-- | src/test/java/com/p4square/ccbapi/model/XmlBinderTestBase.java | 39 |
1 files changed, 39 insertions, 0 deletions
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 <T> The type of the return value. + * @return The parsed response. + * @throws Exception If something fails. + */ + protected <T extends CCBAPIResponse> T parseFile(final String filename, final Class<T> 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(); + } + } +} |