Sanity checker. Yes I like it. You apply that to each file and in addition do some testing of individual things you're more interested in.
-- Glen ----- Original Message ----- From: "Andrew C. Oliver" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, February 20, 2002 2:53 PM Subject: Re: Re: cvs commit:jakarta-poi/src/java/org/apache/poi/hssf/usermodel/examplesCreateCell s.java CreateDateCells.java > I agree, it was basically a matter of I needed to know if the length > changed.. In earlier days this was actually *possible* without me being > aware of it. I think all those problems are fixed. The only issue is > what I really want is "load this up in excel and see if it doesn't > crash"...since that isn't feasible, maybe we should run through the > event based API and do some record checking? I'd like to do some basic > sanity checking. Maybe check that the first record is a BOF and so is > the last and maybe some counting of sheet records etc to ensure that the > file is "well formed" (no off by one error or any nastiness like > that).. I think that would be more appropriate than the length yet > achieve what I was kinda-achieving by the length check. > > -Andy > > On Tue, 2002-02-19 at 22:37, Glen Stampoultzis wrote: > > Good question. I'm not sure. We already have unit tests that test the > > underlying framework (although these could be better). Right now I'm just > > running the example and looking at the output. Since the examples aren't > > likely to change (much) and the underlying framework has at least some level > > of tests I'm inclined to simply test manually once. I am open to discussion > > on this however. > > > > While were on the subject I had another question regarding the some of the > > existing tests. I noticed a common technique is to simply write out a file > > and check it's length. This approach seems a little brittle to me but I'm > > not sure what the best thing to test for is. The disadvantages I can see > > for the current technique are: > > > > * Brittle - The introduction of a new record could easily break numerous > > tests. > > * Incomplete - The test does nothing to check the contents of the file are > > what you expect. > > * Opaque - If you view the test as a form of documentation, as I tend to, it > > seems that we are not saying enough about what the expected result is. > > > > Testing for every record is simply not practical so that's probably out of > > the question. But testing for certain records or for certain attributes > > seems as if it could provide some more concrete form of testing. Any > > thoughts on this. Am I barking up the wrong tree here? > > > > Regards, > > > > Glen Stampoultzis > > [EMAIL PROTECTED] > > +61 3 9753-6850 - 0402 835 458 (mob) > > ICQ: 62722370 AIM: FubbleWobble > > > > > > > > ----- Original Message ----- > > From: "acoliver" <[EMAIL PROTECTED]> > > To: <[EMAIL PROTECTED]> > > Sent: Wednesday, February 20, 2002 10:05 AM > > Subject: Re: Re: cvs commit: > > jakarta-poi/src/java/org/apache/poi/hssf/usermodel/examples CreateCells.java > > CreateDateCells.java > > > > > > > Cool thanks! Should we do unit tests for the examples? (just curious > > what > > > you think). > > > > > > -Andy > > > > > > >On Wed, 20 Feb 2002 10:01:50 1100 "Glen Stampoultzis" > > > <[EMAIL PROTECTED]> wrote. > > > >I agree and will move it... > > > > > > > >The intend is to use these examples in the documentation I'm producing. > > > I'd > > > >rather have examples that compile and run against the actual source than > > > >just embedded into a text file with no verification that they actually > > work > > > >against the latest and greated source. > > > > > > > >-- Glen > > > > > > > >----- Original Message ----- > > > >From: "acoliver" <[EMAIL PROTECTED]> > > > >To: <[EMAIL PROTECTED]> > > > >Sent: Wednesday, February 20, 2002 9:45 AM > > > >Subject: Re: cvs commit: > > > >jakarta-poi/src/java/org/apache/poi/hssf/usermodel/examples > > > CreateCells.java > > > >CreateDateCells.java > > > > > > > > > > > >> Oooh like the work, hate the location. I don't want people to need to > > > >> deploy examples into production. . please move this to > > > >> > > > >> jakarta-poi/examples/java.org.... > > > >> > > > >> create new ant target "examples" > > > >> > > > >> (also compiled-only examples are practically useless anyhow) > > > >> > > > >> >On 19 Feb 2002 22:42:15 -0000 [EMAIL PROTECTED] wrote. > > > >> >glens 02/02/19 14:42:15 > > > >> > > > > >> > Added: src/java/org/apache/poi/hssf/usermodel/examples > > > >> > CreateCells.java CreateDateCells.java > > > >> > Log: > > > >> > Examples galore. Well okay, only two. More to come... Really! > > > >> > > > > >> > Revision Changes Path > > > >> > 1.1 > > > >> > > > > > >jakarta-poi/src/java/org/apache/poi/hssf/usermodel/examples/CreateCells.jav > > a > > > >> > > > > >> > Index: CreateCells.java > > > >> > =================================================================== > > > >> > /* > > > ==================================================================== > > > >> > * The Apache Software License, Version 1.1 > > > >> > * > > > >> > * Copyright (c) 2002 The Apache Software Foundation. All rights > > > >> > * reserved. > > > >> > * > > > >> > * Redistribution and use in source and binary forms, with or > > without > > > >> > * modification, are permitted provided that the following > > conditions > > > >> > * are met: > > > >> > * > > > >> > * 1. Redistributions of source code must retain the above copyright > > > >> > * notice, this list of conditions and the following disclaimer. > > > >> > * > > > >> > * 2. Redistributions in binary form must reproduce the above > > > copyright > > > >> > * notice, this list of conditions and the following disclaimer > > in > > > >> > * the documentation and/or other materials provided with the > > > >> > * distribution. > > > >> > * > > > >> > * 3. The end-user documentation included with the redistribution, > > > >> > * if any, must include the following acknowledgment: > > > >> > * "This product includes software developed by the > > > >> > * Apache Software Foundation (http://www.apache.org/)." > > > >> > * Alternately, this acknowledgment may appear in the software > > > >itself, > > > >> > * if and wherever such third-party acknowledgments normally > > > appear. > > > >> > * > > > >> > * 4. The names "Apache" and "Apache Software Foundation" and > > > >> > * "Apache POI" must not be used to endorse or promote products > > > >> > * derived from this software without prior written permission. > > For > > > >> > * written permission, please contact [EMAIL PROTECTED] > > > >> > * > > > >> > * 5. Products derived from this software may not be called > > "Apache", > > > >> > * "Apache POI", nor may "Apache" appear in their name, without > > > >> > * prior written permission of the Apache Software Foundation. > > > >> > * > > > >> > * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED > > > >> > * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > > > >> > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > > > >> > * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR > > > >> > * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > > > >> > * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > > > >> > * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF > > > >> > * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > > AND > > > >> > * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > > LIABILITY, > > > >> > * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > > OUT > > > >> > * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY > > OF > > > >> > * SUCH DAMAGE. > > > >> > * > > > ==================================================================== > > > >> > * > > > >> > * This software consists of voluntary contributions made by many > > > >> > * individuals on behalf of the Apache Software Foundation. For > > more > > > >> > * information on the Apache Software Foundation, please see > > > >> > * <http://www.apache.org/>. > > > >> > */ > > > >> > > > > >> > package org.apache.poi.hssf.usermodel.examples; > > > >> > > > > >> > import org.apache.poi.hssf.usermodel.HSSFWorkbook; > > > >> > import org.apache.poi.hssf.usermodel.HSSFSheet; > > > >> > import org.apache.poi.hssf.usermodel.HSSFRow; > > > >> > import org.apache.poi.hssf.usermodel.HSSFCell; > > > >> > > > > >> > import java.io.FileOutputStream; > > > >> > import java.io.IOException; > > > >> > > > > >> > /** > > > >> > * Illustrates how to create cell values. > > > >> > * > > > >> > * @author Glen Stampoultzis (glens at apache.org) > > > >> > */ > > > >> > public class CreateCells > > > >> > { > > > >> > public static void main(String[] args) > > > >> > throws IOException > > > >> > { > > > >> > HSSFWorkbook wb = new HSSFWorkbook(); > > > >> > HSSFSheet sheet = wb.createSheet("new sheet"); > > > >> > > > > >> > // Create a row and put some cells in it. Rows are 0 based. > > > >> > HSSFRow row = sheet.createRow((short)0); > > > >> > // Create a cell and put a value in it. > > > >> > HSSFCell cell = row.createCell((short)0); > > > >> > cell.setCellValue(1); > > > >> > > > > >> > // Or do it on one line. > > > >> > row.createCell((short)1).setCellValue(1.2); > > > >> > row.createCell((short)2).setCellValue("This is a string"); > > > >> > row.createCell((short)3).setCellValue(true); > > > >> > > > > >> > // Write the output to a file > > > >> > FileOutputStream fileOut = new > > > >FileOutputStream("workbook.xls"); > > > >> > wb.write(fileOut); > > > >> > fileOut.close(); > > > >> > } > > > >> > } > > > >> > > > > >> > > > > >> > > > > >> > 1.1 > > > >> > > > > > >jakarta-poi/src/java/org/apache/poi/hssf/usermodel/examples/CreateDateCells > > . > > > >java > > > >> > > > > >> > Index: CreateDateCells.java > > > >> > =================================================================== > > > >> > /* > > > ==================================================================== > > > >> > * The Apache Software License, Version 1.1 > > > >> > * > > > >> > * Copyright (c) 2002 The Apache Software Foundation. All rights > > > >> > * reserved. > > > >> > * > > > >> > * Redistribution and use in source and binary forms, with or > > without > > > >> > * modification, are permitted provided that the following > > conditions > > > >> > * are met: > > > >> > * > > > >> > * 1. Redistributions of source code must retain the above copyright > > > >> > * notice, this list of conditions and the following disclaimer. > > > >> > * > > > >> > * 2. Redistributions in binary form must reproduce the above > > > copyright > > > >> > * notice, this list of conditions and the following disclaimer > > in > > > >> > * the documentation and/or other materials provided with the > > > >> > * distribution. > > > >> > * > > > >> > * 3. The end-user documentation included with the redistribution, > > > >> > * if any, must include the following acknowledgment: > > > >> > * "This product includes software developed by the > > > >> > * Apache Software Foundation (http://www.apache.org/)." > > > >> > * Alternately, this acknowledgment may appear in the software > > > >itself, > > > >> > * if and wherever such third-party acknowledgments normally > > > appear. > > > >> > * > > > >> > * 4. The names "Apache" and "Apache Software Foundation" and > > > >> > * "Apache POI" must not be used to endorse or promote products > > > >> > * derived from this software without prior written permission. > > For > > > >> > * written permission, please contact [EMAIL PROTECTED] > > > >> > * > > > >> > * 5. Products derived from this software may not be called > > "Apache", > > > >> > * "Apache POI", nor may "Apache" appear in their name, without > > > >> > * prior written permission of the Apache Software Foundation. > > > >> > * > > > >> > * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED > > > >> > * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES > > > >> > * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE > > > >> > * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR > > > >> > * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, > > > >> > * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT > > > >> > * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF > > > >> > * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED > > AND > > > >> > * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > > LIABILITY, > > > >> > * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > > OUT > > > >> > * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY > > OF > > > >> > * SUCH DAMAGE. > > > >> > * > > > ==================================================================== > > > >> > * > > > >> > * This software consists of voluntary contributions made by many > > > >> > * individuals on behalf of the Apache Software Foundation. For > > more > > > >> > * information on the Apache Software Foundation, please see > > > >> > * <http://www.apache.org/>. > > > >> > */ > > > >> > > > > >> > package org.apache.poi.hssf.usermodel.examples; > > > >> > > > > >> > import org.apache.poi.hssf.usermodel.*; > > > >> > > > > >> > import java.io.FileOutputStream; > > > >> > import java.io.IOException; > > > >> > import java.util.Date; > > > >> > > > > >> > /** > > > >> > * An example on how to cells with dates. The important thing to > > note > > > >> > * about dates is that they are really normal numeric cells that are > > > >> > * formatted specially. > > > >> > * > > > >> > * @author Glen Stampoultzis (glens at apache.org) > > > >> > */ > > > >> > public class CreateDateCells > > > >> > { > > > >> > public static void main(String[] args) > > > >> > throws IOException > > > >> > { > > > >> > HSSFWorkbook wb = new HSSFWorkbook(); > > > >> > HSSFSheet sheet = wb.createSheet("new sheet"); > > > >> > > > > >> > // Create a row and put some cells in it. Rows are 0 based. > > > >> > HSSFRow row = sheet.createRow((short)0); > > > >> > > > > >> > // Create a cell and put a date value in it. The first cell > > > is > > > >> not styled as a date. > > > >> > HSSFCell cell = row.createCell((short)0); > > > >> > cell.setCellValue(new Date()); > > > >> > > > > >> > // we style the second cell as a date (and time). It is > > > >> important to create a new cell style from the workbook > > > >> > // otherwise you can end up modifying the built in style and > > > >> effecting not only this cell but other cells. > > > >> > HSSFCellStyle cellStyle = wb.createCellStyle(); > > > >> > cellStyle.setDataFormat(HSSFDataFormat.getFormat("m/d/yy > > > >h:mm")); > > > >> > cell = row.createCell((short)1); > > > >> > cell.setCellValue(new Date()); > > > >> > cell.setCellStyle(cellStyle); > > > >> > > > > >> > // Write the output to a file > > > >> > FileOutputStream fileOut = new > > > >FileOutputStream("workbook.xls"); > > > >> > wb.write(fileOut); > > > >> > fileOut.close(); > > > >> > > > > >> > } > > > >> > } > > > >> > > > > >> > > > > >> > > > > >> > > > > > > > > > > > > > > > > -- > www.superlinksoftware.com > www.sourceforge.net/projects/poi - port of Excel format to java > http://developer.java.sun.com/developer/bugParade/bugs/4487555.html > - fix java generics! > > > The avalanche has already started. It is too late for the pebbles to > vote. > -Ambassador Kosh >