Skip to content

Commit d9cadfb

Browse files
committed
fix test cases, improve docker startup scripts
1 parent 437e617 commit d9cadfb

File tree

45 files changed

+332
-294
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+332
-294
lines changed

data-service/pom.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@
124124
</outputPaths>
125125
<container>
126126
<appRoot>/usr/local/tomcat/webapps/ROOT</appRoot>
127+
<jvmFlags>
128+
<jvmFlag>-server</jvmFlag>
129+
<jvmFlag>-Xmx512m</jvmFlag>
130+
</jvmFlags>
127131
<environment>
128132
<DATA_SERVICE_PROPS>/config/data-service.properties</DATA_SERVICE_PROPS>
129133
</environment>

data-service/src/main/java/password/pwm/receiver/PwmReceiverLogger.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525

2626
public class PwmReceiverLogger
2727
{
28-
private final Class clazz;
28+
private final Class<?> clazz;
2929

30-
private PwmReceiverLogger( final Class clazz )
30+
private PwmReceiverLogger( final Class<?> clazz )
3131
{
3232
this.clazz = clazz;
3333
}
3434

35-
public static PwmReceiverLogger forClass( final Class clazz )
35+
public static PwmReceiverLogger forClass( final Class<?> clazz )
3636
{
3737
return new PwmReceiverLogger( clazz );
3838
}

data-service/src/main/java/password/pwm/receiver/TestServlet.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

data-service/src/main/webapp/WEB-INF/jsp/telemetry-viewer.jsp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
<%@ page import="java.time.Instant" %>
2727
<%@ page import="password.pwm.receiver.PwmReceiverApp" %>
2828
<%@ page import="password.pwm.receiver.ContextManager" %>
29+
<%@ page import="password.pwm.util.java.StringUtil" %>
2930

3031
<!DOCTYPE html>
3132
<%@ page contentType="text/html" %>
@@ -35,10 +36,11 @@
3536
<head>
3637
<title>Telemetry Data</title>
3738
<link href="data-service-style.css" rel="stylesheet" type="text/css"/>
39+
<script src="https://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script>
3840
</head>
3941
<body>
4042
<div>
41-
Current Time: <%=Instant.now().toString()%>
43+
Current Time: <%=StringUtil.toIsoDate( Instant.now() )%>
4244
<br/>
4345
<% if (app.getSettings().isFtpEnabled()) {%>
4446
<% Instant lastIngest = app.getStatus().getLastFtpIngest(); %>
@@ -63,7 +65,7 @@
6365
</form>
6466

6567
<h2>Versions</h2>
66-
<table>
68+
<table class="sortable">
6769
<tr>
6870
<td><b>Version</b></td>
6971
<td><b>Count</b></td>
@@ -76,7 +78,7 @@
7678
<% } %>
7779
</table>
7880
<h2>LDAP Vendors</h2>
79-
<table>
81+
<table class="sortable">
8082
<tr>
8183
<td><b>Ldap</b></td>
8284
<td><b>Count</b></td>
@@ -89,7 +91,7 @@
8991
<% } %>
9092
</table>
9193
<h2>App Servers</h2>
92-
<table>
94+
<table class="sortable">
9395
<tr>
9496
<td><b>App Server Info</b></td>
9597
<td><b>Count</b></td>
@@ -102,7 +104,7 @@
102104
<% } %>
103105
</table>
104106
<h2>OS Vendors</h2>
105-
<table>
107+
<table class="sortable">
106108
<tr>
107109
<td><b>OS Vendor</b></td>
108110
<td><b>Count</b></td>
@@ -115,7 +117,7 @@
115117
<% } %>
116118
</table>
117119
<h2>DB Vendors</h2>
118-
<table>
120+
<table class="sortable">
119121
<tr>
120122
<td><b>DB Vendor</b></td>
121123
<td><b>Count</b></td>
@@ -128,7 +130,7 @@
128130
<% } %>
129131
</table>
130132
<h2>Java VMs</h2>
131-
<table>
133+
<table class="sortable">
132134
<tr>
133135
<td><b>Java VM</b></td>
134136
<td><b>Count</b></td>
@@ -141,7 +143,7 @@
141143
<% } %>
142144
</table>
143145
<h2>Settings</h2>
144-
<table>
146+
<table class="sortable">
145147
<tr>
146148
<td><b>Setting</b></td>
147149
<td><b>Count</b></td>
@@ -154,7 +156,7 @@
154156
<% } %>
155157
</table>
156158
<h2>Statistics</h2>
157-
<table>
159+
<table class="sortable">
158160
<tr>
159161
<td><b>Statistic</b></td>
160162
<td><b>Count</b></td>

