[teiid-commits] teiid SVN: r1695 - in trunk: common-core/src/test/java/com/metamatrix/core/util and 1 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Mon Dec 21 15:53:50 EST 2009


Author: shawkins
Date: 2009-12-21 15:53:49 -0500 (Mon, 21 Dec 2009)
New Revision: 1695

Removed:
   trunk/common-core/src/main/java/com/metamatrix/core/util/ChecksumUtil.java
   trunk/common-core/src/main/java/com/metamatrix/core/util/ResourceNameUtil.java
   trunk/common-core/src/test/java/com/metamatrix/core/util/TestResourceNameUtil.java
   trunk/common-internal/src/main/resources/com/metamatrix/common/util/crypto/
Modified:
   trunk/common-core/src/main/java/com/metamatrix/core/util/FileUtils.java
Log:
removing unused code

Deleted: trunk/common-core/src/main/java/com/metamatrix/core/util/ChecksumUtil.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/ChecksumUtil.java	2009-12-21 20:52:51 UTC (rev 1694)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/ChecksumUtil.java	2009-12-21 20:53:49 UTC (rev 1695)
@@ -1,97 +0,0 @@
-/*
- * 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 com.metamatrix.core.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.CRC32;
-import java.util.zip.Checksum;
-
-/**
- * This utility class provides mechanisms for computing the checksum.
- */
-public class ChecksumUtil {
-    
-    protected static final int BUFFER_SIZE = 1024;
-
-	/**
-	 * Compute and return the checksum (using the default CRC-32 algorithm) 
-	 * of the contents on the specified stream.
-	 * This method closes the stream upon completion.
-	 * @param stream the stream containing the contents for which
-	 * the checksum is to be computed; may not be null
-	 * @return the Checksum for the contents
-	 * @throws AssertionError if <code>stream</code> is null
-	 * @throws IOException if there is an error reading the stream
-	 */
-	public static Checksum computeChecksum( InputStream stream ) throws IOException {
-		Checksum checksum = new CRC32();
-		computeChecksum(stream,checksum);  
-		return checksum;  
-	}
-
-	/**
-	 * Compute the checksum of the contents on the specified stream
-	 * using the supplied Checksum algorithm, and modify that
-	 * Checksum instance with the checksum value.
-	 * This method closes the stream upon completion.
-	 * @param stream the stream containing the contents for which
-	 * the checksum is to be computed; may not be null
-	 * @param algorithm the checksum algorithm to be used.
-	 * @return the number of bytes from <code>stream</code>
-	 * that were processed
-	 * @throws AssertionError if <code>stream</code> or
-	 * <code>algorithm</code> is null
-	 * @throws IOException if there is an error reading the stream
-	 */
-	public static long computeChecksum( InputStream stream, Checksum algorithm ) throws IOException {
-        byte[] buffer = new byte[BUFFER_SIZE];
-        int n = 0;
-        long sizeInBytes = 0;
-
-		// Compute the checksum ...
-		IOException ioe = null;
-        try {
-	        while ((n = stream.read(buffer)) > -1){
-	            algorithm.update(buffer, 0, n);
-	            sizeInBytes += n;
-	        }
-        } catch ( IOException e ) {
-        	ioe = e;
-        } finally {
-            try {
-        		stream.close(); 
-            } catch ( IOException e ) {
-            	//Throw this only if there was no IOException from processing above    
-                if ( ioe == null ) {
-                	ioe = e;    
-                }
-            }   
-        }
-        if ( ioe != null ) {
-        	throw ioe;    
-        }
-		return sizeInBytes;
-	}
-
-}

