<commit_before>/*
 * Copyright (c) 2010, <NAME>. All Rights Reserved.
 *
 * 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.qi4j.entitystore.sql;

import java.sql.Connection;
import java.sql.Statement;
import org.apache.derby.iapi.services.io.FileUtil;
import org.junit.Assume;
import org.qi4j.api.common.Visibility;
import org.qi4j.api.unitofwork.UnitOfWork;
import org.qi4j.bootstrap.AssemblyException;
import org.qi4j.bootstrap.ModuleAssembly;
import org.qi4j.entitystore.memory.MemoryEntityStoreService;
import org.qi4j.entitystore.sql.assembly.DerbySQLEntityStoreAssembler;
import org.qi4j.entitystore.sql.internal.SQLs;
import org.qi4j.library.sql.common.SQLConfiguration;
import org.qi4j.library.sql.common.SQLUtil;
import org.qi4j.library.sql.ds.DBCPDataSourceConfiguration;
import org.qi4j.test.entity.AbstractEntityStoreTest;

/**
 * @author <NAME>
 * @author <NAME>
 */
public class DerbySQLEntityStoreTest extends AbstractEntityStoreTest
{

    @Override
    @SuppressWarnings( "unchecked" )
    public void assemble( ModuleAssembly module )
        throws AssemblyException
    {
        super.assemble( module );

        try
        {
            new DerbySQLEntityStoreAssembler().assemble( module );
        }
        catch( AssemblyException e )
        {
            System.err.println( "TEST WILL BE SKIPPED!!!!!" );
            Assume.assumeNoException( e );
        }

        ModuleAssembly config = module.layer().module( "config" );
        config.services( MemoryEntityStoreService.class );
        config.entities( DBCPDataSourceConfiguration.class, SQLConfiguration.class ).visibleIn( Visibility.layer );
    }

    @Override
    public void tearDown()
        throws Exception
    {
        if( unitOfWorkFactory == null )
        {
            return;
        }
        UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork();
        try
        {
            SQLConfiguration config = uow.get( SQLConfiguration.class,
                                               DerbySQLEntityStoreAssembler.ENTITYSTORE_SERVICE_NAME );
            Connection connection = SQLUtil.getConnection( serviceLocator );
            String schemaName = config.schemaName().get();
            if( schemaName == null )
            {<commit_msg>entitystore-sql: add @Ignore to DerbySQLEntityStoreTest<commit_after>/*
 * Copyright (c) 2010, <NAME>. All Rights Reserved.
 *
 * 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.qi4j.entitystore.sql;

import org.apache.derby.iapi.services.io.FileUtil;
import org.junit.Ignore;
import org.qi4j.api.common.Visibility;
import org.qi4j.api.unitofwork.UnitOfWork;
import org.qi4j.bootstrap.AssemblyException;
import org.qi4j.bootstrap.ModuleAssembly;
import org.qi4j.entitystore.memory.MemoryEntityStoreService;
import org.qi4j.entitystore.sql.assembly.DerbySQLEntityStoreAssembler;
import org.qi4j.entitystore.sql.internal.SQLs;
import org.qi4j.library.sql.common.SQLConfiguration;
import org.qi4j.library.sql.common.SQLUtil;
import org.qi4j.library.sql.ds.DBCPDataSourceConfiguration;
import org.qi4j.test.entity.AbstractEntityStoreTest;

import java.sql.Connection;
import java.sql.Statement;

/**
 * @author <NAME>
 * @author <NAME>
 */
@Ignore // Do not work anymore since the use of java-sql-generator that do not support Derby
public class DerbySQLEntityStoreTest extends AbstractEntityStoreTest
{

    @Override
    @SuppressWarnings( "unchecked" )
    public void assemble( ModuleAssembly module )
        throws AssemblyException
    {
        super.assemble( module );

        new DerbySQLEntityStoreAssembler().assemble( module );

        ModuleAssembly config = module.layer().module( "config" );
        config.services( MemoryEntityStoreService.class );
        config.entities( DBCPDataSourceConfiguration.class, SQLConfiguration.class ).visibleIn( Visibility.layer );
    }

    @Override
    public void tearDown()
        throws Exception
    {
        if( unitOfWorkFactory == null )
        {
            return;
        }
        UnitOfWork uow = this.unitOfWorkFactory.newUnitOfWork();
        try
        {
            SQLConfiguration config = uow.get( SQLConfiguration.class,
                                               DerbySQLEntityStoreAssembler.ENTITYSTORE_SERVICE_NAME );
            Connection connection = SQLUtil.getConnection( serviceLocator );
            String schemaName = config.schemaName().get();
            if( schemaName == null )
            {
{'fraction_non_alphanumeric': 0.09009338948910456, 'fraction_numerical': 0.007324665812122322, 'mean_word_length': 3.1378787878787877, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4267771', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1490, 'n_words': 394}