<commit_before>package com.cedarsoftware.ncube

import com.cedarsoftware.ncube.util.CdnRouter
import com.cedarsoftware.ncube.util.CdnRoutingProvider
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito

import javax.servlet.ServletInputStream
import javax.servlet.ServletOutputStream
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

import static org.mockito.Mockito.doThrow
import static org.mockito.Mockito.times
import static org.mockito.Mockito.verify
import static org.mockito.Mockito.when

/**
 * @author <NAME> (<EMAIL>)
 *         <br/>
 *         Copyright (c) Cedar Software LLC
 *         <br/><br/>
 *         Licensed under the Apache License, Version 2.0 (the 'License')
 *         you may not use this file except in compliance with the License.
 *         You may obtain a copy of the License at
 *         <br/><br/>
 *         http://www.apache.org/licenses/LICENSE-2.0
 *         <br/><br/>
 *         Unless required by applicable law or agreed to in writing, software
 *         distributed under the License is distributed on an 'AS IS' BASIS,
 *         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *         See the License for the specific language governing permissions and
 *         limitations under the License.
 */
class TestCdnRouter
{
    @Before
    public void setUp() throws Exception
    {
        TestingDatabaseHelper.setupDatabase()
    }

    @After
    public void tearDown() throws Exception
    {
        TestingDatabaseHelper.tearDownDatabase()
    }

