lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1023346 - /lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java
Date Sat, 16 Oct 2010 18:27:09 GMT
Author: uschindler
Date: Sat Oct 16 18:27:08 2010
New Revision: 1023346

URL: http://svn.apache.org/viewvc?rev=1023346&view=rev
Log:
Reenable scripting test, only hudson uses OpenJDK which has no Rhino engine, so add assume.

Modified:
    lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java

Modified: lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java?rev=1023346&r1=1023345&r2=1023346&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java
(original)
+++ lucene/dev/trunk/solr/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestScriptTransformer.java
Sat Oct 16 18:27:08 2010
@@ -16,7 +16,6 @@
  */
 package org.apache.solr.handler.dataimport;
 
-import org.junit.Ignore;
 import org.junit.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -44,17 +43,21 @@ import java.util.Map;
 public class TestScriptTransformer extends AbstractDataImportHandlerTestCase {
 
   @Test
-  @Ignore
   public void testBasic() {
-    String script = "function f1(row,context){"
-            + "row.put('name','Hello ' + row.get('name'));" + "return row;\n" + "}";
-    Context context = getContext("f1", script);
-    Map<String, Object> map = new HashMap<String, Object>();
-    map.put("name", "Scott");
-    EntityProcessorWrapper sep = new EntityProcessorWrapper(new SqlEntityProcessor(), null);
-    sep.init(context);
-    sep.applyTransformer(map);
-    assertEquals(map.get("name"), "Hello Scott");
+    try {
+      String script = "function f1(row,context){"
+              + "row.put('name','Hello ' + row.get('name'));" + "return row;\n" + "}";
+      Context context = getContext("f1", script);
+      Map<String, Object> map = new HashMap<String, Object>();
+      map.put("name", "Scott");
+      EntityProcessorWrapper sep = new EntityProcessorWrapper(new SqlEntityProcessor(), null);
+      sep.init(context);
+      sep.applyTransformer(map);
+      assertEquals(map.get("name"), "Hello Scott");
+    } catch (DataImportHandlerException e) {
+      assumeFalse("JRE does not contain a JavaScript engine (OpenJDK)", "<script> can
be used only in java 6 or above".equals(e.getMessage()));
+      throw e;
+    }
   }
 
   private Context getContext(String funcName, String script) {
@@ -71,55 +74,66 @@ public class TestScriptTransformer exten
   }
 
   @Test
-  @Ignore
   public void testOneparam() {
-
-    String script = "function f1(row){"
-            + "row.put('name','Hello ' + row.get('name'));" + "return row;\n" + "}";
-
-    Context context = getContext("f1", script);
-    Map<String, Object> map = new HashMap<String, Object>();
-    map.put("name", "Scott");
-    EntityProcessorWrapper sep = new EntityProcessorWrapper(new SqlEntityProcessor(), null);
-    sep.init(context);
-    sep.applyTransformer(map);
-    assertEquals(map.get("name"), "Hello Scott");
+    try {
+      String script = "function f1(row){"
+              + "row.put('name','Hello ' + row.get('name'));" + "return row;\n" + "}";
+
+      Context context = getContext("f1", script);
+      Map<String, Object> map = new HashMap<String, Object>();
+      map.put("name", "Scott");
+      EntityProcessorWrapper sep = new EntityProcessorWrapper(new SqlEntityProcessor(), null);
+      sep.init(context);
+      sep.applyTransformer(map);
+      assertEquals(map.get("name"), "Hello Scott");
+    } catch (DataImportHandlerException e) {
+      assumeFalse("JRE does not contain a JavaScript engine (OpenJDK)", "<script> can
be used only in java 6 or above".equals(e.getMessage()));
+      throw e;
+    }
   }
 
   @Test
-  @Ignore
   public void testReadScriptTag() throws Exception {
-    DocumentBuilder builder = DocumentBuilderFactory.newInstance()
-            .newDocumentBuilder();
-    Document document = builder.parse(new InputSource(new StringReader(xml)));
-    DataConfig config = new DataConfig();
-    config.readFromXml((Element) document.getElementsByTagName("dataConfig")
-            .item(0));
-    assertTrue(config.script.text.indexOf("checkNextToken") > -1);
+    try {
+      DocumentBuilder builder = DocumentBuilderFactory.newInstance()
+              .newDocumentBuilder();
+      Document document = builder.parse(new InputSource(new StringReader(xml)));
+      DataConfig config = new DataConfig();
+      config.readFromXml((Element) document.getElementsByTagName("dataConfig")
+              .item(0));
+      assertTrue(config.script.text.indexOf("checkNextToken") > -1);
+    } catch (DataImportHandlerException e) {
+      assumeFalse("JRE does not contain a JavaScript engine (OpenJDK)", "<script> can
be used only in java 6 or above".equals(e.getMessage()));
+      throw e;
+    }
   }
 
   @Test
-  @Ignore
   public void testCheckScript() throws Exception {
-    DocumentBuilder builder = DocumentBuilderFactory.newInstance()
-            .newDocumentBuilder();
-    Document document = builder.parse(new InputSource(new StringReader(xml)));
-    DataConfig config = new DataConfig();
-    config.readFromXml((Element) document.getElementsByTagName("dataConfig")
-            .item(0));
-
-    Context c = getContext("checkNextToken", config.script.text);
-
-    Map map = new HashMap();
-    map.put("nextToken", "hello");
-    EntityProcessorWrapper sep = new EntityProcessorWrapper(new SqlEntityProcessor(), null);
-    sep.init(c);
-    sep.applyTransformer(map);
-    assertEquals("true", map.get("$hasMore"));
-    map = new HashMap();
-    map.put("nextToken", "");
-    sep.applyTransformer(map);
-    assertNull(map.get("$hasMore"));
+    try {
+      DocumentBuilder builder = DocumentBuilderFactory.newInstance()
+              .newDocumentBuilder();
+      Document document = builder.parse(new InputSource(new StringReader(xml)));
+      DataConfig config = new DataConfig();
+      config.readFromXml((Element) document.getElementsByTagName("dataConfig")
+              .item(0));
+
+      Context c = getContext("checkNextToken", config.script.text);
+
+      Map map = new HashMap();
+      map.put("nextToken", "hello");
+      EntityProcessorWrapper sep = new EntityProcessorWrapper(new SqlEntityProcessor(), null);
+      sep.init(c);
+      sep.applyTransformer(map);
+      assertEquals("true", map.get("$hasMore"));
+      map = new HashMap();
+      map.put("nextToken", "");
+      sep.applyTransformer(map);
+      assertNull(map.get("$hasMore"));
+    } catch (DataImportHandlerException e) {
+      assumeFalse("JRE does not contain a JavaScript engine (OpenJDK)", "<script> can
be used only in java 6 or above".equals(e.getMessage()));
+      throw e;
+    }
   }
 
   static String xml = "<dataConfig>\n"



Mime
View raw message