001: /*
002: * Copyright (c) 2001-2007, Jean Tessier
003: * All rights reserved.
004: *
005: * Redistribution and use in source and binary forms, with or without
006: * modification, are permitted provided that the following conditions
007: * are met:
008: *
009: * * Redistributions of source code must retain the above copyright
010: * notice, this list of conditions and the following disclaimer.
011: *
012: * * Redistributions in binary form must reproduce the above copyright
013: * notice, this list of conditions and the following disclaimer in the
014: * documentation and/or other materials provided with the distribution.
015: *
016: * * Neither the name of Jean Tessier nor the names of his contributors
017: * may be used to endorse or promote products derived from this software
018: * without specific prior written permission.
019: *
020: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
021: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
022: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
023: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
024: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
025: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
026: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
027: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
028: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
029: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
030: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
031: */
032:
033: package com.jeantessier.dependency;
034:
035: import junit.framework.*;
036:
037: public class TestFeatureNode extends TestCase {
038: private NodeFactory factory;
039: private FeatureNode node;
040:
041: protected void setUp() throws Exception {
042: factory = new NodeFactory();
043: }
044:
045: public void testSwitchFeatureNodeFromReferencedToConcrete() {
046: node = factory.createFeature("a.A.a", false);
047:
048: assertFalse("Not referenced", node.getClassNode()
049: .getPackageNode().isConfirmed());
050: assertFalse("Not referenced", node.getClassNode().isConfirmed());
051: assertFalse("Not referenced", node.isConfirmed());
052: node.setConfirmed(true);
053: assertTrue("Not concrete", node.getClassNode().getPackageNode()
054: .isConfirmed());
055: assertTrue("Not concrete", node.getClassNode().isConfirmed());
056: assertTrue("Not concrete", node.isConfirmed());
057: }
058:
059: public void testSwitchOneFeatureNodeOutOfTwoFromReferencedToConcrete() {
060: node = factory.createFeature("a.A.a", false);
061: factory.createFeature("a.A.b", false);
062:
063: assertFalse("Not referenced", node.getClassNode()
064: .getPackageNode().isConfirmed());
065: assertFalse("Not referenced", node.getClassNode().isConfirmed());
066: assertFalse("Not referenced", node.isConfirmed());
067: node.setConfirmed(true);
068: assertTrue("Not concrete", node.getClassNode().getPackageNode()
069: .isConfirmed());
070: assertTrue("Not concrete", node.getClassNode().isConfirmed());
071: assertTrue("Not concrete", node.isConfirmed());
072: }
073:
074: public void testSwitchFeatureNodeFromConcreteToReferenced() {
075: node = factory.createFeature("a.A.a", true);
076:
077: assertTrue("Not concrete", node.getClassNode().getPackageNode()
078: .isConfirmed());
079: assertTrue("Not concrete", node.getClassNode().isConfirmed());
080: assertTrue("Not concrete", node.isConfirmed());
081: node.setConfirmed(false);
082: assertTrue("Not concrete", node.getClassNode().getPackageNode()
083: .isConfirmed());
084: assertTrue("Not concrete", node.getClassNode().isConfirmed());
085: assertFalse("Not referenced", node.isConfirmed());
086: }
087:
088: public void testSwitchOneFeatureNodeOutOfTwoFromConcreteToReferenced() {
089: node = factory.createFeature("a.A.a", true);
090: factory.createFeature("a.A.b", true);
091:
092: assertTrue("Not concrete", node.getClassNode().getPackageNode()
093: .isConfirmed());
094: assertTrue("Not concrete", node.getClassNode().isConfirmed());
095: assertTrue("Not concrete", node.isConfirmed());
096: node.setConfirmed(false);
097: assertTrue("Not concrete", node.getClassNode().getPackageNode()
098: .isConfirmed());
099: assertTrue("Not concrete", node.getClassNode().isConfirmed());
100: assertFalse("Not referenced", node.isConfirmed());
101: }
102: }
|