use of org.apache.jena.shared.Command in project jena by apache.
the class TransactionHandlerContractTest method testTransactionsExistAsPerTransactionSupported.
/**
* Test that Graphs have transaction support methods, and that if they fail
* on some g they fail because they do not support the operation.
*/
@SuppressWarnings("deprecation")
@ContractTest
public void testTransactionsExistAsPerTransactionSupported() {
// Write out explicitly
Command cmd = new Command() {
@Override
public Object execute() {
return null;
}
};
TransactionHandler th = getTransactionHandlerProducer().newInstance();
if (th.transactionsSupported()) {
th.begin();
th.abort();
th.begin();
th.commit();
th.execute(() -> {
});
th.calculate(() -> null);
th.executeInTransaction(cmd);
th.executeInTransaction(() -> null);
} else {
try {
th.begin();
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.abort();
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.commit();
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
/* */
try {
th.execute(() -> {
});
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.calculate(() -> null);
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.executeInTransaction(cmd);
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
try {
th.executeInTransaction(() -> null);
fail("Should have thrown UnsupportedOperationException");
} catch (UnsupportedOperationException x) {
}
}
}
use of org.apache.jena.shared.Command in project jena by apache.
the class rdfparse method runTests.
/**
wrapped this way so JUnit not a compile-time requirement.
*/
protected static void runTests(boolean internetTest) throws Exception {
Class<?> rdfparse = Class.forName("jena.test.rdfparse");
Constructor<?> constructor = rdfparse.getConstructor(new Class[] { boolean.class });
Command c = (Command) constructor.newInstance(new Object[] { internetTest });
c.execute();
// ARPTests.internet = internetTest;
// TestRunner.main( new String[] { "-noloading", ARPTests.class.getName()});
}
use of org.apache.jena.shared.Command in project jena by apache.
the class TransactionHandlerContractTest method testExecuteInTransactionCatchesThrowable.
@SuppressWarnings("deprecation")
@ContractTest
public void testExecuteInTransactionCatchesThrowable() {
TransactionHandler th = getTransactionHandlerProducer().newInstance();
if (th.transactionsSupported()) {
Command cmd = new Command() {
@Override
public Object execute() throws Error {
throw new Error();
}
};
try {
th.executeInTransaction(cmd);
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
try {
th.execute(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
try {
th.calculate(() -> {
throw new Error();
});
fail("Should have thrown JenaException");
} catch (JenaException x) {
}
}
}
use of org.apache.jena.shared.Command in project jena by apache.
the class AbstractTestGraph method testHasTransactions.
// public void testStuff()
// {
//// testAGraph( "StoreMem", new GraphMem() );
//// testAGraph( "StoreMemBySubject", new GraphMem() );
//// String [] empty = new String [] {};
//// Graph g = graphWith( "x R y; p S q; a T b" );
//// /* */
//// assertContainsAll( "simple graph", g, "x R y; p S q; a T b" );
//// graphAdd( g, "spindizzies lift cities; Diracs communicate instantaneously" );
//// g.delete( triple( "x R y" ) );
//// g.delete( triple( "a T b" ) );
//// assertContainsAll( "modified simple graph", g, "p S q; spindizzies lift cities; Diracs communicate instantaneously" );
//// assertOmitsAll( "modified simple graph", g, "x R y; a T b" );
// }
/**
Test that Graphs have transaction support methods, and that if they fail
on some g they fail because they do not support the operation.
*/
public void testHasTransactions() {
Graph g = getGraph();
TransactionHandler th = g.getTransactionHandler();
th.transactionsSupported();
try {
th.begin();
} catch (UnsupportedOperationException x) {
}
try {
th.abort();
} catch (UnsupportedOperationException x) {
}
try {
th.begin();
th.commit();
} catch (UnsupportedOperationException x) {
}
/* */
Command cmd = new Command() {
@Override
public Object execute() {
return null;
}
};
try {
th.execute(() -> {
});
} catch (UnsupportedOperationException x) {
}
}
Aggregations