Skip to content

Commit cb7460f

Browse files
committed
Merge branch 'jira-wdt-917-injectors' into 'main'
Fix paths in target injector, add unit test to check all files See merge request weblogic-cloud/weblogic-deploy-tooling!1748
2 parents 23b4043 + e9e11ff commit cb7460f

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2058,7 +2058,7 @@ WLSDPLY-19030=Failed to get the model attribute list that use path tokens for mo
20582058
at location ({1}): {2}
20592059
WLSDPLY-19031=Failed to determine if the model attribute name {0} at location ({1}) is valid: {2}
20602060
WLSDPLY-19032=Failed to get the default value for model attribute {0} at location ({1}): {2}
2061-
WLSDPLY-19033=Failed to determine if location ({0}) is valid for this version of WebLogic Server
2061+
WLSDPLY-19033=Failed to determine if location ({0}) is valid for this version of WebLogic Server: {1}
20622062
WLSDPLY-19034=Failed to get the model attribute list that require a special processing via a method for model \
20632063
folder ({0}) at location ({1}): {2}
20642064
WLSDPLY-19035=Failed to determine if the location ({0}) allows custom folder types: {1}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
"""
2+
Copyright (c) 2024, Oracle and/or its affiliates.
3+
The Universal Permissive License (UPL), Version 1.0
4+
"""
5+
import os
6+
import unittest
7+
8+
from base_test import BaseTestCase
9+
from wlsdeploy.aliases.aliases import Aliases
10+
from wlsdeploy.aliases.location_context import LocationContext
11+
from wlsdeploy.aliases.validation_codes import ValidationCodes
12+
from wlsdeploy.util.model_context import ModelContext
13+
from wlsdeploy.util.model_translator import FileToPython
14+
15+
16+
class VariableInjectorFilesTest(BaseTestCase):
17+
"""
18+
Test the variable injector file contents.
19+
"""
20+
def __init__(self, *args):
21+
BaseTestCase.__init__(self, *args)
22+
self.INJECTORS_DIR = os.path.join(self.TEST_CONFIG_DIR, 'injectors')
23+
self.VALID_CODES = [ValidationCodes.VALID, ValidationCodes.CONTEXT_INVALID]
24+
25+
def setUp(self):
26+
model_context = ModelContext("test", {})
27+
self.aliases = Aliases(model_context, wls_version=self.ALIAS_WLS_VERSION)
28+
29+
def test_injector_files(self):
30+
"""
31+
Verify that paths in the injector files are valid.
32+
"""
33+
for file_name in os.listdir(self.INJECTORS_DIR):
34+
if file_name.endswith(".json"):
35+
file_path = os.path.join(self.INJECTORS_DIR, file_name)
36+
translator = FileToPython(file_path, use_ordering=True)
37+
injector_dict = translator.parse()
38+
for injector_path in injector_dict:
39+
elements = injector_path.split('.')
40+
location = LocationContext()
41+
for element in elements[:-1]:
42+
location.append_location(element)
43+
name_token = self.aliases.get_name_token(location)
44+
if name_token is not None:
45+
location.add_name_token(name_token, 'TOKEN')
46+
47+
code, _message = self.aliases.is_version_valid_location(location)
48+
is_valid = code in self.VALID_CODES
49+
self.assertEqual(is_valid, True, "Folder " + str(element) + " in path " + str(injector_path)
50+
+ " in injector file " + str(file_name) + " is not valid")
51+
52+
attribute_name = elements[-1]
53+
code, _message = self.aliases.is_valid_model_attribute_name(location, attribute_name)
54+
is_valid = code in self.VALID_CODES
55+
self.assertEqual(is_valid, True, "Attribute " + str(attribute_name) + " in path " +
56+
str(injector_path) + " in injector file " + str(file_name) + " is not valid")
57+
58+
59+
if __name__ == '__main__':
60+
unittest.main()

installer/src/main/lib/injectors/target.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
{
2-
"AppDeployment.Target": {},
2+
"Application.SubDeployment.Target": {},
3+
"Application.Target": {},
34
"CoherenceClusterSystemResource.CoherenceCacheConfig.Target": {},
5+
"CoherenceClusterSystemResource.SubDeployment.Target": {},
46
"CoherenceClusterSystemResource.Target": {},
7+
"CustomResource.SubDeployment.Target": {},
58
"FileStore.Target": {},
69
"ForeignJNDIProvider.Target": {},
710
"JDBCStore.Target": {},
11+
"JDBCSystemResource.SubDeployment.Target": {},
812
"JDBCSystemResource.Target": {},
9-
"JMSServer.SubDeployment.Target": {},
1013
"JMSServer.Target": {},
14+
"JMSSystemResource.SubDeployment.Target": {},
15+
"JMSSystemResource.Target": {},
1116
"Library.SubDeployment.Target": {},
1217
"Library.Target": {},
1318
"MailSession.Target": {},
@@ -36,5 +41,6 @@
3641
"VirtualHost.Target": {},
3742
"VirtualTarget.Target": {},
3843
"VirtualTarget.WebServer.Target": {},
44+
"WLDFSystemResource.SubDeployment.Target": {},
3945
"WLDFSystemResource.Target": {}
4046
}

0 commit comments

Comments
 (0)