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 2016/07/15 17:47:23 UTC
svn commit: r1752858 - in /uima/uimaj/trunk/jcasgen-maven-plugin/src:
main/java/org/apache/uima/tools/jcasgen/maven/
test/java/org/apache/uima/tools/jcasgen/maven/
test/resources/invalidFeature/ test/resources/invalidFeature/type/
Author: schor
Date: Fri Jul 15 17:47:23 2016
New Revision: 1752858
URL: http://svn.apache.org/viewvc?rev=1752858&view=rev
Log:
[UIMA-4618] fix the jcasgen plugin to handle errors from common jcasgen code where the exception is "null". Add a test case for this.
Added:
uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/
uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/pom.xml
uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/type/
uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/type/TypeSystem.xml
Modified:
uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java
uima/uimaj/trunk/jcasgen-maven-plugin/src/test/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojoTest.java
Modified: uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java?rev=1752858&r1=1752857&r2=1752858&view=diff
==============================================================================
--- uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java (original)
+++ uima/uimaj/trunk/jcasgen-maven-plugin/src/main/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojo.java Fri Jul 15 17:47:23 2016
@@ -249,6 +249,10 @@ public class JCasGenMojo extends Abstrac
public JCasGenErrors() {
}
+ /*
+ * called by the common JCasGen code when it detects an error
+ * If no exception, the "exception" parameter is null
+ */
public void newError(int severity, String message, Exception exception) {
String fullMessage = "JCasGen: " + message;
if (severity == IError.INFO) {
@@ -256,7 +260,11 @@ public class JCasGenMojo extends Abstrac
} else if (severity == IError.WARN) {
getLog().warn(fullMessage, exception);
} else if (severity == IError.ERROR) {
- throw new JCasGenException(exception.getMessage(), exception);
+ String m = fullMessage;
+ if (exception != null) {
+ m = m + "\nException: " + exception.getMessage();
+ }
+ throw new JCasGenException(m, exception);
} else {
throw new UnsupportedOperationException("Unknown severity level: " + severity);
}
Modified: uima/uimaj/trunk/jcasgen-maven-plugin/src/test/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojoTest.java
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/jcasgen-maven-plugin/src/test/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojoTest.java?rev=1752858&r1=1752857&r2=1752858&view=diff
==============================================================================
--- uima/uimaj/trunk/jcasgen-maven-plugin/src/test/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojoTest.java (original)
+++ uima/uimaj/trunk/jcasgen-maven-plugin/src/test/java/org/apache/uima/tools/jcasgen/maven/JCasGenMojoTest.java Fri Jul 15 17:47:23 2016
@@ -35,6 +35,17 @@ import org.codehaus.plexus.util.FileUtil
public class JCasGenMojoTest extends AbstractMojoTestCase {
+ public void testInvalidFeature() throws Exception {
+ Exception ee = null;
+ try {
+ this.test("invalidFeature");
+ } catch (Exception e) {
+ ee = e;
+ }
+ assertTrue(ee != null);
+ assertEquals("JCasGen: The feature name 'type', specified in Type 'type.span.Sentence' is reserved. Please choose another name.", ee.getMessage());
+ }
+
public void testSimple() throws Exception {
this.test("simple", "type.span.Sentence", "type.span.Token", "type.relation.Dependency");
}
Added: uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/pom.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/pom.xml?rev=1752858&view=auto
==============================================================================
--- uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/pom.xml (added)
+++ uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/pom.xml Fri Jul 15 17:47:23 2016
@@ -0,0 +1,45 @@
+<!--
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>test</groupId>
+ <artifactId>simple</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.uima</groupId>
+ <artifactId>jcasgen-maven-plugin</artifactId>
+ <configuration>
+ <typeSystemIncludes>
+ <typeSystemInclude>type/TypeSystem.xml</typeSystemInclude>
+ </typeSystemIncludes>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
Added: uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/type/TypeSystem.xml
URL: http://svn.apache.org/viewvc/uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/type/TypeSystem.xml?rev=1752858&view=auto
==============================================================================
--- uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/type/TypeSystem.xml (added)
+++ uima/uimaj/trunk/jcasgen-maven-plugin/src/test/resources/invalidFeature/type/TypeSystem.xml Fri Jul 15 17:47:23 2016
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<typeSystemDescription xmlns="http://uima.apache.org/resourceSpecifier">
+ <name>TypeSystem</name>
+ <description/>
+ <version>1.0</version>
+ <vendor/>
+ <types>
+ <typeDescription>
+ <name>type.span.Sentence</name>
+ <description/>
+ <supertypeName>uima.tcas.Annotation</supertypeName>
+ <features>
+ <featureDescription>
+ <name>type</name>
+ <description/>
+ <rangeTypeName>uima.cas.Integer</rangeTypeName>
+ </featureDescription>
+ </features>
+ </typeDescription>
+ </types>
+</typeSystemDescription>