incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r1557911 - in /sling/trunk/bundles/scripting/javascript/src: main/java/org/apache/sling/scripting/javascript/wrapper/ test/java/org/apache/sling/scripting/wrapper/
Date Tue, 14 Jan 2014 02:41:13 GMT
Author: fmeschbe
Date: Tue Jan 14 02:41:13 2014
New Revision: 1557911

URL: http://svn.apache.org/r1557911
Log:
SLING-3314 Remove test method "jsGet_javascriptWrapperClass" and respective tests

Modified:
    sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableBase.java
    sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java
    sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
    sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java
    sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersion.java
    sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersionHistory.java
    sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
    sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableVersionTest.java

Modified: sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableBase.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableBase.java?rev=1557911&r1=1557910&r2=1557911&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableBase.java
(original)
+++ sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableBase.java
Tue Jan 14 02:41:13 2014
@@ -28,23 +28,23 @@ import org.mozilla.javascript.Scriptable
  *  default wrapping of methods and properties (SLING-397)
  */
 public abstract class ScriptableBase extends ScriptableObject {
-    
+
     private NativeJavaObject njo;
     private final Set<String> jsMethods = getJsMethodNames();
-    
+
     public static final String JSFUNC_PREFIX = "jsFunction_";
-    
+
     protected Object getNative(String name, Scriptable start) {
         final Object wrapped = getWrappedObject();
-        
+
         if(wrapped == null) {
             return Scriptable.NOT_FOUND;
         }
-        
+
         if(jsMethods.contains(name)) {
             return Scriptable.NOT_FOUND;
         }
-        
+
         if(njo == null) {
             synchronized (this) {
                 if(njo == null) {
@@ -52,35 +52,29 @@ public abstract class ScriptableBase ext
                 }
             }
         }
-        
+
         return njo.get(name, start);
     }
-    
+
     /** @return the Java object that we're wrapping, used to create a NativeJavaObject
      *  instance for default wrapping.
      */
     protected abstract Object getWrappedObject();
-    
+
     /** @return the static type to use for NativeJavaObject wrapping */
     protected abstract Class<?> getStaticType();
-    
-    /** Used in testing, to check that the right wrapper is used. 
-     *  For some reason, defining the method here didn't work, it had to be
-     *  defined in all descendant classes.      
-     */
-    public abstract Class<?> jsGet_javascriptWrapperClass();
-    
+
     /** @return the Set of method names that clazz defines, i.e. all public methods
      *  with names that start with jsFunction_ */
     private Set<String> getJsMethodNames() {
         final Set<String> result = new HashSet<String>();
-        
+
         for(Method m : getClass().getMethods()) {
             if(m.getName().startsWith(JSFUNC_PREFIX)) {
                 result.add(m.getName().substring(JSFUNC_PREFIX.length()));
             }
         }
-        
+
         return result;
     }
 }

Modified: sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java?rev=1557911&r1=1557910&r2=1557911&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java
(original)
+++ sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableCalendar.java
Tue Jan 14 02:41:13 2014
@@ -80,11 +80,6 @@ public class ScriptableCalendar extends 
 	}
 
 	@Override
-	public Class<?> jsGet_javascriptWrapperClass() {
-		return getClass();
-	}
-
-	@Override
 	public String getClassName() {
 		return CLASSNAME;
 	}

Modified: sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java?rev=1557911&r1=1557910&r2=1557911&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
(original)
+++ sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableNode.java
Tue Jan 14 02:41:13 2014
@@ -414,10 +414,6 @@ public class ScriptableNode extends Scri
         return false;
     }
 
