<commit_before>/*
 * Copyright 2009 - 2011 the original author or authors.
 *
 * 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
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 */
package org.grails.jaxrs.itest

import org.grails.jaxrs.JaxrsController
import org.junit.Before
import org.junit.BeforeClass

import javax.servlet.http.HttpServletResponse

/**
 * Base class for JUnit integration testing JAX-RS resources and providers.
 *
 * @author <NAME>
 */
abstract class IntegrationTestCase implements JaxRsIntegrationTest {

    def grailsApplication

    static transactional = false
    static testEnvironment

    def controller

    JaxRsIntegrationTest defaultMixin

    @BeforeClass
    static void setUpBeforeClass() {
        testEnvironment = null
    }

    @Before
    void setUp() {
        grailsApplication.config.org.grails.jaxrs.dowriter.require.generic.collections = false
        grailsApplication.config.org.grails.jaxrs.doreader.disable = false
        grailsApplication.config.org.grails.jaxrs.dowriter.disable = false

        controller = new JaxrsController()
        defaultMixin = new JaxRsIntegrationTestMixin(controller)

        if (!testEnvironment) {
            testEnvironment = new IntegrationTestEnvironment(getContextLocations(), getJaxrsImplementation(),
                    getJaxrsClasses(), isAutoDetectJaxrsClasses())
        }

        controller.jaxrsContext = testEnvironment.jaxrsContext
    }

    @Override
    void setRequestUrl(String url) {
        defaultMixin.setRequestUrl(url)
    }

    @Override
    void setRequestMethod(String method) {
        defaultMixin.setRequestMethod(method)
    }

    @Override
    void setRequestContent(byte[] content) {
        defaultMixin.setRequestContent(content)
    }

    @Override<commit_msg>* Manually autowire the base integration test<commit_after>/*
 * Copyright 2009 - 2011 the original author or authors.
 *
 * 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
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 */
package org.grails.jaxrs.itest

import org.codehaus.groovy.grails.commons.ApplicationHolder
import org.codehaus.groovy.grails.test.support.GrailsTestAutowirer
import org.grails.jaxrs.JaxrsController
import org.junit.Before
import org.junit.BeforeClass

import javax.servlet.http.HttpServletResponse
/**
 * Base class for JUnit integration testing JAX-RS resources and providers.
 *
 * @author <NAME>
 */
abstract class IntegrationTestCase implements JaxRsIntegrationTest {

    private applicationContext = ApplicationHolder.application.mainContext
    private autowirer = new GrailsTestAutowirer(applicationContext)

    def grailsApplication

    static testEnvironment

    def controller

    JaxRsIntegrationTest defaultMixin

    @BeforeClass
    static void setUpBeforeClass() {
        testEnvironment = null
    }

    @Before
    void setUp() {
        autowirer.autowire(this)
        grailsApplication.config.org.grails.jaxrs.dowriter.require.generic.collections = false
        grailsApplication.config.org.grails.jaxrs.doreader.disable = false
        grailsApplication.config.org.grails.jaxrs.dowriter.disable = false

        controller = new JaxrsController()
        defaultMixin = new JaxRsIntegrationTestMixin(controller)

        if (!testEnvironment) {
            testEnvironment = new IntegrationTestEnvironment(getContextLocations(), getJaxrsImplementation(),
                    getJaxrsClasses(), isAutoDetectJaxrsClasses())
        }

        controller.jaxrsContext = testEnvironment.jaxrsContext
    }

    @Override
    void setRequestUrl(String url) {
        defaultMixin.setRequestUrl(url)
    }

    @Override
    void setRequestMethod(String method) {
        defaultMixin.setRequestMethod(method)
    }

    @Override
    void setRequestContent(byte[] content) {
        defaultMixin.setRequestContent(content)
    }

    @Override
{'fraction_non_alphanumeric': 0.07214345287739783, 'fraction_numerical': 0.0050041701417848205, 'mean_word_length': 3.4211981566820278, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '2494755', 'n_tokens_mistral': 1311, 'n_tokens_neox': 1254, 'n_words': 358}