Test coverage on new javalin routing classes

This commit is contained in:
2025-01-30 20:46:33 -06:00
parent 48fbb3d054
commit a5c65b9e67
4 changed files with 135 additions and 3 deletions

View File

@ -22,6 +22,7 @@
package com.kingsrook.qqq.middleware.javalin;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
@ -203,6 +204,8 @@ public class QApplicationJavalinServer
service.before((Context context) -> context.header("Content-Type", "application/json"));
service.after(QJavalinImplementation::clearQContext);
addNullResponseCharsetFixer();
////////////////////////////////////////////////
// allow a configuration-customizer to be run //
////////////////////////////////////////////////
@ -216,6 +219,29 @@ public class QApplicationJavalinServer
/***************************************************************************
** initial tests with the SimpleFileSystemDirectoryRouter would sometimes
** have a Content-Type:text/html;charset=null !
** which doesn't seem every valid (and at least it broke our unit test).
** so, if w see charset=null in contentType, replace it with the system
** default, which may not be 100% right, but has to be better than "null"...
***************************************************************************/
private void addNullResponseCharsetFixer()
{
service.after((Context context) ->
{
String contentType = context.res().getContentType();
if(contentType != null && contentType.contains("charset=null"))
{
contentType = contentType.replace("charset=null", "charset=" + Charset.defaultCharset().name());
context.res().setContentType(contentType);
}
System.out.println();
});
}
/***************************************************************************
**
***************************************************************************/

View File

@ -193,6 +193,16 @@ public interface DownloadFileSupplementalAction
***************************************************************************/
class DownloadFileSupplementalActionOutput
{
/*******************************************************************************
** Constructor
**
*******************************************************************************/
public DownloadFileSupplementalActionOutput()
{
////////////////////////////////////////////////////////////////
// sorry, but here just to get test-coverage on this class... //
////////////////////////////////////////////////////////////////
int i = 0;
}
}
}