File tree Expand file tree Collapse file tree 8 files changed +86
-8
lines changed
main/java/com/microsoft/applicationinsights/smoketestapp
smokeTest/java/com/microsoft/applicationinsights/smoketest
main/java/com/microsoft/applicationinsights/smoketestapp
smokeTest/java/com/microsoft/applicationinsights/smoketest
main/java/com/microsoft/applicationinsights/smoketestapp
smokeTest/java/com/microsoft/applicationinsights/smoketest
main/java/com/microsoft/applicationinsights/smoketestapp
smokeTest/java/com/microsoft/applicationinsights/smoketest Expand file tree Collapse file tree 8 files changed +86
-8
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ public class JavaUtilLoggingWithExceptionServlet extends HttpServlet {
16
16
private static final Logger logger = Logger .getLogger ("smoketestapp" );
17
17
18
18
protected void doGet (HttpServletRequest request , HttpServletResponse response ) {
19
- logger .log (Level .SEVERE , "This is an exception!" , new Exception ("Fake Exception" ));
19
+ String testNullMessage = request .getParameter ("test-null-message" );
20
+ if ("true" .equalsIgnoreCase (testNullMessage )) {
21
+ logger .log (Level .SEVERE , "This is an exception with null message!" , new Exception ());
22
+ } else {
23
+ logger .log (Level .SEVERE , "This is an exception!" , new Exception ("Fake Exception" ));
24
+ }
20
25
}
21
26
}
Original file line number Diff line number Diff line change @@ -78,6 +78,16 @@ void test() throws Exception {
78
78
@ Test
79
79
@ TargetUri ("/testWithException" )
80
80
void testWithException () throws Exception {
81
+ testWithException (false );
82
+ }
83
+
84
+ @ Test
85
+ @ TargetUri ("/testWithException?test-null-message=true" )
86
+ void testWithExceptionWithNullMessage () throws Exception {
87
+ testWithException (true );
88
+ }
89
+
90
+ private void testWithException (boolean testNullMessage ) throws Exception {
81
91
List <Envelope > rdList = testing .mockedIngestion .waitForItems ("RequestData" , 1 );
82
92
83
93
Envelope rdEnvelope = rdList .get (0 );
@@ -97,7 +107,11 @@ void testWithException() throws Exception {
97
107
ExceptionData ed = (ExceptionData ) ((Data <?>) edEnvelope .getData ()).getBaseData ();
98
108
99
109
assertThat (ed .getExceptions ().get (0 ).getTypeName ()).isEqualTo ("java.lang.Exception" );
100
- assertThat (ed .getExceptions ().get (0 ).getMessage ()).isEqualTo ("Fake Exception" );
110
+ if (testNullMessage ) {
111
+ assertThat (ed .getExceptions ().get (0 ).getMessage ()).isEqualTo ("java.lang.Exception" );
112
+ } else {
113
+ assertThat (ed .getExceptions ().get (0 ).getMessage ()).isEqualTo ("Fake Exception" );
114
+ }
101
115
assertThat (ed .getSeverityLevel ()).isEqualTo (SeverityLevel .ERROR );
102
116
assertThat (ed .getProperties ()).containsEntry ("Logger Message" , "This is an exception!" );
103
117
assertThat (ed .getProperties ()).containsEntry ("SourceType" , "Logger" );
Original file line number Diff line number Diff line change 4
4
package com .microsoft .applicationinsights .smoketestapp ;
5
5
6
6
import java .lang .reflect .Field ;
7
+ import java .util .logging .Level ;
8
+
7
9
import javax .servlet .annotation .WebServlet ;
8
10
import javax .servlet .http .HttpServlet ;
9
11
import javax .servlet .http .HttpServletRequest ;
@@ -35,7 +37,12 @@ public class Log4j1WithExceptionServlet extends HttpServlet {
35
37
@ Override
36
38
protected void doGet (HttpServletRequest request , HttpServletResponse response ) {
37
39
MDC .put ("MDC key" , "MDC value" );
38
- logger .error ("This is an exception!" , new Exception ("Fake Exception" ));
40
+ String testNullMessage = request .getParameter ("test-null-message" );
41
+ if ("true" .equalsIgnoreCase (testNullMessage )) {
42
+ logger .error ("This is an exception with null message!" , new Exception ());
43
+ } else {
44
+ logger .error ("This is an exception!" , new Exception ("Fake Exception" ));
45
+ }
39
46
MDC .remove ("MDC key" );
40
47
}
41
48
}
Original file line number Diff line number Diff line change @@ -99,6 +99,16 @@ private void logDisableMessage() {
99
99
@ Test
100
100
@ TargetUri ("/testWithException" )
101
101
void testWithException () throws Exception {
102
+ testWithException (false );
103
+ }
104
+
105
+ @ Test
106
+ @ TargetUri ("/testWithException?test-null-message=true" )
107
+ void testWithExceptionWithNullMessage () throws Exception {
108
+ testWithException (true );
109
+ }
110
+
111
+ private void testWithException (boolean testNullMessage ) throws Exception {
102
112
List <Envelope > rdList = testing .mockedIngestion .waitForItems ("RequestData" , 1 );
103
113
104
114
Envelope rdEnvelope = rdList .get (0 );
@@ -119,7 +129,11 @@ void testWithException() throws Exception {
119
129
ExceptionDetails ex = details .get (0 );
120
130
121
131
assertThat (ex .getTypeName ()).isEqualTo ("java.lang.Exception" );
122
- assertThat (ex .getMessage ()).isEqualTo ("Fake Exception" );
132
+ if (testNullMessage ) {
133
+ assertThat (ex .getMessage ()).isEqualTo ("java.lang.Exception" );
134
+ } else {
135
+ assertThat (ex .getMessage ()).isEqualTo ("Fake Exception" );
136
+ }
123
137
assertThat (ed .getSeverityLevel ()).isEqualTo (SeverityLevel .ERROR );
124
138
assertThat (ed .getProperties ()).containsEntry ("Logger Message" , "This is an exception!" );
125
139
assertThat (ed .getProperties ()).containsEntry ("SourceType" , "Logger" );
Original file line number Diff line number Diff line change @@ -18,7 +18,12 @@ public class Log4j2WithExceptionServlet extends HttpServlet {
18
18
19
19
protected void doGet (HttpServletRequest request , HttpServletResponse response ) {
20
20
ThreadContext .put ("MDC key" , "MDC value" );
21
- logger .error ("This is an exception!" , new Exception ("Fake Exception" ));
21
+ String testNullMessage = request .getParameter ("test-null-message" );
22
+ if ("true" .equalsIgnoreCase (testNullMessage )) {
23
+ logger .error ("This is an exception with null message!" , new Exception ());
24
+ } else {
25
+ logger .error ("This is an exception!" , new Exception ("Fake Exception" ));
26
+ }
22
27
ThreadContext .remove ("MDC key" );
23
28
}
24
29
}
Original file line number Diff line number Diff line change @@ -110,6 +110,16 @@ void test() throws Exception {
110
110
@ Test
111
111
@ TargetUri ("/testWithException" )
112
112
void testWithException () throws Exception {
113
+ testWithException (false );
114
+ }
115
+
116
+ @ Test
117
+ @ TargetUri ("/testWithException?test-null-message=true" )
118
+ void testWithExceptionWithNullMessage () throws Exception {
119
+ testWithException (true );
120
+ }
121
+
122
+ private void testWithException (boolean testNullMessage ) throws Exception {
113
123
List <Envelope > rdList = testing .mockedIngestion .waitForItems ("RequestData" , 1 );
114
124
115
125
Envelope rdEnvelope = rdList .get (0 );
@@ -130,7 +140,11 @@ void testWithException() throws Exception {
130
140
ExceptionDetails ex = details .get (0 );
131
141
132
142
assertThat (ex .getTypeName ()).isEqualTo ("java.lang.Exception" );
133
- assertThat (ex .getMessage ()).isEqualTo ("Fake Exception" );
143
+ if (testNullMessage ) {
144
+ assertThat (ex .getMessage ()).isEqualTo ("java.lang.Exception" );
145
+ } else {
146
+ assertThat (ex .getMessage ()).isEqualTo ("Fake Exception" );
147
+ }
134
148
assertThat (ed .getSeverityLevel ()).isEqualTo (SeverityLevel .ERROR );
135
149
assertThat (ed .getProperties ()).containsEntry ("Logger Message" , "This is an exception!" );
136
150
assertThat (ed .getProperties ()).containsEntry ("SourceType" , "Logger" );
Original file line number Diff line number Diff line change @@ -18,7 +18,12 @@ public class LogbackWithExceptionServlet extends HttpServlet {
18
18
19
19
protected void doGet (HttpServletRequest request , HttpServletResponse response ) {
20
20
MDC .put ("MDC key" , "MDC value" );
21
- logger .error ("This is an exception!" , new Exception ("Fake Exception" ));
21
+ String testNullMessage = request .getParameter ("test-null-message" );
22
+ if ("true" .equalsIgnoreCase (testNullMessage )) {
23
+ logger .error ("This is an exception with null message!" , new Exception ());
24
+ } else {
25
+ logger .error ("This is an exception!" , new Exception ("Fake Exception" ));
26
+ }
22
27
MDC .remove ("MDC key" );
23
28
}
24
29
}
Original file line number Diff line number Diff line change @@ -115,6 +115,16 @@ void test() throws Exception {
115
115
@ Test
116
116
@ TargetUri ("/testWithException" )
117
117
void testWithException () throws Exception {
118
+ testWithException (false );
119
+ }
120
+
121
+ @ Test
122
+ @ TargetUri ("/testWithException?test-null-message=true" )
123
+ void testWithExceptionWithNullMessage () throws Exception {
124
+ testWithException (true );
125
+ }
126
+
127
+ private void testWithException (boolean testNullMessage ) throws Exception {
118
128
List <Envelope > rdList = testing .mockedIngestion .waitForItems ("RequestData" , 1 );
119
129
120
130
Envelope rdEnvelope = rdList .get (0 );
@@ -132,7 +142,11 @@ void testWithException() throws Exception {
132
142
ExceptionData ed = (ExceptionData ) ((Data <?>) edEnvelope .getData ()).getBaseData ();
133
143
134
144
assertThat (ed .getExceptions ().get (0 ).getTypeName ()).isEqualTo ("java.lang.Exception" );
135
- assertThat (ed .getExceptions ().get (0 ).getMessage ()).isEqualTo ("Fake Exception" );
145
+ if (testNullMessage ) {
146
+ assertThat (ed .getExceptions ().get (0 ).getMessage ()).isEqualTo ("java.lang.Exception" );
147
+ } else {
148
+ assertThat (ed .getExceptions ().get (0 ).getMessage ()).isEqualTo ("Fake Exception" );
149
+ }
136
150
assertThat (ed .getSeverityLevel ()).isEqualTo (SeverityLevel .ERROR );
137
151
assertThat (ed .getProperties ())
138
152
.containsEntry ("Logger Message" , "This is an exception!" )
You can’t perform that action at this time.
0 commit comments