001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.commons.flatfile;
018
019import static org.junit.Assert.fail;
020
021import org.junit.Test;
022
023/**
024 *
025 */
026public class FieldOptionsTest extends EntityParserTestBase {
027
028    @Test
029    public void test1() {
030        assertValue("foo   ", entityFactory.getEntity("field1"));
031        assertValue("fooxxx", entityFactory.getEntity("field2"));
032        assertValue("fooxxx", entityFactory.getEntity("field3"));
033        assertValue("xxxfoo", entityFactory.getEntity("field4"));
034        assertValue("xfooxx", entityFactory.getEntity("field5"));
035        try {
036            assertValue("fo", entityFactory.getEntity("field6"));
037            fail("value foo too big and overflow = default (error)");
038        } catch (IllegalArgumentException e) {
039        }
040        assertValue("fo", entityFactory.getEntity("field7"));
041        assertValue("ob", entityFactory.getEntity("field8"));
042        assertValue("foo", entityFactory.getEntity("field9"));
043        assertValue("owl", entityFactory.getEntity("field10"));
044        assertValue("03.14", entityFactory.getEntity("field11"));
045        assertValue("foo bar", entityFactory.getEntity("field12"));
046        assertValue("foo   b", entityFactory.getEntity("field13"));
047        assertValue("foofoo", entityFactory.getEntity("field14"));
048        assertValue("foofoo", entityFactory.getEntity("field15"));
049        assertValue("foofoo", entityFactory.getEntity("field16"));
050    }
051
052    protected String getSource() {
053        return "fieldOptions.test";
054    }
055}