Repository: tika Updated Branches: refs/heads/master 2d06bc2c3 -> e2fdcaa7e
fix for TIKA-1943 contributed by Mark Duske Includes Unit Tests for support to Yandex Translate API Project: http://git-wip-us.apache.org/repos/asf/tika/repo Commit: http://git-wip-us.apache.org/repos/asf/tika/commit/08e932bd Tree: http://git-wip-us.apache.org/repos/asf/tika/tree/08e932bd Diff: http://git-wip-us.apache.org/repos/asf/tika/diff/08e932bd Branch: refs/heads/master Commit: 08e932bd75d3a8922d04fe30e7e097b6e84e6dfd Parents: 81bc3cd Author: ReEvApp - Re-Evolution Applications, LLC <[email protected]> Authored: Tue Apr 12 13:58:54 2016 -0400 Committer: ReEvApp - Re-Evolution Applications, LLC <[email protected]> Committed: Tue Apr 12 13:58:54 2016 -0400 ---------------------------------------------------------------------- .../translate/YandexTranslatorTest.java | 102 +++++++++++++++++++ 1 file changed, 102 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tika/blob/08e932bd/tika-translate/src/test/java/org/apache/tika/language/translate/YandexTranslatorTest.java ---------------------------------------------------------------------- diff --git a/tika-translate/src/test/java/org/apache/tika/language/translate/YandexTranslatorTest.java b/tika-translate/src/test/java/org/apache/tika/language/translate/YandexTranslatorTest.java new file mode 100644 index 0000000..6a5fe17 --- /dev/null +++ b/tika-translate/src/test/java/org/apache/tika/language/translate/YandexTranslatorTest.java @@ -0,0 +1,102 @@ + +/** + * 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. + */ + +package org.apache.tika.language.translate; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import org.junit.Before; +import org.junit.FixMethodOrder; +import org.junit.Test; +import org.junit.runners.MethodSorters; + +/** + * Generic Tests to ensure that the RSS library behaves as expected + * @author mark + * + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class YandexTranslatorTest { + + private YandexTranslator translator; + + @Before + public void setUp() throws Exception { + this.translator = new YandexTranslator(); + } + + @Test + public void test1EN_ES_Translation() { + String inputText = "Hello World!!!"; + String expectedText = "Hola Mundo!!!"; + + try { + String transText = translator.translate(inputText, "en", "es"); + + assertNotNull("Text not translated", transText); + + assertEquals("Result: [" + transText + + "]: not equal to expected: [" + expectedText + "]", + expectedText, transText); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @Test + public void test2UNDEFINED_DE_ES_Translation() { + String inputText = "Guten Tag!!!"; + String expectedText = "Buen DÃa!!!"; + + try { + String transText = translator.translate(inputText, "es"); + + assertNotNull("Text not translated", transText); + + assertEquals("Result: [" + transText + + "]: not equal to expected: [" + expectedText + "]", + expectedText, transText); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + @Test + public void test3UNDEFINED_IT_EN_Translation() { + String inputText = "Buona Sera!!!"; + String expectedText = "Good Evening!!!"; + + try { + String transText = translator.translate(inputText, "en"); + + assertNotNull("Text not translated", transText); + + assertEquals("Result: [" + transText + + "]: not equal to expected: [" + expectedText + "]", + expectedText, transText); + } catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + +}
