You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2011/11/01 20:51:56 UTC
svn commit: r1196243 - in /lucene/dev/branches/lucene2621/lucene/src:
java/org/apache/lucene/index/SegmentInfo.java
test/org/apache/lucene/util/TestNamedSPILoader.java
Author: rmuir
Date: Tue Nov 1 19:51:56 2011
New Revision: 1196243
URL: http://svn.apache.org/viewvc?rev=1196243&view=rev
Log:
LUCENE-3490: remove obselete nocommit
Added:
lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/TestNamedSPILoader.java (with props)
Modified:
lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
Modified: lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentInfo.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentInfo.java?rev=1196243&r1=1196242&r2=1196243&view=diff
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentInfo.java (original)
+++ lucene/dev/branches/lucene2621/lucene/src/java/org/apache/lucene/index/SegmentInfo.java Tue Nov 1 19:51:56 2011
@@ -220,16 +220,10 @@ public final class SegmentInfo implement
hasProx = input.readByte();
- // nocommit: who should handle the case of codec not found?
- // Codec.forName() itself throw an exception? or callers check for null?
// System.out.println(Thread.currentThread().getName() + ": si.read hasProx=" + hasProx + " seg=" + name);
if (format <= DefaultSegmentInfosWriter.FORMAT_4_0) {
- String codecName = input.readString();
- codec = Codec.forName(codecName);
- if (codec == null) {
- throw new IllegalArgumentException("Required codec '" + codecName + "' not found!");
- }
+ codec = Codec.forName(input.readString());
} else {
// TODO what todo if preflex is not available in the provider? register it or fail?
codec = Codec.forName("Lucene3x");
Added: lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/TestNamedSPILoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/TestNamedSPILoader.java?rev=1196243&view=auto
==============================================================================
--- lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/TestNamedSPILoader.java (added)
+++ lucene/dev/branches/lucene2621/lucene/src/test/org/apache/lucene/util/TestNamedSPILoader.java Tue Nov 1 19:51:56 2011
@@ -0,0 +1,44 @@
+package org.apache.lucene.util;
+
+import java.util.Set;
+
+import org.apache.lucene.index.codecs.Codec;
+
+/**
+ * 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.
+ */
+
+// TODO: maybe we should test this with mocks, but its easy
+// enough to test the basics via Codec
+public class TestNamedSPILoader extends LuceneTestCase {
+ public void testLookup() {
+ Codec codec = Codec.forName("Lucene40");
+ assertEquals("Lucene40", codec.getName());
+ }
+
+ // we want an exception if its not found.
+ public void testBogusLookup() {
+ try {
+ Codec codec = Codec.forName("dskfdskfsdfksdfdsf");
+ fail();
+ } catch (IllegalArgumentException expected) {}
+ }
+
+ public void testAvailableServices() {
+ Set<String> codecs = Codec.availableCodecs();
+ assertTrue(codecs.contains("Lucene40"));
+ }
+}