fix HttpContent.Factory config in ResourceHandlerTest

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
This commit is contained in:
Lachlan Roberts 2022-12-14 18:16:32 +11:00
parent 60656ebb72
commit a5817144f6
2 changed files with 12 additions and 6 deletions

View File

@ -104,11 +104,11 @@ public class ResourceHandler extends Handler.Wrapper
protected HttpContent.Factory newHttpContentFactory()
{
HttpContent.Factory contentFactory = new ResourceHttpContentFactory(ResourceFactory.of(_resourceBase), _mimeTypes);
HttpContent.Factory contentFactory = new ResourceHttpContentFactory(ResourceFactory.of(getBaseResource()), getMimeTypes());
contentFactory = new FileMappingHttpContentFactory(contentFactory);
contentFactory = new StaticHttpContentFactory(contentFactory, getStyleSheet());
contentFactory = new PreCompressedHttpContentFactory(contentFactory, _resourceService.getPrecompressedFormats());
contentFactory = new ValidatingCachingHttpContentFactory(contentFactory, Duration.ofSeconds(1).toMillis(), _byteBufferPool);
contentFactory = new PreCompressedHttpContentFactory(contentFactory, getPrecompressedFormats());
contentFactory = new ValidatingCachingHttpContentFactory(contentFactory, Duration.ofSeconds(1).toMillis(), getByteBufferPool());
return contentFactory;
}
@ -156,6 +156,11 @@ public class ResourceHandler extends Handler.Wrapper
return _resourceBase;
}
public ByteBufferPool getByteBufferPool()
{
return _byteBufferPool;
}
/**
* @return the cacheControl header to set on all static content.
*/

View File

@ -47,6 +47,7 @@ import org.eclipse.jetty.http.content.FileMappingHttpContentFactory;
import org.eclipse.jetty.http.content.HttpContent;
import org.eclipse.jetty.http.content.PreCompressedHttpContentFactory;
import org.eclipse.jetty.http.content.ResourceHttpContentFactory;
import org.eclipse.jetty.http.content.StaticHttpContentFactory;
import org.eclipse.jetty.http.content.ValidatingCachingHttpContentFactory;
import org.eclipse.jetty.logging.StacklessLogging;
import org.eclipse.jetty.server.Handler;
@ -665,11 +666,11 @@ public class ResourceHandlerTest
@Override
protected HttpContent.Factory newHttpContentFactory()
{
// For testing the cache should be configured to validate the entry on every request.
HttpContent.Factory contentFactory = new ResourceHttpContentFactory(ResourceFactory.of(getBaseResource()), getMimeTypes());
contentFactory = new PreCompressedHttpContentFactory(contentFactory, getPrecompressedFormats());
contentFactory = new FileMappingHttpContentFactory(contentFactory);
contentFactory = new ValidatingCachingHttpContentFactory(contentFactory, 0, _local.getByteBufferPool());
contentFactory = new StaticHttpContentFactory(contentFactory, getStyleSheet());
contentFactory = new PreCompressedHttpContentFactory(contentFactory, getPrecompressedFormats());
contentFactory = new ValidatingCachingHttpContentFactory(contentFactory, 0, getByteBufferPool());
return contentFactory;
}
};