You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/03/31 09:44:15 UTC

svn commit: r929416 - in /myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src: main/java/org/apache/myfaces/scripting/core/dependencyScan/core/ test/java/org/apache/myfaces/scripting/core/ test/java/org/apache/myfaces/scripting/co...

Author: werpu
Date: Wed Mar 31 07:44:15 2010
New Revision: 929416

URL: http://svn.apache.org/viewvc?rev=929416&view=rev
Log:
http://issues.apache.org/jira/browse/EXTSCRIPT-109

Added:
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/dependencyScan/core/
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtilsTest.java   (with props)
Modified:
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtils.java
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandlerTest.java

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtils.java?rev=929416&r1=929415&r2=929416&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtils.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtils.java Wed Mar 31 07:44:15 2010
@@ -78,96 +78,5 @@ public class ClassScanUtils {
                 ((in.startsWith(DOMAIN_APACHE) &&
                         !in.startsWith(DOMAIN_MYFACES)));
     }
-
-    /**
-     * checks for an allowed namespaces from a given namespace list
-     * if the class or package is in the list of allowed namespaces
-     * a true is returned otherwise a false
-     *
-     * @param classOrPackage the class or package name to be checked for allowance
-     * @param nameSpaces     the list of allowed namespaces
-     * @return true if the namespace is within the boundaries of the whitelist false otherwise
-     */
-    @SuppressWarnings("unused")
-    public static final boolean allowedNamespaces(String classOrPackage, String[] nameSpaces) {
-
-        //ok this is probably the fastest way to iterate hence we use this old construct
-        //a direct or would be faster but we cannot do it here since we are not dynamic here
-        int len = nameSpaces.length;
-        for (int cnt = 0; cnt < len; cnt++) {
-            if (classOrPackage.startsWith(nameSpaces[cnt])) {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * renames the internal member class descriptors of L<qualified classnamewith />; to its source name
-     *
-     * @param internalClassName the internal class name
-     * @return the changed classname in its sourceform
-     */
-    public static final String internalClassDescriptorToSource(String internalClassName) {
-        //we strip the meta information which is not needed
-        //aka start with ( strip all to )
-
-        //()means usually beginning of a native type
-        if (internalClassName.startsWith("(")) {
-            internalClassName = internalClassName.substring(internalClassName.lastIndexOf(')') + 1);
-        }
-
-        //()I for single data types
-        if (internalClassName.equals("") || internalClassName.length() == 1) {
-            return null;
-        }
-
-        //fully qualified name with meta information
-        if (internalClassName.endsWith(";")) {
-            //we can skip all the other meta information, a class identifier on sub class level
-            //has to start with L the format is <META ATTRIBUTES>L<CLASS QUALIFIED NAME>;
-            //The meta attributes can be for instance [ for array
-            internalClassName = internalClassName.substring(internalClassName.indexOf('L') + 1, internalClassName.length() - 1);
-        }
-
-        //normal fully qualified name with no meta info attached
-        internalClassName = internalClassName.replaceAll(BINARY_PACKAGE, ".");
-        return internalClassName;
-    }
-
-    /**
-     * logs a dependency if it does not belong to the standard namespaces
-     * and also it only is added if it belongs to our whitelist of
-     * non standard namespaces (the standard check is just a short circuiting
-     * for performance reasons, before going into the heavier whitelist
-     * namespace check)
-     *
-     * @param dependencies the target which has to receive the dependency in source format
-     * @param whiteList    the whitelist of allowed dependencies
-     * @param parameters   the list of dependencies which have to be added
-     */
-    public static final void logParmList(Collection<String> dependencies, final Set<String> whiteList, final String... parameters) {
-        for (String singleParameter : parameters) {
-            if (singleParameter == null || singleParameter.trim().equals("") || isStandardNamespace(singleParameter)) continue;
-       
-            String[] packages = singleParameter.split("\\.");
-
-            StringBuilder fullPackage = null;
-            for (String currPackage : packages) {
-                if (fullPackage != null) {
-                    fullPackage.append(".");
-                    fullPackage.append(currPackage);
-                } else {
-                    fullPackage = new StringBuilder(singleParameter.length());
-                    fullPackage.append(currPackage);
-                }
-
-                String tempPackage = fullPackage.toString();
-                if (whiteList.contains(tempPackage)) {
-                    dependencies.add(singleParameter);
-                    break;
-                }
-            }
-        }
-    }
+   
 }

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandlerTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandlerTest.java?rev=929416&r1=929415&r2=929416&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandlerTest.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/MethodLevelReloadingHandlerTest.java Wed Mar 31 07:44:15 2010
@@ -41,6 +41,7 @@ import static junit.framework.Assert.ass
 public class MethodLevelReloadingHandlerTest {
 
     MethodReloadingProbe _probe;
+    private static final String MSG_REPLACED = "objects must be replaced";
 
     /**
      * This weaver does nothing except instantiating
@@ -49,11 +50,11 @@ public class MethodLevelReloadingHandler
      * we need it to simulate the object level reloading
      * at every method call
      */
-    class ObjectReladingWeaver extends BaseWeaver {
+    class ObjectReloadingWeaver extends BaseWeaver {
 
         Class _clazz;
 
-        public ObjectReladingWeaver(Class clazz) {
+        public ObjectReloadingWeaver(Class clazz) {
             super();
             _clazz = clazz;
         }
@@ -92,7 +93,7 @@ public class MethodLevelReloadingHandler
      */
     @Before
     public void init() {
-        WeavingContext.setWeaver(new ObjectReladingWeaver(Probe.class));
+        WeavingContext.setWeaver(new ObjectReloadingWeaver(Probe.class));
         _probe = new Probe();
     }
 
@@ -101,11 +102,11 @@ public class MethodLevelReloadingHandler
         MethodLevelReloadingHandler handler = new MethodLevelReloadingHandler(_probe, ScriptingConst.ARTIFACT_TYPE_PHASELISTENER);
 
         ReflectUtil.executeMethod(handler, "testMethod1");
-        assertTrue("objects must be replaced", handler.getDelegate() != _probe && handler.getDelegate() != null);
+        assertTrue(MSG_REPLACED, handler.getDelegate() != _probe && handler.getDelegate() != null);
         Object secondObject = handler.getDelegate();
         Boolean retVal = (Boolean) ReflectUtil.executeMethod(handler, "testMethod3", "true");
         assertTrue(retVal); 
-        assertTrue("objects must be replaced", handler.getDelegate() != secondObject && handler.getDelegate() != null);
+        assertTrue(MSG_REPLACED, handler.getDelegate() != secondObject && handler.getDelegate() != null);
 
     }
 }

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtilsTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtilsTest.java?rev=929416&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtilsTest.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtilsTest.java Wed Mar 31 07:44:15 2010
@@ -0,0 +1,51 @@
+/*
+ * 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.myfaces.scripting.core.dependencyScan.core;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class ClassScanUtilsTest {
+    @Test
+    public void testIsStandardNamespace() throws Exception {
+        new ClassScanUtils();//to reduce the dummy line coverage
+        assertTrue(ClassScanUtils.isStandardNamespace("java.lang.String"));
+        assertTrue(ClassScanUtils.isStandardNamespace("javax.faces"));
+        assertTrue(ClassScanUtils.isStandardNamespace("com.sun"));
+        assertTrue(ClassScanUtils.isStandardNamespace("org.jboss"));
+        assertTrue(ClassScanUtils.isStandardNamespace("org.junit"));
+        assertTrue(ClassScanUtils.isStandardNamespace("org.netbeans"));
+        assertTrue(ClassScanUtils.isStandardNamespace("groovy.lang"));
+        assertTrue(ClassScanUtils.isStandardNamespace("scala.lang"));
+        assertTrue(ClassScanUtils.isStandardNamespace("org.springframework"));
+        assertTrue(ClassScanUtils.isStandardNamespace("org.eclipse"));
+        assertFalse(ClassScanUtils.isStandardNamespace("org.myproject"));
+        assertFalse(ClassScanUtils.isStandardNamespace("groovy"));
+    }
+
+    
+}

Propchange: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtilsTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/dependencyScan/core/ClassScanUtilsTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL