/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you 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 com.hp.hpl.jena.tdb.transaction;

import static com.hp.hpl.jena.query.ReadWrite.READ ;
import static com.hp.hpl.jena.query.ReadWrite.WRITE ;
import org.junit.After ;
import org.junit.Before ;
import org.junit.Test ;
import org.openjena.atlas.lib.FileOps ;

import com.hp.hpl.jena.graph.Triple ;
import com.hp.hpl.jena.query.Dataset ;
import com.hp.hpl.jena.sparql.sse.SSE ;
import com.hp.hpl.jena.tdb.ConfigTest ;
import com.hp.hpl.jena.tdb.StoreConnection ;
import com.hp.hpl.jena.tdb.TDBFactory ;
import com.hp.hpl.jena.tdb.base.file.Location ;
import com.hp.hpl.jena.tdb.migrate.AbstractTestTransaction ;

public class TestTransactionTDB extends AbstractTestTransaction
{
    static final String DIR = ConfigTest.getTestingDirDB() ; 
    
    @Before public void before()
    {
        FileOps.clearDirectory(DIR) ; 
        StoreConnection.release(new Location(DIR)) ;
    }
    
    @After public void after()
    {
        FileOps.clearDirectory(DIR) ; 
    }
    
    @Override
    protected Dataset create()
    { 
        return TDBFactory.createDataset(DIR) ;
    }
    
    private static Triple triple1 = SSE.parseTriple("(<s> <p> <o>)") ;  

    
    @Test public void transaction_50()
    {
        // This assumes you have two datasets on the same location.
        // That's not necessarily true for uncached memory datasets, 
        // where you get two separate datasets so changes to one are
        // not seen by the other at all.
        
        Dataset ds1 = create() ;
        Dataset ds2 = create() ;
        
        ds1.begin(WRITE) ;
        ds1.getDefaultModel().getGraph().add(triple1) ; 
        
        ds2.begin(READ) ;
        assertTrue(ds2.getDefaultModel().isEmpty()) ;
        ds2.commit() ;
        
        ds1.commit() ;

        ds2.begin(READ) ;
        assertFalse(ds2.getDefaultModel().isEmpty()) ;
        assertEquals(1, ds2.getDefaultModel().size()) ;
        ds2.commit() ;
    }
}


@@ -1416,16 +1416,59 @@
 action ;
+%0Aimport com.hp.hpl.jena.tdb.sys.SystemTDB ;
 %0A%0Apublic
@@ -1542,102 +1542,236 @@
 tic 
-final String DIR = ConfigTest.getTestingDirDB() ; %0A    %0A    @Before public void before()%0A    %7B
+boolean nonDeleteableMMapFiles = SystemTDB.isWindows ;%0A    String DIR = null ; %0A    %0A    @Before public void before()%0A    %7B%0A        DIR = nonDeleteableMMapFiles ? ConfigTest.getTestingDirUnique() : ConfigTest.getTestingDirDB() ;
 %0A   

Adapt to Windows restrictions.