data-service/src/main/webapp/data-service-style.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ table, td, th {
2929
border-collapse: collapse;
3030
}
3131

32+
thead {
33+
cursor: pointer;
34+
}

docker/src/main/image-files/app/startup.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,20 @@ USER_REPLACE_FILE="/config/java.vmoptions.replace"
99

1010
JAVA_OPTS=""
1111

12-
if [[ -f ${PRIMARY_OPTIONS_FILE} ]]; then
12+
if [ -f ${PRIMARY_OPTIONS_FILE} ]; then
1313
echo "file $PRIMARY_OPTIONS_FILE exists, adding to java options"
14-
JAVA_OPTS+="$(sed 's/./&/' ${PRIMARY_OPTIONS_FILE} | tr '\n' ' ')"
14+
JAVA_OPTS="$JAVA_OPTS $(sed 's/./&/' ${PRIMARY_OPTIONS_FILE} | tr '\n' ' ')"
1515
else
1616
echo "file $PRIMARY_OPTIONS_FILE does not exist."
1717
fi
1818

19-
if [[ -f ${USER_OPTIONS_FILE} ]]; then
20-
if [[ -f ${USER_REPLACE_FILE} ]]; then
19+
if [ -f ${USER_OPTIONS_FILE} ]; then
20+
if [ -f ${USER_REPLACE_FILE} ]; then
2121
echo "file $USER_OPTIONS_FILE and $USER_REPLACE_FILE both exists, replacing java options"
2222
JAVA_OPTS="$(sed 's/./&/' ${USER_OPTIONS_FILE} | tr '\n' ' ')"
2323
else
2424
echo "file $USER_OPTIONS_FILE exists, adding to java options"
25-
JAVA_OPTS+="$(sed 's/./&/' ${USER_OPTIONS_FILE} | tr '\n' ' ')"
25+
JAVA_OPTS="$JAVA_OPTS $(sed 's/./&/' ${USER_OPTIONS_FILE} | tr '\n' ' ')"
2626
fi
2727
else
2828
echo "file $USER_OPTIONS_FILE does not exist."
@@ -31,5 +31,8 @@ fi
3131
export JAVA_OPTS
3232
echo "effective java options: $JAVA_OPTS"
3333

34-
echo "starting java"
35-
java ${JAVA_OPTS} -jar /app/libs/*onejar*.jar -applicationPath /config
34+
JAVA_CMD_LINE="java $JAVA_OPTS -jar /app/libs/*onejar*.jar -applicationPath /config"
35+
export JAVA_CMD_LINE
36+
echo "starting java with command line: $JAVA_CMD_LINE"
37+
38+
$JAVA_CMD_LINE

lib-util/src/main/java/password/pwm/util/java/CollectionUtil.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public static <E extends Enum<E>> Set<E> readEnumSetFromStringCollection( final
102102
.flatMap( Optional::stream )
103103
.collect( Collectors.toSet() );
104104

105-
return Collections.unmodifiableSet( copiedEnumSet( set, enumClass ) );
105+
return Collections.unmodifiableSet( copyToEnumSet( set, enumClass ) );
106106
}
107107

108108
public static <E extends Enum<E>> Set<E> enumSetFromArray( final E[] arrayValues )
@@ -112,10 +112,20 @@ public static <E extends Enum<E>> Set<E> enumSetFromArray( final E[] arrayValues
112112
: Collections.unmodifiableSet( EnumSet.copyOf( Arrays.asList( arrayValues ) ) );
113113
}
114114

115-
public static <E extends Enum<E>> Map<String, String> enumMapToStringMap( final Map<E, String> inputMap )
115+
public static <E extends Enum<E>> Map<String, String> enumMapToStringMap(
116+
final Map<E, String> inputMap,
117+
final Function<E, String> keyToStringFunction
118+
)
116119
{
117120
return Collections.unmodifiableMap( inputMap.entrySet().stream()
118-
.collect( Collectors.toMap( entry -> entry.getKey().name(), Map.Entry::getValue, ( a, b ) -> b, java.util.LinkedHashMap::new ) ) );
121+
.collect( collectorToLinkedMap(
122+
entry -> keyToStringFunction.apply( entry.getKey() ),
123+
Map.Entry::getValue ) ) );
124+
}
125+
126+
public static <E extends Enum<E>> Map<String, String> enumMapToStringMap( final Map<E, String> inputMap )
127+
{
128+
return enumMapToStringMap( inputMap, Enum::name );
119129
}
120130

121131
public static <K> boolean isEmpty( final Collection<K> collection )
@@ -128,7 +138,7 @@ public static <K, V> boolean isEmpty( final Map<K, V> map )
128138
return map == null || map.isEmpty();
129139
}
130140

131-
public static <E extends Enum<E>> EnumSet<E> copiedEnumSet( final Collection<E> source, final Class<E> classOfT )
141+
public static <E extends Enum<E>> EnumSet<E> copyToEnumSet( final Collection<E> source, final Class<E> classOfT )
132142
{
133143
return isEmpty( source )
134144
? EnumSet.noneOf( classOfT )

lib-util/src/main/java/password/pwm/util/java/CopyingOutputStream.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
*/
3131
public class CopyingOutputStream extends OutputStream
3232
{
33-
private static final int DEFAULT_BUFFER_SIZE = 8192;
3433
private final OutputStream realStream;
3534
private final Consumer<byte[]> consumer;
3635

lib-util/src/main/java/password/pwm/util/java/JavaHelper.java

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import java.io.OutputStream;
3030
import java.io.PrintWriter;
3131
import java.io.StringWriter;
32+
import java.io.Writer;
3233
import java.lang.management.LockInfo;
3334
import java.lang.management.MonitorInfo;
3435
import java.lang.management.ThreadInfo;
@@ -200,9 +201,7 @@ public static <E extends Enum<E>> boolean enumArrayContainsValue( final E[] enum
200201
public static long copy( final InputStream input, final OutputStream output )
201202
throws IOException
202203
{
203-
final int bufferSize = 4 * 1024;
204-
final byte[] buffer = new byte[bufferSize];
205-
return IOUtils.copyLarge( input, output, 0, -1, buffer );
204+
return IOUtils.copyLarge( input, output, 0, -1 );
206205
}
207206

208207

@@ -446,11 +445,6 @@ public static LongAccumulator newAbsLongAccumulator()
446445
}, 0L );
447446
}
448447

449-
public static Properties newSortedProperties()
450-
{
451-
return new org.apache.commons.collections4.properties.SortedProperties();
452-
}
453-
454448
public static int silentParseInt( final String input, final int defaultValue )
455449
{
456450
try
@@ -583,4 +577,12 @@ public static void closeAndWaitExecutor( final ExecutorService executor, final T
583577
/* ignore */
584578
}
585579
}
580+
581+
public static String stackTraceToString( final Throwable e )
582+
{
583+
final Writer stackTraceOutput = new StringWriter();
584+
e.printStackTrace( new PrintWriter( stackTraceOutput ) );
585+
return stackTraceOutput.toString();
586+
587+
}
586588
}

onejar/src/main/java/password/pwm/onejar/TomcatOnejarRunner.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ Properties executeOnejarHelper( final OnejarConfig onejarConfig )
227227

228228
try ( URLClassLoader classLoader = warClassLoaderFromConfig( onejarConfig ) )
229229
{
230-
final Class pwmMainClass = classLoader.loadClass( "password.pwm.util.OnejarHelper" );
230+
final Class<?> pwmMainClass = classLoader.loadClass( "password.pwm.util.OnejarHelper" );
231231
final String keystoreFile = onejarConfig.getKeystoreFile().getAbsolutePath();
232232
final Method mainMethod = pwmMainClass.getMethod(
233233
"onejarHelper",
@@ -244,7 +244,7 @@ Properties executeOnejarHelper( final OnejarConfig onejarConfig )
244244
onejarConfig.getKeystorePass(),
245245
};
246246

247-
final Object returnObjValue = mainMethod.invoke( null, arguments );
247+
final Object returnObjValue = mainMethod.invoke( null, ( Object[] ) arguments );
248248
final Properties returnProps = ( Properties ) returnObjValue;
249249
out( "completed read of tlsProperties", startTime );
250250
return returnProps;

0 commit comments

Comments
 (0)