@@ -21,7 +21,7 @@ describe("makeRelativePath",function() {
2121 var aggregatesReferenceTypeNodeId = resolveNodeId ( "Aggregates" ) ;
2222 var sinon = require ( "sinon" ) ;
2323
24- it ( "T1 should construct simple RelativePath for '/' " , function ( ) {
24+ it ( "T1 should construct simple RelativePath for '/' " , function ( ) {
2525 var relativePath = makeRelativePath ( "/" ) ;
2626 relativePath . elements . length . should . eql ( 1 ) ;
2727 relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
@@ -32,7 +32,7 @@ describe("makeRelativePath",function() {
3232 } ) ) ;
3333 } ) ;
3434
35- it ( "T2 should construct simple RelativePath for '.' " , function ( ) {
35+ it ( "T2 should construct simple RelativePath for '.' " , function ( ) {
3636 var relativePath = makeRelativePath ( "." ) ;
3737 relativePath . elements . length . should . eql ( 1 ) ;
3838 relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
@@ -43,7 +43,7 @@ describe("makeRelativePath",function() {
4343 } ) ) ;
4444 } ) ;
4545
46- it ( "T3 should construct simple RelativePath for '<HasChild>' " , function ( ) {
46+ it ( "T3 should construct simple RelativePath for '<HasChild>' " , function ( ) {
4747 var relativePath = makeRelativePath ( "<HasChild>" ) ;
4848 relativePath . elements . length . should . eql ( 1 ) ;
4949 relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
@@ -54,7 +54,7 @@ describe("makeRelativePath",function() {
5454 } ) ) ;
5555 } ) ;
5656
57- it ( "T4 should construct simple RelativePath for '<#HasChild>' " , function ( ) {
57+ it ( "T4 should construct simple RelativePath for '<#HasChild>' " , function ( ) {
5858 var relativePath = makeRelativePath ( "<#HasChild>" ) ;
5959 relativePath . elements . length . should . eql ( 1 ) ;
6060 relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
@@ -65,7 +65,7 @@ describe("makeRelativePath",function() {
6565 } ) ) ;
6666 } ) ;
6767
68- it ( "T5 should construct simple RelativePath for '<!HasChild>' " , function ( ) {
68+ it ( "T5 should construct simple RelativePath for '<!HasChild>' " , function ( ) {
6969 var relativePath = makeRelativePath ( "<!HasChild>" ) ;
7070 relativePath . elements . length . should . eql ( 1 ) ;
7171 relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
@@ -75,7 +75,7 @@ describe("makeRelativePath",function() {
7575 targetName : new QualifiedName ( { } )
7676 } ) ) ;
7777 } ) ;
78- it ( "T6 should construct simple RelativePath for '<#!HasChild>' " , function ( ) {
78+ it ( "T6 should construct simple RelativePath for '<#!HasChild>' " , function ( ) {
7979 var relativePath = makeRelativePath ( "<#!HasChild>" ) ;
8080 relativePath . elements . length . should . eql ( 1 ) ;
8181 relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
@@ -85,7 +85,7 @@ describe("makeRelativePath",function() {
8585 targetName : new QualifiedName ( { } )
8686 } ) ) ;
8787 } ) ;
88- it ( "T7 should construct simple RelativePath for '/3:Truck'" , function ( ) {
88+ it ( "T7 should construct simple RelativePath for '/3:Truck'" , function ( ) {
8989
9090 var relativePath = makeRelativePath ( "/3:Truck" ) ;
9191 relativePath . elements . length . should . eql ( 1 ) ;
@@ -101,7 +101,7 @@ describe("makeRelativePath",function() {
101101 // “/3:Truck.0:NodeVersion”
102102 // Follows any forward hierarchical Reference with target BrowseName = “3:Truck” and from there a forward
103103 // Aggregates Reference to a target with BrowseName “0:NodeVersion”.
104- it ( "T8 should construct simple RelativePath for '/3:Truck.0:NodeVersion' " , function ( ) {
104+ it ( "T8 should construct simple RelativePath for '/3:Truck.0:NodeVersion' " , function ( ) {
105105
106106 var relativePath = makeRelativePath ( "/3:Truck.0:NodeVersion" ) ;
107107 relativePath . elements . length . should . eql ( 2 ) ;
@@ -121,7 +121,7 @@ describe("makeRelativePath",function() {
121121 } ) ;
122122
123123 /// “/2:Block&.Output” Follows any forward hierarchical Reference with target BrowseName = “2:Block.Output”.
124- it ( "T9 should construct simple RelativePath for '/2:Block&.Output'" , function ( ) {
124+ it ( "T9 should construct simple RelativePath for '/2:Block&.Output'" , function ( ) {
125125 var relativePath = makeRelativePath ( "/2:Block&.Output" ) ;
126126
127127 relativePath . elements . length . should . eql ( 1 ) ;
@@ -138,17 +138,17 @@ describe("makeRelativePath",function() {
138138 // Follows any forward Reference with a BrowseName = ‘1:ConnectedTo’ and
139139 // finds targets with BrowseName = ‘1:Boiler’. From there follows any hierarchical
140140 // Reference and find targets with BrowseName = ‘1:HeatSensor’.
141- it ( "TA should construct simple RelativePath for '<1:ConnectedTo>1:Boiler/1:HeatSensor'" , function ( ) {
141+ it ( "TA should construct simple RelativePath for '<1:ConnectedTo>1:Boiler/1:HeatSensor'" , function ( ) {
142142
143143 var sinon = require ( "sinon" ) ;
144144 var addressSpace = {
145- findReferenceType : sinon . stub ( ) . returns ( makeNodeId ( 555 , 1 ) )
145+ findReferenceType : sinon . stub ( ) . returns ( makeNodeId ( 555 , 1 ) )
146146 } ;
147- var relativePath = makeRelativePath ( "<1:ConnectedTo>1:Boiler/1:HeatSensor" , addressSpace ) ;
147+ var relativePath = makeRelativePath ( "<1:ConnectedTo>1:Boiler/1:HeatSensor" , addressSpace ) ;
148148
149149 relativePath . elements . length . should . eql ( 2 ) ;
150150 relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
151- referenceTypeId : makeNodeId ( 555 , 1 ) ,
151+ referenceTypeId : makeNodeId ( 555 , 1 ) ,
152152 isInverse : false ,
153153 includeSubtypes : true ,
154154 targetName : new QualifiedName ( { namespaceIndex : 1 , name : "Boiler" } )
@@ -166,20 +166,20 @@ describe("makeRelativePath",function() {
166166 // “<1:ConnectedTo>1:Boiler/”
167167 // Follows any forward Reference with a BrowseName = ‘1:ConnectedTo’ and finds targets
168168 // with BrowseName = ‘1:Boiler’. From there it finds all targets of hierarchical References.
169- it ( "TB should construct simple RelativePath for '<1:ConnectedTo>1:Boiler/'" , function ( ) {
169+ it ( "TB should construct simple RelativePath for '<1:ConnectedTo>1:Boiler/'" , function ( ) {
170170
171171 var sinon = require ( "sinon" ) ;
172172 var addressSpace = {
173- findReferenceType : sinon . stub ( ) . returns ( makeNodeId ( 555 , 1 ) )
173+ findReferenceType : sinon . stub ( ) . returns ( makeNodeId ( 555 , 1 ) )
174174 } ;
175- var relativePath = makeRelativePath ( "<1:ConnectedTo>1:Boiler/" , addressSpace ) ;
175+ var relativePath = makeRelativePath ( "<1:ConnectedTo>1:Boiler/" , addressSpace ) ;
176176
177177 addressSpace . findReferenceType . getCall ( 0 ) . args [ 0 ] . should . eql ( "ConnectedTo" ) ;
178178 addressSpace . findReferenceType . getCall ( 0 ) . args [ 1 ] . should . eql ( 1 ) ;
179179
180180 relativePath . elements . length . should . eql ( 2 ) ;
181181 relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
182- referenceTypeId : makeNodeId ( 555 , 1 ) ,
182+ referenceTypeId : makeNodeId ( 555 , 1 ) ,
183183 isInverse : false ,
184184 includeSubtypes : true ,
185185 targetName : new QualifiedName ( { namespaceIndex : 1 , name : "Boiler" } )
@@ -197,7 +197,7 @@ describe("makeRelativePath",function() {
197197 // Follows any forward Reference with a BrowseName = ‘HasChild’ and qualified
198198 // with the default OPC UA namespace. Then find targets with BrowseName =
199199 // ‘Wheel’ qualified with namespace index ‘2’.
200- it ( "TC should construct simple RelativePath for '<0:HasChild>2:Wheel'" , function ( ) {
200+ it ( "TC should construct simple RelativePath for '<0:HasChild>2:Wheel'" , function ( ) {
201201 var addressSpace = {
202202 findReferenceType : sinon . stub ( ) . returns ( makeNodeId ( 555 , 1 ) )
203203 } ;
@@ -218,7 +218,7 @@ describe("makeRelativePath",function() {
218218 // “<!HasChild>Truck”
219219 // Follows any inverse Reference with a BrowseName = ‘HasChild’. Then find targets with BrowseName = ‘Truck’.
220220 // In both cases, the namespace component of the BrowseName is assumed to be 0.
221- it ( "TD should construct simple RelativePath for '<!HasChild>2:Wheel'" , function ( ) {
221+ it ( "TD should construct simple RelativePath for '<!HasChild>2:Wheel'" , function ( ) {
222222 var addressSpace = {
223223 findReferenceType : sinon . stub ( ) . returns ( makeNodeId ( 555 , 1 ) )
224224 } ;
@@ -237,7 +237,7 @@ describe("makeRelativePath",function() {
237237 // “<0:HasChild>”
238238 // Finds all targets of forward References with a BrowseName = ‘HasChild’
239239 // and qualified with the default OPC UA namespace.
240- it ( "TE should construct simple RelativePath for '<0:HasChild>'" , function ( ) {
240+ it ( "TE should construct simple RelativePath for '<0:HasChild>'" , function ( ) {
241241
242242 var addressSpace = {
243243 findReferenceType : sinon . stub ( ) . returns ( resolveNodeId ( "HasChild" ) )
@@ -257,7 +257,7 @@ describe("makeRelativePath",function() {
257257 } ) ) ;
258258 } ) ;
259259
260- it ( "TF should construct simple RelativePath for '<Organizes>Server.ServerStatus.CurrentTime'" , function ( ) {
260+ it ( "TF should construct simple RelativePath for '<Organizes>Server.ServerStatus.CurrentTime'" , function ( ) {
261261
262262 var relativePath = makeRelativePath ( "<Organizes>Server.ServerStatus.CurrentTime" , null ) ;
263263
@@ -267,7 +267,7 @@ describe("makeRelativePath",function() {
267267 referenceTypeId : resolveNodeId ( "Organizes" ) ,
268268 isInverse : false ,
269269 includeSubtypes : true ,
270- targetName : new QualifiedName ( { namespaceIndex :0 , name : "Server" } )
270+ targetName : new QualifiedName ( { namespaceIndex : 0 , name : "Server" } )
271271 } ) ) ;
272272 relativePath . elements [ 1 ] . should . eql ( new RelativePathElement ( {
273273 referenceTypeId : aggregatesReferenceTypeNodeId ,
@@ -279,11 +279,11 @@ describe("makeRelativePath",function() {
279279 referenceTypeId : aggregatesReferenceTypeNodeId ,
280280 isInverse : false ,
281281 includeSubtypes : true ,
282- targetName : new QualifiedName ( { namespaceIndex :0 , name : "CurrentTime" } )
282+ targetName : new QualifiedName ( { namespaceIndex : 0 , name : "CurrentTime" } )
283283 } ) ) ;
284284 } ) ;
285285
286- it ( "TF should construct simple RelativePath for '<Organizes>Server2.ServerStatus.1.2'" , function ( ) {
286+ it ( "TG should construct simple RelativePath for '<Organizes>Server2.ServerStatus.1.2'" , function ( ) {
287287
288288 var relativePath = makeRelativePath ( "<Organizes>Server2.ServerStatus.100.200" , null ) ;
289289
@@ -293,7 +293,7 @@ describe("makeRelativePath",function() {
293293 referenceTypeId : resolveNodeId ( "Organizes" ) ,
294294 isInverse : false ,
295295 includeSubtypes : true ,
296- targetName : new QualifiedName ( { namespaceIndex :0 , name : "Server2" } )
296+ targetName : new QualifiedName ( { namespaceIndex : 0 , name : "Server2" } )
297297 } ) ) ;
298298 relativePath . elements [ 1 ] . should . eql ( new RelativePathElement ( {
299299 referenceTypeId : aggregatesReferenceTypeNodeId ,
@@ -305,9 +305,51 @@ describe("makeRelativePath",function() {
305305 referenceTypeId : aggregatesReferenceTypeNodeId ,
306306 isInverse : false ,
307307 includeSubtypes : true ,
308- targetName : new QualifiedName ( { namespaceIndex :0 , name : "100" } )
308+ targetName : new QualifiedName ( { namespaceIndex : 0 , name : "100" } )
309309 } ) ) ;
310310
311311 } ) ;
312+ it ( "TH should construct simple RelativePath for '/3:TOTO/1:Channel#1/2:TOTO'" , function ( ) {
313+
314+ // note : # is a reserved char and must be prepended with &
315+ var relativePath = makeRelativePath ( "/3:Tag1/1:Channel/2:Tag2" , null ) ;
312316
317+ relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
318+ referenceTypeId : hierarchicalReferenceTypeNodeId ,
319+ isInverse : false ,
320+ includeSubtypes : true ,
321+ targetName : new QualifiedName ( { namespaceIndex : 3 , name : "Tag1" } )
322+ } ) ) ;
323+ relativePath . elements [ 1 ] . should . eql ( new RelativePathElement ( {
324+ referenceTypeId : hierarchicalReferenceTypeNodeId ,
325+ isInverse : false ,
326+ includeSubtypes : true ,
327+ targetName : new QualifiedName ( { namespaceIndex : 1 , name : "Channel#1" } )
328+ } ) ) ;
329+ relativePath . elements [ 2 ] . should . eql ( new RelativePathElement ( {
330+ referenceTypeId : hierarchicalReferenceTypeNodeId ,
331+ isInverse : false ,
332+ includeSubtypes : true ,
333+ targetName : new QualifiedName ( { namespaceIndex : 2 , name : "Tag2" } )
334+ } ) ) ;
335+
336+ } ) ;
337+ it ( "TI (issue#344) should construct simple RelativePath for '/0:Objects/2:test-path'" , function ( ) {
338+ // note : # is a reserved char and must be prepended with &
339+ var relativePath = makeRelativePath ( "/0:Objects/2:test-path" , null ) ;
340+
341+ relativePath . elements [ 0 ] . should . eql ( new RelativePathElement ( {
342+ referenceTypeId : hierarchicalReferenceTypeNodeId ,
343+ isInverse : false ,
344+ includeSubtypes : true ,
345+ targetName : new QualifiedName ( { namespaceIndex : 0 , name : "Objects" } )
346+ } ) ) ;
347+ relativePath . elements [ 1 ] . should . eql ( new RelativePathElement ( {
348+ referenceTypeId : hierarchicalReferenceTypeNodeId ,
349+ isInverse : false ,
350+ includeSubtypes : true ,
351+ targetName : new QualifiedName ( { namespaceIndex : 2 , name : "test-path" } )
352+ } ) ) ;
353+
354+ } ) ;
313355} ) ;
0 commit comments