Package org.activemq.store.journal

Source Code of org.activemq.store.journal.JournalTestHelper

/**
*
* Copyright 2004 Hiram Chirino
*
* 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.activemq.store.journal;

import java.io.File;

import org.activemq.store.PersistenceAdapter;
import org.activemq.store.vm.VMPersistenceAdapter;


/**
* Tests the JournalPersistenceAdapter
*
* @version $Revision: 1.1 $
*/
public class JournalTestHelper {

    VMPersistenceAdapter vmPersistenceAdapter;
   
    public PersistenceAdapter createPersistenceAdapter(String journalType) throws Exception {
        File directory = new File("target/journal");
        if( vmPersistenceAdapter==null ) {
            delete(directory);
            vmPersistenceAdapter = new VMPersistenceAdapter();
        }
        JournalPersistenceAdapter adapter = new JournalPersistenceAdapter(directory, vmPersistenceAdapter);
        adapter.setJournalType(journalType);
        return adapter;
    }

    static public void delete(File file) {
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (int i = 0; i < files.length; i++) {
                delete(files[i]);
            }
        }
        file.delete();
    }

}
TOP

Related Classes of org.activemq.store.journal.JournalTestHelper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.