<commit_before>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.filter.instance.internal.output;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.xwiki.extension.ExtensionId;
import org.xwiki.extension.ResolveException;
import org.xwiki.extension.repository.ExtensionRepositoryManager;
import org.xwiki.extension.repository.InstalledExtensionRepository;
import org.xwiki.extension.test.EmptyExtension;
import org.xwiki.extension.test.MockitoRepositoryUtilsRule;
import org.xwiki.filter.FilterException;
import org.xwiki.filter.filterxml.input.FilterXMLInputProperties;
import org.xwiki.filter.input.BeanInputFilterStreamFactory;
import org.xwiki.filter.input.DefaultURLInputSource;
import org.xwiki.filter.input.InputFilterStream;
import org.xwiki.filter.input.InputFilterStreamFactory;
import org.xwiki.filter.instance.output.ExtensionInstanceOutputProperties;
import org.xwiki.filter.instance.output.InstanceOutputProperties;
import org.xwiki.filter.output.BeanOutputFilterStreamFactory;
import org.xwiki.filter.output.OutputFilterStream;
import org.xwiki.filter.output.OutputFilterStreamFactory;
import org.xwiki.filter.type.FilterStreamType;
import org.xwiki.test.annotation.AfterComponent;
import org.xwiki.test.annotation.AllComponents;

/**
 * Validate {@link ExtensionInstanceOutputProperties}.
 * 
 * @version $Id$
 */
@AllComponents
public class ExtensionInstanceOutputFilterStreamTest
{
    @Rule
    public MockitoRepositoryUtilsRule repositoryUtil = new MockitoRepositoryUtilsRule();

    private BeanInputFilterStreamFactory<FilterXMLInputProperties> xmlInputFilterStreamFactory;

    private BeanOutputFilterStreamFactory<InstanceOutputProperties> outputFilterStreamFactory;

    private InstalledExtensionRepository installedExtensionRepository;

    private ExtensionRepositoryManager extensionRepositoryMock;

    @AfterComponent
    public void afterComponent() throws Exception
    {
        this.extensionRepositoryMock =
            this.repositoryUtil.getComponentManager().registerMockComponent(ExtensionRepositoryManager.class);
        doThrow(ResolveException.class).when(this.extensionRepositoryMock).resolve((ExtensionId) any());
    }

    // Tests

    @Before
    public void before() throws Exception
    {
        this.xmlInputFilterStreamFactory =
            this.repositoryUtil.getComponentManager().getInstance(InputFilterStreamFactory.class,
                FilterStreamType.FILTER_XML.serialize());
        this.outputFilterStreamFactory =
            this.repositoryUtil.getComponentManager().getInstance(OutputFilterStreamFactory.class,
                FilterStreamType.XWIKI_INSTANCE.serialize());

        this.installedExtensionRepository =
            this.repositoryUtil.getComponentManager().getInstance(InstalledExtensionRepository.class);<commit_msg>[misc] Skip core extension scanner<commit_after>/*
 * See the NOTICE file distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2.1 of
 * the License, or (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this software; if not, write to the Free
 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 */
package org.xwiki.filter.instance.internal.output;

import static org.mockito.Matchers.any;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.doThrow;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URL;

import org.junit.Assert;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.xwiki.extension.ExtensionId;
import org.xwiki.extension.ResolveException;
import org.xwiki.extension.repository.ExtensionRepositoryManager;
import org.xwiki.extension.repository.InstalledExtensionRepository;
import org.xwiki.extension.repository.internal.core.CoreExtensionScanner;
import org.xwiki.extension.test.EmptyExtension;
import org.xwiki.extension.test.MockitoRepositoryUtilsRule;
import org.xwiki.filter.FilterException;
import org.xwiki.filter.filterxml.input.FilterXMLInputProperties;
import org.xwiki.filter.input.BeanInputFilterStreamFactory;
import org.xwiki.filter.input.DefaultURLInputSource;
import org.xwiki.filter.input.InputFilterStream;
import org.xwiki.filter.input.InputFilterStreamFactory;
import org.xwiki.filter.instance.output.ExtensionInstanceOutputProperties;
import org.xwiki.filter.instance.output.InstanceOutputProperties;
import org.xwiki.filter.output.BeanOutputFilterStreamFactory;
import org.xwiki.filter.output.OutputFilterStream;
import org.xwiki.filter.output.OutputFilterStreamFactory;
import org.xwiki.filter.type.FilterStreamType;
import org.xwiki.test.annotation.AfterComponent;
import org.xwiki.test.annotation.AllComponents;

/**
 * Validate {@link ExtensionInstanceOutputProperties}.
 * 
 * @version $Id$
 */
@AllComponents
public class ExtensionInstanceOutputFilterStreamTest
{
    @Rule
    public MockitoRepositoryUtilsRule repositoryUtil = new MockitoRepositoryUtilsRule();

    private BeanInputFilterStreamFactory<FilterXMLInputProperties> xmlInputFilterStreamFactory;

    private BeanOutputFilterStreamFactory<InstanceOutputProperties> outputFilterStreamFactory;

    private InstalledExtensionRepository installedExtensionRepository;

    private ExtensionRepositoryManager extensionRepositoryMock;

    @AfterComponent
    public void afterComponent() throws Exception
    {
        this.extensionRepositoryMock =
            this.repositoryUtil.getComponentManager().registerMockComponent(ExtensionRepositoryManager.class);
        doThrow(ResolveException.class).when(this.extensionRepositoryMock).resolve((ExtensionId) any());

        // Skip core extension scanner
        this.repositoryUtil.getComponentManager().registerMockComponent(CoreExtensionScanner.class);
    }

    // Tests

    @Before
    public void before() throws Exception
    {
        this.xmlInputFilterStreamFactory =
            this.repositoryUtil.getComponentManager().getInstance(InputFilterStreamFactory.class,
                FilterStreamType.FILTER_XML.serialize());
        this.outputFilterStreamFactory =
            this.repositoryUtil.getComponentManager().getInstance(OutputFilterStreamFactory.class,
                FilterStreamType.XWIKI_INSTANCE.serialize());

        this.installedExtensionRepository =
            this.repositoryUtil.getComponentManager().getInstance(InstalledExtensionRepository.class);
{'fraction_non_alphanumeric': 0.07703667240954959, 'fraction_numerical': 0.0031996062023135615, 'mean_word_length': 5.037890044576523, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, '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': '5113061', 'n_tokens_mistral': 2044, 'n_tokens_neox': 2000, 'n_words': 516}