ctakes-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vjapa...@apache.org
Subject svn commit: r1551254 [26/26] - in /ctakes/branches/ytex: ctakes-ytex-res/ ctakes-ytex-res/.settings/ ctakes-ytex-res/src/ ctakes-ytex-res/src/main/ ctakes-ytex-res/src/main/resources/ ctakes-ytex-res/src/main/resources/org/ ctakes-ytex-res/src/main/res...
Date Mon, 16 Dec 2013 16:30:40 GMT
Added: ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/ValidationTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/ValidationTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/ValidationTest.java
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/ValidationTest.java
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,77 @@
+package org.apache.ctakes.jdl.data.xml;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.junit.Assert.assertThat;
+
+import java.net.URL;
+
+import javax.xml.validation.Schema;
+
+
+import org.apache.ctakes.jdl.AppJdl;
+import org.apache.ctakes.jdl.common.FileUtil;
+import org.apache.ctakes.jdl.data.xml.DomUtil;
+import org.apache.ctakes.jdl.data.xml.SchemaUtil;
+import org.apache.ctakes.jdl.data.xml.Validation;
+import org.apache.ctakes.jdl.test.Resources;
+import org.junit.After;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.theories.DataPoint;
+import org.junit.experimental.theories.Theories;
+import org.junit.experimental.theories.Theory;
+import org.junit.runner.RunWith;
+
+@RunWith(Theories.class)
+public class ValidationTest {
+	private static final URL XSD = AppJdl.XSD;
+	private static Validation validation;
+	@DataPoint
+	public static String CX = Resources.CONN_X;
+	@DataPoint
+	public static String L1C = Resources.LOAD1C;
+	@DataPoint
+	public static String L1X = Resources.LOAD1X;
+	@DataPoint
+	public static String L2C = Resources.LOAD2C;
+	@DataPoint
+	public static String L2X = Resources.LOAD2X;
+
+	@BeforeClass
+	public static void initClass() {
+		Schema schema = SchemaUtil.urlToSchema(XSD);
+		validation = new Validation(schema);
+	}
+
+	@Test
+	public void setSchema() {
+		validation.setSchema(SchemaUtil.urlToSchema(XSD));
+		assertThat(validation.getError(), nullValue());
+		validation.setSchema(XSD.getPath());
+		assertThat(validation.getError(), nullValue());
+	}
+
+	@Theory
+	public void setDocument(String xml) {
+		xml = FileUtil.getFile(xml).toString();
+		validation.setDocument(DomUtil.srcToDocument(xml));
+		assertThat(validation.succeed(), is(true));
+		validation.setDocument(xml);
+		assertThat(validation.succeed(), is(true));
+	}
+
+	@After
+	public void getError() {
+		assertThat(validation.getError(), nullValue());
+	}
+
+	@Theory
+	public void succeed(String xml) {
+		xml = FileUtil.getFile(xml).toString();
+		validation.setDocument(DomUtil.srcToDocument(xml));
+		assertThat(validation.succeed(), is(true));
+		validation.setDocument(xml);
+		assertThat(validation.succeed(), is(true));
+	}
+}

Added: ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/jaxb/ObjectFactoryBindTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/jaxb/ObjectFactoryBindTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/jaxb/ObjectFactoryBindTest.java
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/jaxb/ObjectFactoryBindTest.java
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,44 @@
+package org.apache.ctakes.jdl.data.xml.jaxb;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.UnmarshalException;
+
+
+import org.apache.ctakes.jdl.common.FileUtil;
+import org.apache.ctakes.jdl.data.xml.jaxb.ObjectFactoryBind;
+import org.apache.ctakes.jdl.test.Resources;
+import org.junit.Test;
+import org.junit.experimental.theories.DataPoint;
+import org.junit.experimental.theories.Theories;
+import org.junit.experimental.theories.Theory;
+import org.junit.runner.RunWith;
+
+@RunWith(Theories.class)
+public class ObjectFactoryBindTest {
+	@DataPoint
+	public static String CX = Resources.CONN_X;
+	@DataPoint
+	public static String L1C = Resources.LOAD1C;
+	@DataPoint
+	public static String L1X = Resources.LOAD1X;
+	@DataPoint
+	public static String L2C = Resources.LOAD2C;
+	@DataPoint
+	public static String L2X = Resources.LOAD1X;
+
+	@Theory
+	public void unmarshalSrcXml(String xml) throws JAXBException {
+		xml = FileUtil.getFile(xml).toString();
+		Object obj = new ObjectFactoryBind().unmarshalSrcXml(xml);
+		assertThat(obj, instanceOf(JAXBElement.class));
+	}
+
+	@Test(expected = UnmarshalException.class)
+	public void unmarshalStrXml() throws JAXBException {
+		new ObjectFactoryBind().unmarshalStrXml("<root />");
+	}
+}

