001: //$Id: ProcessConstructorValuesTest.java 135 2005-04-13 22:55:26Z jg_hamburg $
002: /********************************************************************************
003: * DDTUnit, a Datadriven Approach to Unit- and Moduletesting
004: * Copyright (c) 2004, Joerg and Kai Gellien
005: * All rights reserved.
006: *
007: * The Software is provided under the terms of the Common Public License 1.0
008: * as provided with the distribution of DDTUnit in the file cpl-v10.html.
009: * Redistribution and use in source and binary forms, with or without
010: * modification, are permitted provided that the following conditions
011: * are met:
012: *
013: * + Redistributions of source code must retain the above copyright
014: * notice, this list of conditions and the following disclaimer.
015: *
016: * + Redistributions in binary form must reproduce the above
017: * copyright notice, this list of conditions and the following
018: * disclaimer in the documentation and/or other materials provided
019: * with the distribution.
020: *
021: * + Neither the name of the authors or DDTUnit, nor the
022: * names of its contributors may be used to endorse or promote
023: * products derived from this software without specific prior
024: * written permission.
025: *
026: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
027: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
028: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
029: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
030: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
031: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
032: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
033: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
034: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
035: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
036: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
037: ********************************************************************************/package junitx.ddtunit.functest;
038:
039: import java.util.List;
040:
041: import junitx.ddtunit.DDTTestCase;
042: import junitx.ddtunit.resources.ComplexVO;
043: import junitx.ddtunit.resources.SimpleVO;
044:
045: /**
046: * Test reading/instanciation of objects by defining a constructor call.
047: *
048: * @author jg
049: */
050: public class ProcessConstructorValuesTest extends DDTTestCase {
051: /**
052: * @param name of testmethod to execute
053: */
054: public ProcessConstructorValuesTest(String name) {
055: super (name);
056: }
057:
058: /*
059: * (non-Javadoc)
060: *
061: * @see junitx.ddtunit.DDTTestCase#initContext()
062: */
063: protected void initContext() {
064: initTestData("ProcessConstructorValuesTest",
065: "ProcessConstructorValuesTest");
066: }
067:
068: /**
069: * Test retrieval of objects with different types of constructors.
070: */
071: public void testReadConstructor() {
072: SimpleVO simpleVO = (SimpleVO) getObject("mySimpleVO");
073: assertNotNull("Retrieved object should not be null", simpleVO);
074: addObjectToAssert("result", simpleVO);
075: }
076:
077: public void testGenericWithComplexField() {
078: ComplexVO complexVO = (ComplexVO) getObject("myComplexVO");
079: assertNotNull("Retrieved object should not be null", complexVO);
080: addObjectToAssert("result", complexVO.getSimpleVO());
081: }
082:
083: public void testCollectionWithConstructorElements() {
084: List myCollect = (List) getObject("myCollection");
085: assertNotNull("Collection should not be null", myCollect);
086: addObjectToAssert("firstResult", myCollect.get(0));
087: addObjectToAssert("secondResult", myCollect.get(1));
088: }
089:
090: public void testComplexWithConstructorCollectionArg() {
091: ComplexVO myComplex = (ComplexVO) getObject("myComplex");
092: assertNotNull("ComplexVO should not be null", myComplex);
093: assertNotNull("Collection should not be null", myComplex
094: .getCollect());
095: List myCollect = (List) myComplex.getCollect();
096: addObjectToAssert("firstResult", myCollect.get(0));
097: addObjectToAssert("secondResult", myCollect.get(1));
098: }
099:
100: }
|