ontomde-uml2 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ require 'ontomde-uml2'
2
+ require 'test/unit'
3
+
4
+ log.info("!! test")
5
+
6
+ class Test_ontomde_base < Test::Unit::TestCase
7
+ @@model=nil
8
+ def setup
9
+ return if !@@model.nil?
10
+ log.debug "Chargement du meta-modele UML2"
11
+ @@model=Crdf_Model.new
12
+ @@model.loadUml2
13
+ log.debug "Chargement du modele"
14
+ @@model.loadModelFromFile("#{File.dirname(__FILE__)}/model/simple2.emx.nt")
15
+ log.debug "Generation des sorties"
16
+
17
+ @@c1=find("ClassDeTest")
18
+ @@p1=find("pack1")
19
+ @@i1=find("Interface1")
20
+ @@calr=find("ClasseAlaRacine")
21
+
22
+ log.debug "***************** MODEL LOADED *************"
23
+ end
24
+
25
+ def find(str)
26
+ @@model.each { |k,v|
27
+ if v.respond_to? :uml_name
28
+ #log.debug "-->#{v.uml_name} :#{v.class.name}"
29
+ return v if v.uml_name.to_s==str
30
+ end
31
+ }
32
+ return nil
33
+ end
34
+
35
+
36
+ def test_c1_non_null
37
+ assert(@@c1!=nil,"@@c1 est nil")
38
+ end
39
+ def test_p1_non_null
40
+ assert(@@p1!=nil,"@@p1 est nil")
41
+ end
42
+ def test_i1_non_null
43
+ assert(@@i1!=nil,"@@i1 est nil")
44
+ end
45
+ def test_calr_non_null
46
+ assert(@@calr!=nil,"@@calr est nil")
47
+ end
48
+
49
+ def test_calr_no_package
50
+ assert(@@calr!=nil,"@@calr est nil")
51
+ assert(@@calr.umlx_package==nil, "")
52
+ end
53
+
54
+ def test_visibility
55
+ #log.debug "Visibility=#{@@c1.uml_namedElement_visibility}"
56
+ #assert(@@c1.uml_namedElement_visibility.kind_of
57
+ # ?(::Muml_visibilityKindpublic), "c1 est public")
58
+
59
+ #log.debug ""
60
+ #log.debug "Public-->#{Cuml_VisibilityKind::Public.uri}"
61
+ #log.debug "Private-->#{Cuml_VisibilityKind::Private.uri}"
62
+ #log.debug "Package-->#{Cuml_VisibilityKind::Package.uri}"
63
+ #log.debug "Protected-->#{Cuml_VisibilityKind::Protected.uri}"
64
+
65
+ assert(Cuml_VisibilityKind::Protected.isProtected?,"protected is protected")
66
+ assert(Cuml_VisibilityKind::Package.isPackage?,"package is package")
67
+ assert(Cuml_VisibilityKind::Public.isPublic?,"public is public")
68
+ assert(Cuml_VisibilityKind::Private.isPrivate?,"private is private")
69
+ assert(!Cuml_VisibilityKind::Public.isPrivate?,"Private is not public")
70
+ end
71
+
72
+ def test_uml_owner
73
+ assert(@@c1!=nil,"@@c1 est nil")
74
+ #log.debug "#{@@c1.umlx_packageableElement_owner}"
75
+
76
+ assert(@@c1.umlx_packageableElement_owner[0]==@@p1,"p1 owner c1")
77
+ end
78
+
79
+ def off_test_allMethodsResponds
80
+ @@model.each { |c|
81
+ self.methods.each { |m|
82
+ #eval( "#{m}" ) if
83
+ }
84
+ }
85
+ end
86
+
87
+
88
+ #
89
+ #def teardown
90
+ #end
91
+ #
92
+ end
93
+
94
+ require 'test/unit/ui/console/testrunner'
95
+ Test::Unit::UI::Console::TestRunner.run(Test_ontomde_base)
96
+
97
+
@@ -0,0 +1,78 @@
1
+ require 'ontomde-uml2'
2
+ require 'test/unit'
3
+
4
+ class TC_unit_test_clone < Test::Unit::TestCase
5
+ @@model=nil
6
+ def setup
7
+ if(@@model==nil)
8
+ log.debug 'Chargement du meta-modele UML2'
9
+ @@model=Crdf_Model.new
10
+ @@model.loadUml2
11
+ log.debug 'Chargement du modele simple2.emx.nt'
12
+ @@model.loadModelFromFile("#{File.dirname(__FILE__)}/model/simple2.emx.nt")
13
+ log.debug 'Generation des sorties'
14
+ @@model.each { |k,v|
15
+ if v.respond_to? :uml_name
16
+ #log.debug "-->#{v.uml_name} #{v.class.name}"
17
+ @@c1=v if v.uml_name.to_s=='ClassDeTest'
18
+ @@p1=v if v.uml_name.to_s=='pack1'
19
+ @@i1=v if v.uml_name.to_s=='Interface1'
20
+ @@calr=v if v.uml_name.to_s=='ClasseAlaRacine'
21
+ end
22
+ }
23
+ end
24
+ end
25
+
26
+ #def teardown
27
+ #end
28
+ def test_notNil
29
+ assert(! @@c1.nil?)
30
+ assert(! @@p1.nil?)
31
+ assert(! @@i1.nil?)
32
+ assert(! @@calr.nil?)
33
+ end
34
+ def test_clone_set_add
35
+ #log.debug 'A) test_clone'
36
+ model_length_initial=@@model.length
37
+ c1=@@c1
38
+ c2=c1.rdfx_clone
39
+ assert(!c2.nil?)
40
+ #log.debug "B) #{model_length_initial} ---> #{@@model.length} (+#{@@model.length-model_length_initial})"
41
+ assert(c1.rdf_model.length > model_length_initial)
42
+ assert(c1.rdf_model==c2.rdf_model)
43
+ # 21 : valeur de reference (a verifier)
44
+ log.debug c1.rdf_model.length - model_length_initial
45
+ assert(c1.rdf_model.length - model_length_initial == 23)
46
+
47
+ #log.debug "C) c2.to_s=\"#{c2.to_s}\""
48
+ assert(c2.to_s=='ClassDeTest')
49
+ c2.uml_name='AA'
50
+
51
+ #log.debug "D) c2.to_s=\"#{c2.to_s}\""
52
+ assert(c2.to_s=='AA')
53
+ assert(c1.to_s=='ClassDeTest')
54
+
55
+ c2.uml_name='AA'
56
+ c2.uml_name_add('BB')
57
+ c2.uml_name_add('CC')
58
+ #log.debug "E) c2.uml_name.to_s=\"#{c2.to_s}\" length=#{c2.uml_name.length}"
59
+ assert(c2.to_s=='AA BB CC')
60
+ assert(c1.to_s=='ClassDeTest')
61
+
62
+ c2.uml_name=nil
63
+ #log.debug "F) c2.uml_name.to_s=\"#{c2.uml_name.to_s}\" length=#{c2.uml_name.length}"
64
+ assert(c2.uml_name.length==0)
65
+ assert(c2.uml_name.to_s=='')
66
+
67
+ c2.uml_name_add('CC')
68
+ assert(c2.to_s=='CC')
69
+
70
+ end
71
+
72
+
73
+ end
74
+
75
+ require 'test/unit/ui/console/testrunner'
76
+ Test::Unit::UI::Console::TestRunner.run(TC_unit_test_clone)
77
+
78
+
@@ -0,0 +1,196 @@
1
+
2
+ require 'ontomde-uml2'
3
+ #require 'ontomde-core/clone.rb'
4
+
5
+ #class Crdf_Model
6
+ #{ include Uml2
7
+ #e0ind
8
+
9
+ module DumpUML
10
+ def toJavaName (str)
11
+ ret=str.to_s.gsub(/[^a-zA-Z0-9_]/,'_')
12
+ return ret
13
+ end
14
+
15
+
16
+ def genClass()
17
+ return if (self.class != ::Cuml_Class)
18
+ #raise Warningnew(),"node class is not a Cuml_class(#{self.class})" if (self.class != ::Cuml_Class)
19
+ raise Warning.new(),'Entry skipped (no @uml_name)' if respond_to?("uml_name")
20
+
21
+ f=File.new('tmp/'+toJavaName(@uml_name.to_s)+'.java','w+')
22
+ #f.write('Package '+@uml_Owner);
23
+ f.write("Class #{uml_name.to_s}\n");
24
+
25
+ uml_generalization.each { |g|
26
+ #parent=g.
27
+ #f.write("extends #{parent.uml_name.to_s} \n")
28
+ }
29
+
30
+ f.write('{\n')
31
+
32
+ uml_ownedAttribute.each { |feature|
33
+ f.write( '#feature \n')
34
+ }
35
+
36
+
37
+
38
+ f.write('}\n')
39
+
40
+ instance_variables.each {
41
+ |iv|
42
+ if (iv!='@rdf_model')
43
+ f.write('\/\/ variable '+iv+"-->#{instance_variable_get(iv).to_s}\n")
44
+ end
45
+ }
46
+
47
+ f.close
48
+ end
49
+ end
50
+
51
+ class Crdf_Resource
52
+ include DumpUML
53
+ end
54
+
55
+ module Muml_Namespace
56
+ def test_heritage_mm
57
+ return 1
58
+ end
59
+ end
60
+
61
+ module Muml_Class
62
+ def test_heritage_mm
63
+ return 2
64
+ end
65
+ end
66
+
67
+
68
+
69
+ require 'test/unit'
70
+ class TC_MyTest < Test::Unit::TestCase
71
+ @@model=nil
72
+ def setup
73
+ if(@@model==nil)
74
+ log.info 'Chargement du meta-modele UML2'
75
+ @@model=Crdf_Model.new
76
+ @@model.loadUml2
77
+ log.info 'Chargement du modele sid'
78
+ @@model.loadModelFromFile("#{File.dirname(__FILE__)}/model/SID.emx.nt")
79
+ log.info 'Generation des sorties'
80
+ end
81
+ end
82
+
83
+ #def teardown
84
+ #end
85
+
86
+ def test_inverseProperty
87
+ log.warn "TODO: refaire le test"
88
+ return
89
+ co=@@model[k1='uml_ownedOperation']
90
+ oc=@@model[k2='uml_operation_class_']
91
+
92
+
93
+ assert(co!=nil,k1)
94
+ assert(oc!=nil,k2)
95
+ assert(oc!=co,'')
96
+ assert(oc.sys_inverseProperty!=nil,'test inverseProperty')
97
+ assert(co.sys_inverseProperty!=nil,'test inverseProperty')
98
+
99
+
100
+ #log.debug "co=#{co} oc.sys_inverseProperty=#{co.sys_inverseProperty}"
101
+ #log.debug "oc=#{oc} co.sys_inverseProperty=#{oc.sys_inverseProperty}"
102
+
103
+ assert(co.to_s==oc.sys_inverseProperty.to_s,'')
104
+ assert(oc.to_s==co.sys_inverseProperty.to_s,'')
105
+ assert(oc.to_s!=co.to_s,'')
106
+ end
107
+
108
+ def test_heritage_mm
109
+ c=Cuml_Class.new(@@model,'test_heritage_c')
110
+ p=Cuml_Package.new(@@model,'test_heritage_p')
111
+ assert_equal(1,p.test_heritage_mm,'Heritage package incorrect')
112
+ assert_equal(2,c.test_heritage_mm,'Redefinition classe incorrect')
113
+ end
114
+
115
+ def test_model_uml_rempli
116
+ assert(@@model.length > 10000,"Modele UML faiblement rempli (#{@@model.length})")
117
+ end
118
+
119
+ def test_uml_metaClassesLoaded
120
+ log.warn "TODO: reecrire test"
121
+ return
122
+ k1='test_uml_metaClassesLoaded_c1'
123
+ Cuml_Class.new(@@model,k1)
124
+ @@model.delete(k1)
125
+ k2='test_uml_metaClassesLoaded_p1'
126
+ Cuml_Package.new(@@model,k2)
127
+ @@model.delete(k2)
128
+
129
+ end
130
+
131
+
132
+ def test_contains_many_uml_elements
133
+ nClass=0
134
+ nPackage=0
135
+ @@model.each_value { |i|
136
+ if i.class==::Cuml_Class
137
+ nClass=nClass+1
138
+ end
139
+ if i.class==::Cuml_Package
140
+ nPackage=nPackage+1
141
+ end
142
+ }
143
+ assert_equal(924,nClass,'nombre de classes uml dans le modele')
144
+ assert_equal(210,nPackage,'nombre de packages uml dans le modele')
145
+ end
146
+ def test_instance_enumerated
147
+ x=@@model[k='uml_visibilityKindpublic']
148
+ assert(x==nil,"#{k} ne devrait pas etre dans uml2")
149
+
150
+ x=@@model[k='uml_visibilityKind_public']
151
+ assert(x!=nil,"#{k} absent du modele")
152
+ end
153
+
154
+
155
+ def test_no_uml_null
156
+ k="http://uml/2#null"
157
+ assert(@@model[k]==nil,"Modele UML ne devrait pas contenir #{k}")
158
+ k='uml_null'
159
+ assert(@@model[k]==nil,"Modele UML devrait contenir #{k}")
160
+ assert(@@model.length>10000,"Modele UML faiblement rempli (#{@@model.length})")
161
+ end
162
+
163
+ def test_safe_attr_reader
164
+ c=Cuml_Class.new(@@model,'test_safe_attr_reader_c1')
165
+ o=c.uml_ownedOperation
166
+ assert_not_nil(o,'empty list expected not nil element');
167
+ assert_equal(0,o.length,'empty list expected');
168
+ end
169
+
170
+ def test_gen
171
+ gotErrors=false
172
+ @@model.each { |key,value|
173
+ begin
174
+ value.genClass
175
+ rescue Warning
176
+ #log.debug "#{$!}"
177
+ rescue
178
+ log.error "#{__FILE__} #{__LINE__}: #{$!}"
179
+ gotErrors=true
180
+ end
181
+ #log.debug "#{key}:#{value.class} = #{value.to_s}"
182
+ }
183
+ assert(!gotErrors,'Erreurs lors de la generation')
184
+ end
185
+
186
+ def test_clone
187
+ #c2=c1.umlx_clone
188
+ end
189
+
190
+
191
+ end
192
+
193
+ require 'test/unit/ui/console/testrunner'
194
+ Test::Unit::UI::Console::TestRunner.run(TC_MyTest)
195
+
196
+
File without changes
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ontomde-uml2
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Stephane (Pierre) Carrie
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-03-03 00:00:00 +01:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: ontomde-core
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.0.4
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: hoe
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.5.0
32
+ version:
33
+ description: "ontoMDE-uml2 contains UML2 meta-model and helper files to manipulate a UML2 model. ontoMDE-uml2 uses ontoMDA-core which provides core fonctionalities for loading a model in RDF/RDFS format. ontoMDE-UML2 is used by ontoMDE-java which contains rules for generating java Code. == FEATURES/PROBLEMS: * UML2 meta-model definition in RDFS format * Ruby helper methods for handling a UML2 model. * UML Stereotype handling helpers. * UML predefined enumerations handling helper. * UML model manipulations helpers (add interface implementations, transform multiple inheritance into single inheritance, ...) == SYNOPSIS: require 'ontomde-uml2'"
34
+ email: stephanepierre.carrie -nospam- @orange-ftgroup.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - History.txt
41
+ - Manifest.txt
42
+ - README.txt
43
+ files:
44
+ - History.txt
45
+ - Manifest.txt
46
+ - README.txt
47
+ - Rakefile
48
+ - lib/ontomde-uml2.rb
49
+ - lib/ontomde-uml2/version.rb
50
+ - lib/ontomde-uml2/cardinality.rb
51
+ - lib/ontomde-uml2/check.rb
52
+ - lib/ontomde-uml2/uml2.rdfs.nt
53
+ - lib/ontomde-uml2/dotDiagram.rb
54
+ - lib/ontomde-uml2/nt_old_to_nt_new.sh
55
+ - lib/ontomde-uml2/createAndAdd.rb
56
+ - lib/ontomde-uml2/enumerated.rb
57
+ - lib/ontomde-uml2/select.rb
58
+ - lib/ontomde-uml2/salvageErrors.rb
59
+ - lib/ontomde-uml2/multipleInheritance.rb
60
+ - lib/ontomde-uml2/uml2.rb
61
+ - lib/ontomde-uml2/owner.rb
62
+ - lib/ontomde-uml2/versionSignature.rb
63
+ - lib/ontomde-uml2/depencies.rb
64
+ - lib/ontomde-uml2/extension.rb
65
+ - lib/ontomde-uml2/umlx.rb
66
+ - lib/ontomde-uml2/autoImplement.rb
67
+ - lib/ontomde-uml2/helper.rb
68
+ - lib/ontomde-uml2/shortcut.rb
69
+ - test/_test_perf.rb
70
+ - test/test_misc.rb
71
+ - test/test_base.rb
72
+ - test/test_ontomde-uml2.rb
73
+ - test/model/SID.emx
74
+ - test/model/SID.emx.nt
75
+ - test/model/simple2WithProfile.emx
76
+ - test/model/simple2.emx
77
+ - test/model/SID.uml2
78
+ - test/model/.project
79
+ - test/model/simple2.emx.nt
80
+ - test/test_clone.rb
81
+ - test/_test_dot.rb
82
+ has_rdoc: true
83
+ homepage: http://ontomde.rubyforge.org
84
+ post_install_message:
85
+ rdoc_options:
86
+ - --main
87
+ - README.txt
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 1.8.6
95
+ version:
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: 1.0.0
101
+ version:
102
+ requirements: []
103
+
104
+ rubyforge_project: ontomde
105
+ rubygems_version: 1.0.1
106
+ signing_key:
107
+ specification_version: 2
108
+ summary: OntoMDE UML2 handling cartridge
109
+ test_files:
110
+ - test/test_base.rb
111
+ - test/test_clone.rb
112
+ - test/test_misc.rb
113
+ - test/test_ontomde-uml2.rb