Handling Large String Constants in Java -


what best way handle large string constants in java?

imagine have test fixture soap , want send following string:

<?xml version="1.0" encoding="utf-8"?> <soap:envelope    xmlns:xsi="http://www.w3.org/2001/xmlschema-instance"    xmlns:xsd="http://www.w3.org/2001/xmlschema"    xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">     <soap:body>        <quoterequest xmlns="https://www.bcponline.co.uk">             <header>                 <sourcecode>bn325</sourcecode>                 <messagesource>b2b3</messagesource>                 <profile>b08a</profile>                 <password>ap3u86v</password>                 <operatorid>flightline</operatorid>                 <showweboptions>0</showweboptions>             </header>             <serviceselection>                 <serviceprovidercode></serviceprovidercode>                 <productcode>carparking</productcode>                 <iatacode>lgw</iatacode>             </serviceselection>             <quotedetails>                 <departuredate>21-jun-2005</departuredate>                 <departuretime>07:00</departuretime>                 <returndate>28-jun-2005</returndate>                 <returntime>07:00</returntime>                 <quotereference></quotereference>                 <nopax>1</nopax>             </quotedetails>             <spostcode></spostcode>         </quoterequest>     </soap:body> </soap:envelope> 

i'd rather not put quotes , pluses around every line. if put in file it's code , hard put several strings in same file. xml has problems escaping text (i have use cdata ugliness). there easier way?

if strings unrelated, put them in separate files if it's lot of files (what problem that?).

if insist on 1 file, come unique delimiter, paying price when attempting randomly access specific entry.

data files should externalized (likely in separate directory) , read when needed, rather hardcoded code. it's cleaner, reduces code size, reduces need compilation, , allows use same data file multiple test. test fixtures build , integration tools support external files.

or, write code or builder builds soap arguments, making lot more concise (if you're willing pay runtime cost). (correction: see changed sample, nasty auto-generate).


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -