-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadabas_message_test.go
111 lines (88 loc) · 4.52 KB
/
adabas_message_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
* Copyright © 2018-2025 Software GmbH, Darmstadt, Germany and/or its licensors
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package adabas
import (
"testing"
"github.com/SoftwareAG/adabas-go-api/adatypes"
"github.com/stretchr/testify/assert"
)
func TestAdabasMessageGeneric(t *testing.T) {
initTestLogWithFile(t, "messages.log")
err := adatypes.NewGenericError(2, "XX")
assert.Equal(t, "ADG0000002: Invalid Adabas command send: XX", err.Error())
err = adatypes.NewGenericError(21, "TESTMAP")
assert.Equal(t, "ADG0000021: Map TESTMAP not found", err.Error())
}
func TestAdabasMessage(t *testing.T) {
initTestLogWithFile(t, "messages.log")
assert.Equal(t, "Normal successful completion", adatypes.Translate("en", "ADAGE00000"))
assert.Equal(t, "Invalid command ID value was detected", adatypes.Translate("en", "ADAGE15000"))
assert.Equal(t, "Insufficient space in attached buffer", adatypes.Translate("en", "ADAGEFF000"))
assert.Equal(t, "Adabas versuchte eine ISN in Hold zu setzen die gerade bei einem anderen User in Hold gesetzt ist.", adatypes.Translate("de", "ADAGE02001"))
assert.Equal(t, "Funktion noch nicht implementiert", adatypes.Translate("de", "ADAGEFA000"))
// Not available in german, use english one
assert.Equal(t, "Compressed record area too small (internal error)", adatypes.Translate("de", "ADAGE05001"))
// Not available at all, use empty response
assert.Equal(t, "", adatypes.Translate("en", "ABC"))
}
func TestAdabasMessageError(t *testing.T) {
initTestLogWithFile(t, "messages.log")
ada, err := NewAdabas(21)
assert.NoError(t, err)
// Return: Hello, i18n
assert.Equal(t, "ADAGE94000: Adabas is not active or accessible (rsp=148,subrsp=0,dbid=21,file=0)", NewError(ada).Error())
ada.Acbx.Acbxrsp = AdaNormal
assert.Equal(t, "ADAGE00000: Normal successful completion (rsp=0,subrsp=0,dbid=21,file=0)", NewError(ada).Error())
ada.Acbx.Acbxrsp = AdaInvalidFileNumber
assert.Equal(t, "ADAGE11000: Invalid or unauthorized file number (rsp=17,subrsp=0,dbid=21,file=0)", NewError(ada).Error())
ada.Acbx.Acbxerrc = AdaISNNotSorted
assert.Equal(t, "ADAGE11001: The program tried to access system file 1 or 2, and no OP command was issued. (rsp=17,subrsp=1,dbid=21,file=0)", NewError(ada).Error())
ada.Acbx.Acbxrsp = 200
ada.Acbx.Acbxerrc = 199
assert.Equal(t, "ADAGEC80C7: Security violation (rsp=200,subrsp=199,dbid=21,file=0)", NewError(ada).Error())
ada.Acbx.Acbxrsp = 120
ada.Acbx.Acbxerrc = 0
assert.Equal(t, "ADAGE78000: Unknown response and subcode (rsp=120,subrsp=0,dbid=21,file=0)", NewError(ada).Error())
m := []string{"ADAGE78000", "Unknown error response 120 subcode 0 (ADAGE78000) (rsp=120,subrsp=0,dbid=21,file=0)"}
assert.Equal(t, m, ada.getAdabasMessage())
ada.Acbx.Acbxerrc = 0
ada.Acbx.Acbxerrc = 0
ada.status.version = "6.1.1.1"
assert.Equal(t, "6.1.1.1", ada.Version())
ada.status.platform = adatypes.NewPlatformIsl(553779200)
assert.Equal(t, "Open System,Low Order", ada.Platform())
ada.status.platform = adatypes.NewPlatformIsl(67108864)
assert.Equal(t, "Mainframe,High Order", ada.Platform())
}
func TestAdabasMessageTranslate(t *testing.T) {
initTestLogWithFile(t, "messages.log")
ada, err := NewAdabas(21)
assert.NoError(t, err)
// Return: Hello, i18n
assert.Equal(t, "Adabas ist nicht aktiv oder erreichbar (rsp=148,subrsp=0,dbid=21,file=0)", NewError(ada).Translate("de"))
ada.Acbx.Acbxrsp = AdaNormal
assert.Equal(t, "Erfolgreich beendet (rsp=0,subrsp=0,dbid=21,file=0)", NewError(ada).Translate("de"))
ada.Acbx.Acbxrsp = AdaInvalidFileNumber
assert.Equal(t, "Falsche oder nicht authorizierte File-Nummer (rsp=17,subrsp=0,dbid=21,file=0)", NewError(ada).Translate("de"))
ada.Acbx.Acbxerrc = AdaISNNotSorted
assert.Equal(t, "The program tried to access system file 1 or 2, and no OP command was issued. (rsp=17,subrsp=1,dbid=21,file=0)", NewError(ada).Translate("de"))
ada.Acbx.Acbxrsp = 120
ada.Acbx.Acbxerrc = 0
assert.Equal(t, "Unbekannter Response und Subcode Wert (rsp=120,subrsp=0,dbid=21,file=0)", NewError(ada).Translate("de"))
}