本文整理匯總了Java中javax.transaction.SystemException類的典型用法代碼示例。如果您正苦於以下問題:Java SystemException類的具體用法?Java SystemException怎麽用?Java SystemException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SystemException類屬於javax.transaction包,在下文中一共展示了SystemException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testStatefulLocalNaming
import javax.transaction.SystemException; //導入依賴的package包/類
@Test
public void testStatefulLocalNaming() {
logger.info("starting session local stateful test");
try {
userTransaction.begin();
logger.info(stateEngineLocal + "");
int result = stateEngineLocal.go(1);
assertEquals(stateEngineLocal.getSpeed(), 1);
logger.info(result + "");
logger.info(stateEngineLocal + "");
assertEquals(stateEngineLocal.getSpeed(), 1);
stateEngineLocal.add(new MyData());
stateEngineLocal.log();
userTransaction.commit();
} catch (Exception ex) {
try {
userTransaction.rollback();
} catch (IllegalStateException | SecurityException | SystemException e) {
logger.severe("extreme error. The rollback doesn't work");
}
}
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:23,代碼來源:SessionContextTestCase.java
示例2: testPasswordConverter
import javax.transaction.SystemException; //導入依賴的package包/類
@Test
public void testPasswordConverter() {
logger.info("starting persistence converter test");
Citizen citizen = new Citizen();
citizen.setPassword("prova");
try {
userTransaction.begin();
entityManager.persist(citizen);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
Citizen citizenFromDB = (Citizen) entityManager.createQuery("from citizen").getSingleResult();
assertEquals("the password is always converted by the converter", "prova", citizenFromDB.getPassword());
assertEquals("this is the password we have in the database", "cHJvdmE=", NEVER_DO_IT);
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:18,代碼來源:ConverterTestCase.java
示例3: testTablePerClass
import javax.transaction.SystemException; //導入依賴的package包/類
/**
* Tests annotation literals in a jar archive
*/
@Test
@SuppressWarnings("unchecked")
public void testTablePerClass() {
logger.info("starting table per class inheritance test");
Vehicle vehicle = new Vehicle("peugeot", "car");
Car car = new Car("fiat", "car");
try {
userTransaction.begin();
entityManager.persist(vehicle);
entityManager.persist(car);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
List<Vehicle> vehiclesFromDB = entityManager.createNativeQuery("select * from vehicle").getResultList();
assertEquals("the vehicle table exists", 1, vehiclesFromDB.size());
List<Car> carsFromDB = entityManager.createNativeQuery("select * from car").getResultList();
assertEquals("the car table exists", 1, carsFromDB.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:24,代碼來源:InheritanceTestCase.java
示例4: testJoin
import javax.transaction.SystemException; //導入依賴的package包/類
/**
* Tests annotation literals in a jar archive
*/
@Test
@SuppressWarnings("unchecked")
public void testJoin() {
logger.info("starting joined inheritance event test");
Watch watch = new Watch();
TopicWatch topicWatch = new TopicWatch();
try {
userTransaction.begin();
entityManager.persist(watch);
entityManager.persist(topicWatch);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
List<Watch> watchesFromDB = entityManager.createNativeQuery("select * from JBP_FORUMS_WATCH").getResultList();
assertEquals("the watch table exists", 2, watchesFromDB.size());
List<TopicWatch> topicWatchesFromDB = entityManager.createNativeQuery("select * from JBP_FORUMS_TOPICSWATCH")
.getResultList();
assertEquals("the topic watch table exists", 1, topicWatchesFromDB.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:25,代碼來源:InheritanceTestCase.java
示例5: testSearch
import javax.transaction.SystemException; //導入依賴的package包/類
@Test
public void testSearch() {
Forum forum = entityManager.find(Forum.class, 0);
Poster poster = new Poster("root");
Topic topic = new Topic(forum, TOPIC_TEXT);
topic.setPoster(poster);
Post post = new Post(topic, POST_TEXT);
post.setCreateDate(new Date());
post.setPoster(poster);
try {
userTransaction.begin();
entityManager.persist(poster);
entityManager.persist(topic);
entityManager.persist(post);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
e.printStackTrace();
}
List<Topic> topics = findTopics();
List<Post> posts = findPosts();
assertEquals("find topics", 1, topics.size());
assertEquals("find posts", 1, posts.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:25,代碼來源:SearchTestCase.java
示例6: testDeleteManyToMany
import javax.transaction.SystemException; //導入依賴的package包/類
@Test
public void testDeleteManyToMany() {
logger.info("starting merge many to many cascade test");
testPersistManyToMany();
try {
userTransaction.begin();
Author davide_scala = (Author) entityManager.createQuery("from Author where fullName = :fullName")
.setParameter("fullName", "Davide Scala").getSingleResult();
davide_scala.remove();
entityManager.remove(davide_scala);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
@SuppressWarnings("unchecked")
List<Book> booksFromDb = entityManager.createNativeQuery("select * from Book").getResultList();
assertEquals("the book table exists", 2, booksFromDb.size());
@SuppressWarnings("unchecked")
List<Author> authorsFromDb = entityManager.createNativeQuery("select * from Author").getResultList();
assertEquals("the author table exists", 2, authorsFromDb.size());
@SuppressWarnings("unchecked")
List<Author> bookAuthorsFromDb = entityManager.createNativeQuery("select * from Book_Author").getResultList();
assertEquals("the author table exists", 4, bookAuthorsFromDb.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:26,代碼來源:CascadeTestCase.java
示例7: testDeleteBooksAllManyToMany
import javax.transaction.SystemException; //導入依賴的package包/類
@Test
public void testDeleteBooksAllManyToMany() {
logger.info("starting merge many to many cascade test");
testPersistManyToMany();
try {
userTransaction.begin();
PMAuthor davide_scala = (PMAuthor) entityManager.createQuery("from PMAuthor where fullName = :fullName")
.setParameter("fullName", "Davide Scala").getSingleResult();
entityManager.remove(davide_scala);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
@SuppressWarnings("unchecked")
List<PMBook> booksFromDb = entityManager.createNativeQuery("select * from PMBook").getResultList();
assertEquals("the pm book table exists", 1, booksFromDb.size());
@SuppressWarnings("unchecked")
List<PMAuthor> authorsFromDb = entityManager.createNativeQuery("select * from PMAuthor").getResultList();
assertEquals("the pm author table exists", 2, authorsFromDb.size());
@SuppressWarnings("unchecked")
List<PMAuthor> bookAuthorsFromDb = entityManager.createNativeQuery("select * from Book_PM_Author")
.getResultList();
assertEquals("the pm book author table exists", 2, bookAuthorsFromDb.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:26,代碼來源:CascadeTestCase.java
示例8: testDeleteBooksJoinTableAllManyToMany
import javax.transaction.SystemException; //導入依賴的package包/類
@Test
public void testDeleteBooksJoinTableAllManyToMany() {
logger.info("starting merge many to many cascade test");
testPersistManyToMany();
try {
userTransaction.begin();
AllAuthor davide_scala = (AllAuthor) entityManager.createQuery("from AllAuthor where fullName = :fullName")
.setParameter("fullName", "Davide Scala").getSingleResult();
entityManager.remove(davide_scala);
userTransaction.commit();
} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
fail();
}
@SuppressWarnings("unchecked")
List<AllBook> booksFromDb = entityManager.createNativeQuery("select * from AllBook").getResultList();
assertEquals("the all book table doesn't exist", 0, booksFromDb.size());
@SuppressWarnings("unchecked")
List<AllAuthor> authorsFromDb = entityManager.createNativeQuery("select * from AllAuthor").getResultList();
assertEquals("the all author table doesn't exist", 0, authorsFromDb.size());
@SuppressWarnings("unchecked")
List<AllAuthor> bookAuthorsFromDb = entityManager.createNativeQuery("select * from Book_All_Author")
.getResultList();
assertEquals("the all book author table exists", 0, bookAuthorsFromDb.size());
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:26,代碼來源:CascadeTestCase.java
示例9: testFailedTransaction
import javax.transaction.SystemException; //導入依賴的package包/類
/**
* Tests the fire of the event inside a failed transaction
*/
@Test
public void testFailedTransaction() {
Bill bill = null;
try {
userTransaction.begin();
bill = fire();
assertEquals(
"The id generation passes through the always and it is incremented only by inprogess always observer method",
1, bill.getId());
throw new RollbackException();
} catch (NotSupportedException | SystemException | SecurityException | IllegalStateException
| RollbackException e) {
try {
userTransaction.rollback();
assertEquals(
"The id generation passes through the always and it is incremented only by transactional failure observer methods",
3, bill.getId());
} catch (SystemException se) {
}
}
}
開發者ID:PacktPublishing,項目名稱:Mastering-Java-EE-Development-with-WildFly,代碼行數:27,代碼來源:EventTestCase.java
示例10: basicRollbackTest
import javax.transaction.SystemException; //導入依賴的package包/類
@Test
@DisplayName( "Basic rollback test" )
public void basicRollbackTest() throws SQLException {
TransactionManager txManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
TransactionSynchronizationRegistry txSyncRegistry = new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple();
AgroalDataSourceConfigurationSupplier configurationSupplier = new AgroalDataSourceConfigurationSupplier()
.connectionPoolConfiguration( cp -> cp
.transactionIntegration( new NarayanaTransactionIntegration( txManager, txSyncRegistry ) )
);
try ( AgroalDataSource dataSource = AgroalDataSource.from( configurationSupplier ) ) {
txManager.begin();
Connection connection = dataSource.getConnection();
logger.info( format( "Got connection {0}", connection ) );
txManager.rollback();
assertTrue( connection.isClosed() );
} catch ( NotSupportedException | SystemException e ) {
fail( "Exception: " + e.getMessage() );
}
}
示例11: configTest
import javax.transaction.SystemException; //導入依賴的package包/類
/**
* Configuración inicial de la prueba.
*
* @generated
*/
@Before
public void configTest()
{
try {
utx.begin();
clearData();
insertData();
utx.commit();
} catch (IllegalStateException | SecurityException | HeuristicMixedException | HeuristicRollbackException | NotSupportedException | RollbackException | SystemException e) {
e.printStackTrace();
try {
utx.rollback();
} catch (IllegalStateException | SecurityException | SystemException e1) {
e1.printStackTrace();
}
}
}
示例12: setSiteMembership
import javax.transaction.SystemException; //導入依賴的package包/類
private void setSiteMembership(String authority, String siteName, String doAsUser)
throws SystemException, Exception
{
String currentUser = authenticationComponent.getCurrentUserName();
UserTransaction txn = transactionService.getUserTransaction();
try
{
if (doAsUser != null)
authenticationComponent.setCurrentUser(doAsUser);
txn.begin();
siteService.setMembership(siteName, authority, SiteModel.SITE_COLLABORATOR);
txn.commit();
}
catch (Exception e)
{
txn.rollback();
throw e;
}
finally
{
authenticationComponent.setCurrentUser(currentUser);
}
}
示例13: suspend
import javax.transaction.SystemException; //導入依賴的package包/類
/**
* @see javax.transaction.TransactionManager#suspend()
*/
public Transaction suspend() throws SystemException {
if (!isActive) {
throw new SystemException(
LocalizedStrings.TransactionManagerImpl_TRANSACTIONMANAGER_INVALID.toLocalizedString());
}
Transaction txn = getTransaction();
if (null != txn) {
GlobalTransaction gtx = getGlobalTransaction(txn);
gtx.suspend();
transactionMap.remove(Thread.currentThread());
LogWriterI18n writer = TransactionUtils.getLogWriterI18n();
if (writer.infoEnabled())
writer.info(
LocalizedStrings.TransactionManagerImpl_TRANSACTIONMANAGERIMPLSUSPENDTRANSACTION_SUSPENDED);
}
return txn;
}
示例14: afterAfterCompletion
import javax.transaction.SystemException; //導入依賴的package包/類
@Override
protected void afterAfterCompletion() {
// this method is a noop if there is a Synchronization!
try {
if ( isDriver ) {
if ( !isInitiator ) {
LOG.setManagerLookupClass();
}
try {
transactionCoordinator().afterTransaction( this, userTransaction.getStatus() );
}
catch (SystemException e) {
throw new TransactionException( "Unable to determine UserTransaction status", e );
}
}
}
finally {
isInitiator = false;
}
}
示例15: enrollConnectionCloseTest
import javax.transaction.SystemException; //導入依賴的package包/類
@Test
@DisplayName( "Enroll connection after previous connection close test" )
public void enrollConnectionCloseTest() throws SQLException {
TransactionManager txManager = com.arjuna.ats.jta.TransactionManager.transactionManager();
TransactionSynchronizationRegistry txSyncRegistry = new com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionSynchronizationRegistryImple();
AgroalDataSourceConfigurationSupplier configurationSupplier = new AgroalDataSourceConfigurationSupplier()
.connectionPoolConfiguration( cp -> cp
.transactionIntegration( new NarayanaTransactionIntegration( txManager, txSyncRegistry ) )
.connectionFactoryConfiguration( cf -> cf
.autoCommit( true ) )
);
try ( AgroalDataSource dataSource = AgroalDataSource.from( configurationSupplier ) ) {
txManager.begin();
Connection connection = dataSource.getConnection();
logger.info( format( "Got connection {0}", connection ) );
String connectionToString = connection.toString();
connection.close();
Connection secondConnection = dataSource.getConnection();
logger.info( format( "Got connection {0}", secondConnection ) );
// TODO: comparing toString is brittle. Find a better way to make sure the underlying physical connection is the same.
assertEquals( connectionToString, secondConnection.toString(), "Expect the same connection under the same transaction" );
assertFalse( secondConnection.getAutoCommit(), "AutoCommit temporarily disabled in enlisted connection" );
secondConnection.close();
txManager.commit();
assertTrue( connection.isClosed() );
assertTrue( secondConnection.isClosed() );
} catch ( NotSupportedException | SystemException | RollbackException | HeuristicMixedException | HeuristicRollbackException e ) {
fail( "Exception: " + e.getMessage() );
}
}