Commit 4bee6a7a authored by Andre Freyssinet's avatar Andre Freyssinet

Tests JMQ-215: CREATE after DELETE.

parent e98af919
package fr.dyade.aaa.util;
import java.io.File;
import java.io.IOException;
import org.junit.Test;
import fr.dyade.aaa.ext.NGTransaction;
import junit.framework.Assert;
/**
* This test highlights a bad behavior of txlog when using the create operation (see JMQ-215).
* This bug could be present in the other transaction modules but only manifests itself with
* the transaction grouping specific to txlog and batchengine.
*/
public class CreateTest {
@Test
public void test1() throws Exception {
byte[] bytes = new byte[100];
String name = "nameOfTheObject";
String logpath = "./target/createTestTxDir1";
delete(new File(logpath));
NGTransaction transaction = new NGTransaction();
transaction.init(logpath);
transaction.createByteArray(bytes, name);
transaction.begin();
transaction.commit(true);
for (int i=0; i<10; i++) {
bytes = new byte[100];
transaction.saveByteArray(bytes, name);
transaction.begin();
transaction.commit(true);
}
transaction.delete(name);
transaction.begin();
transaction.commit(true);
bytes = new byte[100];
transaction.saveByteArray(bytes, name);
transaction.begin();
transaction.commit(true);
transaction.garbage(0);
transaction.delete(name);
transaction.createByteArray(bytes, name);
transaction.begin();
transaction.commit(true);
transaction.delete(name);
transaction.begin();
transaction.commit(true);
transaction.garbage(0);
transaction.close();
transaction.init(logpath);
bytes = transaction.loadByteArray(name);
Assert.assertNull(bytes);
transaction.close();
}
public static void delete(File f) throws IOException {
if (! f.exists()) return;
if (f.isDirectory()) {
for (File c : f.listFiles())
delete(c);
}
if (!f.delete())
throw new IOException("Failed to delete file: " + f);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment