	@Test
	public void testProcessAndSaveDoc() throws UIMAException, IOException {

		// JCas jCas =
		// JCasFactory.createJCasFromPath("src/main/resources/org/apache/ctakes/ytex/types/TypeSystem.xml");
		String text = "Title: US Abdomen\n\nDr. Doolitle asked patient\nto take a deep breath\nand exhale slowly.  Patient coughed.  Prescribed acetominophen";
		AnalysisEngine engine = TestUtils.createTokenizerAE(null);
		JCas jCas = engine.newJCas();
		jCas.setDocumentText(text);
		// create a docKey so we can find the doc
		long key = System.currentTimeMillis();
		DocKey docKey = new DocKey(jCas);
		KeyValuePair kvp = new KeyValuePair(jCas);
		kvp.setKey("instance_id");
		kvp.setValueLong(key);
		FSArray fsa = new FSArray(jCas, 1);
		fsa.set(0, kvp);
		docKey.setKeyValuePairs(fsa);
		docKey.addToIndexes();
		// run the analysis engine
		engine.process(jCas);
		DataSource ds = ctx.getBean(DataSource.class);
		Properties ytexProperties = (Properties) ctx.getBean("ytexProperties");
		String schema = ytexProperties.getProperty("db.schema");
		String schemaPrefix = Strings.isNullOrEmpty(schema) ? "" : schema + ".";
		JdbcTemplate jt = new JdbcTemplate(ds);
		String query = String.format(
				"select count(*) from %sdocument where instance_id=%s",
				schemaPrefix, key);
		Assert.assertTrue(query, jt.queryForObject(query,Integer.class) == 1);
		query = String
				.format("select count(*) from %sdocument d inner join %sanno_base ab on ab.document_id = d.document_id inner join %sanno_segment s on s.anno_base_id = ab.anno_base_id where d.instance_id=%s",
						schemaPrefix, schemaPrefix, schemaPrefix, key);
		Assert.assertTrue(query, jt.queryForObject(query,Integer.class) == 1);
		query = String
				.format("select count(*) from %sdocument d inner join %sanno_base ab on ab.document_id = d.document_id inner join %sanno_sentence s on s.anno_base_id = ab.anno_base_id where d.instance_id=%s",
						schemaPrefix, schemaPrefix, schemaPrefix, key);
		Assert.assertTrue(query, jt.queryForObject(query,Integer.class) > 1);
		query = String
				.format("select count(*) from %sdocument d inner join %sanno_base ab on ab.document_id = d.document_id inner join %sanno_token s on s.anno_base_id = ab.anno_base_id where d.instance_id=%s",
						schemaPrefix, schemaPrefix, schemaPrefix, key);
		Assert.assertTrue(query, jt.queryForObject(query,Integer.class) > 1);
	}