<commit_before>package org.sagebionetworks.repo.web.controller;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.http.HttpStatus;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.servlet.DispatcherServlet;

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;

/**
 * Unit tests for the Dataset CRUD operations exposed by the DatasetController
 * with XML request and response encoding.
 * <p>
 * 
 * This is just a smattering of tests to check that we can do XML with no code
 * changes other than @XmlRootElement at the top of the model class and adding
 * the model class to the JAXB bean configuration.
 * <p>
 * 
 * TODO parse the XML to a map using XStream
 * http://xstream.codehaus.org/tutorial.html if we get more serious about
 * supporting XML encoding as a first class citizen
 * 
 * @author deflaux
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:repository-context.xml",
		"classpath:repository-servlet.xml" })
public class DatasetControllerXMLTest {

	private static final Logger log = Logger
			.getLogger(DatasetControllerXMLTest.class.getName());

	private static final LocalServiceTestHelper datastoreHelper = new LocalServiceTestHelper(
			new LocalDatastoreServiceTestConfig());

	private DispatcherServlet servlet = null;

	// Dev Note: these ids cannot just be any string, they have to be parsable
	// by our key utility
	private static final String NON_EXISTENT_DATASET_ID = "agR0ZXN0chMLEg1HQUVKRE9EYXRhc2V0GAEM";

	private static final Pattern ENTITY_ID_PATTERN = Pattern
			.compile("<id>([^<]+)</id>");

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {<commit_msg>Added a comment about a potential tool to use for XML tests.<commit_after>package org.sagebionetworks.repo.web.controller;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.http.HttpStatus;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletConfig;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.servlet.DispatcherServlet;

import com.google.appengine.tools.development.testing.LocalDatastoreServiceTestConfig;
import com.google.appengine.tools.development.testing.LocalServiceTestHelper;

/**
 * Unit tests for the Dataset CRUD operations exposed by the DatasetController
 * with XML request and response encoding.
 * <p>
 * 
 * This is just a smattering of tests to check that we can do XML with no code
 * changes other than @XmlRootElement at the top of the model class and adding
 * the model class to the JAXB bean configuration.
 * <p>
 * 
 * TODO parse the XML to a map using XStream
 * http://xstream.codehaus.org/tutorial.html if we get more serious about
 * supporting XML encoding as a first class citizen. Alternatively
 * http://xmlunit.sourceforge.net/ could help.
 * 
 * @author deflaux
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:repository-context.xml",
		"classpath:repository-servlet.xml" })
public class DatasetControllerXMLTest {

	private static final Logger log = Logger
			.getLogger(DatasetControllerXMLTest.class.getName());

	private static final LocalServiceTestHelper datastoreHelper = new LocalServiceTestHelper(
			new LocalDatastoreServiceTestConfig());

	private DispatcherServlet servlet = null;

	// Dev Note: these ids cannot just be any string, they have to be parsable
	// by our key utility
	private static final String NON_EXISTENT_DATASET_ID = "agR0ZXN0chMLEg1HQUVKRE9EYXRhc2V0GAEM";

	private static final Pattern ENTITY_ID_PATTERN = Pattern
			.compile("<id>([^<]+)</id>");

	/**
	 * @throws java.lang.Exception
	 */
	@Before
	public void setUp() throws Exception {
{'fraction_non_alphanumeric': 0.087281305287989, 'fraction_numerical': 0.003538431295459013, 'mean_word_length': 5.391959798994975, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, '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': '4338273', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1428, 'n_words': 409}