Modified: trunk/common-core/src/main/java/com/metamatrix/core/util/FileUtils.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/FileUtils.java	2009-12-21 20:52:51 UTC (rev 1694)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/FileUtils.java	2009-12-21 20:53:49 UTC (rev 1695)
@@ -750,29 +750,6 @@
     }
     
     /**
-     * Compute checksum for the given file. 
-     * @param f The file for which checksum needs to be computed
-     * @return The checksum
-     * @since 4.3
-     */
-    public static long getCheckSum(final File f)  throws Exception {
-        ArgCheck.isNotNull(f);
-        FileInputStream is = null;
-        try {
-            is = new FileInputStream(f);
-            return ChecksumUtil.computeChecksum(is).getValue();
-        } finally {
-            if (is != null) {
-                try {
-                    is.close();
-                } catch (IOException err1) {
-                }
-            }
-        }
-    }    
-
-    
-    /**
      * Test whether it's possible to read and write files in the specified directory. 
      * @param dirPath Name of the directory to test
      * @throws MetaMatrixException

Deleted: trunk/common-core/src/main/java/com/metamatrix/core/util/ResourceNameUtil.java
===================================================================
--- trunk/common-core/src/main/java/com/metamatrix/core/util/ResourceNameUtil.java	2009-12-21 20:52:51 UTC (rev 1694)
+++ trunk/common-core/src/main/java/com/metamatrix/core/util/ResourceNameUtil.java	2009-12-21 20:53:49 UTC (rev 1695)
@@ -1,369 +0,0 @@
-/*
- * 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 com.metamatrix.core.util;
-
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.CorePlugin;
-
-/** 
- * Utility class used for determining if proposed resource names are reserved names or not.
- * This applies for *.vdb, *.xmi and *.xsd resources
- * NOTE: These lists are arranged in alphabetical order. When adding new reserved names, please place them appropriately.
- * @since 4.3
- */
-public abstract class ResourceNameUtil {
-    private static final String INVALID_EXTENSION_ERROR_ID = "ResourceNameUtil.invalidFileExtensionError"; //$NON-NLS-1$
-    private static final String COMMA_SPACE = ", "; //$NON-NLS-1$
-    
-    // STATIC RESERVED NAME CONSTANTS
-    public static final String XMI_FILE_EXTENSION   = "xmi"; //$NON-NLS-1$
-    public static final String VDB_FILE_EXTENSION   = "vdb"; //$NON-NLS-1$
-    public static final String XSD_FILE_EXTENSION   = "xsd"; //$NON-NLS-1$
-    public static final String XML_FILE_EXTENSION   = "xml"; //$NON-NLS-1$
-    public static final String WSDL_FILE_EXTENSION  = "wsdl"; //$NON-NLS-1$
-    
-    public static final String DOT_XMI_FILE_EXTENSION = ".xmi"; //$NON-NLS-1$
-    public static final String DOT_VDB_FILE_EXTENSION   = ".vdb"; //$NON-NLS-1$
-    public static final String DOT_XSD_FILE_EXTENSION   = ".xsd"; //$NON-NLS-1$
-    public static final String DOT_XML_FILE_EXTENSION   = ".xml"; //$NON-NLS-1$
-    public static final String DOT_WSDL_FILE_EXTENSION   = ".wsdl"; //$NON-NLS-1$
-    
-    public static final String ADMIN_NAME                       = "Admin"; //$NON-NLS-1$
-    public static final String BUILTINDATATYPES_NAME            = "builtInDataTypes"; //$NON-NLS-1$
-    public static final String BUILTINRELATIONALTYPES_NAME      = "builtInRelationshipTypes"; //$NON-NLS-1$
-    public static final String CORE_NAME                        = "Core"; //$NON-NLS-1$
-    public static final String DATAACCESS_NAME                  = "Dataaccess"; //$NON-NLS-1$
-    public static final String DATASERVICESYSTEMMODEL_NAME      = "DataServiceSystemModel"; //$NON-NLS-1$
-    public static final String DTCBASE_NAME                     = "DtcBase"; //$NON-NLS-1$
-    public static final String ECORE_NAME                       = "Ecore"; //$NON-NLS-1$
-    public static final String ENTERPRISEDATATYPES_NAME         = "EnterpriseDatatypes"; //$NON-NLS-1$
-    public static final String EXTENSION_NAME                   = "Extension"; //$NON-NLS-1$
-    public static final String FUNCTION_NAME                    = "Function"; //$NON-NLS-1$
-    public static final String HELP_NAME                        = "Help"; //$NON-NLS-1$
-    public static final String JDBC_NAME                        = "Jdbc"; //$NON-NLS-1$
-    public static final String JDBCMODEL_NAME                   = "jdbcModel"; //$NON-NLS-1$
-    public static final String JDBCSYSTEM_NAME                  = "JDBCSystem"; //$NON-NLS-1$
-    public static final String MAGICXMLSCHEMA_NAME              = "MagicXMLSchema"; //$NON-NLS-1$
-    public static final String MANIFEST_NAME                    = "Manifest"; //$NON-NLS-1$
-    public static final String MAPPING_NAME                     = "Mapping"; //$NON-NLS-1$
-    public static final String MBR_NAME                         = "Mbr"; //$NON-NLS-1$
-    public static final String METAMATRIX_VDBMANIFESTMODEL_NAME = "MetaMatrix-VdbManifestModel"; //$NON-NLS-1$
-    public static final String METAMODELRELATIONALMODEL_NAME    = "MetamodelRelationalModel"; //$NON-NLS-1$
-    public static final String NAMESPACE_NAME                   = "namespace"; //$NON-NLS-1$
-    public static final String PRIMATIVETYPES_NAME              = "primitiveTypes"; //$NON-NLS-1$
-    public static final String RELATIONAL_NAME                  = "Relational"; //$NON-NLS-1$
-    public static final String RELATIONSHIP_NAME                = "Relationship"; //$NON-NLS-1$
-    public static final String SIMPLEDATATYPES_INSTANCE_NAME    = "SimpleDatatypes-instance"; //$NON-NLS-1$
-    public static final String SYSTEM_NAME                      = CoreConstants.SYSTEM_MODEL;    
-    public static final String SYSTEMADMIN_NAME                 = CoreConstants.SYSTEM_ADMIN_MODEL_NAME;
-    public static final String SYSTEMADMINPHYSICAL_NAME         = CoreConstants.SYSTEM_ADMIN_PHYSICAL_MODEL_NAME;
-    public static final String SYSTEMPHYSICAL_NAME              = CoreConstants.SYSTEM_PHYSICAL_MODEL_NAME;
-    public static final String SYSTEMSCHEMA_NAME                = "SystemSchema"; //$NON-NLS-1$
-    public static final String SYSTEMVIRTUALDATABASE_NAME       = "SystemVirtualDatabase"; //$NON-NLS-1$
-    public static final String SYSTEMODBCMODEL                  = "System.ODBC"; //$NON-NLS-1$
-    public static final String TRANSFORMATION_NAME              = "Transformation"; //$NON-NLS-1$
-    public static final String UML2_NAME                        = "Uml2"; //$NON-NLS-1$
-    public static final String WEBSERVICE_NAME                  = "Webservice"; //$NON-NLS-1$
-    public static final String WSDL1_1_NAME                     = "WSDL1_1"; //$NON-NLS-1$
-    public static final String WSDLSOAP_NAME                    = "WSDLSOAP"; //$NON-NLS-1$
-    public static final String XML_NAME                         = "Xml"; //$NON-NLS-1$
-    public static final String XMLSCHEMA_NAME                   = "XMLSchema"; //$NON-NLS-1$
-    public static final String XMLSCHEMA_INSTANCE_NAME          = "XMLSchema-instance"; //$NON-NLS-1$
-    public static final String XSD_NAME                         = "Xsd"; //$NON-NLS-1$
-    
-    public static final String[] RESERVED_VDB_NAMES = {
-        ADMIN_NAME,
-        HELP_NAME,
-        SYSTEM_NAME,
-        SYSTEMVIRTUALDATABASE_NAME,
-    };
-
-    public static final String USERFILES_FOLDERNAME             = "user-files"; //$NON-NLS-1$
-    
-    public static final String[] RESERVED_XMI_NAMES = {
-        CORE_NAME,
-        BUILTINRELATIONALTYPES_NAME,
-        DATAACCESS_NAME,
-        DATASERVICESYSTEMMODEL_NAME,
-        DTCBASE_NAME,
-        ECORE_NAME,
-        ENTERPRISEDATATYPES_NAME,
-        EXTENSION_NAME,
-        FUNCTION_NAME,
-        JDBC_NAME,
-        JDBCMODEL_NAME,
-        JDBCSYSTEM_NAME,
-        MANIFEST_NAME,
-        MAPPING_NAME,
-        MBR_NAME,
-        METAMATRIX_VDBMANIFESTMODEL_NAME,
-        METAMODELRELATIONALMODEL_NAME,
-        PRIMATIVETYPES_NAME,
-        RELATIONAL_NAME,
-        RELATIONSHIP_NAME,
-        SIMPLEDATATYPES_INSTANCE_NAME,
-        SYSTEM_NAME,
-        SYSTEMADMIN_NAME,
-        SYSTEMADMINPHYSICAL_NAME,
-        SYSTEMPHYSICAL_NAME,
-        TRANSFORMATION_NAME,
-        UML2_NAME,
-        WEBSERVICE_NAME,
-        WSDL1_1_NAME,
-        WSDLSOAP_NAME,
-        XML_NAME,
-        XSD_NAME,
-    };
-
-
-    public static final String[] RESERVED_XSD_NAMES = {
-        BUILTINDATATYPES_NAME,
-        ENTERPRISEDATATYPES_NAME,
-        MAGICXMLSCHEMA_NAME,
-        NAMESPACE_NAME,
-        SIMPLEDATATYPES_INSTANCE_NAME,
-        SYSTEMSCHEMA_NAME,
-        XML_NAME,
-        XMLSCHEMA_NAME,
-        XMLSCHEMA_INSTANCE_NAME,
-    };
-    
-    
-    public static final String[] RESERVED_PROJECT_NAMES = {
-        USERFILES_FOLDERNAME,
-    };
-    
-    /**
-     * This method checks whether or not a proposed project name is reserved or not.
-     * @param proposedName may or may not inlude the file extension
-     * @return true if it is reserved, false if not.
-     * @since 5.5.3
-     */
-    public static boolean isReservedProjectName(String proposedName) {
-        if( proposedName == null || proposedName.length() <= 0 ){
-            return false;
-        }
-        
-        for( int i=0; i<RESERVED_PROJECT_NAMES.length; i++ ) {
-            if( proposedName.equalsIgnoreCase(RESERVED_PROJECT_NAMES[i])) {
-                return true;
-            }
-        }
-        
-        return false;
-    }
-    
-    /**
-     * This method checks whether or not a proposed vdb name is reserved or not.
-     * It will return false if the proposed name includes an extension AND one or more "." characters.
-     * @param proposedName may or may not inlude the file extension
-     * @return true if it is reserved, false if not.
-     * @throws IllegalArgumentException if proposed name contains an apparent file extension (one or more '.' characters) 
-     * and it is NOT a ".vdb" extension
-     * @since 5.0
-     */
-    public static boolean isReservedVdbName(String proposedName) throws IllegalArgumentException {
-        if( proposedName == null || proposedName.length() <= 0 ){
-            return false;
-        }
-        
-        // Check the extension
-        if ( proposedName.indexOf('.') != -1 ) {
-            // Check ends with
-            if( !proposedName.endsWith(DOT_VDB_FILE_EXTENSION)) {
-                throw new IllegalArgumentException(CorePlugin.Util.getString(INVALID_EXTENSION_ERROR_ID, proposedName, VDB_FILE_EXTENSION));
-            }
-            
-            // So, let's take the extension off
-            proposedName = proposedName.substring(0, proposedName.lastIndexOf(DOT_VDB_FILE_EXTENSION));
-            
-            // If the name still has a "." in it, then it will not be a reserved name
-            // Note 
-            if ( proposedName.indexOf('.') != -1 ) {
-                return false;
-            }
-        }
-
-        for( int i=0; i<RESERVED_VDB_NAMES.length; i++ ) {
-            if( proposedName.equalsIgnoreCase(RESERVED_VDB_NAMES[i])) {
-                return true;
-            }
-        }
-        
-        return false;
-    }
-    
-    /**
-     * This method checks whether or not a proposed xmi model name is reserved or not.
-     * It will return false if the proposed name includes an extension AND one or more "." characters.
-     * @param proposedName may or may not inlude the file extension
-     * @return true if it is reserved, false if not.
-     * @throws IllegalArgumentException if proposed name contains an apparent file extension (one or more '.' characters) 
-     * and it is NOT a ".xmi" extension
-     * @since 5.0
-     */
-    public static boolean isReservedModelName(String proposedName) throws IllegalArgumentException  {
-        if( proposedName == null || proposedName.length() <= 0 ){
-            return false;
-        }
-        
-        // Check the extension
-        if ( proposedName.indexOf('.') != -1 ) {
-            // Check ends with
-            if( !proposedName.endsWith(DOT_XMI_FILE_EXTENSION)) {
-                throw new IllegalArgumentException(CorePlugin.Util.getString(INVALID_EXTENSION_ERROR_ID, proposedName, XMI_FILE_EXTENSION));
-            }
-            
-            // So, let's take the extension off
-            proposedName = proposedName.substring(0, proposedName.lastIndexOf(DOT_XMI_FILE_EXTENSION));
-            
-            // If the name still has a "." in it, then it will not be a reserved name
-            // Note 
-            if ( proposedName.indexOf('.') != -1 ) {
-                return false;
-            }
-        }
-        
-        for( int i=0; i<RESERVED_XMI_NAMES.length; i++ ) {
-            if( proposedName.equalsIgnoreCase(RESERVED_XMI_NAMES[i])) {
-                return true;
-            }
-        }
-        
-        return false;
-    }
-    
-    /**
-     * This method checks whether or not a proposed xsd model name is reserved or not.
-     * It will return false if the proposed name includes an extension AND one or more "." characters.
-     * @param proposedName may or may not inlude the file extension
-     * @return true if it is reserved, false if not.
-     * @throws IllegalArgumentException if proposed name contains an apparent file extension (one or more '.' characters) 
-     * and it is NOT a ".xsd" extension
-     * @since 5.0
-     */
-    public static boolean isReservedSchemaName(String proposedName) throws IllegalArgumentException  {
-        if( proposedName == null || proposedName.length() <= 0 ){
-            return false;
-        }
-        
-        // Check the extension
-        if ( proposedName.indexOf('.') != -1 ) {
-            // Check ends with
-            if( !proposedName.endsWith(DOT_XSD_FILE_EXTENSION)) {
-                throw new IllegalArgumentException(CorePlugin.Util.getString(INVALID_EXTENSION_ERROR_ID, proposedName, XSD_FILE_EXTENSION));
-            }
-            
-            // So, let's take the extension off
-            proposedName = proposedName.substring(0, proposedName.lastIndexOf(DOT_XSD_FILE_EXTENSION));
-            
-            // If the name still has a "." in it, then it will not be a reserved name
-            // Note 
-            if ( proposedName.indexOf('.') != -1 ) {
-                return false;
-            }
-        }
-        
-        for( int i=0; i<RESERVED_XSD_NAMES.length; i++ ) {
-            if( proposedName.equalsIgnoreCase(RESERVED_XSD_NAMES[i])) {
-                return true;
-            }
-        }
-        
-        return false;
-    }
-    
-    /**
-     * This method checks whether or not a proposed name is reserved or not.
-     * It will check all reserved resource names including vdb, xmi and xsd resources.
-     * It will return false if the proposed name includes an extension AND one or more "." characters.
-     * @param proposedName may or may not inlude the file extension
-     * @return true if it is reserved, false if not.
-     * @throws IllegalArgumentException if proposed name contains an apparent file extension (one or more '.' characters) 
-     * and it is NOT a ".xmi, .xsd, or .vdb" extension
-     * @since 5.0
-     */
-    public static boolean isReservedResourceName(String proposedName) throws IllegalArgumentException  {
-        boolean result = false;
-        
-        if( proposedName == null || proposedName.length() <= 0 ){
-            return false;
-        }
-        
-        // Check the extension
-        if ( proposedName.indexOf('.') != -1 ) {
-            // Check ends with
-            if( !proposedName.endsWith(DOT_XSD_FILE_EXTENSION) && 
-                !proposedName.endsWith(DOT_XMI_FILE_EXTENSION) &&
-                !proposedName.endsWith(DOT_VDB_FILE_EXTENSION)) {
-                String allExtensions = XMI_FILE_EXTENSION + COMMA_SPACE + XSD_FILE_EXTENSION + COMMA_SPACE + VDB_FILE_EXTENSION;
-                throw new IllegalArgumentException(CorePlugin.Util.getString(INVALID_EXTENSION_ERROR_ID, proposedName, allExtensions));
-            }
-            
-            
-            // So, let's take the extension off
-            if( proposedName.endsWith(DOT_XSD_FILE_EXTENSION)) {
-                proposedName = proposedName.substring(0, proposedName.lastIndexOf(DOT_XSD_FILE_EXTENSION));
-                if ( proposedName.indexOf('.') != -1 ) {
-                    result = false;
-                } else  {
-                    result = isReservedSchemaName(proposedName);
-                }
-            }
-            
-            if( !result ) {
-                if( proposedName.endsWith(DOT_XMI_FILE_EXTENSION)) {
-                    proposedName = proposedName.substring(0, proposedName.lastIndexOf(DOT_XMI_FILE_EXTENSION));
-                    if ( proposedName.indexOf('.') != -1 ) {
-                        result = false;
-                    } else  {
-                        result = isReservedModelName(proposedName);
-                    }
-                }
-            }
-            
-            if( !result ) {
-                if( proposedName.endsWith(DOT_VDB_FILE_EXTENSION)) {
-                    proposedName = proposedName.substring(0, proposedName.lastIndexOf(DOT_VDB_FILE_EXTENSION));
-                    if ( proposedName.indexOf('.') != -1 ) {
-                        result = false;
-                    } else  {
-                        result = isReservedVdbName(proposedName);
-                    }
-                }
-            }
-        } else {
-            result = isReservedSchemaName(proposedName);
-            
-            if( !result ) {
-                result = isReservedModelName(proposedName);
-            }
-            
-            if( !result ) {
-                result = isReservedVdbName(proposedName);
-            }
-        }
-        
-        return result;
-    }
-}

