#-- # ============================================================================= # Copyright (c) 2004, Jamis Buck (jgb3@email.byu.edu) # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # * Redistributions of source code must retain the above copyright notice, # this list of conditions and the following disclaimer. # # * 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. # # * The names of its contributors may not be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # AND ANY EXPRESS 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 COPYRIGHT OWNER OR 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. # ============================================================================= #++ $:.unshift "../lib" require 'test/unit' require 'copland/configuration-point' require 'copland/errors' require 'copland' require 'mock' class TC_ConfigurationPoint < Test::Unit::TestCase def setup @factory = Factory.new( Copland::ConfigurationPoint::POOL_NAME ) @package = MockPackage.new( MockRegistry.new ) end def test_factory list = @factory.get( "list", @package, "list" ) map = @factory.get( "map", @package, "map" ) assert_raise( Copland::NoSuchRegisteredClassException ) do @factory.get( "bogus", @package, "bogus" ) end end def test_list list = @factory.get( "list", @package, "list" ) assert_equal "list", list.name assert_equal @package.name + "." "list", list.full_name assert_equal @package, list.owner assert_instance_of Copland::ConfigurationPoint::ListConfigurationPoint, list assert list.empty? list.contribute [ 1, 2, 3, 4, 5 ] assert_equal [ 1, 2, 3, 4, 5 ], list end def test_map map = @factory.get( "map", @package, "map" ) assert_equal "map", map.name assert_equal @package.name + "." "map", map.full_name assert_equal @package, map.owner assert_instance_of Copland::ConfigurationPoint::MapConfigurationPoint, map assert map.empty? map.contribute :one=>:two, :three=>:four assert_equal( { :one=>:two, :three=>:four }, map ) assert_raise( Copland::ConfigurationPoint::ContributionTypeMismatch ) do map.contribute [ 1, 2, 3, 4, 5 ] end end end