<commit_before>package jj.http.server.servable;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;

import java.io.IOException;

import jj.configuration.resolution.AppLocation;
import jj.css.CssResource;
import jj.http.server.servable.CssServable;
import jj.http.server.servable.RequestProcessor;
import jj.uri.URIMatch;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;


public class CssServableTest extends ServableTestBase{
	
	@Mock CssResource cssResource;
	
	CssServable cs;
	
	@Before
	public void before() {
		
		cs = new CssServable(app, resourceFinder);
	}

	@Test
	public void testBasicOperation() throws IOException {
		
		// given
		given(request.uriMatch()).willReturn(new URIMatch("/style.css"));
		given(resourceFinder.loadResource(CssResource.class, AppLocation.Base, "style.css", true)).willReturn(cssResource);
		given(cssResource.path()).willReturn(appPath.resolve("style.css"));
		
		// then
		assertThat(cs.isMatchingRequest(request.uriMatch()), is(true));
		
		// when
		RequestProcessor requestProcessor = cs.makeRequestProcessor(request, response);
		
		// then
		assertThat(requestProcessor, is(notNullValue()));
	}
	
	@Test
	public void testOutsideApplicationIsRejected() throws Exception {
		
		given(request.uriMatch()).willReturn(new URIMatch("/../not-servable/style.css"));
		
		RequestProcessor rp = cs.makeRequestProcessor(request, response);
		
		assertThat(rp, is(nullValue()));
	}
}
<commit_msg>pointless cleaning up a space<commit_after>package jj.http.server.servable;

import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.BDDMockito.*;

import java.io.IOException;

import jj.configuration.resolution.AppLocation;
import jj.css.CssResource;
import jj.http.server.servable.CssServable;
import jj.http.server.servable.RequestProcessor;
import jj.uri.URIMatch;

import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;


public class CssServableTest extends ServableTestBase {
	
	@Mock CssResource cssResource;
	
	CssServable cs;
	
	@Before
	public void before() {
		
		cs = new CssServable(app, resourceFinder);
	}

	@Test
	public void testBasicOperation() throws IOException {
		
		// given
		given(request.uriMatch()).willReturn(new URIMatch("/style.css"));
		given(resourceFinder.loadResource(CssResource.class, AppLocation.Base, "style.css", true)).willReturn(cssResource);
		given(cssResource.path()).willReturn(appPath.resolve("style.css"));
		
		// then
		assertThat(cs.isMatchingRequest(request.uriMatch()), is(true));
		
		// when
		RequestProcessor requestProcessor = cs.makeRequestProcessor(request, response);
		
		// then
		assertThat(requestProcessor, is(notNullValue()));
	}
	
	@Test
	public void testOutsideApplicationIsRejected() throws Exception {
		
		given(request.uriMatch()).willReturn(new URIMatch("/../not-servable/style.css"));
		
		RequestProcessor rp = cs.makeRequestProcessor(request, response);
		
		assertThat(rp, is(nullValue()));
	}
}

{'fraction_non_alphanumeric': 0.12708811005568293, 'fraction_numerical': 0.0, 'mean_word_length': 5.108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7391531', 'n_tokens_mistral': 1040, 'n_tokens_neox': 929, 'n_words': 176}