Commit 2fb3620a authored by balaskoa's avatar balaskoa
Browse files

EncodeDecode: JSON tests added; BER test migration-first step


Signed-off-by: default avatarbalaskoa <Jeno.Balasko@ericsson.com>
parent a8c79c29
......@@ -88,21 +88,21 @@
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>src/cfgFile/testport_parameters</FolderPath>
<FolderPath>src/EncodeDecode/BER</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>src/done</FolderPath>
<FolderPath>src/cfgFile/testport_parameters</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
</FolderProperties>
</FolderResource>
<FolderResource>
<FolderPath>src/json</FolderPath>
<FolderPath>src/done</FolderPath>
<FolderProperties>
<CentralStorage>false</CentralStorage>
<ExcludeFromBuild>true</ExcludeFromBuild>
......
......@@ -27,8 +27,14 @@
"src/recofOper/config.cfg" #only for init! (58 pass)
[EXECUTE]
#all_from_with_functions #TODO: JSON enc-dec function handling,
#encdec_OK #TODO: JSON, BER encoder
#encdec_OK #TODO: JSON, BER, TEXT encoder
#TbitstrOper.tc__value_list_bs #fails
#### EncodeDecode folder #####
## JsonBasicTestFolder ##
#JsonBasicASN1EncDecTest1.tc_asn1_bs2bs #fails in java
#JsonBasicEncDecTest_bs #2 error
#cstr_content.tc_unichar_utf8_mp2
#TcharstrOper.tc_altstep_cs_idx # bring back the uncommented test!
#TmultipleRedirects.commMessageDecodedValueRedirect #error JSON encode is missing
......
......@@ -125,6 +125,14 @@ no.control
#customEncoding: not implemented codings!
#defaultOper:
#TdefaultOper #ok, parallel
#### EncodeDecode folder #####
## BER
#TODO: develop BER encode-decode
## JSON:
## JsonBasicTestFolder ##
##TODO: meve here the json folder!
#enumOper:
TenumOper.control
EnumDefBitHexOct
......
......@@ -4,18 +4,26 @@
# This section shall contain the values of all parameters that are defined in your TTCN-3 modules.
[ORDERED_INCLUDE]
#"src/templatePatternRef/config.cfg"
[EXECUTE]
#### EncodeDecode folder #####
## JsonBasicTestFolder ##
JsonBasicASN1EncDecTest1.tc_asn1_i2bs
#JsonBasicASN1EncDecTest1.tc_asn1_bs2bs #fails in java
JsonBasicASN1EncDecTest1.tc_asn1_bool2bs
JsonBasicAttributeTest
#JsonBasicEncDecTest_bs #2 error
[LOGGING]
# In this section you can specify the name of the log file and the classes of events
# you want to log into the file or display on console (standard error).
LogFile := "logs/%e.%h-%r_experimental.%s"
FileMask := LOG_ALL #|TESTCASE | STATISTICS #|LOG_ALL #| DEBUG | MATCHING
ConsoleMask := LOG_ALL | ERROR | WARNING | TESTCASE | STATISTICS #| PORTEVENT | USER
FileMask := ACTION|DEFAULTOP|ERROR|FUNCTION|PARALLEL|PORTEVENT|STATISTICS|TESTCASE|TIMEROP|USER|VERDICTOP|WARNING|MATCHING #|TESTCASE | STATISTICS #|LOG_ALL #| DEBUG | MATCHING
ConsoleMask := ACTION|DEFAULTOP|ERROR|FUNCTION|PARALLEL|PORTEVENT|STATISTICS|TESTCASE|TIMEROP|USER|VERDICTOP|WARNING|MATCHING
AppendFile := No
TimeStampFormat := Time
LogEventTypes := No
SourceInfoFormat := Single
LogEventTypes := Yes
SourceInfoFormat := Stack
LogEntityName := Yes
\ No newline at end of file
--/////////////////////////////////////////////////////////////////////////////
-- Copyright (c) 2000-2020 Ericsson Telecom AB
-- All rights reserved. This program and the accompanying materials
-- are made available under the terms of the Eclipse Public License v2.0
-- which accompanies this distribution, and is available at
-- https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
--
-- Contributors:
-- Balasko, Jeno
-- Forstner, Matyas
-- Koppany, Csaba
-- Szabados, Kristof
-- Szabo, Janos Zoltan – initial implementation
--
--/////////////////////////////////////////////////////////////////////////////
BER1
DEFINITIONS
AUTOMATIC TAGS
EXTENSIBILITY IMPLIED
::=
BEGIN
EXPORTS T4, c4e, c6a;
IMPORTS ;
T0 ::= NULL
c0a T0 ::= NULL
d0a OCTET STRING ::= '0500'H
T1 ::= BOOLEAN
c1a T1 ::= TRUE
d1a OCTET STRING ::= '0101FF'H
c1b T1 ::= FALSE
d1b OCTET STRING ::= '010100'H
T2 ::= [APPLICATION 1] EXPLICIT [PRIVATE v2] [APPLICATION 3] EXPLICIT [PRIVATE 20021018] T1
c2a T2 ::= c1a
d2a OCTET STRING ::= '6109E307DF89C5FE1A01FF'H
c2b T2 ::= c1b
d2b OCTET STRING ::= '6109E307DF89C5FE1A0100'H
v1 INTEGER ::= 2002
v2 INTEGER ::= 3
v3 INTEGER {v1(v2), v2(v1)} ::= v2 -- 2002
T3 ::= [c3a] EXPLICIT INTEGER {zero(0), v1(1492), v2(v3)}
c3a T3 ::= v1 -- 1492
d3a OCTET STRING ::= 'BF8B5404020205D4'H
c3b T3 ::= v2 -- 2002
d3b OCTET STRING ::= 'BF8B5404020207D2'H
c3c T3 ::= 0
d3c OCTET STRING ::= 'BF8B5403020100'H
c3d T3 ::= 127
d3d OCTET STRING ::= 'BF8B540302017F'H
c3e T3 ::= 128
d3e OCTET STRING ::= 'BF8B540402020080'H
c3f T3 ::= 32767
d3f OCTET STRING ::= 'BF8B540402027FFF'H
c3g T3 ::= 32768
d3g OCTET STRING ::= 'BF8B54050203008000'H
c3h T3 ::= 8388607
d3h OCTET STRING ::= 'BF8B540502037FFFFF'H
c3i T3 ::= 8388608
d3i OCTET STRING ::= 'BF8B5406020400800000'H
c3j T3 ::= 2147483647
d3j OCTET STRING ::= 'BF8B540602047FFFFFFF'H
c3k T3 ::= -128
d3k OCTET STRING ::= 'BF8B5403020180'H
c3l T3 ::= -129
d3l OCTET STRING ::= 'BF8B54040202FF7F'H
c3m T3 ::= -32768
d3m OCTET STRING ::= 'BF8B540402028000'H
c3n T3 ::= -32769
d3n OCTET STRING ::= 'BF8B54050203FF7FFF'H
c3o T3 ::= -8388608
d3o OCTET STRING ::= 'BF8B54050203800000'H
c3p T3 ::= -8388609
d3p OCTET STRING ::= 'BF8B54060204FF7FFFFF'H
c3q T3 ::= -2147483648
d3q OCTET STRING ::= 'BF8B5406020480000000'H
T4 ::= ENUMERATED {three(v2), one, zero(0), minusone(-1), two}
c4a T4 ::= minusone
c4b T4 ::= zero
c4c T4 ::= one
c4d T4 ::= two
c4e T4 ::= three
d4a OCTET STRING ::= '0A01FF'H
d4b OCTET STRING ::= '0A0100'H
d4c OCTET STRING ::= '0A0101'H
d4d OCTET STRING ::= '0A0102'H
d4e OCTET STRING ::= '0A0103'H
T5 ::= REAL
c5a T5 ::= PLUS-INFINITY
c5b T5 ::= MINUS-INFINITY
c5c T5 ::= 0
c5d T5 ::= {mantissa v2, base 10, exponent 2} -- 300.0
c5e T5 ::= {mantissa 3, base 2, exponent 4} -- 48.0
c5f T5 ::= 0.34
d5a OCTET STRING ::= '090140'H
d5b OCTET STRING ::= '090141'H
d5c OCTET STRING ::= '0900'H
d5d OCTET STRING ::= '090503 33 2E45 32'H -- 3 .E 2
d5e OCTET STRING ::= '090703 3438 2E45 2B 30'H -- 48 .E + 0
d5f OCTET STRING ::= '090703 3334 2E45 2D 32'H -- 34 .E - 2
T6 ::= BIT STRING {first(0), third(v2)}
c6a T6 ::= '11000011'B
c6b T6 ::= 'A'H
c6c T6 ::= {}
c6d T6 ::= ''H
c6e T6 ::= '0'B
c6f T6 ::= {first, third}
d6a OCTET STRING ::= '030200C3'H
d6b OCTET STRING ::= '030204A0'H
d6c OCTET STRING ::= '030100'H
d6d OCTET STRING ::= d6c
d6e OCTET STRING ::= '03020700'H
T7 ::= OCTET STRING
c7a T7 ::= '11000011'B
c7b T7 ::= 'A'H
c7c T7 ::= 'FABAB'H
c7d T7 ::= ''H
c7e T7 ::= '0'B
d7a OCTET STRING ::= '0401C3'H
d7b OCTET STRING ::= '0401A0'H
d7c OCTET STRING ::= '0403FABAB0'H
d7d OCTET STRING ::= '0400'H
d7e OCTET STRING ::= '040100'H
T8 ::= OBJECT IDENTIFIER
c8a T8 ::= {iso member-body bsi(826) disc(0) ericsson(1249)}
c8b T8 ::= {itu-t identified-organization etsi(0) reserved(127)
etsi-identified-organization(0) ericsson(5) 3 4}
d8a OCTET STRING ::= '06062A863A008961'H
d8b OCTET STRING ::= '060704007F00050304'H
END
--/////////////////////////////////////////////////////////////////////////////
-- Copyright (c) 2000-2019 Ericsson Telecom AB
-- All rights reserved. This program and the accompanying materials
-- are made available under the terms of the Eclipse Public License v2.0
-- which accompanies this distribution, and is available at
-- https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
--
-- Contributors:
-- Balasko, Jeno
-- Forstner, Matyas
-- Koppany, Csaba
-- Szabados, Kristof
--
--/////////////////////////////////////////////////////////////////////////////
BER2
DEFINITIONS
AUTOMATIC TAGS
EXTENSIBILITY IMPLIED
::=
BEGIN
EXPORTS ;
IMPORTS c6a, T4, c4e FROM BER1;
T10 ::= CHOICE {
f1 BOOLEAN,
f2 CHOICE {
f1 INTEGER,
f2 BIT STRING
}
}
c10a T10 ::= f1 : TRUE
c10b T10 ::= f2 : f2 : c6a
d10a OCTET STRING ::= '8001FF'H
d10b OCTET STRING ::= 'A104810200C3'H
T11 ::= [APPLICATION 1] CHOICE {
f12 T12,
f13 T13,
f14 T14,
f15 T15,
f16 T16,
f17 T17,
f18 T18,
f19 T19,
f20 T20,
f21 T21,
f22 T22
}
T12 ::= SEQUENCE {
f1 INTEGER,
f2 [3] BOOLEAN
}
c11-12a T11 ::= f12 : {f1 3, f2 TRUE}
d11-12a OCTET STRING ::= '6108A0060201038301FF'H
T13 ::= SEQUENCE {
f-mand INTEGER,
f-opt INTEGER OPTIONAL,
f-def INTEGER DEFAULT 2002
}
c11-13a T11 ::= f13 : {f-mand 255, f-def 2002}
d11-13a OCTET STRING ::= '6106A104800200FF'H
c11-13b T11 ::= f13 : {f-mand -255, f-opt 83, f-def 0}
d11-13b OCTET STRING ::= '610CA10A8002FF01810153820100'H
T14 ::= SEQUENCE {
f1 INTEGER,
f2 OCTET STRING,
COMPONENTS OF T13,
f3 NULL OPTIONAL
}
c11-14a T11 ::= f14 : {f1 3378, f2 'BA3'H, f-mand -553}
d11-14a OCTET STRING ::= '610EA20C80020D328102BA308202FDD7'H
c11-14b T11 ::= f14 : {f1 245, f2 '110'B, f-mand 337, f-def -1, f3 NULL}
d11-14b OCTET STRING ::= '6112A210800200F58101C0820201518401FF8500'H
T15 ::= SEQUENCE {
f3 T4,
COMPONENTS OF T12
}
c11-15a T11 ::= f15 : {f3 c4e, f1 -337, f2 FALSE}
d11-15a OCTET STRING ::= '610CA30A8001038102FEAF820100'H
T16 ::= SEQUENCE OF INTEGER
c11-16a T11 ::= f16 : {1, 2, 3, 4}
c11-16b T11 ::= f16 : {}
d11-16a OCTET STRING ::= '610EA40C020101020102020103020104'H
d11-16b OCTET STRING ::= '6102A400'H
T17 ::= SEQUENCE OF T11
c11-17a T11 ::= f17 : {c11-15a, c11-16a, c11-13b, c11-14b, c11-12a}
d11-17a OCTET STRING ::='614CA54A610CA30A8001038102FEAF820100610E
A40C020101020102020103020104610CA10A8002FF018101538201006112A21
0800200F58101C0820201518401FF85006108A0060201038301FF'H
T18 ::= SET {
f1 INTEGER,
...,
f4 OCTET STRING,
f5 BIT STRING OPTIONAL,
...,
f2 BOOLEAN DEFAULT TRUE,
f3 NULL
}
c11-18a T11 ::= f18 : {f1 18, f3 NULL, f4 '101'H, f5 'B'H}
d11-18a OCTET STRING ::= '610F A60D 800112 8200 83021010 840204B0'H
T19 ::= SET OF INTEGER
c11-19a T11 ::= f19 : {4, 2, 3, 1}
c11-19b T11 ::= f19 : {}
c11-19c T11 ::= f19 : {4, 2, 3, 1, 4}
d11-19a OCTET STRING ::= '610EA70C020101020102020103020104'H
d11-19b OCTET STRING ::= '6102A700'H
d11-19c OCTET STRING ::= '6111A70F020101020102020103020104020104'H
T20 ::= EXTERNAL
c11-20a T11 ::= f20 : {
identification presentation-context-id : 555,
data-value-descriptor "What is the matter?",
data-value '00FF00'H
}
d11-20a OCTET STRING ::=
'6120 A81E 0202022B 07135768617420697320746865206D61747465723F 810300FF00'H
etsi-objid RELATIVE-OID ::= {itu-t(0) identified-organization(4) etsi(0)}
etsi-ericsson RELATIVE-OID ::= {reserved(127) etsi-identified-organization(0)
ericsson(5) 3 4}
T21 ::= RELATIVE-OID
c11-21a T11 ::= f21 : {iso(1) member-body(2) bsi(826) disc(0)
ericsson(1249)}
c11-21b T11 ::= f21 : {etsi-objid etsi-ericsson}
d11-21a OCTET STRING ::= '610989070102863A008961'H
d11-21b OCTET STRING ::= '610A89080004007F00050304'H
nagykisarvizturo UniversalString ::=
{nagyarvizturo, " ", {0,0,0,173}, " ", kisarvizturo}
/* UTF8: ... 20C2AD20 ... */
nagyarvizturo UniversalString ::= {
{0,0,0,193}, "RV", {0,0,0,205}, "ZT", {0,0,1,112}, "R", {0,0,1,80},
" T", {0,0,0,220}, "K", {0,0,0,214}, "RF", {0,0,0,218}, "R", {0,0,0,211}, "G", {0,0,0,201}, "P"
}
/*
UTF8: "
c3815256 c38d5a54 c5b052c5 902054c3
9c4bc396 5246c39a 52c39347 c38950
"
*/
kisarvizturo UniversalString ::= {
{0,0,0,225}, "rv", {0,0,0,237}, "zt", {0,0,1,113}, "r", {0,0,1,81},
" t", {0,0,0,252}, "k", {0,0,0,246}, "rf", {0,0,0,250}, "r", {0,0,0,243}, "g", {0,0,0,233}, "p"
}
/*
UTF8: "
c3a17276 c3ad7a74 c5b172c5 912074c3
bc6bc3b6 7266c3ba 72c3b367 c3a970
"
*/
T22 ::= UTF8String
c11-22a T11 ::= f22 : nagykisarvizturo
d11-22a OCTET STRING ::=
'61448A42
C3815256C38D5A54C5B052C5902054C39C4BC3965246C39A52C39347C38950
20C2AD20
C3A17276C3AD7A74C5B172C5912074C3BC6BC3B67266C3BA72C3B367C3A970'H
/* extra checks for semantic analyzer */
/* extra check 1 */
XC-T2 ::= CHOICE {
f2 XC-T1,
f3 [2] XC-T1,
f4 NULL
}
XC-T1 ::= CHOICE {
f1 XC-T2
}
END
/******************************************************************************
* Copyright (c) 2000-2020 Ericsson Telecom AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html
*
* Contributors:
* Balasko, Jeno
* Beres, Szabolcs
* Forstner, Matyas
* Koppany, Csaba
* Kovacs, Ferenc
* Szabados, Kristof
* Szabo, Janos Zoltan – initial implementation
*
******************************************************************************/
module BERTest
{
import from BER1 language "ASN.1:1997" all
with {encode "DER:1997"};
import from BER2 language "ASN.1:1997" all
with {encode "DER:1997"};
//=== encoding functions ====
external function enc_ber_T0(in T0 r) return octetstring
with { extension "encode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" };
external function enc_ber_T1(in T1 r) return octetstring
with { extension "encode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" };
external function enc_ber_T2(in T2 r) return octetstring
with { extension "encode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" };
external function enc_ber_T3(in T3 r) return octetstring
with { extension "encode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" };
external function enc_ber_T4(in T4 r) return octetstring
with { extension "encode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" };
external function enc_ber_T5(in T5 r) return octetstring
with { extension "encode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" };
//=== decoding functions ====
external function dec_ber_T0(in octetstring r) return T0
with { extension "decode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" }
external function dec_ber_T1(in octetstring r) return T1
with { extension "decode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" }
external function dec_ber_T2(in octetstring r) return T2
with { extension "decode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" }
external function dec_ber_T3(in octetstring r) return T3
with { extension "decode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" }
external function dec_ber_T4(in octetstring r) return T4
with { extension "decode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" }
external function dec_ber_T5(in octetstring r) return T5
with { extension "decode(BER:BER_ENCODE_DER) prototype(convert) errorbehavior(ALL:WARNING)" }
//=== functions ====
function f_compare_octetstring(in octetstring pl_val, in octetstring pl_expected) {
if ( pl_val == pl_expected ){
setverdict(pass);
} else {
setverdict( fail, "expected:", pl_expected, " got: ", pl_val)
}
} with { extension "transparent"}
//==== types
type component CT { }
//==== Testcases =====
testcase TC0a() runs on CT {
var octetstring encoded, expected;
encoded := enc_ber_T0(c0a);
log(encoded);
f_compare_octetstring(encoded,d0a);
var T0 decoded := dec_ber_T0(encoded);
log(decoded);
if ( decoded == c0a ) {
setverdict(pass)
} else {
setverdict(fail, "Expected: ", c0a, " got: ",decoded);
}
}
testcase TC1a() runs on CT {
var octetstring encoded, expected;
encoded := enc_ber_T1(c1a);
log(encoded);
f_compare_octetstring(encoded,d1a);
var T1 decoded := dec_ber_T1(encoded);
log(decoded);
if ( decoded == c1a ) {
setverdict(pass)
} else {
setverdict(fail, "Expected: ", c1a, " got: ",decoded);
}
}
testcase TC2a() runs on CT {
var octetstring encoded, expected;
encoded := enc_ber_T2(c2a);
log(encoded);
f_compare_octetstring(encoded,d2a);
var T2 decoded := dec_ber_T2(encoded);
log(decoded);
if ( decoded == c2a ) {
setverdict(pass)
} else {
setverdict(fail, "Expected: ", c2a, " got: ",decoded);
}
}
testcase TC2b() runs on CT {
var octetstring encoded, expected;
encoded := enc_ber_T2(c2b);
log(encoded);
f_compare_octetstring(encoded,d2b);
var T2 decoded := dec_ber_T2(encoded);
log(decoded);
if ( decoded == c2b ) {
setverdict(pass)
} else {
setverdict(fail, "Expected: ", c2b, " got: ",decoded);
}
}
testcase TC3a() runs on CT {
var octetstring encoded, expected;
encoded := enc_ber_T3(c3a);
log(encoded);
f_compare_octetstring(encoded,d3a);
var T3 decoded := dec_ber_T3(encoded);
log(decoded);
if ( decoded == c3a ) {
setverdict(pass)
} else {
setverdict(fail, "Expected: ", c3a, " got: ",decoded);
}
}
testcase TC3b() runs on CT {
var octetstring encoded, expected;
encoded := enc_ber_T3(c3b);
log(encoded);
f_compare_octetstring(encoded,d3b);
var T3 decoded := dec_ber_T3(encoded);
log(decoded);
if ( decoded == c3b ) {
setverdict(pass)
} else {
setverdict(fail, "Expected: ", c3b, " got: ",decoded);
}
}
type record of T3 RoT3;
type record of octetstring RoOS;
testcase TC3c() runs on CT {
var octetstring encoded, expected;
var T3 decoded;
const RoT3 c3list := { c3c, c3d, c3e, c3f, c3g, c3h, c3i, c3j, c3k, c3l, c3m, c3n, c3o, c3p, c3q }
const RoOS d3list := { d3c, d3d, d3e, d3f, d3g, d3h, d3i, d3j, d3k, d3l, d3m, d3n, d3o, d3p, d3q }
const integer N := sizeof(c3list);
for( var integer i := 0; i<N; i:=i+1){
encoded := enc_ber_T3(c3list[i]);
log(encoded);
f_compare_octetstring(encoded,d3list[i]);
decoded := dec_ber_T3(encoded);
log(decoded);
if ( decoded == c3list[i] ) {
setverdict(pass)
} else {
setverdict(fail, "Expected: ", c3list[i], " got: ",decoded);
}
}
}
type record of T4 RoT4;