1 package org.apache.lucene.index;
4 * Licensed to the Apache Software Foundation (ASF) under one or more
5 * contributor license agreements. See the NOTICE file distributed with
6 * this work for additional information regarding copyright ownership.
7 * The ASF licenses this file to You under the Apache License, Version 2.0
8 * (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
20 import java.lang.reflect.Constructor;
21 import java.lang.reflect.Method;
22 import java.lang.reflect.Modifier;
23 import java.util.Arrays;
25 import org.apache.lucene.util.LuceneTestCase;
26 import org.junit.Test;
28 public class TestNoMergeScheduler extends LuceneTestCase {
31 public void testNoMergeScheduler() throws Exception {
32 MergeScheduler ms = NoMergeScheduler.INSTANCE;
38 public void testFinalSingleton() throws Exception {
39 assertTrue(Modifier.isFinal(NoMergeScheduler.class.getModifiers()));
40 Constructor<?>[] ctors = NoMergeScheduler.class.getDeclaredConstructors();
41 assertEquals("expected 1 private ctor only: " + Arrays.toString(ctors), 1, ctors.length);
42 assertTrue("that 1 should be private: " + ctors[0], Modifier.isPrivate(ctors[0].getModifiers()));
46 public void testMethodsOverridden() throws Exception {
47 // Ensures that all methods of MergeScheduler are overridden. That's
48 // important to ensure that NoMergeScheduler overrides everything, so that
49 // no unexpected behavior/error occurs
50 for (Method m : NoMergeScheduler.class.getMethods()) {
51 // getDeclaredMethods() returns just those methods that are declared on
52 // NoMergeScheduler. getMethods() returns those that are visible in that
53 // context, including ones from Object. So just filter out Object. If in
54 // the future MergeScheduler will extend a different class than Object,
55 // this will need to change.
56 if (m.getDeclaringClass() != Object.class) {
57 assertTrue(m + " is not overridden !", m.getDeclaringClass() == NoMergeScheduler.class);