[teiid-commits] teiid SVN: r1594 - in trunk/engine/src: main/resources/com/metamatrix/query and 2 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Wed Nov 25 10:51:46 EST 2009


Author: shawkins
Date: 2009-11-25 10:51:46 -0500 (Wed, 25 Nov 2009)
New Revision: 1594

Added:
   trunk/engine/src/test/java/org/teiid/metadata/
   trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java
Modified:
   trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
   trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties
Log:
TEIID-46 refining the fix for proc resolution

Modified: trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java	2009-11-25 15:29:54 UTC (rev 1593)
+++ trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java	2009-11-25 15:51:46 UTC (rev 1594)
@@ -37,6 +37,7 @@
 import com.metamatrix.api.exception.MetaMatrixComponentException;
 import com.metamatrix.api.exception.query.QueryMetadataException;
 import com.metamatrix.metadata.runtime.api.MetadataSource;
+import com.metamatrix.query.QueryPlugin;
 
 /**
  * Aggregates the metadata from multiple stores.  
@@ -113,7 +114,7 @@
 				String fullName = p.getFullName();
 				if (fullName.regionMatches(true, fullName.length() - name.length(), name, 0, name.length())) {
 					if (result != null) {
-						return null; //don't allow ambiguous
+						throw new QueryMetadataException(QueryPlugin.Util.getString("ambiguous_procedure", name.substring(1))); //$NON-NLS-1$
 					}
 					result = p;	
 				}

Modified: trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties	2009-11-25 15:29:54 UTC (rev 1593)
+++ trunk/engine/src/main/resources/com/metamatrix/query/i18n.properties	2009-11-25 15:51:46 UTC (rev 1594)
@@ -193,6 +193,7 @@
 ERR.015.008.0053= Element "{0}" is ambiguous, it exists in two or more groups.
 ERR.015.008.0054= Element "{0}" is not defined by any relevant group.
 ERR.015.008.0055= Group specified is ambiguous, resubmit the query by fully qualifying the group name
+ambiguous_procedure= Procedure ''{0}'' is ambiguous, use the fully qualified name instead
 ERR.015.008.0056= Group does not exist
 ERR.015.008.0057= Variable {0} is not resolvable.
 ERR.015.008.0058= Variable {0} is declared with an invalid datatype {1}

Added: trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java	                        (rev 0)
+++ trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java	2009-11-25 15:51:46 UTC (rev 1594)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.metadata;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.connector.metadata.runtime.Datatype;
+import org.teiid.connector.metadata.runtime.MetadataFactory;
+
+import com.metamatrix.api.exception.query.QueryMetadataException;
+import com.metamatrix.common.types.DataTypeManager;
+import com.metamatrix.metadata.runtime.api.MetadataSource;
+
+public class TestCompositeMetadataStore {
+
+	@Test public void testAmbiguousProc() throws Exception {
+		Map<String, Datatype> datatypes = new HashMap<String, Datatype>();
+        datatypes.put(DataTypeManager.DefaultDataTypes.STRING, new Datatype());
+		MetadataFactory mf = new MetadataFactory("x", datatypes, new Properties()); //$NON-NLS-1$
+		mf.addProcedure("y"); //$NON-NLS-1$
+		MetadataFactory mf1 = new MetadataFactory("x1", datatypes, new Properties()); //$NON-NLS-1$
+		mf1.addProcedure("y"); //$NON-NLS-1$
+		CompositeMetadataStore cms = new CompositeMetadataStore(Arrays.asList(mf.getMetadataStore(), mf1.getMetadataStore()), Mockito.mock(MetadataSource.class));
+		try {
+			cms.getStoredProcedure("y"); //$NON-NLS-1$
+			fail("expected exception"); //$NON-NLS-1$
+		} catch (QueryMetadataException e) {
+			assertEquals("Procedure 'y' is ambiguous, use the fully qualified name instead", e.getMessage()); //$NON-NLS-1$
+		}
+	}
+	
+}


Property changes on: trunk/engine/src/test/java/org/teiid/metadata/TestCompositeMetadataStore.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain



More information about the teiid-commits mailing list