-    public Class<?> jsGet_javascriptWrapperClass() {
-        return getClass();
-    }
-
     @Override
     public String toString() {
         if (node != null) {

Modified: sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java?rev=1557911&r1=1557910&r2=1557911&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java
(original)
+++ sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableProperty.java
Tue Jan 14 02:41:13 2014
@@ -210,10 +210,6 @@ public class ScriptableProperty extends 
         return property.isModified();
     }
 
-    public Class<?> jsGet_javascriptWrapperClass() {
-        return getClass();
-    }
-
     public Object jsFunction_valueOf(String hint) {
         if ("undefined".equals(hint)) {
 

Modified: sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersion.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersion.java?rev=1557911&r1=1557910&r2=1557911&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersion.java
(original)
+++ sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersion.java
Tue Jan 14 02:41:13 2014
@@ -24,9 +24,9 @@ public class ScriptableVersion extends S
 
     public static final String CLASSNAME = "Version";
     public static final Class<?> [] WRAPPED_CLASSES = { Version.class };
-    
+
     private Version version;
-    
+
     @Override
     public void jsConstructor(Object res) {
         super.jsConstructor(res);
@@ -52,8 +52,4 @@ public class ScriptableVersion extends S
     protected Object getWrappedObject() {
         return version;
     }
-    
-    public Class<?> jsGet_javascriptWrapperClass() {
-        return getClass();
-    }
 }
\ No newline at end of file

Modified: sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersionHistory.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersionHistory.java?rev=1557911&r1=1557910&r2=1557911&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersionHistory.java
(original)
+++ sling/trunk/bundles/scripting/javascript/src/main/java/org/apache/sling/scripting/javascript/wrapper/ScriptableVersionHistory.java
Tue Jan 14 02:41:13 2014
@@ -24,9 +24,9 @@ public class ScriptableVersionHistory ex
 
     public static final String CLASSNAME = "VersionHistory";
     public static final Class<?> [] WRAPPED_CLASSES = { VersionHistory.class };
-    
+
     private VersionHistory versionHistory;
-    
+
     @Override
     public void jsConstructor(Object res) {
         super.jsConstructor(res);
@@ -52,8 +52,4 @@ public class ScriptableVersionHistory ex
     protected Object getWrappedObject() {
         return versionHistory;
     }
-    
-    public Class<?> jsGet_javascriptWrapperClass() {
-        return getClass();
-    }
 }
\ No newline at end of file

Modified: sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java?rev=1557911&r1=1557910&r2=1557911&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
(original)
+++ sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableNodeTest.java
Tue Jan 14 02:41:13 2014
@@ -43,22 +43,22 @@ public class ScriptableNodeTest extends 
     private Property calProperty;
     private Calendar testCal;
     private ScriptEngineHelper.Data data;
-    
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
-        
+
         node = getNewNode();
         testText = "Test-" + System.currentTimeMillis();
         node.setProperty("text", testText);
         node.setProperty("otherProperty", node.getPath());
-        
+
         testNum = System.currentTimeMillis();
         node.setProperty("num", testNum);
-        
+
         testCal = Calendar.getInstance();
         node.setProperty("cal", testCal);
-        
+
         data = new ScriptEngineHelper.Data();
         data.put("node", node);
         textProperty = node.getProperty("text");
@@ -102,56 +102,49 @@ public class ScriptableNodeTest extends 
             script.evalToString("out.print(property.value.string)", data)
         );
     }
-    
+
     public void testViaPropertyWithWrappers() throws Exception {
         assertEquals(
             textProperty.getString(),
             script.evalToString("out.print(property)", data)
         );
     }
-    
+
     public void testViaNodeDirectPropertyAccess() throws Exception {
         assertEquals(
             testText,
             script.evalToString("out.print(node.text)", data)
         );
     }
-    
+
     public void testViaPropertyNoWrappersNum() throws Exception {
         assertEquals(
             testNum,
             script.eval("numProperty.value.getDouble()", data)
         );
     }
-    
+
     public void testViaPropertyWithWrappersNum() throws Exception {
         assertEquals(
             testNum,
             script.eval("0+numProperty", data)
         );
     }
-    
+
     public void testViaNodeDirectPropertyAccessNum() throws Exception {
         assertEquals(
             testNum,
             script.eval("node.num", data)
         );
     }
-    
+
     public void testViaPropertyNoWrappersCal() throws Exception {
         assertEquals(
                 testCal,
                 script.eval("calProperty.value.getDate()", data)
         );
     }
-    
-    public void testDateWrapperClass() throws Exception {
-        assertEquals(
-                "org.apache.sling.scripting.javascript.wrapper.ScriptableCalendar", 
-                script.eval("node.cal.javascriptWrapperClass.getName()", data)
-        );
-    }
-    
+
     public void testViaNodeDirectPropertyAccessCal() throws Exception {
     	final SimpleDateFormat f = new SimpleDateFormat(JsonItemWriter.ECMA_DATE_FORMAT, JsonItemWriter.DATE_FORMAT_LOCALE);
     	final String expected = f.format(testCal.getTime());
@@ -160,14 +153,14 @@ public class ScriptableNodeTest extends 
                 script.evalToString("out.print(node.cal)", data)
         );
     }