    @Test
    void testRoute() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setDefaultCdnRoutingProvider()

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        byte[] bytes = ((DumboOutputStream) out).bytes
        String s = new String(bytes)
        assert 'CAFEBABE' == s
    }

    @Test
    void test500() throws Exception
    {
        HttpServletRequest request = Mockito.mock(HttpServletRequest.class)
        HttpServletResponse response = Mockito.mock(HttpServletResponse.class)

        when(request.servletPath).thenReturn '/dyn/view/500'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn(out)
        when(request.inputStream).thenReturn(input)

        setDefaultCdnRoutingProvider()

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response

        verify(response, times(1)).sendError 500, 'Unable to resolve URL, make sure appropriate resource urls are added to the sys.classpath cube, url: tests/does/not/exist/index.html, cube: CdnRouterTest, app: ' + ApplicationID.testAppId
    }

    @Test
    void testInvalidVersion() throws Exception
    {
        HttpServletRequest request = Mockito.mock(HttpServletRequest.class)
        HttpServletResponse response = Mockito.mock(HttpServletResponse.class)

        when(request.servletPath).thenReturn '/foo/bar'

        setDefaultCdnRoutingProvider()

        new CdnRouter().route request, response
        verify(response, times(1)).sendError 400, 'CdnRouter - Invalid ServletPath request: /foo/bar'
    }

    @Test
    void testNullServletPathThoughItMayBeImpossibleToReproduceInTomcat() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn null

        setDefaultCdnRoutingProvider()

        new CdnRouter().route request, response
        verify(response, times(1)).sendError 400, 'CdnRouter - Invalid ServletPath request: null'
    }

    @Test
    void testInvalidCubeName() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/404'
        setupMockRequestHeaders(request)
        setupMockResponseHeaders(response)

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, ReleaseStatus.SNAPSHOT.name(), "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        new CdnRouter().route request, response

        verify(response, times(1)).sendError 500, 'CdnRouter - Error occurred: Could not load routing cube using app: none / default_app / 999.99.9 / test /, cube name: foo'
    }

    @Test
    void test404() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/404'
        setupMockRequestHeaders request

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setDefaultCdnRoutingProvider()

        ApplicationID appId = new ApplicationID(ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, ApplicationID.DEFAULT_STATUS, ApplicationID.TEST_BRANCH)
        NCubeManager.getUrlClassLoader(appId, [:])
        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'

        CdnRouter router = new CdnRouter()
        router.route(request, response)

        verify(response, times(1)).sendError(404, 'Not Found')
    }

    @Test
    void testCdnRouterErrorHandleNoCubeName() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, ReleaseStatus.SNAPSHOT.name(), "TEST", null, true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.cubeName\' in the Map coordinate.'
    }

    @Test
    void testCdnRouterErrorHandleNoTenant() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider null, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, ReleaseStatus.SNAPSHOT.name(), "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.tenant\' in the Map coordinate.'
    }

    @Test
    void testCdnRouterErrorHandleNoApp() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, null, ApplicationID.DEFAULT_VERSION, ReleaseStatus.SNAPSHOT.name(), "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.app\' in the Map coordinate.'
    }

    @Test
    void testCdnRouterErrorHandleNoVersion() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, null, ReleaseStatus.SNAPSHOT.name(), "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.version\' in the Map coordinate.'
    }

    @Test
    void testCdnRouterErrorHandleNoStatus() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, null, "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.status\' in the Map coordinate.'
    }

    private static class TestCdnRoutingProvider implements CdnRoutingProvider
    {
        final String tenant
        final String app
        final String version
        final String status
        final String branch
        final String cubeName
        final boolean isAuthorized<commit_msg>Added test for branch in cdn router<commit_after>package com.cedarsoftware.ncube

import com.cedarsoftware.ncube.util.CdnRouter
import com.cedarsoftware.ncube.util.CdnRoutingProvider
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.mockito.Mockito

import javax.servlet.ServletInputStream
import javax.servlet.ServletOutputStream
import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse

import static org.mockito.Mockito.*

/**
 * @author <NAME> (<EMAIL>)
 *         <br/>
 *         Copyright (c) Cedar Software LLC
 *         <br/><br/>
 *         Licensed under the Apache License, Version 2.0 (the 'License')
 *         you may not use this file except in compliance with the License.
 *         You may obtain a copy of the License at
 *         <br/><br/>
 *         http://www.apache.org/licenses/LICENSE-2.0
 *         <br/><br/>
 *         Unless required by applicable law or agreed to in writing, software
 *         distributed under the License is distributed on an 'AS IS' BASIS,
 *         WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *         See the License for the specific language governing permissions and
 *         limitations under the License.
 */
class TestCdnRouter
{
    @Before
    public void setUp() throws Exception
    {
        TestingDatabaseHelper.setupDatabase()
    }

    @After
    public void tearDown() throws Exception
    {
        TestingDatabaseHelper.tearDownDatabase()
    }

    @Test
    void testRoute() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setDefaultCdnRoutingProvider()

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        byte[] bytes = ((DumboOutputStream) out).bytes
        String s = new String(bytes)
        assert 'CAFEBABE' == s
    }

    @Test
    void test500() throws Exception
    {
        HttpServletRequest request = Mockito.mock(HttpServletRequest.class)
        HttpServletResponse response = Mockito.mock(HttpServletResponse.class)

        when(request.servletPath).thenReturn '/dyn/view/500'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn(out)
        when(request.inputStream).thenReturn(input)

        setDefaultCdnRoutingProvider()

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response

        verify(response, times(1)).sendError 500, 'Unable to resolve URL, make sure appropriate resource urls are added to the sys.classpath cube, url: tests/does/not/exist/index.html, cube: CdnRouterTest, app: ' + ApplicationID.testAppId
    }

    @Test
    void testInvalidVersion() throws Exception
    {
        HttpServletRequest request = Mockito.mock(HttpServletRequest.class)
        HttpServletResponse response = Mockito.mock(HttpServletResponse.class)

        when(request.servletPath).thenReturn '/foo/bar'

        setDefaultCdnRoutingProvider()

        new CdnRouter().route request, response
        verify(response, times(1)).sendError 400, 'CdnRouter - Invalid ServletPath request: /foo/bar'
    }

    @Test
    void testNullServletPathThoughItMayBeImpossibleToReproduceInTomcat() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn null

        setDefaultCdnRoutingProvider()

        new CdnRouter().route request, response
        verify(response, times(1)).sendError 400, 'CdnRouter - Invalid ServletPath request: null'
    }

    @Test
    void testInvalidCubeName() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/404'
        setupMockRequestHeaders(request)
        setupMockResponseHeaders(response)

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, ReleaseStatus.SNAPSHOT.name(), "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        new CdnRouter().route request, response

        verify(response, times(1)).sendError 500, 'CdnRouter - Error occurred: Could not load routing cube using app: none / default_app / 999.99.9 / test /, cube name: foo'
    }

    @Test
    void test404() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/404'
        setupMockRequestHeaders request

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setDefaultCdnRoutingProvider()

        ApplicationID appId = new ApplicationID(ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, ApplicationID.DEFAULT_STATUS, ApplicationID.TEST_BRANCH)
        NCubeManager.getUrlClassLoader(appId, [:])
        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'

        CdnRouter router = new CdnRouter()
        router.route(request, response)

        verify(response, times(1)).sendError(404, 'Not Found')
    }

    @Test
    void testCdnRouterErrorHandleNoCubeName() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, ReleaseStatus.SNAPSHOT.name(), "TEST", null, true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.cubeName\' in the Map coordinate.'
    }

    @Test
    void testCdnRouterErrorHandleNoTenant() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider null, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, ReleaseStatus.SNAPSHOT.name(), "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.tenant\' in the Map coordinate.'
    }

    @Test
    void testCdnRouterErrorHandleNoApp() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, null, ApplicationID.DEFAULT_VERSION, ReleaseStatus.SNAPSHOT.name(), "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.app\' in the Map coordinate.'
    }

    @Test
    void testCdnRouterErrorHandleNoVersion() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, null, ReleaseStatus.SNAPSHOT.name(), "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.version\' in the Map coordinate.'
    }

    @Test
    void testCdnRouterErrorHandleNoStatus() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, null, "TEST", 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.status\' in the Map coordinate.'
    }

    @Test
    void testCdnRouterErrorHandleNoBranch() throws Exception
    {
        HttpServletRequest request = Mockito.mock HttpServletRequest.class
        HttpServletResponse response = Mockito.mock HttpServletResponse.class

        when(request.servletPath).thenReturn '/dyn/view/index'
        setupMockRequestHeaders request
        setupMockResponseHeaders response

        ServletOutputStream out = new DumboOutputStream()
        ServletInputStream input = new DumboInputStream()

        when(response.outputStream).thenReturn out
        when(request.inputStream).thenReturn input

        setCdnRoutingProvider ApplicationID.DEFAULT_TENANT, ApplicationID.DEFAULT_APP, ApplicationID.DEFAULT_VERSION, ReleaseStatus.SNAPSHOT.name(), null, 'foo', true

        NCubeManager.getNCubeFromResource 'cdnRouterTest.json'
        CdnRouter router = new CdnRouter()
        router.route request, response
        verify(response, times(1)).sendError HttpServletResponse.SC_INTERNAL_SERVER_ERROR, 'CdnRouter - CdnRoutingProvider did not set up \'router.branch\' in the Map coordinate.'
    }

    private static class TestCdnRoutingProvider implements CdnRoutingProvider
    {
        final String tenant
        final String app
        final String version
        final String status
        final String branch
        final String cubeName
        final boolean isAuthorized
{'fraction_non_alphanumeric': 0.07170018424869654, 'fraction_numerical': 0.00395938688306088, 'mean_word_length': 3.3975176693673506, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3954360', 'n_tokens_mistral': 6566, 'n_tokens_neox': 6339, 'n_words': 1574}