Package com.google.enterprise.connector.traversal

Source Code of com.google.enterprise.connector.traversal.SpringBasedProductionTraversalContextTest

// Copyright 2007 Google Inc.
//
// Licensed 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.

package com.google.enterprise.connector.traversal;

import com.google.enterprise.connector.manager.Context;
import com.google.enterprise.connector.spi.TraversalContext;

import junit.framework.TestCase;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

import java.util.Collections;

/**
* Tests that use Spring to test the ProductionTraversalContext class.
*/
public class SpringBasedProductionTraversalContextTest extends TestCase {
  public final void testSpringBased() {
    ApplicationContext applicationContext;
    applicationContext = new FileSystemXmlApplicationContext(
        "testdata/traversalContextData/applicationContext.xml");
    TraversalContext traversalContext = (TraversalContext) applicationContext
        .getBean("TraversalContext");
    assertNotNull(traversalContext);
    assertEquals(2500000, traversalContext.maxDocumentSize());
    assertTrue(traversalContext.mimeTypeSupportLevel("text/plain") <= 0);
    assertTrue(traversalContext.mimeTypeSupportLevel("text/notplain")
                      <= 0);
    assertEquals(1, traversalContext.mimeTypeSupportLevel("ibblefrix"));
    assertEquals("ibblefrix", traversalContext.preferredMimeType(
                 Collections.singleton("ibblefrix")));
  }

  public final void testContextBasedTraversalContext() {
    Context.refresh();
    Context.getInstance().setStandaloneContext(
        Context.DEFAULT_JUNIT_CONTEXT_LOCATION,
        Context.DEFAULT_JUNIT_COMMON_DIR_PATH);
    Context.getInstance().setFeeding(false);
    Context.getInstance().start();
    TraversalContext traversalContext = Context.getInstance()
        .getTraversalContext();
    assertNotNull(traversalContext);
    Context.getInstance().shutdown(true);
    Context.refresh();
  }
}
TOP

Related Classes of com.google.enterprise.connector.traversal.SpringBasedProductionTraversalContextTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.