Added: ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/jaxb/ObjectFactoryUtilTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/jaxb/ObjectFactoryUtilTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/jaxb/ObjectFactoryUtilTest.java
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/data/xml/jaxb/ObjectFactoryUtilTest.java
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,65 @@
+package org.apache.ctakes.jdl.data.xml.jaxb;
+
+import static org.hamcrest.CoreMatchers.instanceOf;
+import static org.junit.Assert.assertThat;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.bind.UnmarshalException;
+
+
+import org.apache.ctakes.jdl.common.FileUtil;
+import org.apache.ctakes.jdl.data.xml.jaxb.ObjectFactoryUtil;
+import org.apache.ctakes.jdl.schema.xdl.ConnType;
+import org.apache.ctakes.jdl.schema.xdl.JdbcType;
+import org.apache.ctakes.jdl.schema.xdl.LoadType;
+import org.apache.ctakes.jdl.test.Resources;
+import org.junit.Test;
+import org.junit.experimental.theories.DataPoint;
+import org.junit.experimental.theories.Theories;
+import org.junit.experimental.theories.Theory;
+import org.junit.runner.RunWith;
+
+@RunWith(Theories.class)
+public final class ObjectFactoryUtilTest {
+	private static final String CX = FileUtil.getFile(Resources.CONN_X).toString();
+	@DataPoint
+	public static String L1C = Resources.LOAD1C;
+	@DataPoint
+	public static String L1X = Resources.LOAD1X;
+	@DataPoint
+	public static String L2C = Resources.LOAD2C;
+	@DataPoint
+	public static String L2X = Resources.LOAD1X;
+
+	public void getJdbcTypeBySrcXml() throws JAXBException {
+		Object obj = ObjectFactoryUtil.getJdbcTypeBySrcXml(CX);
+		assertThat(obj, instanceOf(JdbcType.class));
+	}
+
+	@Test(expected = UnmarshalException.class)
+	public void getJdbcTypeByStrXml() throws JAXBException {
+		ObjectFactoryUtil.getJdbcTypeByStrXml("<root />");
+	}
+
+	public void getConnTypeBySrcXml() throws JAXBException {
+		Object obj = ObjectFactoryUtil.getJdbcTypeBySrcXml(CX);
+		assertThat(obj, instanceOf(ConnType.class));
+	}
+
+	@Test(expected = UnmarshalException.class)
+	public void getConnTypeByStrXml() throws JAXBException {
+		ObjectFactoryUtil.getConnTypeByStrXml("<root />");
+	}
+
+	@Theory
+	public void getBindTypeBySrcXml(String xml) throws JAXBException {
+		xml = FileUtil.getFile(xml).toString();
+		Object obj = ObjectFactoryUtil.getLoadTypeBySrcXml(xml);
+		assertThat(obj, instanceOf(LoadType.class));
+	}
+
+	@Test(expected = UnmarshalException.class)
+	public void getBindTypeByStrXml() throws JAXBException {
+		ObjectFactoryUtil.getJdbcTypeByStrXml("<root />");
+	}
+}

