当前位置: 首页>>代码示例>>Java>>正文


Java NotSupportedException类代码示例

本文整理汇总了Java中javax.transaction.NotSupportedException的典型用法代码示例。如果您正苦于以下问题:Java NotSupportedException类的具体用法?Java NotSupportedException怎么用?Java NotSupportedException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NotSupportedException类属于javax.transaction包,在下文中一共展示了NotSupportedException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPasswordConverter

import javax.transaction.NotSupportedException; //导入依赖的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

示例2: testSingleTable

import javax.transaction.NotSupportedException; //导入依赖的package包/类
/**
 * Tests annotation literals in a jar archive
 */
@Test
@SuppressWarnings("unchecked")
public void testSingleTable() {
	logger.info("starting single table inheritance test");
	Pet pet = new Pet("jackrussell", "dog");
	Dog dog = new Dog("mastino", "dog");
	try {
		userTransaction.begin();
		entityManager.persist(pet);
		entityManager.persist(dog);
		userTransaction.commit();
	} catch (NotSupportedException | SystemException | IllegalStateException | SecurityException
			| HeuristicMixedException | HeuristicRollbackException | RollbackException e) {
		fail();
	}
	List<Pet> petsFromDB = entityManager.createNativeQuery("select * from pet").getResultList();
	assertEquals("only the pet table exists", 2, petsFromDB.size());
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:22,代码来源:InheritanceTestCase.java

示例3: testTablePerClass

import javax.transaction.NotSupportedException; //导入依赖的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.NotSupportedException; //导入依赖的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.NotSupportedException; //导入依赖的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.NotSupportedException; //导入依赖的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.NotSupportedException; //导入依赖的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.NotSupportedException; //导入依赖的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: testSimpleTransaction

import javax.transaction.NotSupportedException; //导入依赖的package包/类
/**
 * Tests the fire of the event inside a transaction
 */
@Test
public void testSimpleTransaction() {
	try {
		userTransaction.begin();
		Bill bill = fire();
		assertEquals(
				"The id generation passes through the always and it is incremented only by inprogess always observer method",
				1, bill.getId());
		userTransaction.commit();
		assertEquals(
				"The id generation passes through the always and it is incremented only by transactional observer methods",
				4, bill.getId());
	} catch (NotSupportedException | SystemException | SecurityException | IllegalStateException | RollbackException
			| HeuristicMixedException | HeuristicRollbackException e) {
		fail("no fail for the transaction");
	}

}
 
开发者ID:PacktPublishing,项目名称:Mastering-Java-EE-Development-with-WildFly,代码行数:22,代码来源:EventTestCase.java

示例10: testFailedTransaction

import javax.transaction.NotSupportedException; //导入依赖的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

示例11: createUsers

import javax.transaction.NotSupportedException; //导入依赖的package包/类
private void createUsers() throws HeuristicRollbackException, RollbackException, HeuristicMixedException, SystemException, NotSupportedException
    {
        txn = transactionService.getUserTransaction();
        txn.begin();
        for (UserInfo user : userInfos)
        {
            String username = user.getUserName();
            NodeRef nodeRef = personService.getPersonOrNull(username);
            boolean create = nodeRef == null;
            if (create)
            {
                PropertyMap testUser = new PropertyMap();
                testUser.put(ContentModel.PROP_USERNAME, username);
                testUser.put(ContentModel.PROP_FIRSTNAME, user.getFirstName());
                testUser.put(ContentModel.PROP_LASTNAME, user.getLastName());
                testUser.put(ContentModel.PROP_EMAIL, user.getUserName() + "@acme.test");
                testUser.put(ContentModel.PROP_PASSWORD, "password");

                nodeRef = personService.createPerson(testUser);
            }
            userNodeRefs.add(nodeRef);
//            System.out.println((create ? "create" : "existing")+" user " + username + " nodeRef=" + nodeRef);
        }
        txn.commit();
    }
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:PeopleTest.java

示例12: basicRollbackTest

import javax.transaction.NotSupportedException; //导入依赖的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() );
    }
}
 
开发者ID:agroal,项目名称:agroal,代码行数:25,代码来源:BasicNarayanaTests.java

示例13: multipleCloseTest

import javax.transaction.NotSupportedException; //导入依赖的package包/类
@Test
@DisplayName( "Multiple close test" )
public void multipleCloseTest() 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 ) ) {

        // there is a call to connection#close in the try-with-resources block and another on the callback from the transaction#commit()
        try ( Connection connection = dataSource.getConnection() ) {
            logger.info( format( "Got connection {0}", connection ) );
            try {
                txManager.begin();
                txManager.commit();
            } catch ( NotSupportedException | SystemException | RollbackException | HeuristicMixedException | HeuristicRollbackException e ) {
                fail( "Exception: " + e.getMessage() );
            }
        }  
    }
}
 
开发者ID:agroal,项目名称:agroal,代码行数:26,代码来源:BasicNarayanaTests.java

示例14: configTest

import javax.transaction.NotSupportedException; //导入依赖的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();
        }
    }
}
 
开发者ID:Uniandes-ISIS2603-backup,项目名称:201710-paseos_01,代码行数:23,代码来源:FotoPersistenceTest.java

示例15: configTest

import javax.transaction.NotSupportedException; //导入依赖的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();
        }
    }
}
 
开发者ID:Uniandes-ISIS2603-backup,项目名称:201710-paseos_01,代码行数:22,代码来源:FotoLogicTest.java


注:本文中的javax.transaction.NotSupportedException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。