-    
+
     public void testCalDateClass() throws Exception {
         assertEquals(
                 "number",
                 script.evalToString("out.print(typeof node.cal.date.time)", data)
         );
     }
-    
+
     public void testPropertyParent() throws Exception {
         // need to use node.getProperty('num') to have a ScriptableProperty,
         // node.num only returns a wrapped value
@@ -176,26 +169,19 @@ public class ScriptableNodeTest extends 
                 script.eval("node.getProperty('num').parent['jcr:primaryType']", data)
         );
     }
-    
-    public void testPropertyWrapperClass() throws Exception {
-        assertEquals(
-                "org.apache.sling.scripting.javascript.wrapper.ScriptableProperty", 
-                script.eval("node.getProperty('num').javascriptWrapperClass.getName()", data)
-        );
-    }
-    
+
     public void testPropertyAncestor() throws Exception {
         // call getAncestor which is not explicitly defined in ScriptableProperty,
-        // to verify that all Property methods are available and that we get a 
+        // to verify that all Property methods are available and that we get a
         // correctly wrapped result (SLING-397)
         assertEquals(
                 "rep:root",
                 script.eval("node.getProperty('num').getAncestor(0)['jcr:primaryType']",
data)
         );
     }
-    
+
     public void testPropertiesIterationNoWrapper() throws Exception {
-        final String code = 
+        final String code =
             "var props = node.getProperties();"
             + " for(i in props) { out.print(props[i].name); out.print(' '); }"
         ;
@@ -205,7 +191,7 @@ public class ScriptableNodeTest extends 
             assertTrue("result (" + result + ") contains '" + name + "'", result.contains(name));
         }
     }
-    
+
     public void testAddNodeDefaultType() throws Exception {
         final String path = "subdt_" + System.currentTimeMillis();
         final String code =
@@ -214,7 +200,7 @@ public class ScriptableNodeTest extends 
         ;
         assertEquals("nt:unstructured", script.evalToString(code, data));
     }
-    
+
     public void testAddNodeSpecificType() throws Exception {
         final String path = "subst_" + System.currentTimeMillis();
         final String code =
@@ -223,7 +209,7 @@ public class ScriptableNodeTest extends 
         ;
         assertEquals("nt:folder", script.evalToString(code, data));
     }
-    
+
     public void testGetNode() throws Exception {
         final String path = "subgn_" + System.currentTimeMillis();
         final String code =
@@ -238,7 +224,7 @@ public class ScriptableNodeTest extends 
         final String code = "out.print(node.getProperty('text'));";
         assertEquals(testText, script.evalToString(code, data));
     }
-    
+
     public void testGetNodesNoPattern() throws Exception {
         final String path = "subgnnp_" + System.currentTimeMillis();
         final String code =
@@ -249,7 +235,7 @@ public class ScriptableNodeTest extends 
         ;
         assertEquals(path + "_A " + path + "_B ", script.evalToString(code, data));
     }
-    
+
     public void testGetNodesWithPattern() throws Exception {
         final String path = "subgnnp_" + System.currentTimeMillis();
         final String code =
@@ -261,7 +247,7 @@ public class ScriptableNodeTest extends 
         ;
         assertEquals("1_" + path + "_A 1_" + path + "_B ", script.evalToString(code, data));
     }
