	@Test
	public void testWhitespaceBeforeDocument() throws IOException, XMLStreamException
	{

		String message = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/submit_document.xml"));
		String documentString = IOUtils.toString(ProvideAndRegisterDocumentSetTest.class.getResourceAsStream("/data/referral_summary.xml"));
		//replace document and submission set uniqueId variables with actual uniqueIds. 
		message = message.replace("$XDSDocumentEntry.uniqueId", "2.16.840.1.113883.3.65.2." + System.currentTimeMillis());
		message = message.replace("$XDSSubmissionSet.uniqueId", "1.3.6.1.4.1.21367.2009.1.2.108." + System.currentTimeMillis());
		//message = message.replace("$patientId", patientId);
		//replace the document uuid.
		//String uuid = getUUID();
		//message = message.replace("$doc1", uuid);

		for (Boolean includeWhitespace : new Boolean[] { false, true })
		{
			OMElement request = OMUtil.xmlStringToOM(message);
			request = addOneDocument(request, documentString, "doc1", includeWhitespace);
	
			for (OMElement document : MetadataSupport.childrenWithLocalName(request, "Document")) {
				OMText text = ProvideAndRegisterDocumentSet.getBinaryNode(document);
				assertTrue("Blank document. Included whitespace: " + includeWhitespace, StringUtils.isNotBlank(text.getText()));
			}
		}
	}