Added: ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/PropFileMaps.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/PropFileMaps.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/PropFileMaps.java
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/PropFileMaps.java
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,39 @@
+package org.apache.ctakes.jdl.test;
+
+import java.util.Properties;
+
+import org.apache.ctakes.jdl.common.PropFile;
+
+
+/**
+ * Access to maps.properties file.
+ * 
+ * @author mas
+ */
+public class PropFileMaps {
+	private static final boolean INTERNAL = true;
+	private static final String SRC_FILE = "/maps.properties";
+	private static Properties properties = PropFile.getProperties(SRC_FILE, INTERNAL);
+
+	/**
+	 * @param property
+	 *            the property to get
+	 * @return
+	 */
+	public static final String getProperty(final String property) {
+		return PropFile.getProperty(properties, property);
+	}
+
+	/**
+	 * Reset the properties.
+	 */
+	public static final void reset() {
+		properties = PropFile.getProperties(SRC_FILE, INTERNAL);
+	}
+
+	public static final String ID = getProperty("id");
+	public static final String KEY = getProperty("key");
+
+	// If true you can use: mvn clean test -P jdbc,h2
+	public static final boolean DEMO = Boolean.parseBoolean(getProperty("demo"));
+}

Added: ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/Resources.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/Resources.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/Resources.java
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/Resources.java
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,34 @@
+package org.apache.ctakes.jdl.test;
+
+/**
+ * Resources files.
+ * 
+ * @author mas
+ */
+public class Resources {
+	// env
+	public static final String ENV_DRIVER = "${jdbc.driver}";
+	public static final String ENV_URL = "${jdbc.url}";
+
+	// map
+	public static final String MAP_ID = "id";
+	public static final String MAP_NAME = "name";
+	public static final String MAP_KEY = "key";
+	public static final String MAP_VALUE = "value";
+
+	// resources
+	public static final String CONN_X = "conn.xml";
+	public static final String DATA1C = "data1.csv";
+	public static final String DATA1X = "data1.xml";
+	public static final String DATA2C = "data2.csv";
+	public static final String DATA2X = "data2.xml";
+	public static final String LOAD1C = "load1csv.xml";
+	public static final String LOAD1X = "load1xml.xml";
+	public static final String LOAD2C = "load2csv.xml";
+	public static final String LOAD2X = "load2xml.xml";
+	public static final String MAPS_P = "maps.properties";
+
+	// root
+	public static final String ROOT_CONN = "conn";
+	public static final String ROOT_LOAD = "load";
+}

Added: ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/SqlJdl.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/SqlJdl.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/SqlJdl.java
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/SqlJdl.java
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,95 @@
+package org.apache.ctakes.jdl.test;
+
+import java.sql.Connection;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+
+/**
+ * Manage of sql for resources files.
+ * 
+ * @author mas
+ */
+public class SqlJdl {
+	/**
+	 * @param connection
+	 *            the connection to manage
+	 * @throws SQLException
+	 *             exception
+	 */
+	public static void create(Connection connection) throws SQLException {
+		String sql = "create table tab_test (id numeric, name varchar(32), thekey numeric, thevalue
varchar(64), code numeric, descr varchar(256));";
+		Statement statement = connection.createStatement();
+		statement.executeUpdate(sql);
+		statement.close();
+	}
+
+	/**
+	 * @param connection
+	 *            the connection to manage
+	 * @return list of rows
+	 * @throws SQLException
+	 *             exception
+	 */
+	private static List<String[]> select(Connection connection) throws SQLException {
+		String sql = "select * from tab_test;";
+		Statement statement = connection.createStatement();
+		ResultSet resultSet = statement.executeQuery(sql);
+		List<String[]> list = new ArrayList<String[]>();
+		while (resultSet.next()) {
+			list.add(new String[] { resultSet.getString(1), resultSet.getString(2), resultSet.getString(3),
resultSet.getString(4), resultSet.getString(5), resultSet.getString(6) });
+		}
+		resultSet.close();
+		statement.close();
+		return list;
+	}
+
+	/**
+	 * @param connection
+	 *            the connetcion to manage
+	 * @param print
+	 *            check if print rows
+	 * @return list of rows
+	 * @throws SQLException
+	 *             exception
+	 */
+	public static List<String[]> select(Connection connection, boolean print) throws SQLException
{
+		List<String[]> list = select(connection);
+		if (print) {
+			for (String[] c : list) {
+				System.out.println(c[0] + "\t" + StringUtils.rightPad(c[1], 31) + c[2] + "\t" + StringUtils.rightPad(c[3],
23) + c[4] + "\t" + c[5]);
+			}
+		}
+		return list;
+	}
+
+	/**
+	 * @param connection
+	 *            the connection to manage
+	 * @throws SQLException
+	 *             exception
+	 */
+	public static void delete(Connection connection) throws SQLException {
+		String sql = "delete from tab_test";
+		Statement statement = connection.createStatement();
+		statement.executeUpdate(sql);
+		statement.close();
+	}
+
+	/**
+	 * @param connection
+	 *            the connection to manage
+	 * @throws SQLException
+	 *             exception
+	 */
+	public static void drop(Connection connection) throws SQLException {
+		String sql = "drop table tab_test;";
+		Statement statement = connection.createStatement();
+		statement.executeUpdate(sql);
+		statement.close();
+	}
+}

