lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject svn commit: r586516 - in /lucene/solr/trunk/client/java/solrj: src/org/apache/solr/client/solrj/response/LukeResponse.java test/org/apache/solr/client/solrj/SolrExampleTests.java
Date Fri, 19 Oct 2007 16:02:32 GMT
Author: ryan
Date: Fri Oct 19 09:02:31 2007
New Revision: 586516

URL: http://svn.apache.org/viewvc?rev=586516&view=rev
Log:
Adding tests to make sure you get FieldTypeInfo when you ask for the schema 

Modified:
    lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/response/LukeResponse.java
    lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/SolrExampleTests.java

Modified: lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/response/LukeResponse.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/response/LukeResponse.java?rev=586516&r1=586515&r2=586516&view=diff
==============================================================================
--- lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/response/LukeResponse.java
(original)
+++ lucene/solr/trunk/client/java/solrj/src/org/apache/solr/client/solrj/response/LukeResponse.java
Fri Oct 19 09:02:31 2007
@@ -195,9 +195,10 @@
     // Parse indexinfo
     indexInfo = (NamedList<Object>) res.get("index");
 
+    NamedList<Object> schema = (NamedList<Object>) res.get("schema");
     NamedList<Object> flds = (NamedList<Object>) res.get("fields");
-    if (flds == null) {
-      flds = (NamedList<Object>) ((NamedList<Object>) res.get("schema")).get("fields");
+    if (flds == null && schema != null ) {
+      flds = (NamedList<Object>) schema.get("fields");
     }
     if (flds != null) {
       fieldInfo = new HashMap<String, FieldInfo>();
@@ -208,16 +209,17 @@
       }
     }
 
-    NamedList<Object> fldTypes = (NamedList<Object>) ((NamedList<Object>)
res.get("schema")).get("types");
-    if (fldTypes != null) {
-      fieldTypeInfo = new HashMap<String, FieldTypeInfo>();
-      for (Map.Entry<String, Object> fieldType : fldTypes) {
-        FieldTypeInfo ft = new FieldTypeInfo(fieldType.getKey());
-        ft.read((NamedList<Object>) fieldType.getValue());
-        fieldTypeInfo.put(fieldType.getKey(), ft);
+    if( schema != null ) {
+      NamedList<Object> fldTypes = (NamedList<Object>) schema.get("types");
+      if (fldTypes != null) {
+        fieldTypeInfo = new HashMap<String, FieldTypeInfo>();
+        for (Map.Entry<String, Object> fieldType : fldTypes) {
+          FieldTypeInfo ft = new FieldTypeInfo(fieldType.getKey());
+          ft.read((NamedList<Object>) fieldType.getValue());
+          fieldTypeInfo.put(fieldType.getKey(), ft);
+        }
       }
     }
-
   }
 
   //----------------------------------------------------------------

Modified: lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/SolrExampleTests.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/SolrExampleTests.java?rev=586516&r1=586515&r2=586516&view=diff
==============================================================================
--- lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/SolrExampleTests.java
(original)
+++ lucene/solr/trunk/client/java/solrj/test/org/apache/solr/client/solrj/SolrExampleTests.java
Fri Oct 19 09:02:31 2007
@@ -27,6 +27,8 @@
 import junit.framework.Assert;
 
 import org.apache.solr.client.solrj.request.DirectXmlRequest;
+import org.apache.solr.client.solrj.request.LukeRequest;
+import org.apache.solr.client.solrj.response.LukeResponse;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.client.solrj.response.UpdateResponse;
 import org.apache.solr.client.solrj.util.ClientUtils;
@@ -251,5 +253,32 @@
     server.request( up );
     server.commit();
     assertNumFound( "*:*", 0 ); // make sure it got out
+  }
+  
+  
+  public void testLukeHandler() throws Exception
+  {    
+    SolrServer server = getSolrServer();
+    
+    // Empty the database...
+    server.deleteByQuery( "*:*" );// delete everything!
+    
+    SolrInputDocument[] doc = new SolrInputDocument[5];
+    for( int i=0; i<doc.length; i++ ) {
+      doc[i] = new SolrInputDocument();
+      doc[i].setField( "id", "ID"+i, 1.0f );
+      server.add( doc[i] );
+    }
+    server.commit();
+    assertNumFound( "*:*", doc.length ); // make sure it got in
+    
+    LukeRequest luke = new LukeRequest();
+    luke.setShowSchema( false );
+    LukeResponse rsp = luke.process( server );
+    assertNull( rsp.getFieldTypeInfo() ); // if you don't ask for it, the schema is null
+    
+    luke.setShowSchema( true );
+    rsp = luke.process( server );
+    assertNotNull( rsp.getFieldTypeInfo() ); 
   }
 }



Mime
View raw message