You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by sc...@apache.org on 2007/06/07 17:43:00 UTC

svn commit: r545218 - /incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java

Author: schor
Date: Thu Jun  7 08:42:59 2007
New Revision: 545218

URL: http://svn.apache.org/viewvc?view=rev&rev=545218
Log:
No Jira - add a test to verify that all CASes in a cas pool, in all views, JCas or not,
share the type system.

Added:
    incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java

Added: incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java?view=auto&rev=545218
==============================================================================
--- incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java (added)
+++ incubator/uima/uimaj/trunk/uimaj-core/src/test/java/org/apache/uima/cas/impl/CasPoolTest.java Thu Jun  7 08:42:59 2007
@@ -0,0 +1,76 @@
+/*
+ * 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.
+ */
+
+package org.apache.uima.cas.impl;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.analysis_engine.AnalysisEngine;
+import org.apache.uima.analysis_engine.AnalysisEngineDescription;
+import org.apache.uima.analysis_engine.TaeDescription;
+import org.apache.uima.analysis_engine.TextAnalysisEngine;
+import org.apache.uima.cas.CAS;
+import org.apache.uima.cas.Type;
+import org.apache.uima.cas.TypeSystem;
+import org.apache.uima.impl.UimaContext_ImplBase;
+import org.apache.uima.resource.CasManager;
+import org.apache.uima.test.junit_extension.JUnitExtension;
+import org.apache.uima.util.XMLInputSource;
+
+
+public class CasPoolTest extends TestCase {
+
+  
+  // verify that several CASes in a pool in different views share the same type system
+  
+  public void testPool() throws Exception {
+    try {
+      
+      AnalysisEngineDescription aed = (AnalysisEngineDescription)UIMAFramework.getXMLParser().parse(
+              new XMLInputSource(JUnitExtension
+                      .getFile("TextAnalysisEngineImplTest/TestPrimitiveTae1.xml")));
+      
+      AnalysisEngine ae = UIMAFramework.produceAnalysisEngine(aed);
+
+      // define a caspool of size 2
+      CasManager cm = ((UimaContext_ImplBase)ae.getUimaContext()).getResourceManager().getCasManager();
+      cm.defineCasPool("uniqueString", 2, null);
+      
+      CAS c1 = cm.getCas("uniqueString");
+      CAS c2 = cm.getCas("uniqueString");
+      c1.getJCas();
+      
+      CAS c1v2 = c1.createView("view2");
+      CAS c2v2 = c2.createView("view3");
+      c2v2.getJCas();
+      
+      TypeSystem ts = c1.getTypeSystem();
+      
+      Assert.assertTrue(ts == c2.getTypeSystem());
+      Assert.assertTrue(ts == c1v2.getTypeSystem());
+      Assert.assertTrue(ts == c2v2.getTypeSystem());
+
+    } catch (Exception e) {
+      JUnitExtension.handleException(e);
+    }
+  }
+
+}