You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by re...@apache.org on 2013/01/27 14:23:33 UTC

svn commit: r1439080 - in /uima/sandbox/uimafit/trunk/uimafit/src: main/java/org/apache/uima/fit/descriptor/ main/java/org/apache/uima/fit/factory/ test/java/org/apache/uima/fit/factory/

Author: rec
Date: Sun Jan 27 13:23:33 2013
New Revision: 1439080

URL: http://svn.apache.org/viewvc?rev=1439080&view=rev
Log:
[UIMA-2607] New annotation for component metadata 
- Added new annotation ResourceMetaData
- Added new ResourceMetaDataFactory + test
- Added support for this annotation to AE, CR and FC factories

Added:
    uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java   (with props)
    uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java   (with props)
Modified:
    uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java
    uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java
    uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java
    uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryTest.java
    uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryTest.java

Added: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java?rev=1439080&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java Sun Jan 27 13:23:33 2013
@@ -0,0 +1,69 @@
+/*
+ * 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.fit.descriptor;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * This can be used to add component-level meta data such as version, vendor, etc.
+ * 
+ * @see org.apache.uima.resource.metadata.ResourceMetaData
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface ResourceMetaData {
+  
+  /**
+   * Gets the name of this Resource.
+   * 
+   * @see org.apache.uima.resource.metadata.ResourceMetaData#getName()
+   */
+  String name() default "";
+  
+  /**
+   * Gets the copyright notice for this Resource.
+   * 
+   * @see org.apache.uima.resource.metadata.ResourceMetaData#getCopyright()
+   */
+  String copyright() default "";
+
+  /**
+   * Gets the description of this Resource.
+   * 
+   * @see org.apache.uima.resource.metadata.ResourceMetaData#getDescription()
+   */
+  String description() default "";
+  
+  /**
+   * Gets the vendor of this Resource.
+   * 
+   * @see org.apache.uima.resource.metadata.ResourceMetaData#getVendor()
+   */
+  String vendor() default "";
+  
+  /**
+   * Gets the version number of this Resource.
+   * 
+   * @see org.apache.uima.resource.metadata.ResourceMetaData#getVersion()
+   */
+  String version() default "";
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/descriptor/ResourceMetaData.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java?rev=1439080&r1=1439079&r2=1439080&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/AnalysisEngineFactory.java Sun Jan 27 13:23:33 2013
@@ -293,14 +293,9 @@ public final class AnalysisEngineFactory
       op.setOutputsNewCASes(OUTPUTS_NEW_CASES_DEFAULT);
     }
 
+    // Configure resource meta data
     AnalysisEngineMetaData meta = desc.getAnalysisEngineMetaData();
-    meta.setName(componentClass.getName());
-
-    if (componentClass.getPackage() != null) {
-      meta.setVendor(componentClass.getPackage().getName());
-    }
-    meta.setDescription(Defaults.DEFAULT_DESCRIPTION);
-    meta.setVersion(Defaults.DEFAULT_VERSION);
+    ResourceMetaDataFactory.configureResourceMetaData(meta, componentClass);
 
     ConfigurationData reflectedConfigurationData = createConfigurationData(componentClass);
     ResourceCreationSpecifierFactory.setConfigurationParameters(desc,

Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java?rev=1439080&r1=1439079&r2=1439080&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/CollectionReaderFactory.java Sun Jan 27 13:23:33 2013
@@ -48,6 +48,7 @@ import org.apache.uima.resource.metadata
 import org.apache.uima.resource.metadata.ConfigurationParameter;
 import org.apache.uima.resource.metadata.FsIndexCollection;
 import org.apache.uima.resource.metadata.Import;
+import org.apache.uima.resource.metadata.ResourceMetaData;
 import org.apache.uima.resource.metadata.TypePriorities;
 import org.apache.uima.resource.metadata.TypeSystemDescription;
 
@@ -259,6 +260,10 @@ public final class CollectionReaderFacto
               configurationValues);
     }
 
+    // Configure resource meta data
+    ResourceMetaData meta = desc.getMetaData();
+    ResourceMetaDataFactory.configureResourceMetaData(meta, readerClass);
+    
     // set the type system
     if (typeSystem != null) {
       desc.getCollectionReaderMetaData().setTypeSystem(typeSystem);

Modified: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java?rev=1439080&r1=1439079&r2=1439080&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/FlowControllerFactory.java Sun Jan 27 13:23:33 2013
@@ -100,11 +100,9 @@ public final class FlowControllerFactory
               configurationValues);
     }
 