Added: ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/package-info.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/package-info.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/package-info.java
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/jdl/test/package-info.java
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,5 @@
+/**
+ * Test classes.
+ */
+package org.apache.ctakes.jdl.test;
+

Added: ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/ytex/ConceptDaoTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/ytex/ConceptDaoTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/ytex/ConceptDaoTest.java
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/ytex/ConceptDaoTest.java
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,103 @@
+package org.apache.ctakes.ytex;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Properties;
+
+import javax.sql.DataSource;
+
+import org.apache.ctakes.ytex.kernel.SimSvcContextHolder;
+import org.apache.ctakes.ytex.kernel.dao.ConceptDao;
+import org.apache.ctakes.ytex.kernel.metric.ConceptPairSimilarity;
+import org.apache.ctakes.ytex.kernel.metric.ConceptSimilarityService;
+import org.apache.ctakes.ytex.kernel.metric.ConceptSimilarityService.SimilarityMetricEnum;
+import org.apache.ctakes.ytex.kernel.model.ConceptGraph;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
+import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
+import org.springframework.jdbc.core.JdbcTemplate;
+import org.springframework.util.Assert;
+
+public class ConceptDaoTest {
+	ConceptDao conceptDao;
+	ApplicationContext appCtx;
+
+	@Before
+	public void setUp() throws Exception {
+		 ClassLoader cl = ClassLoader.getSystemClassLoader();
+		 
+		URL[] urls = ((URLClassLoader)cl).getURLs();
+	 
+	        for(URL url: urls){
+	        	System.out.println(url.getFile());
+	        }		
+		URL is = this.getClass().getClassLoader().getResource("org/apache/ctakes/ytex/kernelBeanRefContext.xml");
+		System.out.println(is);
+		appCtx = (ApplicationContext) ContextSingletonBeanFactoryLocator
+				.getInstance("classpath*:org/apache/ctakes/ytex/kernelBeanRefContext.xml")
+				.useBeanFactory("kernelApplicationContext").getFactory();
+		conceptDao = appCtx.getBean(ConceptDao.class);
+		JdbcTemplate jdbcTemplate = new JdbcTemplate();
+		jdbcTemplate.setDataSource(appCtx.getBean(DataSource.class));
+		Properties ytexProperties = (Properties)appCtx.getBean("ytexProperties");
+		String dbtype = ytexProperties.getProperty("db.type");
+		if("hsql".equals(dbtype) || "mysql".equals(dbtype))
+			jdbcTemplate.execute("drop table if exists test_concepts");
+		if("mssql".equals(dbtype))
+			jdbcTemplate.execute("if exists(select * from sys.objects where object_id = object_id('test_concepts'))
drop table test_concepts");
+		//TODO if("orcl".equals(dbtype)))
+		jdbcTemplate
+				.execute("create table test_concepts(parent varchar(20), child varchar(20))");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('root', 'animal')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('animal', 'vertebrate')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('vertebrate', 'cat')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('vertebrate', 'dog')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('root', 'bacteria')");
+		jdbcTemplate
+				.execute("insert into test_concepts values ('bacteria', 'e coli')");
+		conceptDao.createConceptGraph("test",
+				"select child, parent from test_concepts", true,
+				Collections.EMPTY_SET);
+		ConceptGraph cg = conceptDao.getConceptGraph("test");
+		Assert.notNull(cg);
+		((ConfigurableApplicationContext)appCtx).close();
+	}
+
+	@Test
+	public void testCreateConceptGraph() throws IOException {
+		System.setProperty("ytex.conceptGraphName", "test");
+		System.setProperty("ytex.conceptPreload", "false");
+		System.setProperty("ytex.conceptSetName", "");
+		// ApplicationContext appCtxSim = new ClassPathXmlApplicationContext(
+		// new String[] { "org/apache/ctakes/ytex/beans-kernel-sim.xml" },
+		// appCtx);
+		// ConceptSimilarityService simSvc = appCtxSim
+		// .getBean(ConceptSimilarityService.class);
+		ConceptSimilarityService simSvc = SimSvcContextHolder
+				.getApplicationContext()
+				.getBean(ConceptSimilarityService.class);
+		ConceptPairSimilarity simDogCat = simSvc.similarity(
+				Arrays.asList(SimilarityMetricEnum.PATH,
+						SimilarityMetricEnum.INTRINSIC_PATH), "dog", "cat",
+				null, false);
+		ConceptPairSimilarity simDogEColi = simSvc.similarity(
+				Arrays.asList(SimilarityMetricEnum.PATH,
+						SimilarityMetricEnum.INTRINSIC_PATH), "dog", "e coli",
+				null, false);
+		Assert.isTrue(simDogCat.getSimilarities().get(0) > simDogEColi
+				.getSimilarities().get(0));
+		Assert.isTrue(simDogCat.getSimilarities().get(1) > simDogEColi
+				.getSimilarities().get(1));
+	}
+
+}

Added: ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/ytex/umls/dao/UMLSDaoTest.java
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/ytex/umls/dao/UMLSDaoTest.java?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/ytex/umls/dao/UMLSDaoTest.java
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/java/org/apache/ctakes/ytex/umls/dao/UMLSDaoTest.java
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,45 @@
+package org.apache.ctakes.ytex.umls.dao;
+
+import java.util.List;
+
+import org.apache.log4j.Logger;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.access.ContextSingletonBeanFactoryLocator;
+
+/**
+ * this test only works if MRCONSO is in the database (not the case for default
+ * test settings). In case MRCONSO is not there, catch exception and ignore.
+ * 
+ * @author vgarla
+ * 
+ */
+public class UMLSDaoTest {
+	private static final Logger log = Logger.getLogger(UMLSDaoTest.class);
+	UMLSDao umlsDao = null;
+
+	@Before
+	public void setUp() throws Exception {
+		ApplicationContext appCtx = (ApplicationContext) ContextSingletonBeanFactoryLocator
+				.getInstance(
+						"classpath*:org/apache/ctakes/ytex/kernelBeanRefContext.xml")
+				.useBeanFactory("kernelApplicationContext").getFactory();
+		umlsDao = appCtx.getBean(UMLSDao.class);
+	}
+
+	@Test
+	public void testGetAllAuiStr() {
+		try {
+			List<Object[]> auis = umlsDao.getAllAuiStr("");
+			Assert.assertNotNull(auis);
+			log.debug("testGetAllAuiStr()" + auis.size());
+		} catch (Exception e) {
+			log.warn(
+					"sql exception - mrconso probably doesn't exist, check error",
+					e);
+		}
+	}
+
+}

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/conn.xml
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/conn.xml?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/conn.xml (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/conn.xml Mon Dec 16 16:30:30 2013
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<conn xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://jdl-prj.googlecode.com/files/xdl.xsd">
+	<jdbc>
+		<driver>${jdbc.driver}</driver>
+		<url>${jdbc.url}</url>
+		<username>${jdbc.username}</username>
+		<password>${jdbc.password}</password>
+	</jdbc>
+</conn>
\ No newline at end of file

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/data1.csv
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/data1.csv?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/data1.csv (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/data1.csv Mon Dec 16 16:30:30 2013
@@ -0,0 +1,4 @@
+#,year,title,storage,composer born
+1,1984,Once Upon A Time In America,Video Home System,1928
+2,1986,The Mission,Digital Versatile Disc,1928
+3,1988,Cinema Paradiso,Blu-ray Disc,1928

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/data1.xml
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/data1.xml?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/data1.xml (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/data1.xml Mon Dec 16 16:30:30 2013
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE data [
+<!ENTITY VHS "Video Home System">
+<!ENTITY DVD "Digital Versatile Disc">
+<!ENTITY BrD "Blu-ray Disc">
+]>
+<composer>
+	<name born="1928">Ennio Morricone</name>
+	<movie storage="&VHS;">
+		<year>1984</year>
+		<title>Once Upon A Time In America</title>
+		<number>9</number>
+	</movie>
+	<movie storage="&DVD;">
+		<year>1986</year>
+		<title>The Mission</title>
+		<number>10</number>
+	</movie>
+	<movie storage="&BrD;">
+		<year>1988</year>
+		<title>Cinema Paradiso</title>
+		<number>11</number>
+	</movie>
+</composer>
\ No newline at end of file

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/data2.csv
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/data2.csv?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/data2.csv (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/data2.csv Mon Dec 16 16:30:30 2013
@@ -0,0 +1,3 @@
+1981;Speak & Spell;1;"Long Play";1980;Depeche Mode
+1990;Violator;7;Compact Cassette;1980;Depeche Mode
+2001;Exciter;10;Compact Disc;1980;Depeche Mode

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/data2.xml
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/data2.xml?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/data2.xml (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/data2.xml Mon Dec 16 16:30:30 2013
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE data [
+<!ENTITY LP "Long Play">
+<!ENTITY CC "Compact Cassette">
+<!ENTITY CD "Compact Disc">
+]>
+<band>
+	<name formed="1980">Depeche Mode</name>
+	<album storage="&LP;">
+		<year>1981</year>
+		<title>Speak &amp; Spell</title>
+		<number>1</number>
+	</album>
+	<album storage="&CC;">
+		<year>1990</year>
+		<title>Violator</title>
+		<number>7</number>
+	</album>
+	<album storage="&CD;">
+		<year>2001</year>
+		<title>Exc<![CDATA[it]]>er</title>
+		<number>10</number>
+	</album>
+</band>
\ No newline at end of file

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/load1csv.xml
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/load1csv.xml?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/load1csv.xml (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/load1csv.xml Mon Dec 16 16:30:30 2013
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<load xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://jdl-prj.googlecode.com/files/xdl.xsd">
+	<csv table="tab_test" skip="1" commit="2">
+		<column name="void" skip="true" />
+		<column name="id" />
+		<column name="name" />
+		<column name="thekey">
+			<seq>9</seq>
+		</column>
+		<column name="thevalue" />
+		<column name="code" />
+		<column name="descr">
+			<constant>Ennio Morricone</constant>
+		</column>
+	</csv>
+</load>
\ No newline at end of file

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/load1xml.xml
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/load1xml.xml?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/load1xml.xml (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/load1xml.xml Mon Dec 16 16:30:30 2013
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<load xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://jdl-prj.googlecode.com/files/xdl.xsd">
+	<xml table="tab_test">
+		<xroot>/composer/movie</xroot>
+		<column name="id">
+			<xleaf>number(/movie/year)</xleaf>
+		</column>
+		<column name="name">
+			<xleaf>/movie/title</xleaf>
+		</column>
+		<column name="thekey">
+			<seq>9</seq>
+		</column>
+		<column name="thevalue">
+			<xleaf>/movie/@storage</xleaf>
+		</column>
+		<column name="code">
+			<constant>1928</constant>
+		</column>
+		<column name="descr">
+			<xpath>/composer/name</xpath>
+		</column>
+	</xml>
+</load>
\ No newline at end of file

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/load2csv.xml
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/load2csv.xml?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/load2csv.xml (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/load2csv.xml Mon Dec 16 16:30:30 2013
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8"?>
+<load xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://jdl-prj.googlecode.com/files/xdl.xsd">
+	<csv table="tab_test" delimiter=";">
+		<column name="id" />
+		<column name="name" />
+		<column name="thekey" />
+		<column name="thevalue" />
+		<column name="code" />
+		<column name="descr" />
+	</csv>
+</load>
\ No newline at end of file

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/load2xml.xml
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/load2xml.xml?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/load2xml.xml (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/load2xml.xml Mon Dec 16 16:30:30 2013
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<load xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://jdl-prj.googlecode.com/files/xdl.xsd">
+	<xml table="tab_test">
+		<xroot>/band/album</xroot>
+		<column name="id">
+			<xleaf>number(/album/year)</xleaf>
+		</column>
+		<column name="name">
+			<xleaf>/album/title</xleaf>
+		</column>
+		<column name="thekey">
+			<xleaf>number(/album/number)</xleaf>
+		</column>
+		<column name="thevalue">
+			<xleaf>/album/@storage</xleaf>
+		</column>
+		<column name="code">
+			<xpath>/band/name/@formed</xpath>
+		</column>
+		<column name="descr">
+			<xpath>/band/name</xpath>
+		</column>
+	</xml>
+</load>
\ No newline at end of file

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/log4j.properties?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/log4j.properties (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/log4j.properties Mon Dec 16 16:30:30
2013
@@ -0,0 +1,44 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+###############################################################################
+
+log4j.rootLogger=INFO, Console
+
+###############################################################################
+
+# Rolling File Appender definition
+log4j.appender.RFile=org.apache.log4j.RollingFileAppender
+log4j.appender.RFile.File=textAnalysis.log
+log4j.appender.RFile.MaxFileSize=1024KB
+log4j.appender.RFile.MaxBackupIndex=1
+log4j.appender.RFile.layout=org.apache.log4j.PatternLayout
+log4j.appender.RFile.layout.ConversionPattern=%d %-5p %c %x - %m%n
+
+###############################################################################
+
+# Console Appender definition
+log4j.appender.Console=org.apache.log4j.ConsoleAppender
+log4j.appender.Console.layout=org.apache.log4j.PatternLayout
+log4j.appender.Console.layout.ConversionPattern=%d %-5p %c %x - %m%n
+
+###############################################################################
+log4j.category.org.hibernate=INFO
+log4j.category.org.springframework=INFO
+log4j.category.org.apache.ctakes.ytex=DEBUG
\ No newline at end of file

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/maps.properties
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/maps.properties?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/maps.properties (added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/maps.properties Mon Dec 16 16:30:30
2013
@@ -0,0 +1,5 @@
+id=name
+key=value
+
+# If true you can use: mvn clean test -P jdbc,h2
+demo=false

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/umls/model/UMLS.hbm.xml
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/umls/model/UMLS.hbm.xml?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/umls/model/UMLS.hbm.xml
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/umls/model/UMLS.hbm.xml
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,48 @@
+<?xml version="1.0"?>
+<!-- umls tables in a different schema no easy way known to me to override 
+	schema for specific tables at runtime use this template to create the hibernate 
+	mapping -->
+<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
+<hibernate-mapping package="org.apache.ctakes.ytex.umls.model"
+	schema="PUBLIC">
+	<!-- mrrel doesn't really have a primary key / unique index -->
+	<class name="MRREL" table="MRREL">
+		<id name="rui" column="rui" />
+		<property name="cui1"></property>
+		<property name="cui2"></property>
+		<property name="rel"></property>
+		<property name="sab"></property>
+		<property name="rela" />
+	</class>
+	<class name="MRCONSO" table="MRCONSO">
+		<id name="aui" column="aui" />
+		<property name="cui" />
+		<property name="lat" />
+		<property name="ts" />
+		<property name="lui" />
+		<property name="stt" />
+		<property name="sui" />
+		<property name="ispref" />
+		<property name="saui" />
+		<property name="scui" />
+		<property name="sdui" />
+		<property name="sab" />
+		<property name="tty" />
+		<property name="code" />
+		<property name="str" />
+		<property name="srl" />
+		<property name="suppress" />
+		<property name="cvf" />
+	</class>
+
+	<class name="MRSTY" table="MRSTY">
+		<composite-id>
+			<key-property name="cui"></key-property>
+			<key-property name="tui"></key-property>
+		</composite-id>
+		<property name="stn" />
+		<property name="sty" />
+		<property name="atui" />
+		<property name="cvf" />
+	</class>
+</hibernate-mapping>

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.hsql.properties.template
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.hsql.properties.template?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.hsql.properties.template
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.hsql.properties.template
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,24 @@
+# schema/database name 
+db.schema=PUBLIC
+# username
+db.username=SA
+# password
+db.password=
+
+db.directory=@ytex.hsql.db@
+# jdbc url for database.  schema name must match db.schema
+db.url=jdbc:hsqldb:file://@ytex.hsql.db@;shutdown=true
+
+# the schema where umls is installed
+# if not specified, will default to schema from ytex
+#umls.schema=umls
+
+
+# you should not have to modify anything below
+db.type=hsql
+db.driver=org.hsqldb.jdbcDriver
+db.initStatements=
+hibernate.dialect=org.hibernate.dialect.HSQLDialect
+
+# transaction isolation level
+db.isolationLevel=READ_UNCOMMITTED

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.mssql.properties
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.mssql.properties?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.mssql.properties
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.mssql.properties
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,27 @@
+# database (catalog) name
+db.name=YTEX_TEST
+
+# schema. default is dbo
+db.schema=ytex
+
+# jdbc url for database.  Replace localhost and YTEX_TEST 
+# with the values of db.host and db.name respectively
+db.url=jdbc:sqlserver://localhost;databaseName=YTEX_TEST;integratedSecurity=false
+
+# assume windows integrated authentication, change if necessary
+db.username=ytex_test
+db.password=ytex
+
+# the schema and catalog (database) where umls is installed
+# if not specified, will default to schema/database from ytex
+#umls.schema=dbo
+#umls.catalog=umls_test
+
+# you should not have to modify anything below
+db.type=mssql
+db.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
+db.initStatements=
+hibernate.dialect=org.hibernate.dialect.SQLServerDialect
+
+# transaction isolation level
+db.isolationLevel=READ_UNCOMMITTED

Added: ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.mysql.properties
URL: http://svn.apache.org/viewvc/ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.mysql.properties?rev=1551254&view=auto
==============================================================================
--- ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.mysql.properties
(added)
+++ ctakes/branches/ytex/ctakes-ytex/src/test/resources/org/apache/ctakes/ytex/ytex.mysql.properties
Mon Dec 16 16:30:30 2013
@@ -0,0 +1,29 @@
+# schema/database name 
+db.schema=ytex_test
+# username
+db.username=ytex
+# password
+db.password=ytex
+
+# jdbc url for database.  schema name must match db.schema
+db.url=jdbc:mysql://localhost:3306/ytex_test?autoReconnect=true
+
+# the schema where umls is installed
+# if not specified, will default to schema from ytex
+#umls.schema=umls
+
+
+# you should not have to modify anything below
+db.type=mysql
+db.driver=com.mysql.jdbc.Driver
+db.initStatements=
+hibernate.dialect=org.hibernate.dialect.MySQLMyISAMDialect
+
+# transaction isolation level
+db.isolationLevel=READ_UNCOMMITTED
+
+# the parameters passed to mysql
+# if you have any additional parameters that must be passed to mysql 
+# (e.g. if you are using a non-standard port)
+# uncomment and modify the line below
+# mysql.line=--user=${db.username} --password=${db.password} --host=${db.host} ${db.schema}




Mime
View raw message