Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 12AC8793E for ; Tue, 1 Nov 2011 19:52:21 +0000 (UTC) Received: (qmail 2348 invoked by uid 500); 1 Nov 2011 19:52:20 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 2341 invoked by uid 99); 1 Nov 2011 19:52:20 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2011 19:52:20 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 Nov 2011 19:52:18 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BB2DA23888FE; Tue, 1 Nov 2011 19:51:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1196243 - in /lucene/dev/branches/lucene2621/lucene/src: java/org/apache/lucene/index/SegmentInfo.java test/org/apache/lucene/util/TestNamedSPILoader.java Date: Tue, 01 Nov 2011 19:51:56 -0000 To: commits@lucene.apache.org From: rmuir@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20111101195156.BB2DA23888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 codecs = Codec.availableCodecs(); + assertTrue(codecs.contains("Lucene40")); + } +}