1------------------------------------------------------------------------------
2--                                                                          --
3--                            Matreshka Project                             --
4--                                                                          --
5--                          Ada Modeling Framework                          --
6--                                                                          --
7--                            Testsuite Component                           --
8--                                                                          --
9------------------------------------------------------------------------------
10--                                                                          --
11-- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com>                     --
12-- All rights reserved.                                                     --
13--                                                                          --
14-- Redistribution and use in source and binary forms, with or without       --
15-- modification, are permitted provided that the following conditions       --
16-- are met:                                                                 --
17--                                                                          --
18--  * Redistributions of source code must retain the above copyright        --
19--    notice, this list of conditions and the following disclaimer.         --
20--                                                                          --
21--  * Redistributions in binary form must reproduce the above copyright     --
22--    notice, this list of conditions and the following disclaimer in the   --
23--    documentation and/or other materials provided with the distribution.  --
24--                                                                          --
25--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
26--    contributors may be used to endorse or promote products derived from  --
27--    this software without specific prior written permission.              --
28--                                                                          --
29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
40--                                                                          --
41------------------------------------------------------------------------------
42--  $Revision: 3368 $ $Date: 2012-11-11 02:20:22 +0400 (Sun, 11 Nov 2012) $
43------------------------------------------------------------------------------
44--  Checks whether type of property is not null when it imported from another
45--  metamodel and critical error was encountered when one of XMI document is
46--  loaded.
47------------------------------------------------------------------------------
48with League.Application;
49
50with AMF.Facility;
51with AMF.UML.Properties;
52with AMF.UML.Types;
53with AMF.URI_Stores;
54with AMF.Visitors.UML_Visitors;
55with AMF.Visitors.UML_Containment;
56with XMI.Reader;
57
58with AMF.Internals.Modules.MOFEXT_Module;
59pragma Unreferenced (AMF.Internals.Modules.MOFEXT_Module);
60with AMF.Internals.Modules.UML_Module;
61pragma Unreferenced (AMF.Internals.Modules.UML_Module);
62
63procedure Test_226 is
64
65   type Test_226_Visitor is
66     limited new AMF.Visitors.UML_Visitors.UML_Visitor with
67   record
68      Found : Boolean := False;
69   end record;
70
71   overriding procedure Enter_Property
72    (Self    : in out Test_226_Visitor;
73     Element : not null AMF.UML.Properties.UML_Property_Access;
74     Control : in out AMF.Visitors.Traverse_Control);
75
76   --------------------
77   -- Enter_Property --
78   --------------------
79
80   overriding procedure Enter_Property
81    (Self    : in out Test_226_Visitor;
82     Element : not null AMF.UML.Properties.UML_Property_Access;
83     Control : in out AMF.Visitors.Traverse_Control)
84   is
85      use type AMF.UML.Types.UML_Type_Access;
86
87      The_Type : constant AMF.UML.Types.UML_Type_Access := Element.Get_Type;
88
89   begin
90      Self.Found := True;
91
92      if The_Type = null then
93         raise Program_Error;
94      end if;
95   end Enter_Property;
96
97   Store    : AMF.URI_Stores.URI_Store_Access;
98   Iterator : AMF.Visitors.UML_Containment.UML_Containment_Iterator;
99   Test     : Test_226_Visitor;
100
101begin
102   AMF.Facility.Initialize;
103   Store := XMI.Reader.Read_URI (League.Application.Arguments.Element (1));
104   Iterator.Visit (Test, Store);
105
106   if not Test.Found then
107      raise Program_Error;
108   end if;
109end Test_226;
110