+    // Configure resource meta data
     ResourceMetaData meta = desc.getMetaData();
-    meta.setName(flowControllerClass.getName());
-    meta.setVendor(flowControllerClass.getPackage().toString());
-    meta.setDescription(Defaults.DEFAULT_DESCRIPTION);
-    meta.setVersion(Defaults.DEFAULT_VERSION);
+    ResourceMetaDataFactory.configureResourceMetaData(meta, flowControllerClass);
 
     // Extract external resource dependencies
     Collection<ExternalResourceDependency> deps = ExternalResourceInitializer

Added: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java?rev=1439080&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java Sun Jan 27 13:23:33 2013
@@ -0,0 +1,74 @@
+/*
+ * 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.fit.factory;
+
+import org.apache.uima.fit.util.ReflectionUtil;
+import org.apache.uima.resource.metadata.ResourceMetaData;
+
+public final class ResourceMetaDataFactory {
+
+  private ResourceMetaDataFactory() {
+    // This class is not meant to be instantiated
+  }
+
+  /**
+   * Adds meta data from a {@link org.apache.uima.fit.descriptor.ResourceMetaData} annotation to the
+   * given meta data object if such an annotation is present on the component class. If no
+   * annotation is present, default values are be added.
+   * 
+   * @param aMetaData
+   *          the meta data object to configure.
+   * @param aComponentClass
+   *          the class that may carry the {@link org.apache.uima.fit.descriptor.ResourceMetaData}
+   *          annotation
+   */
+  public static void configureResourceMetaData(ResourceMetaData aMetaData, Class<?> aComponentClass) {
+    org.apache.uima.fit.descriptor.ResourceMetaData componentAnno = ReflectionUtil
+            .getInheritableAnnotation(org.apache.uima.fit.descriptor.ResourceMetaData.class,
+                    aComponentClass);
+
+    if (componentAnno == null) {
+      // Default handling if no annotation is present.
+      if (aComponentClass.getPackage() != null) {
+        aMetaData.setVendor(aComponentClass.getPackage().getName());
+      }
+      aMetaData.setName(aComponentClass.getName());
+      aMetaData.setDescription(Defaults.DEFAULT_DESCRIPTION);
+      aMetaData.setVersion(Defaults.DEFAULT_VERSION);
+    } else {
+      // If annotation is present, use it
+      // Annotation values cannot be null, but we want to avoid empty strings in the meta data,
+      // thus we set to null when the value is empty.
+      aMetaData.setCopyright(emptyAsNull(componentAnno.copyright()));
+      aMetaData.setDescription(emptyAsNull(componentAnno.description()));
+      aMetaData.setName(emptyAsNull(componentAnno.name()));
+      aMetaData.setVendor(emptyAsNull(componentAnno.vendor()));
+      aMetaData.setVersion(emptyAsNull(componentAnno.version()));
+    }
+  }
+  
+  private static String emptyAsNull(String aString) {
+    if (aString == null || aString.length() == 0) {
+      return null;
+    }
+    else {
+      return aString;
+    }
+  }
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit/src/main/java/org/apache/uima/fit/factory/ResourceMetaDataFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryTest.java?rev=1439080&r1=1439079&r2=1439080&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryTest.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/AnalysisEngineFactoryTest.java Sun Jan 27 13:23:33 2013
@@ -44,6 +44,7 @@ import org.apache.uima.fit.ComponentTest
 import org.apache.uima.fit.component.JCasAnnotator_ImplBase;
 import org.apache.uima.fit.component.NoOpAnnotator;
 import org.apache.uima.fit.descriptor.OperationalProperties;
+import org.apache.uima.fit.descriptor.ResourceMetaData;
 import org.apache.uima.fit.factory.testAes.Annotator1;
 import org.apache.uima.fit.factory.testAes.Annotator2;
 import org.apache.uima.fit.factory.testAes.Annotator3;
@@ -442,6 +443,29 @@ public class AnalysisEngineFactoryTest e
               .getOperationalProperties().isMultipleDeploymentAllowed());
     }
   }
+  
+  @Test
+  public void testResourceMetaData() throws Exception
+  {
+    AnalysisEngineDescription desc = AnalysisEngineFactory
+            .createPrimitiveDescription(AnnotatorWithMetaDataClass.class);
+    
+    org.apache.uima.resource.metadata.ResourceMetaData meta = desc.getMetaData();
+    
+    assertEquals("dummy", meta.getName());
+    assertEquals("1.0", meta.getVersion());
+    assertEquals("Just a dummy", meta.getDescription());
+    assertEquals("ASL 2.0", meta.getCopyright());
+    assertEquals("uimaFIT", meta.getVendor());
+  }
+
+  @ResourceMetaData(name = "dummy", version = "1.0", description = "Just a dummy", copyright = "ASL 2.0", vendor = "uimaFIT")
+  public static class AnnotatorWithMetaDataClass extends JCasAnnotator_ImplBase {
+    @Override
+    public void process(JCas aJCas) throws AnalysisEngineProcessException {
+      // Dummy
+    }
+  }
 
   public static class PristineAnnotatorClass extends JCasAnnotator_ImplBase {
     @Override

Modified: uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryTest.java?rev=1439080&r1=1439079&r2=1439080&view=diff
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryTest.java (original)
+++ uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/CollectionReaderFactoryTest.java Sun Jan 27 13:23:33 2013
@@ -27,8 +27,10 @@ import org.apache.uima.UIMAException;
 import org.apache.uima.cas.CAS;
 import org.apache.uima.collection.CollectionException;
 import org.apache.uima.collection.CollectionReader;
+import org.apache.uima.collection.CollectionReaderDescription;
 import org.apache.uima.collection.CollectionReader_ImplBase;
 import org.apache.uima.fit.ComponentTestBase;
+import org.apache.uima.fit.descriptor.ResourceMetaData;
 import org.apache.uima.fit.factory.testCrs.SingleFileXReader;
 import org.apache.uima.fit.pipeline.JCasIterable;
 import org.apache.uima.fit.type.Token;
@@ -100,6 +102,22 @@ public class CollectionReaderFactoryTest
     assertNotNull(rie);
   }
 
+  @Test
+  public void testResourceMetaData() throws Exception
+  {
+    CollectionReaderDescription desc = CollectionReaderFactory
+            .createDescription(TestCR.class);
+    
+    org.apache.uima.resource.metadata.ResourceMetaData meta = desc.getMetaData();
+    
+    assertEquals("dummy", meta.getName());
+    assertEquals("1.0", meta.getVersion());
+    assertEquals("Just a dummy", meta.getDescription());
+    assertEquals("ASL 2.0", meta.getCopyright());
+    assertEquals("uimaFIT", meta.getVendor());
+  }
+
+  @ResourceMetaData(name = "dummy", version = "1.0", description = "Just a dummy", copyright = "ASL 2.0", vendor = "uimaFIT")
   private class TestCR extends CollectionReader_ImplBase {
 
     private TestCR() {
@@ -107,20 +125,20 @@ public class CollectionReaderFactoryTest
     }
 
     public void getNext(CAS acas) throws IOException, CollectionException {
-      // TODO Auto-generated method stub
+      // Not required for test
     }
 
     public void close() throws IOException {
-      // TODO Auto-generated method stub
+      // Not required for test
     }
 
     public Progress[] getProgress() {
-      // TODO Auto-generated method stub
+      // Not required for test
       return null;
     }
 
     public boolean hasNext() throws IOException, CollectionException {
-      // TODO Auto-generated method stub
+      // Not required for test
       return false;
     }
   }

Added: uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java?rev=1439080&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java Sun Jan 27 13:23:33 2013
@@ -0,0 +1,57 @@
+/*
+ * 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.fit.factory;
+
+import static org.junit.Assert.assertEquals;
+
+import org.apache.uima.analysis_engine.AnalysisEngineProcessException;
+import org.apache.uima.fit.descriptor.ResourceMetaData;
+import org.apache.uima.flow.Flow;
+import org.apache.uima.flow.FlowControllerDescription;
+import org.apache.uima.jcas.JCas;
+import org.junit.Test;
+
+public class FlowControllerFactoryTest {
+
+  @Test
+  public void testResourceMetaData() throws Exception
+  {
+    FlowControllerDescription desc = FlowControllerFactory
+            .createFlowControllerDescription(TestFlowController.class);
+    
+    org.apache.uima.resource.metadata.ResourceMetaData meta = desc.getMetaData();
+    
+    assertEquals("dummy", meta.getName());
+    assertEquals("1.0", meta.getVersion());
+    assertEquals("Just a dummy", meta.getDescription());
+    assertEquals("ASL 2.0", meta.getCopyright());
+    assertEquals("uimaFIT", meta.getVendor());
+  }
+
+  @ResourceMetaData(name = "dummy", version = "1.0", description = "Just a dummy", copyright = "ASL 2.0", vendor = "uimaFIT")
+  public class TestFlowController extends
+  org.apache.uima.fit.component.JCasFlowController_ImplBase {
+
+    @Override
+    public Flow computeFlow(JCas aJCas) throws AnalysisEngineProcessException {
+      // Not require for test
+      return null;
+    }
+  }
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/FlowControllerFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java
URL: http://svn.apache.org/viewvc/uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java?rev=1439080&view=auto
==============================================================================
--- uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java (added)
+++ uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java Sun Jan 27 13:23:33 2013
@@ -0,0 +1,84 @@
+/*
+ * 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.fit.factory;
+
+import static org.junit.Assert.*;
+
+import org.apache.uima.UIMAFramework;
+import org.apache.uima.fit.descriptor.ResourceMetaData;
+import org.junit.Test;
+
+public class ResourceMetaDataFactoryTest {
+
+  @Test
+  public void testWithMetaData() {
+    org.apache.uima.resource.metadata.ResourceMetaData meta = UIMAFramework
+            .getResourceSpecifierFactory().createResourceMetaData();
+    
+    ResourceMetaDataFactory.configureResourceMetaData(meta, DummyComponent1.class);
+    
+    assertEquals("dummy", meta.getName());
+    assertEquals("1.0", meta.getVersion());
+    assertEquals("Just a dummy", meta.getDescription());
+    assertEquals("ASL 2.0", meta.getCopyright());
+    assertEquals("uimaFIT", meta.getVendor());
+  }
+
+  @Test
+  public void testWithPartialMetaData() {
+    org.apache.uima.resource.metadata.ResourceMetaData meta = UIMAFramework
+            .getResourceSpecifierFactory().createResourceMetaData();
+    
+    ResourceMetaDataFactory.configureResourceMetaData(meta, DummyComponent2.class);
+    
+    assertEquals("dummy", meta.getName());
+    assertEquals("1.0", meta.getVersion());
+    assertEquals(null, meta.getDescription());
+    assertEquals(null, meta.getCopyright());
+    assertEquals(null, meta.getVendor());
+  }
+
+  @Test
+  public void testWithNoMetaData() {
+    org.apache.uima.resource.metadata.ResourceMetaData meta = UIMAFramework
+            .getResourceSpecifierFactory().createResourceMetaData();
+    
+    ResourceMetaDataFactory.configureResourceMetaData(meta, DummyComponent3.class);
+    
+    assertEquals(DummyComponent3.class.getName(), meta.getName());
+    assertEquals(Defaults.DEFAULT_VERSION, meta.getVersion());
+    assertEquals(Defaults.DEFAULT_DESCRIPTION, meta.getDescription());
+    assertEquals(null, meta.getCopyright());
+    assertEquals(DummyComponent3.class.getPackage().getName(), meta.getVendor());
+  }
+
+  @ResourceMetaData(name = "dummy", version = "1.0", description = "Just a dummy", copyright = "ASL 2.0", vendor = "uimaFIT")
+  public static class DummyComponent1 {
+    // Really just a dummy.
+  }
+
+  @ResourceMetaData(name = "dummy", version = "1.0")
+  public static class DummyComponent2 {
+    // Really just a dummy.
+  }
+
+  public static class DummyComponent3 {
+    // Really just a dummy.
+  }
+}

Propchange: uima/sandbox/uimafit/trunk/uimafit/src/test/java/org/apache/uima/fit/factory/ResourceMetaDataFactoryTest.java
------------------------------------------------------------------------------
    svn:eol-style = native