@Test(expectedExceptions = IllegalStateException.class) @Transactional(propagation = Propagation.NOT_SUPPORTED) public void flagForCommitWithNonExistentTransactionContext() { TestTransaction.flagForCommit(); }
@Test(expected = IllegalStateException.class) @Transactional(propagation = Propagation.NOT_SUPPORTED) public void flagForCommitWithNonExistentTransactionContext() { TestTransaction.flagForCommit(); }
@Test public void commitTxButDoNotStartNewTx() { assertInTransaction(true); assertTrue(TestTransaction.isActive()); assertUsers("Dilbert"); deleteFromTables("user"); assertUsers(); // Commit TestTransaction.flagForCommit(); assertFalse(TestTransaction.isFlaggedForRollback()); TestTransaction.end(); assertFalse(TestTransaction.isActive()); assertInTransaction(false); assertUsers(); executeSqlScript("classpath:/org/springframework/test/context/jdbc/data-add-dogbert.sql", false); assertUsers("Dogbert"); }
@Test public void commitTxAndStartNewTx() { assertInTransaction(true); assertTrue(TestTransaction.isActive()); assertUsers("Dilbert"); deleteFromTables("user"); assertUsers(); // Commit TestTransaction.flagForCommit(); assertFalse(TestTransaction.isFlaggedForRollback()); TestTransaction.end(); assertInTransaction(false); assertFalse(TestTransaction.isActive()); assertUsers(); executeSqlScript("classpath:/org/springframework/test/context/jdbc/data-add-dogbert.sql", false); assertUsers("Dogbert"); TestTransaction.start(); assertInTransaction(true); assertTrue(TestTransaction.isActive()); }
@Test public void commitTxButDoNotStartNewTx() { assertInTransaction(true); assertTrue(TestTransaction.isActive()); assertUsers("Dilbert"); deleteFromTables("user"); assertUsers(); // Commit TestTransaction.flagForCommit(); assertFalse(TestTransaction.isFlaggedForRollback()); TestTransaction.end(); assertFalse(TestTransaction.isActive()); assertInTransaction(false); assertUsers(); executeSqlScript("classpath:/org/springframework/test/context/jdbc/data-add-dogbert.sql", false); assertUsers("Dogbert"); }
@Test public void commitTxAndStartNewTx() { assertInTransaction(true); assertTrue(TestTransaction.isActive()); assertUsers("Dilbert"); deleteFromTables("user"); assertUsers(); // Commit TestTransaction.flagForCommit(); assertFalse(TestTransaction.isFlaggedForRollback()); TestTransaction.end(); assertInTransaction(false); assertFalse(TestTransaction.isActive()); assertUsers(); executeSqlScript("classpath:/org/springframework/test/context/jdbc/data-add-dogbert.sql", false); assertUsers("Dogbert"); TestTransaction.start(); assertInTransaction(true); assertTrue(TestTransaction.isActive()); }
/** * Manually trigger the cleanup registry */ @SuppressWarnings("deprecation") public void testNodeCleanupRegistry() throws Exception { TestTransaction.flagForCommit(); TestTransaction.end(); // REPO-2963: this test takes a long time in order to pass on a clean DB. NodeCleanupRegistry cleanupRegistry = (NodeCleanupRegistry) applicationContext.getBean("nodeCleanupRegistry"); cleanupRegistry.doClean(); }
@Before public void before() throws Exception { super.before(); System.out.println("java.io.tmpdir == " + System.getProperty("java.io.tmpdir")); // Get the required services this.nodeService = (NodeService) this.applicationContext.getBean("nodeService"); this.contentService = (ContentService) this.applicationContext.getBean("contentService"); this.authenticationService = (MutableAuthenticationService) this.applicationContext .getBean("authenticationService"); this.actionService = (ActionService) this.applicationContext.getBean("actionService"); this.transactionService = (TransactionService) this.applicationContext.getBean("transactionComponent"); this.authenticationComponent = (AuthenticationComponent) this.applicationContext .getBean("authenticationComponent"); this.receiver = (RepoTransferReceiverImpl) this.applicationContext.getBean("transferReceiver"); this.policyComponent = (PolicyComponent) this.applicationContext.getBean("policyComponent"); this.searchService = (SearchService) this.applicationContext.getBean("searchService"); this.repositoryHelper = (Repository) this.applicationContext.getBean("repositoryHelper"); this.namespaceService = (NamespaceService) this.applicationContext.getBean("namespaceService"); this.dummyContent = "This is some dummy content."; this.dummyContentBytes = dummyContent.getBytes("UTF-8"); authenticationComponent.setSystemUserAsCurrentUser(); guestHome = repositoryHelper.getGuestHome(); TestTransaction.flagForCommit(); TestTransaction.end(); }
/** * Ensure that transactionless calls are handled */ public void testCallWithoutTxn() { TestTransaction.flagForCommit(); TestTransaction.end(); nodeService.getAllRootNodes(rootNodeRef.getStoreRef()); }
@Test public void testAddVersionableAspectWithMajorVersionType() { // MAJOR version-type specified when adding the aspect NodeRef nodeRef = createNodeWithVersionType(VersionType.MAJOR); TestTransaction.flagForCommit(); TestTransaction.end(); assertCorrectVersionLabel(nodeRef, "1.0"); }
@Test public void testAddVersionableAspectWithMinorVersionType() { // MINOR version-type specified when adding the aspect NodeRef nodeRef = createNodeWithVersionType(VersionType.MINOR); TestTransaction.flagForCommit(); TestTransaction.end(); assertCorrectVersionLabel(nodeRef, "0.1"); }
@Test public void testAddVersionableAspectWithNoVersionType() { // No version-type specified when adding the aspect NodeRef nodeRef = createNodeWithVersionType(null); TestTransaction.flagForCommit(); TestTransaction.end(); assertCorrectVersionLabel(nodeRef, "1.0"); }
this.dbNodeService.addAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE, props); TestTransaction.flagForCommit(); TestTransaction.end();
public void xtestAsyncLoadTest() { // TODO this is very weak .. how do we improve this ??? Action action = this.actionService.createAction(AddFeaturesActionExecuter.NAME); action.setParameterValue(AddFeaturesActionExecuter.PARAM_ASPECT_NAME, ContentModel.ASPECT_VERSIONABLE); action.setExecuteAsynchronously(true); for (int i = 0; i < 1000; i++) { this.actionService.executeAction(action, this.nodeRef); } TestTransaction.flagForCommit(); TestTransaction.end(); // TODO how do we assess whether the large number of actions stacked cause a problem ?? }
/** * <a href="https://issues.alfresco.com/jira/browse/ALF-14929">ALF-14929</a> */ public synchronized void testTxnCommitTime() throws Exception { String currentTxn = AlfrescoTransactionSupport.getTransactionId(); assertNotNull("Must have a txn change UUID for all transactions."); long start = System.currentTimeMillis(); this.wait(10L); // The listener final TestTxnCommitTimeTxnListener listener = new TestTxnCommitTimeTxnListener(); AlfrescoTransactionSupport.bindListener(listener); // First see what the latest transaction is long currentTxnCommitTime = listener.getTxnCommitTime(currentTxn, start); assertEquals("Should not have found a written txn", 0L, currentTxnCommitTime); // Now commit TestTransaction.flagForCommit(); TestTransaction.end(); // Now check again. The transaction time must be greater than the last time that // the listener wrote through. long recordedCommitTimeMs = listener.getTxnCommitTime(currentTxn, start); assertTrue( "DAO txn write time must be greater than last listener write time", recordedCommitTimeMs > listener.lastWriteTime); }
/** * See REPO-2257, MNT-17661 */ @Test public void testLastThumbnailModificationDataContentCopy() throws Exception { final NodeRef pdfOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_PDF); QName qname = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "doclib"); ThumbnailDefinition details = thumbnailService.getThumbnailRegistry().getThumbnailDefinition(qname.getLocalName()); NodeRef thumbnail = this.thumbnailService.createThumbnail(pdfOrig, ContentModel.PROP_CONTENT, MimetypeMap.MIMETYPE_IMAGE_JPEG, details.getTransformationOptions(), "doclib"); assertNotNull(thumbnail); TestTransaction.flagForCommit(); TestTransaction.end(); Thread.sleep(1000); // Get initial value of property "Last thumbnail modification data" List<String>lastThumbnailData = (List<String>)this.secureNodeService.getProperty(pdfOrig, ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA); assertNotNull(lastThumbnailData); assertEquals(1, lastThumbnailData.size()); assertTrue(lastThumbnailData.get(0).contains("doclib:")); final NodeRef pdfCopy = copyService.copy(pdfOrig, this.folder, ContentModel.ASSOC_CONTAINS, QName.createQName("copyOfOriginal")); List<String> lastThumbnailDataCopy = (List<String>)this.secureNodeService.getProperty(pdfCopy, ContentModel.PROP_LAST_THUMBNAIL_MODIFICATION_DATA); assertNull(lastThumbnailDataCopy); }
1, nodeService.getSourceAssocs(workingCopy, ContentModel.ASSOC_WORKING_COPY_LINK).size()); TestTransaction.flagForCommit(); TestTransaction.end();
TestTransaction.flagForCommit(); TestTransaction.end();
@SuppressWarnings("deprecation") @Test public void testAutoUpdate() throws Exception { checkTransformer(); final NodeRef jpgOrig = createOriginalContent(this.folder, MimetypeMap.MIMETYPE_IMAGE_JPEG); ThumbnailDefinition details = this.thumbnailService.getThumbnailRegistry().getThumbnailDefinition("medium"); @SuppressWarnings("unused") final NodeRef thumbnail = this.thumbnailService.createThumbnail(jpgOrig, ContentModel.PROP_CONTENT, details .getMimetype(), details.getTransformationOptions(), details.getName()); TestTransaction.flagForCommit(); TestTransaction.end(); transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionCallback<Object>() { public Object execute() throws Exception { String ext = ThumbnailServiceImplTest.this.mimetypeMap.getExtension(MimetypeMap.MIMETYPE_IMAGE_JPEG); File origFile = AbstractContentTransformerTest.loadQuickTestFile(ext); ContentWriter writer = ThumbnailServiceImplTest.this.contentService.getWriter(jpgOrig, ContentModel.PROP_CONTENT, true); writer.putContent(origFile); return null; } }); // TODO // this test should wait for the async action to run .. will need to // commit transaction for that thou! // Thread.sleep(1000); }
nodeService.hasAspect(workingCopy, ContentModel.ASPECT_COPIEDFROM)); TestTransaction.flagForCommit(); TestTransaction.end();