svnno****@sourc*****
svnno****@sourc*****
2008年 12月 2日 (火) 12:11:08 JST
Revision: 2212 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=2212 Author: daisuke_m Date: 2008-12-02 12:11:08 +0900 (Tue, 02 Dec 2008) Log Message: ----------- test追加。 Added Paths: ----------- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/AbstractIdentifierValidatorTest.java artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidatorTest.java -------------- next part -------------- Added: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/AbstractIdentifierValidatorTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/AbstractIdentifierValidatorTest.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/AbstractIdentifierValidatorTest.java 2008-12-02 03:11:08 UTC (rev 2212) @@ -0,0 +1,100 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.core.extension.dialect.validator; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.jiemamy.spec.extension.dialect.IdentifierValidator; + +/** + * {@link AbstractIdentifierValidator}のテストクラス。 + * @author dmiyamoto + */ +public class AbstractIdentifierValidatorTest { + + private IdentifierValidator validator; + + + /** + * setup + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + validator = new IdentifierValidatorMock(); + } + + /** + * teardown + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + validator = null; + } + + /** + * バリデータ動作テスト。 + * @throws Exception + */ + @Test + public void test_バリデータ動作テスト() throws Exception { + // 基本的な正規表現バリデート + assertThat(validator.validate("ABC"), is(true)); + assertThat(validator.validate("012"), is(false)); + assertThat(validator.validate("ABC012"), is(true)); + assertThat(validator.validate("abc012"), is(false)); + assertThat(validator.validate(""), is(false)); + + // 予約語バリデート + assertThat(validator.validate("RESERVED1"), is(false)); + assertThat(validator.validate("RESERVED2"), is(false)); + assertThat(validator.validate("RESERVED3"), is(true)); + } + + + private static class IdentifierValidatorMock extends AbstractIdentifierValidator { + + /** + * コンストラクタ。 + * @category instance creation + */ + public IdentifierValidatorMock() { + super("^[A-Z][A-Z0-9]*$", new ReservedWordsProvider() { + + /** + * {@inheritDoc} + */ + public String[] getReservedWords() { + return new String[] { + "RESERVED1", + "RESERVED2" + }; + } + }); + } + + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/AbstractIdentifierValidatorTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Added: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidatorTest.java =================================================================== --- artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidatorTest.java (rev 0) +++ artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidatorTest.java 2008-12-02 03:11:08 UTC (rev 2212) @@ -0,0 +1,68 @@ +/* + * Copyright 2007-2008 MIYAMOTO Daisuke, jiemamy.org and the Others. + * Created on 2008/12/02 + * + * This file is part of Jiemamy. + * + * 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.jiemamy.core.extension.dialect.validator; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.apache.commons.lang.RandomStringUtils; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +import org.jiemamy.spec.extension.dialect.IdentifierValidator; + +/** + * TODO for dmiyamoto + * @author dmiyamoto + */ +public class DefaultIdentifierValidatorTest { + + private IdentifierValidator validator; + + + /** + * setup + * @throws java.lang.Exception + */ + @Before + public void setUp() throws Exception { + validator = new DefaultIdentifierValidator(); + } + + /** + * teardown + * @throws java.lang.Exception + */ + @After + public void tearDown() throws Exception { + validator = null; + } + + /** + * 常に結果はtrue。 + */ + @Test + public void test01_常に結果はtrue() { + for (int i = 0; i < 100; i++) { + assertThat(validator.validate(RandomStringUtils.random(10)), is(true)); + } + } + +} Property changes on: artemis/trunk/org.jiemamy.core/src/test/java/org/jiemamy/core/extension/dialect/validator/DefaultIdentifierValidatorTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain