Skip to content

Commit 2763bf8

Browse files
Merge pull request #78 from oracle/issue#74-parse-negative-integers
parse negative integers in YAML
2 parents 2f71ae1 + 26a1972 commit 2763bf8

File tree

3 files changed

+69
-39
lines changed

3 files changed

+69
-39
lines changed

core/src/main/antlr4/oracle/weblogic/deploy/yaml/Yaml.g4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ fragment FALSE_TEXT
260260
;
261261

262262
fragment INT_TEXT
263-
: [1-9] [0-9]*
263+
: [+-]? [1-9] [0-9]*
264264
;
265265

266266
fragment FLOAT_TEXT

core/src/test/python/validation_test.py

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ class ValidationTestCase(unittest.TestCase):
2222
_program_name = 'validation_test'
2323
_class_name = 'ValidationTestCase'
2424
_resources_dir = '../../test-classes'
25-
_model_file = _resources_dir + '/test_jms_mail.json'
26-
_variable_file = None
27-
_archive_file = None
2825
# _variable_file = _resources_dir + "/test_sub_variable_file.properties"
2926
# _model_file = _resources_dir + '/test_empty.json'
3027
# _variable_file = _resources_dir + "/test_invalid_variable_file.properties"
@@ -37,20 +34,15 @@ def setUp(self):
3734

3835
def testModelValidation(self):
3936

37+
_model_file = self._resources_dir + '/test_jms_mail.json'
4038
_method_name = 'testModelValidation'
4139

4240
mw_home = os.environ['MW_HOME']
4341
args_map = {
4442
'-oracle_home': mw_home,
45-
'-model_file': self._model_file
43+
'-model_file': _model_file
4644
}
4745

48-
if self._variable_file is not None:
49-
args_map['-variable_file'] = self._variable_file
50-
51-
if self._variable_file is not None:
52-
args_map['-archive_file'] = self._archive_file
53-
5446
model_context = ModelContext('ValidationTestCase', args_map)
5547

5648
try:
@@ -85,5 +77,43 @@ def testIsCompatibleDataType(self):
8577
class_name=self._class_name, method_name=_method_name)
8678
self.assertEqual(retval, True)
8779

80+
def testYamlModelValidation(self):
81+
"""
82+
Parse and validate a YAML model with '-' list type and attributes with negative values.
83+
"""
84+
85+
_model_file = self._resources_dir + '/simple-model.yaml'
86+
_archive_file = self._resources_dir + "/SingleAppDomain.zip"
87+
_method_name = 'testYamlModelValidation'
88+
89+
mw_home = os.environ['MW_HOME']
90+
args_map = {
91+
'-oracle_home': mw_home,
92+
'-model_file': _model_file,
93+
'-archive_file': _archive_file
94+
}
95+
96+
model_context = ModelContext('ValidationTestCase', args_map)
97+
98+
try:
99+
model_dictionary = FileToPython(model_context.get_model_file()).parse()
100+
model_validator = Validator(model_context,
101+
wlst_mode=WlstModes.ONLINE)
102+
return_code = model_validator.validate_in_tool_mode(model_dictionary,
103+
model_context.get_variable_file(),
104+
model_context.get_archive_file_name())
105+
self._logger.info('The Validator.validate_in_tool_mode() call returned {0}',
106+
Validator.ReturnCode.from_value(return_code),
107+
class_name=self._class_name, method_name=_method_name)
108+
except TranslateException, te:
109+
return_code = Validator.ReturnCode.STOP
110+
self._logger.severe('WLSDPLY-20009',
111+
self._program_name,
112+
model_context.get_model_file(),
113+
te.getLocalizedMessage(), error=te,
114+
class_name=self._class_name, method_name=_method_name)
115+
116+
self.assertNotEqual(return_code, Validator.ReturnCode.STOP)
117+
88118
if __name__ == '__main__':
89119
unittest.main()

core/src/test/resources/simple-model.yaml

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
domainInfo:
22
# The DOMAIN_TYPE field is for reference only. The actual type of domain created is controlled by
33
# the -domain_type parameter passed to the createDomain shell script.
4-
DOMAIN_TYPE: 'WLS'
54
AdminUserName: 'weblogic'
65
AdminPassword: 'welcome1'
76
ServerStartMode: 'prod'
@@ -10,6 +9,7 @@ topology:
109
Name: simple_domain
1110
Cluster:
1211
mycluster:
12+
MulticastTTL: -1
1313
Server:
1414
AdminServer:
1515
ListenAddress: 127.0.0.1
@@ -49,44 +49,44 @@ resources:
4949
MaxCapacity: 15
5050
TestTableName: SQL ISVALID
5151
TestConnectionsOnReserve: true
52-
Generic2:
53-
Target: mycluster
54-
JdbcResource:
55-
JDBCDataSourceParams:
56-
JNDIName: [
57-
jdbc/generic2,
58-
jdbc/special2
59-
]
60-
GlobalTransactionsProtocol: TwoPhaseCommit
61-
JDBCDriverParams:
62-
DriverName: oracle.jdbc.xa.client.OracleXADataSource
63-
URL : 'jdbc:oracle:thin:@//den00chv.us.oracle.com:1521/PDBORCL'
64-
PasswordEncrypted: welcome1
65-
Properties:
66-
user:
67-
Value: jshum
68-
oracle.net.CONNECT_TIMEOUT:
69-
Value: 5000
70-
oracle.jdbc.ReadTimeout:
71-
Value: 30000
72-
JDBCConnectionPoolParams:
73-
InitialCapacity: 3
74-
MaxCapacity: 15 # This is a comment
75-
TestTableName: SQL ISVALID # This is a comment
76-
TestConnectionsOnReserve: true # This is a comment
52+
Generic2:
53+
Target: mycluster
54+
JdbcResource:
55+
JDBCDataSourceParams:
56+
JNDIName: [
57+
jdbc/generic2,
58+
jdbc/special2
59+
]
60+
GlobalTransactionsProtocol: TwoPhaseCommit
61+
JDBCDriverParams:
62+
DriverName: oracle.jdbc.xa.client.OracleXADataSource
63+
URL : 'jdbc:oracle:thin:@//den00chv.us.oracle.com:1521/PDBORCL'
64+
PasswordEncrypted: welcome1
65+
Properties:
66+
user:
67+
Value: jshum
68+
oracle.net.CONNECT_TIMEOUT:
69+
Value: 5000
70+
oracle.jdbc.ReadTimeout:
71+
Value: 30000
72+
JDBCConnectionPoolParams:
73+
InitialCapacity: 3
74+
MaxCapacity: 15 # This is a comment
75+
TestTableName: SQL ISVALID # This is a comment
76+
TestConnectionsOnReserve: true # This is a comment
7777

7878
# This is a comment
7979
appDeployments:
8080
Application:
8181
# Quote needed because of hyphen in string
8282
'get-listen-address-app':
83-
SourcePath: 'wlsdeploy/apps/get-listen-address-app.war'
83+
SourcePath: 'wlsdeploy/applications/get-listen-address-app.war'
8484
Target: mycluster
8585
ModuleType: war
8686
StagingMode: nostage
8787
PlanStagingMode: nostage
8888
simpleear :
89-
SourcePath: wlsdeploy/apps/simpleear.ear
89+
SourcePath: wlsdeploy/applications/simpleear.ear
9090
Target: mycluster
9191
ModuleType: ear
9292
StagingMode: nostage

0 commit comments

Comments
 (0)