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/30 08:38:14 UTC

svn commit: r929012 - in /myfaces/extensions/scripting/trunk: ./ extscript-core-root/ extscript-core-root/extscript-core/ extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/compilerTest/ extscript-core-root/extscript-cor...

Author: werpu
Date: Tue Mar 30 06:38:14 2010
New Revision: 929012

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

Added:
    myfaces/extensions/scripting/trunk/extscript-core-root/.DS_Store
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/.DS_Store
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/PathUtils.java   (with props)
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/utilsTests/
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/utilsTests/FileUtilsTest.java   (with props)
Modified:
    myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/compilerTest/TestCompilerAPI.java
    myfaces/extensions/scripting/trunk/pom.xml

Added: myfaces/extensions/scripting/trunk/extscript-core-root/.DS_Store
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/.DS_Store?rev=929012&view=auto
==============================================================================
Files myfaces/extensions/scripting/trunk/extscript-core-root/.DS_Store (added) and myfaces/extensions/scripting/trunk/extscript-core-root/.DS_Store Tue Mar 30 06:38:14 2010 differ

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/.DS_Store
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/.DS_Store?rev=929012&view=auto
==============================================================================
Files myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/.DS_Store (added) and myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/.DS_Store Tue Mar 30 06:38:14 2010 differ

Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/compilerTest/TestCompilerAPI.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/compilerTest/TestCompilerAPI.java?rev=929012&r1=929011&r2=929012&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/compilerTest/TestCompilerAPI.java (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/compilerTest/TestCompilerAPI.java Tue Mar 30 06:38:14 2010
@@ -23,6 +23,7 @@ import org.apache.commons.io.FilenameUti
 import org.apache.myfaces.scripting.api.Configuration;
 import org.apache.myfaces.scripting.api.DynamicCompiler;
 import org.apache.myfaces.scripting.api.ScriptingConst;
+import org.apache.myfaces.scripting.core.support.PathUtils;
 import org.apache.myfaces.scripting.core.util.WeavingContext;
 import org.apache.myfaces.scripting.loaders.java.compiler.CompilerFacade;
 import org.junit.Test;
@@ -42,23 +43,19 @@ public class TestCompilerAPI {
 
     private static final String JAVA_FILE_ENDING = ".java";
 
-    private static final String PROBE1 = "../../src/test/resources/compiler/TestProbe1.java";
-    private static final String PROBE2 = "../../src/test/resources/compiler/TestProbe2.java";
-    private static final String RESOURCES = "../../src/test/resources/";
+    private static final PathUtils _pathUtils = new PathUtils();
+    private static final String PROBE1 = _pathUtils.getResource("compiler/TestProbe1.java");
+    private static final String PROBE2 = _pathUtils.getResource("compiler/TestProbe2.java");
+    private static final String RESOURCES = _pathUtils.getResource(".");
 
     File probe1;
     File probe2;
     File root;
 
     public TestCompilerAPI() {
-        ClassLoader loader = Thread.currentThread().getContextClassLoader();
-        //we use a location relative to our current root one to reach the sources
-        //because the test also has to be performed outside of maven
-        //and the ide cannot cope with resource paths for now
-        String currentPath = loader.getResource("./").getPath();
-        String sourcePath1 = currentPath + PROBE1;
-        String sourcePath2 = currentPath + PROBE2;
-        String rootPath = currentPath + RESOURCES;
+        String sourcePath1 =  PROBE1;
+        String sourcePath2 = PROBE2;
+        String rootPath =  RESOURCES;
 
         sourcePath1 = FilenameUtils.normalize(sourcePath1);
         sourcePath2 = FilenameUtils.normalize(sourcePath2);

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/PathUtils.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/PathUtils.java?rev=929012&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/PathUtils.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/support/PathUtils.java Tue Mar 30 06:38:14 2010
@@ -0,0 +1,62 @@
+/*
+ * 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.support;
+
+import java.io.File;
+
+/**
+ * Supportive utils to access the source
+ * probes directly
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class PathUtils {
+
+    String _currentPath;
+    String _resourceRoot;
+
+    public PathUtils() {
+        ClassLoader loader = Thread.currentThread().getContextClassLoader();
+        //we use a location relative to our current root one to reach the sources
+        //because the test also has to be performed outside of maven
+        //and the ide cannot cope with resource paths for now
+        _currentPath = loader.getResource("./").getPath();
+        _resourceRoot = _currentPath + "../../src/test/resources";
+    }
+
+    /**
+     * Resource root dir getter
+     *
+     * @return the resource root dir (from our source package)
+     */
+    public String getResourceRoot() {
+        return _resourceRoot;
+    }
+
+    public String getResource(String in) {
+        if(in.startsWith("//") || in.startsWith("\\")) {
+            in = in.substring(1);
+        }
+        return _resourceRoot + File.separator + in;
+    }
+
+}

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

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

Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/utilsTests/FileUtilsTest.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/utilsTests/FileUtilsTest.java?rev=929012&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/utilsTests/FileUtilsTest.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-core/src/test/java/org/apache/myfaces/scripting/core/utilsTests/FileUtilsTest.java Tue Mar 30 06:38:14 2010
@@ -0,0 +1,71 @@
+/*
+ * 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.utilsTests;
+
+import org.apache.myfaces.scripting.core.util.FileUtils;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.File;
+
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Test cases for our FileUtils
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class FileUtilsTest {
+
+    String _currentPath = "";
+
+    @Before
+    public void init() {
+
+    }
+
+    @Test
+    public void testForRegexp() {
+        String fileSep = FileUtils.getFileSeparatorForRegex();
+        assertTrue("must be double backslash instead of single one", (File.separator.equals("\\")) ? fileSep.equals("\\\\") : fileSep.equals(File.separator));
+    }
+
+    @Test
+    public void testGetFileSeparator() {
+        String fileSeparator = FileUtils.getFileSeparator();
+        assertTrue(fileSeparator.equals(File.separator));
+    }
+
+    @Test
+    public void testGetTempDir() {
+        File tempDir = FileUtils.getTempDir();
+        assertTrue(tempDir != null);
+        assertTrue(tempDir.exists());
+    }
+
+    //@Test
+
+    public void testFileStrategy() {
+
+    }
+
+}

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

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

Modified: myfaces/extensions/scripting/trunk/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/pom.xml?rev=929012&r1=929011&r2=929012&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/pom.xml (original)
+++ myfaces/extensions/scripting/trunk/pom.xml Tue Mar 30 06:38:14 2010
@@ -155,19 +155,9 @@
                     <target>1.5</target>
                 </configuration>
             </plugin>
-
-
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>cobertura-maven-plugin</artifactId>
-                <configuration>
-                    <instrumentation>
-                      
-                        <excludes>
-                            <exclude>**/*Test.class</exclude>
-                        </excludes>
-                    </instrumentation>
-                </configuration>
                 <executions>
                     <execution>
                         <goals>
@@ -177,7 +167,6 @@
                 </executions>
             </plugin>
 
-
         </plugins>
 
 
@@ -253,6 +242,13 @@
             <plugin>
                 <groupId>org.codehaus.mojo</groupId>
                 <artifactId>cobertura-maven-plugin</artifactId>
+                <configuration>
+                    <formats>
+                        <format>html</format>
+                        <format>xml</format>
+                    </formats>
+                    
+                </configuration>
             </plugin>
 
         </plugins>