lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r927660 - /lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java
Date Fri, 26 Mar 2010 01:23:08 GMT
Author: yonik
Date: Fri Mar 26 01:23:08 2010
New Revision: 927660

URL: http://svn.apache.org/viewvc?rev=927660&view=rev
Log:
tests: convert jetty/examples to junit4

Modified:
    lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java

Modified: lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java?rev=927660&r1=927659&r2=927660&view=diff
==============================================================================
--- lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java
(original)
+++ lucene/dev/trunk/solr/src/test/org/apache/solr/client/solrj/response/TestSpellCheckResponse.java
Fri Mar 26 01:23:08 2010
@@ -17,54 +17,39 @@ package org.apache.solr.client.solrj.res
  */
 
 import junit.framework.Assert;
-import org.apache.solr.client.solrj.SolrExampleTestBase;
+import org.apache.solr.client.solrj.SolrJettyTestBase;
 import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrServer;
-import org.apache.solr.client.solrj.embedded.JettySolrRunner;
-import org.apache.solr.client.solrj.impl.CommonsHttpSolrServer;
 import org.apache.solr.client.solrj.request.QueryRequest;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.CommonParams;
 import org.apache.solr.common.params.SpellingParams;
+import org.junit.BeforeClass;
+import org.junit.Test;
 
 import java.util.List;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 /**
  * Test for SpellCheckComponent's response in Solrj
  *
  * @version $Id$
  * @since solr 1.3
  */
-public class TestSpellCheckResponse extends SolrExampleTestBase {
-  @Override public String getSchemaFile()     { return null; }
-  @Override public String getSolrConfigFile() { return null; }
-
-  SolrServer server;
-  JettySolrRunner jetty;
-
-  int port = 0;
-  static final String context = "/example";
-
-  static String field = "name";
-
-  @Override
-  public void setUp() throws Exception {
-    super.setUp();
-
-    jetty = new JettySolrRunner(context, 0);
-    jetty.start();
-    port = jetty.getLocalPort();
-    log.info("Assigned Port: " + port);
-    server = this.createNewSolrServer();
-  }
-
-  @Override
-  public void tearDown() throws Exception {
-    jetty.stop();
-    super.tearDown();
+public class TestSpellCheckResponse extends SolrJettyTestBase {
+  @BeforeClass
+  public static void beforeTest() throws Exception {
+    // createJetty(EXAMPLE_HOME, null, null);
+    initCore(EXAMPLE_CONFIG, EXAMPLE_SCHEMA, EXAMPLE_HOME);
+    // initCore("solrconfig.xml", "schema.xml", null);
   }
+  
+  static String field = "name";
 
+  @Test
   public void testSpellCheckResponse() throws Exception {
+    getSolrServer();
     SolrInputDocument doc = new SolrInputDocument();
     doc.setField("id", "111");
     doc.setField(field, "Samsung");
@@ -81,7 +66,9 @@ public class TestSpellCheckResponse exte
     Assert.assertEquals("samsung", response.getFirstSuggestion("samsang"));
   }
 
+  @Test
   public void testSpellCheckResponse_Extended() throws Exception {
+    getSolrServer();
     SolrInputDocument doc = new SolrInputDocument();
     doc.setField("id", "111");
     doc.setField(field, "Samsung");
@@ -116,23 +103,4 @@ public class TestSpellCheckResponse exte
     // Hmmm... the API for SpellCheckResponse could be nicer:
     response.getSuggestions().get(0).getAlternatives().get(0);
   }
-
-  protected SolrServer getSolrServer() {
-    return server;
-  }
-
-  protected SolrServer createNewSolrServer() {
-    try {
-      // setup the server...
-      String url = "http://localhost:" + port + context;
-      CommonsHttpSolrServer s = new CommonsHttpSolrServer(url);
-      s.setConnectionTimeout(100); // 1/10th sec
-      s.setDefaultMaxConnectionsPerHost(100);
-      s.setMaxTotalConnections(100);
-      return s;
-    }
-    catch (Exception ex) {
-      throw new RuntimeException(ex);
-    }
-  }
 }



Mime
View raw message