File tree Expand file tree Collapse file tree 2 files changed +46
-2
lines changed
main/java/oracle/weblogic/deploy/util
test/java/oracle/weblogic/deploy/util Expand file tree Collapse file tree 2 files changed +46
-2
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ public XPathUtil(String oracle_home){
37
37
this .oracle_home = oracle_home ;
38
38
patches_home = Paths .get (oracle_home , "inventory" , "patches" ).toString ();
39
39
}
40
+ public XPathUtil () {
41
+ // for testing only
42
+ }
40
43
private static XPathFactory factory = null ;
41
44
42
45
private static synchronized XPathFactory factory () {
@@ -64,15 +67,24 @@ public String getPSU() {
64
67
LOGGER .fine ("Description {0}" , descrip );
65
68
if (descrip != null && descrip .startsWith ("WLS PATCH SET UPDATE" )) {
66
69
int idx = descrip .lastIndexOf ('.' );
67
- String psu = descrip .substring (idx +1 );
68
- list .add (psu );
70
+ String psu = descrip .substring (idx +1 ). split ( "[ \\ d]+" )[ 0 ] ;
71
+ list .add (psu );
69
72
Collections .sort (list );
70
73
return list .get (list .size () -1 );
71
74
}
72
75
}
73
76
return null ;
74
77
}
75
78
79
+ public String extractPsu (String descrip ) {
80
+ int idx = descrip .lastIndexOf ('.' ) + 1 ;
81
+ int endIdx = descrip .length () - 1 ;
82
+ if (descrip .charAt (endIdx ) == ')' ) {
83
+ endIdx --;
84
+ }
85
+ return descrip .substring (idx , endIdx +1 );
86
+ }
87
+
76
88
/**
77
89
* Locate the patch files in the Oracle home
78
90
* @return list of patch file names.
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2017, 2022, Oracle Corporation and/or its affiliates.
3
+ * Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
4
+ */
5
+ package oracle .weblogic .deploy .util ;
6
+
7
+ import org .junit .jupiter .api .Test ;
8
+
9
+ import oracle .weblogic .deploy .util .XPathUtil ;
10
+
11
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
12
+
13
+ public class XPathUtilTest {
14
+
15
+ @ Test
16
+ void testPSUWithParen () {
17
+ XPathUtil util = new XPathUtil ();
18
+ String tester = new String (".2145)" );
19
+ String expected = new String ("2145" );
20
+ String actual = util .extractPsu (tester );
21
+ assertEquals (expected , actual );
22
+ }
23
+
24
+ @ Test
25
+ void testPSU () {
26
+ XPathUtil util = new XPathUtil ();
27
+ String tester = new String (".2145" );
28
+ String expected = new String ("2145" );
29
+ String actual = util .extractPsu (tester );
30
+ assertEquals (expected , actual );
31
+ }
32
+ }
You can’t perform that action at this time.
0 commit comments