Package com.gentics.cr.analytics.language.test

Source Code of com.gentics.cr.analytics.language.test.LanguageIdentifyerTest

package com.gentics.cr.analytics.language.test;

import junit.framework.TestCase;

import org.junit.After;
import org.junit.Before;

import com.gentics.cr.CRResolvableBean;
import com.gentics.cr.configuration.GenericConfiguration;
import com.gentics.cr.lucene.indexer.transformer.ContentTransformer;
import com.gentics.cr.lucene.indexer.transformer.lang.LanguageIdentifyer;

public class LanguageIdentifyerTest extends TestCase {

  CRResolvableBean bean;
  GenericConfiguration config;
  ContentTransformer t;

  @Before
  public void setUp() throws Exception {
    bean = new CRResolvableBean();

    config = new GenericConfiguration();
    config.set("attribute", "content");
    config.set("langattribute", "lang");
    t = new LanguageIdentifyer(config);
  }

  public void testTransformerDE() throws Exception {

    bean.set("content", "Dies ist ein Test um den LanguageDetector auf" + " eine Sprache zu bringen");
    t.processBean(bean);
    String s = (String) bean.get("lang");

    assertEquals("The found Language (" + s + ") should be (de).", "de", s);
  }

  public void testTransformerEN() throws Exception {
    bean.set("content", "This is some text to set the LanguageDetector" + "to a language.");
    t.processBean(bean);
    String s = (String) bean.get("lang");

    assertEquals("The found Language (" + s + ") should be (en).", "en", s);
  }

  @After
  public void tearDown() throws Exception {

  }
}
TOP

Related Classes of com.gentics.cr.analytics.language.test.LanguageIdentifyerTest

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.