001    package org.apache.jcs.auxiliary.disk.jdbc.mysql;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import junit.framework.TestCase;
023    
024    import org.apache.jcs.auxiliary.disk.jdbc.JDBCDiskCachePoolAccessFactory;
025    import org.apache.jcs.auxiliary.disk.jdbc.TableState;
026    
027    /**
028     * Hand run tests for the MySQL table optimizer.
029     * <p>
030     * @author Aaron Smuts
031     */
032    public class MySQLTableOptimizerManualTester
033        extends TestCase
034    {
035        /**
036         * Run the optimization against live a table.
037         * <p>
038         * @throws Exception
039         */
040        public void testBasicOptimization()
041            throws Exception
042        {
043            // SETUP
044            MySQLDiskCacheAttributes attributes = new MySQLDiskCacheAttributes();
045            attributes.setUserName( "java" );
046            attributes.setPassword( "letmein" );
047            attributes.setUrl( "jdbc:mysql://10.19.98.43:3306/flight_option_cache" );
048            attributes.setDriverClassName( "org.gjt.mm.mysql.Driver" );
049            String tableName = "JCS_STORE_FLIGHT_OPTION_ITINERARY";
050            attributes.setTableName( tableName );
051            TableState tableState = new TableState( tableName );
052    
053            MySQLTableOptimizer optimizer = new MySQLTableOptimizer( attributes, tableState, JDBCDiskCachePoolAccessFactory
054                .createPoolAccess( attributes ) );
055    
056            // DO WORK
057            optimizer.optimizeTable();
058        }
059    
060        /**
061         * Run the optimization against live a table.
062         * <p>
063         * @throws Exception
064         */
065        public void testBasicOptimizationUnknownTable()
066            throws Exception
067        {
068            // SETUP
069            MySQLDiskCacheAttributes attributes = new MySQLDiskCacheAttributes();
070            attributes.setUserName( "java" );
071            attributes.setPassword( "letmein" );
072            attributes.setUrl( "jdbc:mysql://10.19.98.43:3306/flight_option_cache" );
073            attributes.setDriverClassName( "org.gjt.mm.mysql.Driver" );
074            String tableName = "DOESNTEXIST";
075            attributes.setTableName( tableName );
076            TableState tableState = new TableState( tableName );
077    
078            MySQLTableOptimizer optimizer = new MySQLTableOptimizer( attributes, tableState, JDBCDiskCachePoolAccessFactory
079                .createPoolAccess( attributes ) );
080    
081            // DO WORK
082            optimizer.optimizeTable();
083        }
084    }