-    
+
     public void testRemoveNode() throws Exception {
         final String code =
             "node.addNode('toremove');\n"
@@ -272,13 +258,13 @@ public class ScriptableNodeTest extends 
         ;
         assertEquals("true false", script.evalToString(code, data));
     }
-    
+
     /** Test SLING-389 */
     public void testForCurrentNode() throws Exception {
         final String code = "for (var a in node) {}; out.print('ok')";
         assertEquals("ok", script.evalToString(code, data));
     }
-    
+
     public void testChildNodeAccess() throws Exception {
         final String path = "subtcna_" + System.currentTimeMillis();
         final String code =
@@ -291,7 +277,7 @@ public class ScriptableNodeTest extends 
         ;
         assertEquals("nt:unstructured nt:unstructured", script.evalToString(code, data));
     }
-    
+
     /** Verify that the getAncestor() method (which is not explicitely defined in ScriptableNode)
      *  is available, to check SLING-397.
      */
@@ -300,38 +286,31 @@ public class ScriptableNodeTest extends 
             final String code = "out.print(node.getAncestor(0).getPath());";
             assertEquals("/", script.evalToString(code, data));
         }
-        
+
         {
             final String code = "out.print(node.getAncestor(0)['jcr:primaryType']);";
             assertEquals("rep:root", script.evalToString(code, data));
         }
     }
-    
+
     public void testIsNodeType() throws Exception {
-        final String code = 
+        final String code =
             "out.print(node.isNodeType('nt:unstructured'));\n"
             + "out.print(' ');\n"
             + "out.print(node.isNodeType('nt:file'));"
         ;
         assertEquals("true false", script.evalToString(code, data));
     }
-    
-    public void testNodeWrapperClass() throws Exception {
-        assertEquals(
-                "org.apache.sling.scripting.javascript.wrapper.ScriptableNode", 
-                script.eval("node.javascriptWrapperClass.getName()", data)
-        );
-    }
-    
+
     public void testGetSession() throws Exception {
         assertEquals(
                 "Root node found via node.session",
-                "/", 
+                "/",
                 script.eval("node.session.getRootNode().getPath()", data)
         );
         assertEquals(
                 "Root node found via node.getSession()",
-                "/", 
+                "/",
                 script.eval("node.getSession().getRootNode().getPath()", data)
         );
     }

Modified: sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableVersionTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableVersionTest.java?rev=1557911&r1=1557910&r2=1557911&view=diff
==============================================================================
--- sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableVersionTest.java
(original)
+++ sling/trunk/bundles/scripting/javascript/src/test/java/org/apache/sling/scripting/wrapper/ScriptableVersionTest.java
Tue Jan 14 02:41:13 2014
@@ -52,13 +52,6 @@ public class ScriptableVersionTest exten
         assertEquals("nt:version", script.eval("node.versionHistory.rootVersion['jcr:primaryType']",
data));
     }
 
-    public void testVersionHistoryWrapperClass() throws Exception {
-        assertEquals(
-                "org.apache.sling.scripting.javascript.wrapper.ScriptableVersionHistory",

-                script.eval("node.versionHistory.javascriptWrapperClass.getName()", data)
-        );
-    }
-
     public void testVersionAccess() throws Exception {
         Object result = script.eval("node.getBaseVersion().getCreated()", data);
         assertNotNull(result);
@@ -68,11 +61,4 @@ public class ScriptableVersionTest exten
         assertEquals("nt:version", script.eval("node.baseVersion['jcr:primaryType']", data));
         assertNotNull(script.eval("node.baseVersion.created", data));
     }
-    
-    public void testVersionWrapperClass() throws Exception {
-        assertEquals(
-                "org.apache.sling.scripting.javascript.wrapper.ScriptableVersion", 
-                script.eval("node.baseVersion.javascriptWrapperClass.getName()", data)
-        );
-    }
 }



Mime
View raw message