gautamdudeja90 / beanio

Automatically exported from code.google.com/p/beanio
Apache License 2.0
0 stars 1 forks source link

Within <group>, the "minOccurs" of last record does not work #56

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?  If applicable, please provide a
mapping configuration and sample record input to recreate the problem.
1. Run the BeanIOVerifier as listed below.
2. See "done" with no error reported.
3. Comment out the open and close "<group>" tag from BeanIOTest.xml, and run it 
again.  Error reported.

What is the expected output? What do you see instead?
The record of "fileControl" is missing from the input file.  It has a 
"minOccurs=1". The error should be reported.

What version of BeanIO are you using? What JDK version?
BeanIO 2.0.3
JDK 1.6.0_31

Please provide any additional information below.
=====Content of BeanIOVerifier.java
package fileBean;

import java.io.File;

import org.beanio.BeanReader;
import org.beanio.BeanReaderErrorHandler;
import org.beanio.BeanReaderException;
import org.beanio.StreamFactory;

/**
 * @date Created on 2013-02-01
 */
public class BeanIOVerifier {
    private static String MAPPING_FILE = BeanIOVerifier.class.getPackage().getName().replace('.', '/') + "/BeanIOTest.xml";
    private static String INPUT_FILE = "BeanIOTest.txt";

    public static void main(String[] args) throws Exception {
        // create a BeanIO StreamFactory
        StreamFactory factory = StreamFactory.newInstance();
        // load the mapping file from the working directory
        factory.load(MAPPING_FILE);

        File currInputFile = new File(BeanIOVerifier.class.getResource(INPUT_FILE).toURI());
        BeanReader in = factory.createReader("test", currInputFile);

        Object record = null;
        while ((record = in.read()) != null) {
        }

        in.close();

        System.out.println("done");
    }
}

=====End of Content of BeanIOVerifier.java
======Content of BeanIOTest.txt
11111111111111111111111111111111111111111111111111111111111111111111111111111111
11111111111111
======End of Content of BeanIOTest.txt
======Content of BeanIOTest.xml
<?xml version="1.0" encoding="UTF-8"?>

<beanio xmlns="http://www.beanio.org/2012/03">

    <stream name="test" format="fixedlength" strict="true">
        <group name="filegroup" minOccurs="1" maxOccurs="unbounded">
            <record name="fileHeader" order="1" minOccurs="1" maxOccurs="1" minLength="94" maxLength="94" class="map">
                <field name="recordType" length="1" rid="true" literal="1" />
                <field name="filler1" length="93" />
            </record>

            <record name="fileControl" order="2" minOccurs="1" maxOccurs="1" minLength="94" maxLength="94" class="map">
                <field name="recordType" length="1" rid="true" literal="9" />
                <field name="filler1" length="93" />
            </record>
        </group>
    </stream>
</beanio>
======End of Content of BeanIOTest.xml

Original issue reported on code.google.com by hongqia...@gmail.com on 1 Feb 2013 at 3:32

GoogleCodeExporter commented 9 years ago
Good catch- thanks!

Original comment by kevin.s...@gmail.com on 2 Feb 2013 at 4:19

GoogleCodeExporter commented 9 years ago
Try the attached snapshot JAR.  I plan to add some more unit test cases for 
this, but I believe it fixes the issue.

Thanks,
Kevin

Original comment by kevin.s...@gmail.com on 2 Feb 2013 at 4:36

Attachments:

GoogleCodeExporter commented 9 years ago
Thank you for the quick response. Both issue 55 and 56 have been fixed with the 
attached jar file.
Great work for BeanIO!

Original comment by hongqia...@gmail.com on 4 Feb 2013 at 2:14

GoogleCodeExporter commented 9 years ago

Original comment by kevin.s...@gmail.com on 6 Mar 2013 at 3:14