|
| 1 | +<cfscript> |
| 2 | +// Post-restart round-trip. Assumes Lucee has already been restarted via |
| 3 | +// trigger-lucee-restart.cfm — the CI job orders these correctly and polls |
| 4 | +// for the engine to come back before calling this. |
| 5 | +// |
| 6 | +// Proves the websocket extension's reflection fallback works: Tomcat's endpoint |
| 7 | +// registry still points at the pre-restart class, but the fresh extension injected |
| 8 | +// itself into the static slot via reflection. A successful round-trip confirms the |
| 9 | +// path works; the CI job separately greps catalina.out for the reflection warning |
| 10 | +// to prove the path was actually exercised. |
| 11 | +
|
| 12 | +writeOutput( "=== Post-Restart Reflection Round-Trip ===" & chr( 10 ) ); |
| 13 | +
|
| 14 | +try { |
| 15 | + if ( !structKeyExists( getFunctionList(), "CreateWebSocketClient" ) ) |
| 16 | + throw( message="CreateWebSocketClient not available", type="TestSetupError" ); |
| 17 | +
|
| 18 | + wsUrl = "ws://localhost:8888/ws/TestListener"; |
| 19 | + listener = new tests.integration.ClientListener(); |
| 20 | + ws = CreateWebSocketClient( wsUrl, listener ); |
| 21 | + sleep( 500 ); |
| 22 | +
|
| 23 | + ws.sendText( "reflectionCheck" ); |
| 24 | + sleep( 500 ); |
| 25 | +
|
| 26 | + ws.disconnect(); |
| 27 | + sleep( 500 ); |
| 28 | +
|
| 29 | + received = listener.getMessages(); |
| 30 | + writeOutput( "Received: " & received.toJSON() & chr( 10 ) ); |
| 31 | +
|
| 32 | + errors = []; |
| 33 | + if ( !received.find( "ECHO:reflectionCheck" ) ) |
| 34 | + arrayAppend( errors, "expected ECHO:reflectionCheck post-restart; got: " & received.toJSON() ); |
| 35 | +
|
| 36 | + if ( arrayLen( errors ) ) { |
| 37 | + writeOutput( chr( 10 ) & "FAILED:" & chr( 10 ) ); |
| 38 | + for ( err in errors ) |
| 39 | + writeOutput( " - #err#" & chr( 10 ) ); |
| 40 | + cfheader( statuscode=500, statustext="Test Failed" ); |
| 41 | + } |
| 42 | + else { |
| 43 | + writeOutput( chr( 10 ) & "SUCCESS: round-trip works post-restart — CI will confirm the reflection warning in catalina.out" & chr( 10 ) ); |
| 44 | + } |
| 45 | +} |
| 46 | +catch ( any e ) { |
| 47 | + writeOutput( "FAILED with exception:" & chr( 10 ) ); |
| 48 | + writeOutput( e.stacktrace ); |
| 49 | + cfheader( statuscode=500, statustext="Test Failed" ); |
| 50 | +} |
| 51 | +</cfscript> |
0 commit comments