Deleted: trunk/common-core/src/test/java/com/metamatrix/core/util/TestResourceNameUtil.java
===================================================================
--- trunk/common-core/src/test/java/com/metamatrix/core/util/TestResourceNameUtil.java	2009-12-21 20:52:51 UTC (rev 1694)
+++ trunk/common-core/src/test/java/com/metamatrix/core/util/TestResourceNameUtil.java	2009-12-21 20:53:49 UTC (rev 1695)
@@ -1,263 +0,0 @@
-/*
- * 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 com.metamatrix.core.util;
-
-import junit.framework.TestCase;
-
-
-/** 
- * @since 4.3
- */
-public class TestResourceNameUtil extends TestCase {
-    
-    private static final String NON_RESERVED_VDB_NAME               = "SomeVdb";                //$NON-NLS-1$
-    private static final String NON_RESERVED_VDB_NAME_WITH_EXT      = "SomeVdb.vdb";            //$NON-NLS-1$
-    private static final String RESERVED_VDB_NAME                   = "System";                 //$NON-NLS-1$
-    private static final String RESERVED_VDB_NAME_WITH_EXT          = "System.vdb";             //$NON-NLS-1$
-    private static final String ILLEGAL_VDB_EXTENSION_NAME          = "SomeVdb.someExtension";  //$NON-NLS-1$
-    private static final String RESERVED_VDB_NAME_WITH_EXT_WITH_DOTS = "System.a.b.vdb";  //$NON-NLS-1$
-    
-    private static final String NON_RESERVED_XMI_NAME               = "SomeModel";                  //$NON-NLS-1$
-    private static final String NON_RESERVED_XMI_NAME_WITH_EXT      = "SomeModel.xmi";              //$NON-NLS-1$
-    private static final String RESERVED_XMI_NAME                   = "System";                     //$NON-NLS-1$
-    private static final String RESERVED_XMI_NAME_WITH_EXT          = "System.xmi";                 //$NON-NLS-1$
-    private static final String ILLEGAL_XMI_EXTENSION_NAME          = "SomeModel.someExtension";    //$NON-NLS-1$
-    private static final String RESERVED_XMI_NAME_WITH_EXT_WITH_DOTS = "System.a.b.xmi";  //$NON-NLS-1$
- 
-    private static final String NON_RESERVED_XSD_NAME               = "SomeSchema";                  //$NON-NLS-1$
-    private static final String NON_RESERVED_XSD_NAME_WITH_EXT      = "SomeSchema.xsd";              //$NON-NLS-1$
-    private static final String RESERVED_XSD_NAME                   = "SystemSchema";                //$NON-NLS-1$
-    private static final String RESERVED_XSD_NAME_WITH_EXT          = "SystemSchema.xsd";            //$NON-NLS-1$
-    private static final String ILLEGAL_XSD_EXTENSION_NAME          = "SomeSchema.someExtension";    //$NON-NLS-1$
-    private static final String RESERVED_XSD_NAME_WITH_EXT_WITH_DOTS = "SystemSchema.a.b.xsd";  //$NON-NLS-1$
-    
-    private static final String MSG_EXPECTED = "Expected: "; //$NON-NLS-1$
-    private static final String MSG_VDB_NAME = "VDB Name ["; //$NON-NLS-1$
-    private static final String MSG_XSD_NAME = "XSD Name ["; //$NON-NLS-1$
-    private static final String MSG_XMI_NAME = "Xmi Model Name ["; //$NON-NLS-1$
-    private static final String MSG_RESOURCE_NAME = "XSD Name ["; //$NON-NLS-1$
-    private static final String MSG_IS_NOT_RESERVED = "] is NOT RESERVED"; //$NON-NLS-1$
-    private static final String MSG_IS_RESERVED = "] IS RESERVED"; //$NON-NLS-1$
-    private static final String MSG_THROW_ILLEGAL_ARG_EXC = "] to throw IllegalArgumentException"; //$NON-NLS-1$
-    
-    /** 
-     * 
-     * @since 4.3
-     */
-    public TestResourceNameUtil() {
-        super();
-    }
-
-    /** 
-     * @param theName
-     * @since 4.3
-     */
-    public TestResourceNameUtil(String theName) {
-        super(theName);
-    }
-      
-    // ------------------------------------------------
-    // Test for VDB names
-    // ------------------------------------------------
-    public void testNonReservedVdbNameWithoutExtension() {
-        assertFalse(MSG_EXPECTED + MSG_VDB_NAME + 
-                                                      NON_RESERVED_VDB_NAME + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedVdbName(NON_RESERVED_VDB_NAME));
-    }
-    
-    public void testNonReservedVdbNameWithExtension() {
-        assertFalse(MSG_EXPECTED + MSG_VDB_NAME + 
-                                                      NON_RESERVED_VDB_NAME_WITH_EXT + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedVdbName(NON_RESERVED_VDB_NAME_WITH_EXT));
-    }
-    
-    public void testReservedVdbNameWithoutExtension() {
-        assertTrue(MSG_EXPECTED + MSG_VDB_NAME + 
-                                                      RESERVED_VDB_NAME + 
-                   MSG_IS_RESERVED,
-                   ResourceNameUtil.isReservedVdbName(RESERVED_VDB_NAME));
-    }
-    
-    public void testReservedVdbNameWithExtension() {
-        assertTrue(MSG_EXPECTED + MSG_VDB_NAME + 
-                                                      RESERVED_VDB_NAME_WITH_EXT + 
-                   MSG_IS_RESERVED,
-                   ResourceNameUtil.isReservedVdbName(RESERVED_VDB_NAME_WITH_EXT));
-    }
-    
-    public void testFailIllegalVdbName() {
-        try {
-            ResourceNameUtil.isReservedVdbName(ILLEGAL_VDB_EXTENSION_NAME);
-            fail(MSG_EXPECTED + MSG_VDB_NAME + ILLEGAL_VDB_EXTENSION_NAME + MSG_THROW_ILLEGAL_ARG_EXC);
-        } catch (IllegalArgumentException e) {
-        }
-    }
-    
-    public void testReservedVdbNameWithExtensionAndDots() {
-        assertFalse(MSG_EXPECTED + MSG_VDB_NAME + 
-                                                      RESERVED_VDB_NAME_WITH_EXT_WITH_DOTS + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedVdbName(RESERVED_VDB_NAME_WITH_EXT_WITH_DOTS));
-    }
-    
-    // ------------------------------------------------
-    // Test for XMI model names
-    // ------------------------------------------------
-    public void testNonReservedXmiNameWithoutExtension() {
-        assertFalse(MSG_EXPECTED + MSG_XMI_NAME + 
-                                                      NON_RESERVED_XMI_NAME + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedModelName(NON_RESERVED_XMI_NAME));
-    }
-    
-    public void testNonReservedXmiNameWithExtension() {
-        assertFalse(MSG_EXPECTED + MSG_XMI_NAME + 
-                                                      NON_RESERVED_XMI_NAME_WITH_EXT + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedModelName(NON_RESERVED_XMI_NAME_WITH_EXT));
-    }
-    
-    public void testReservedXmiNameWithoutExtension() {
-        assertTrue(MSG_EXPECTED + MSG_XMI_NAME + 
-                                                      RESERVED_XMI_NAME + 
-                   MSG_IS_RESERVED,
-                   ResourceNameUtil.isReservedModelName(RESERVED_XMI_NAME));
-    }
-    
-    public void testReservedXmiNameWithExtension() {
-        assertTrue(MSG_EXPECTED + MSG_XMI_NAME + 
-                                                      RESERVED_XMI_NAME_WITH_EXT + 
-                   MSG_IS_RESERVED,
-                   ResourceNameUtil.isReservedModelName(RESERVED_XMI_NAME_WITH_EXT));
-    }
-    
-    public void testFailIllegalXmiName() {
-        try {
-            ResourceNameUtil.isReservedModelName(ILLEGAL_XMI_EXTENSION_NAME);
-            fail(MSG_EXPECTED + MSG_XSD_NAME + ILLEGAL_XMI_EXTENSION_NAME + MSG_THROW_ILLEGAL_ARG_EXC);
-        } catch (IllegalArgumentException e) {
-        }
-    }
-    
-    public void testReservedXmiNameWithExtensionAndDots() {
-        assertFalse(MSG_EXPECTED + MSG_VDB_NAME + 
-                                                      RESERVED_XMI_NAME_WITH_EXT_WITH_DOTS + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedModelName(RESERVED_XMI_NAME_WITH_EXT_WITH_DOTS));
-    }
-    
-    // ------------------------------------------------
-    // Test for XSD model names
-    // ------------------------------------------------
-    public void testNonReservedXsdNameWithoutExtension() {
-        assertFalse(MSG_EXPECTED + MSG_XSD_NAME + 
-                                                      NON_RESERVED_XSD_NAME + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedSchemaName(NON_RESERVED_XSD_NAME));
-    }
-    
-    public void testNonReservedXsdNameWithExtension() {
-        assertFalse(MSG_EXPECTED + MSG_XSD_NAME + 
-                                                      NON_RESERVED_XSD_NAME_WITH_EXT + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedSchemaName(NON_RESERVED_XSD_NAME_WITH_EXT));
-    }
-    
-    public void testReservedXsdNameWithoutExtension() {
-        assertTrue(MSG_EXPECTED + MSG_XSD_NAME + 
-                                                      RESERVED_XSD_NAME + 
-                   MSG_IS_RESERVED,
-                   ResourceNameUtil.isReservedSchemaName(RESERVED_XSD_NAME));
-    }
-    
-    public void testReservedXsdNameWithExtension() {
-        assertTrue(MSG_EXPECTED + MSG_XSD_NAME + 
-                                                      RESERVED_XSD_NAME_WITH_EXT + 
-                   MSG_IS_RESERVED,
-                   ResourceNameUtil.isReservedSchemaName(RESERVED_XSD_NAME_WITH_EXT));
-    }
-    
-    public void testFailIllegalXsdName() {
-        try {
-            ResourceNameUtil.isReservedSchemaName(ILLEGAL_XSD_EXTENSION_NAME);
-            fail(MSG_EXPECTED + MSG_XSD_NAME + ILLEGAL_XSD_EXTENSION_NAME + MSG_THROW_ILLEGAL_ARG_EXC);
-        } catch (IllegalArgumentException e) {
-        }
-    }
-    
-    public void testReservedXsdNameWithExtensionAndDots() {
-        assertFalse(MSG_EXPECTED + MSG_VDB_NAME + 
-                                                      RESERVED_XSD_NAME_WITH_EXT_WITH_DOTS + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedSchemaName(RESERVED_XSD_NAME_WITH_EXT_WITH_DOTS));
-    }
-    
-    
-    // ------------------------------------------------
-    // Test for RESOURCE names
-    // ------------------------------------------------
-    public void testNonReservedResourceNameWithoutExtension() {
-        assertFalse(MSG_EXPECTED + MSG_RESOURCE_NAME + 
-                    NON_RESERVED_VDB_NAME + 
-                    MSG_IS_NOT_RESERVED,
-                    ResourceNameUtil.isReservedResourceName(NON_RESERVED_VDB_NAME));
-    }
-    
-    public void testNonReservedResourceNameWithExtension() {
-        assertFalse(MSG_EXPECTED + MSG_RESOURCE_NAME + 
-                    NON_RESERVED_VDB_NAME_WITH_EXT + 
-                    MSG_IS_NOT_RESERVED,
-                    ResourceNameUtil.isReservedResourceName(NON_RESERVED_VDB_NAME_WITH_EXT));
-    }
-    
-    public void testReservedResourceNameWithoutExtension() {
-        assertTrue(MSG_EXPECTED + MSG_RESOURCE_NAME + 
-                    RESERVED_XSD_NAME + 
-                    MSG_IS_RESERVED,
-                    ResourceNameUtil.isReservedResourceName(RESERVED_XSD_NAME));
-    }
-    
-    public void testReservedResourceNameWithExtension() {
-        assertTrue(MSG_EXPECTED + MSG_RESOURCE_NAME + 
-                    RESERVED_VDB_NAME_WITH_EXT + 
-                    MSG_IS_RESERVED,
-                    ResourceNameUtil.isReservedResourceName(RESERVED_VDB_NAME_WITH_EXT));
-    }
-    
-    public void testFailIllegalResourceName() {
-        try {
-            ResourceNameUtil.isReservedResourceName(ILLEGAL_VDB_EXTENSION_NAME);
-            fail(MSG_EXPECTED + MSG_RESOURCE_NAME + ILLEGAL_VDB_EXTENSION_NAME + MSG_THROW_ILLEGAL_ARG_EXC);
-        } catch (IllegalArgumentException e) {
-        }
-    }
-    
-    public void testReservedResourceNameWithExtensionAndDots() {
-        assertFalse(MSG_EXPECTED + MSG_VDB_NAME + 
-                                                      RESERVED_XSD_NAME_WITH_EXT_WITH_DOTS + 
-                   MSG_IS_NOT_RESERVED,
-                   ResourceNameUtil.isReservedResourceName(RESERVED_XSD_NAME_WITH_EXT_WITH_DOTS));
-    }
-}



More information about the teiid-commits mailing list