/*
* Copyright (C) 2013-2017 NTT DATA Corporation
*
* 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 org.terasoluna.gfw.functionaltest.app.string;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.terasoluna.gfw.functionaltest.app.FunctionTestSupport;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:META-INF/spring/seleniumContext.xml" })
public class FullHalfConverterTest extends FunctionTestSupport {
@Test
public void fullHalfConverterTest01_01() {
driver.findElement(By.id("fullHalfConverter01")).click();
inputFieldAccessor
.overrideValue(By.id("halfwidth"), "ア゙!A8ガザ", driver);
driver.findElement(By.id("toFullwidth")).click();
assertThat(
driver.findElement(By.id("fullwidth")).getAttribute("value"),
is("ア゛!A8ガザ"));
}
@Test
public void fullHalfConverterTest01_02() {
driver.findElement(By.id("fullHalfConverter01")).click();
inputFieldAccessor.overrideValue(By.id("fullwidth"), "A!アガサ", driver);
driver.findElement(By.id("toHalfwidth")).click();
assertThat(
driver.findElement(By.id("halfwidth")).getAttribute("value"),
is("A!アガサ"));
}
@Test
public void customFullHalfTest02_01() {
driver.findElement(By.id("customFullHalfConverter02")).click();
String[][] testDatas = { { "!", "!" }, { """, "\"" }, { "#", "#" },
{ "$", "$" }, { "%", "%" }, { "&", "&" }, { "'", "'" },
{ "(", "(" }, { ")", ")" }, { "*", "*" }, { "+", "+" },
{ ",", "," }, { ".", "." }, { "/", "/" }, { "0", "0" },
{ "1", "1" }, { "2", "2" }, { "3", "3" }, { "4", "4" },
{ "5", "5" }, { "6", "6" }, { "7", "7" }, { "8", "8" },
{ "9", "9" }, { ":", ":" }, { ";", ";" }, { "<", "<" },
{ "=", "=" }, { ">", ">" }, { "?", "?" }, { "@", "@" },
{ "A", "A" }, { "B", "B" }, { "C", "C" }, { "D", "D" },
{ "E", "E" }, { "F", "F" }, { "G", "G" }, { "H", "H" },
{ "I", "I" }, { "J", "J" }, { "K", "K" }, { "L", "L" },
{ "M", "M" }, { "N", "N" }, { "O", "O" }, { "P", "P" },
{ "Q", "Q" }, { "R", "R" }, { "S", "S" }, { "T", "T" },
{ "U", "U" }, { "V", "V" }, { "W", "W" }, { "X", "X" },
{ "Y", "Y" }, { "Z", "Z" }, { "[", "[" }, { "\", "\\" },
{ "]", "]" }, { "^", "^" }, { "_", "_" }, { "`", "`" },
{ "a", "a" }, { "b", "b" }, { "c", "c" }, { "d", "d" },
{ "e", "e" }, { "f", "f" }, { "g", "g" }, { "h", "h" },
{ "i", "i" }, { "j", "j" }, { "k", "k" }, { "l", "l" },
{ "m", "m" }, { "n", "n" }, { "o", "o" }, { "p", "p" },
{ "q", "q" }, { "r", "r" }, { "s", "s" }, { "t", "t" },
{ "u", "u" }, { "v", "v" }, { "w", "w" }, { "x", "x" },
{ "y", "y" }, { "z", "z" }, { "{", "{" }, { "|", "|" },
{ "}", "}" }, { "\uff5e", "~" }, { "。", "。" }, { "「", "「" },
{ "」", "」" }, { "、", "、" }, { "・", "・" }, { "ァ", "ァ" },
{ "ィ", "ィ" }, { "ゥ", "ゥ" }, { "ェ", "ェ" }, { "ォ", "ォ" },
{ "ャ", "ャ" }, { "ュ", "ュ" }, { "ョ", "ョ" }, { "ッ", "ッ" },
{ "ア", "ア" }, { "イ", "イ" }, { "ウ", "ウ" }, { "エ", "エ" },
{ "オ", "オ" }, { "カ", "カ" }, { "キ", "キ" }, { "ク", "ク" },
{ "ケ", "ケ" }, { "コ", "コ" }, { "サ", "サ" }, { "シ", "シ" },
{ "ス", "ス" }, { "セ", "セ" }, { "ソ", "ソ" }, { "タ", "タ" },
{ "チ", "チ" }, { "ツ", "ツ" }, { "テ", "テ" }, { "ト", "ト" },
{ "ナ", "ナ" }, { "ニ", "ニ" }, { "ヌ", "ヌ" }, { "ネ", "ネ" },
{ "ノ", "ノ" }, { "ハ", "ハ" }, { "ヒ", "ヒ" }, { "フ", "フ" },
{ "ヘ", "ヘ" }, { "ホ", "ホ" }, { "マ", "マ" }, { "ミ", "ミ" },
{ "ム", "ム" }, { "メ", "メ" }, { "モ", "モ" }, { "ヤ", "ヤ" },
{ "ユ", "ユ" }, { "ヨ", "ヨ" }, { "ラ", "ラ" }, { "リ", "リ" },
{ "ル", "ル" }, { "レ", "レ" }, { "ロ", "ロ" }, { "ワ", "ワ" },
{ "ヲ", "ヲ" }, { "ン", "ン" }, { "ガ", "ガ" }, { "ギ", "ギ" },
{ "グ", "グ" }, { "ゲ", "ゲ" }, { "ゴ", "ゴ" }, { "ザ", "ザ" },
{ "ジ", "ジ" }, { "ズ", "ズ" }, { "ゼ", "ゼ" }, { "ゾ", "ゾ" },
{ "ダ", "ダ" }, { "ヂ", "ヂ" }, { "ヅ", "ヅ" }, { "デ", "デ" },
{ "ド", "ド" }, { "バ", "バ" }, { "ビ", "ビ" }, { "ブ", "ブ" },
{ "べ", "ベ" }, { "ボ", "ボ" }, { "パ", "パ" }, { "ピ", "ピ" },
{ "プ", "プ" }, { "ペ", "ペ" }, { "ポ", "ポ" }, { "ヴ", "ヴ" },
{ "\u30f7", "ヷ" }, { "\u30fa", "ヺ" }, { "゛", "゙" },
{ "゜", "゚" }, { " ", " " }, { "ー", "-" } };
for (String testData[] : testDatas) {
inputFieldAccessor.overrideValue(By.id("halfwidth"), testData[1],
driver);
driver.findElement(By.id("toFullwidth")).click();
assertThat(driver.findElement(By.id("fullwidth")).getAttribute(
"value"), is(testData[0]));
driver.findElement(By.id("toHalfwidth")).click();
assertThat(driver.findElement(By.id("halfwidth")).getAttribute(
"value"), is(testData[1]));
}
}
@Test
public void customFullHalfTest02_02() {
driver.findElement(By.id("customFullHalfConverter02")).click();
inputFieldAccessor
.overrideValue(By.id("fullwidth"), "ハローワールド!", driver);
driver.findElement(By.id("toHalfwidth")).click();
assertThat(
driver.findElement(By.id("halfwidth")).getAttribute("value"),
is("ハロ-ワ-ルド!"));
}
@Test
public void fullHalfPairsBuilderErrorTest03_01() {
driver.findElement(By.id("fullHalfPairsBuilder03")).click();
inputFieldAccessor.overrideValue(By.id("fullwidth"), "", driver);
inputFieldAccessor.overrideValue(By.id("halfwidth"), "a", driver);
driver.findElement(By.id("pair")).click();
assertThat(dbLogProvider.countContainsByRegexExceptionMessage(null,
null, "fullwidth must be 1 length string \\(fullwidth = \\)",
"..*IllegalArgumentException..*"), is(1L));
}
@Test
public void fullHalfPairsBuilderErrorTest03_02() {
driver.findElement(By.id("fullHalfPairsBuilderWithStringTrimmer03"))
.click();
inputFieldAccessor.overrideValue(By.id("fullwidth"), "", driver);
inputFieldAccessor.overrideValue(By.id("halfwidth"), "a", driver);
driver.findElement(By.id("pair")).click();
assertThat(dbLogProvider.countContainsByRegexExceptionMessage(null,
null,
"fullwidth must be 1 length string \\(fullwidth = null\\)",
"..*IllegalArgumentException..*"), is(1L));
}
@Test
public void fullHalfPairsBuilderErrorTest03_03() {
driver.findElement(By.id("fullHalfPairsBuilder03")).click();
inputFieldAccessor.overrideValue(By.id("fullwidth"), "aa", driver);
inputFieldAccessor.overrideValue(By.id("halfwidth"), "a", driver);
driver.findElement(By.id("pair")).click();
assertThat(dbLogProvider.countContainsByRegexExceptionMessage(null,
null, "fullwidth must be 1 length string \\(fullwidth = aa\\)",
"..*IllegalArgumentException..*"), is(1L));
}
@Test
public void fullHalfPairsBuilderErrorTest03_04() {
driver.findElement(By.id("fullHalfPairsBuilder03")).click();
inputFieldAccessor.overrideValue(By.id("fullwidth"), "a", driver);
inputFieldAccessor.overrideValue(By.id("halfwidth"), "", driver);
driver.findElement(By.id("pair")).click();
assertThat(dbLogProvider.countContainsByRegexExceptionMessage(null,
null,
"halfwidth must be 1 or 2 length string \\(halfwidth = \\)",
"..*IllegalArgumentException..*"), is(1L));
}
@Test
public void fullHalfPairsBuilderErrorTest03_05() {
driver.findElement(By.id("fullHalfPairsBuilderWithStringTrimmer03"))
.click();
inputFieldAccessor.overrideValue(By.id("fullwidth"), "a", driver);
inputFieldAccessor.overrideValue(By.id("halfwidth"), "", driver);
driver.findElement(By.id("pair")).click();
assertThat(
dbLogProvider
.countContainsByRegexExceptionMessage(
null,
null,
"halfwidth must be 1 or 2 length string \\(halfwidth = null\\)",
"..*IllegalArgumentException..*"), is(1L));
}
@Test
public void fullHalfPairsBuilderErrorTest03_06() {
driver.findElement(By.id("fullHalfPairsBuilder03")).click();
inputFieldAccessor.overrideValue(By.id("fullwidth"), "a", driver);
inputFieldAccessor.overrideValue(By.id("halfwidth"), "aaa", driver);
driver.findElement(By.id("pair")).click();
assertThat(dbLogProvider.countContainsByRegexExceptionMessage(null,
null,
"halfwidth must be 1 or 2 length string \\(halfwidth = aaa\\)",
"..*IllegalArgumentException..*"), is(1L));
}
}