Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2014-02-03 06:41:28 +0000
committerUwe Stieber2014-02-03 06:41:28 +0000
commit0a4b69d943d532b9ba09b140eec415a431d6a2ac (patch)
treecd1d5ca894b2d6f4fdba3b16e1987794d294ed1e /target_explorer
parentd3ddd92b2b3c59a6f6cf6aedacea82c6c54ba818 (diff)
downloadorg.eclipse.tcf-0a4b69d943d532b9ba09b140eec415a431d6a2ac.tar.gz
org.eclipse.tcf-0a4b69d943d532b9ba09b140eec415a431d6a2ac.tar.xz
org.eclipse.tcf-0a4b69d943d532b9ba09b140eec415a431d6a2ac.zip
Target Explorer: Add a small wait to the state manager conflicting test
Diffstat (limited to 'target_explorer')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/utils/StateManagerTest.java229
1 files changed, 115 insertions, 114 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/utils/StateManagerTest.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/utils/StateManagerTest.java
index 1d04eb870..24c4fd224 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/utils/StateManagerTest.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/utils/StateManagerTest.java
@@ -1,114 +1,115 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tests.tcf.filesystem.utils;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.util.concurrent.TimeoutException;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.tcf.te.runtime.callback.Callback;
-import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCacheUpdate;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
-import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
-
-public class StateManagerTest extends UtilsTestBase {
-
- public void testCacheStateConsistent() throws Exception {
- cleanUp();
- writeFileContent("hello,world!"); //$NON-NLS-1$
- OpCacheUpdate update = new OpCacheUpdate(testFile);
- update.run(new NullProgressMonitor());
- CacheState cacheState = testFile.getCacheState();
- assertEquals(CacheState.consistent, cacheState);
- Thread.sleep(5000L);
- }
-
- public void testCacheStateModified() throws Exception {
- cleanUp();
- writeFileContent("hello,world!"); //$NON-NLS-1$
- OpCacheUpdate update = new OpCacheUpdate(testFile);
- update.run(new NullProgressMonitor());
- File file = CacheManager.getCacheFile(testFile);
- BufferedWriter writer = new BufferedWriter(new FileWriter(file));
- writer.write("hello, test!"); //$NON-NLS-1$
- writer.close();
- updateCacheState();
- CacheState cacheState = testFile.getCacheState();
- assertEquals(CacheState.modified, cacheState);
- Thread.sleep(5000L);
- }
-
- private void updateCacheState() throws TimeoutException {
- FileState digest = PersistenceManager.getInstance().getFileDigest(testFile);
- final Rendezvous rendezvous = new Rendezvous();
- digest.updateState(new Callback(){
- @Override
- protected void internalDone(Object caller, IStatus status) {
- rendezvous.arrive();
- }
- });
- rendezvous.waiting(10000);
- }
-
- private void refreshCacheState() throws TimeoutException {
- final Rendezvous rendezvous = new Rendezvous();
- testFile.refresh(new Callback(){
- @Override
- protected void internalDone(Object caller, IStatus status) {
- rendezvous.arrive();
- }
- });
- rendezvous.waiting(10000);
- }
-
-
- public void testCacheStateOutdated() throws Exception {
- cleanUp();
- writeFileContent("hello,world!"); //$NON-NLS-1$
- OpCacheUpdate update = new OpCacheUpdate(testFile);
- update.run(new NullProgressMonitor());
- writeFileContent("hello,test!"); //$NON-NLS-1$
- refreshCacheState();
- CacheState cacheState = testFile.getCacheState();
- assertEquals(CacheState.outdated, cacheState);
- Thread.sleep(5000L);
- }
-
- private void cleanUp() {
- File cacheFile = CacheManager.getCacheFile(testFile);
- if(cacheFile.exists()) {
- cacheFile.delete();
- }
- PersistenceManager.getInstance().removeFileDigest(testFile.getLocationURI());
- }
-
- public void testCacheStateConflict() throws Exception {
- cleanUp();
- writeFileContent("hello,world!"); //$NON-NLS-1$
- OpCacheUpdate update = new OpCacheUpdate(testFile);
- update.run(new NullProgressMonitor());
- writeFileContent("hello,test!"); //$NON-NLS-1$
- refreshCacheState();
- File file = CacheManager.getCacheFile(testFile);
- BufferedWriter writer = new BufferedWriter(new FileWriter(file));
- writer.write("hello, earth!"); //$NON-NLS-1$
- writer.close();
- updateCacheState();
- CacheState cacheState = testFile.getCacheState();
- assertEquals(CacheState.conflict, cacheState);
- Thread.sleep(5000L);
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tests.tcf.filesystem.utils;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.util.concurrent.TimeoutException;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.tcf.te.runtime.callback.Callback;
+import org.eclipse.tcf.te.tcf.core.concurrent.Rendezvous;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpCacheUpdate;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.CacheManager;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.FileState;
+import org.eclipse.tcf.te.tcf.filesystem.core.internal.utils.PersistenceManager;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.CacheState;
+
+public class StateManagerTest extends UtilsTestBase {
+
+ public void testCacheStateConsistent() throws Exception {
+ cleanUp();
+ writeFileContent("hello,world!"); //$NON-NLS-1$
+ OpCacheUpdate update = new OpCacheUpdate(testFile);
+ update.run(new NullProgressMonitor());
+ CacheState cacheState = testFile.getCacheState();
+ assertEquals(CacheState.consistent, cacheState);
+ Thread.sleep(5000L);
+ }
+
+ public void testCacheStateModified() throws Exception {
+ cleanUp();
+ writeFileContent("hello,world!"); //$NON-NLS-1$
+ OpCacheUpdate update = new OpCacheUpdate(testFile);
+ update.run(new NullProgressMonitor());
+ File file = CacheManager.getCacheFile(testFile);
+ BufferedWriter writer = new BufferedWriter(new FileWriter(file));
+ writer.write("hello, test!"); //$NON-NLS-1$
+ writer.close();
+ updateCacheState();
+ CacheState cacheState = testFile.getCacheState();
+ assertEquals(CacheState.modified, cacheState);
+ Thread.sleep(5000L);
+ }
+
+ private void updateCacheState() throws TimeoutException {
+ FileState digest = PersistenceManager.getInstance().getFileDigest(testFile);
+ final Rendezvous rendezvous = new Rendezvous();
+ digest.updateState(new Callback(){
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ rendezvous.arrive();
+ }
+ });
+ rendezvous.waiting(10000);
+ }
+
+ private void refreshCacheState() throws TimeoutException {
+ final Rendezvous rendezvous = new Rendezvous();
+ testFile.refresh(new Callback(){
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ rendezvous.arrive();
+ }
+ });
+ rendezvous.waiting(10000);
+ }
+
+
+ public void testCacheStateOutdated() throws Exception {
+ cleanUp();
+ writeFileContent("hello,world!"); //$NON-NLS-1$
+ OpCacheUpdate update = new OpCacheUpdate(testFile);
+ update.run(new NullProgressMonitor());
+ writeFileContent("hello,test!"); //$NON-NLS-1$
+ refreshCacheState();
+ CacheState cacheState = testFile.getCacheState();
+ assertEquals(CacheState.outdated, cacheState);
+ Thread.sleep(5000L);
+ }
+
+ private void cleanUp() {
+ File cacheFile = CacheManager.getCacheFile(testFile);
+ if(cacheFile.exists()) {
+ cacheFile.delete();
+ }
+ PersistenceManager.getInstance().removeFileDigest(testFile.getLocationURI());
+ }
+
+ public void testCacheStateConflict() throws Exception {
+ cleanUp();
+ writeFileContent("hello,world!"); //$NON-NLS-1$
+ OpCacheUpdate update = new OpCacheUpdate(testFile);
+ update.run(new NullProgressMonitor());
+ writeFileContent("hello,test!"); //$NON-NLS-1$
+ refreshCacheState();
+ Thread.sleep(2000L);
+ File file = CacheManager.getCacheFile(testFile);
+ BufferedWriter writer = new BufferedWriter(new FileWriter(file));
+ writer.write("hello, earth!"); //$NON-NLS-1$
+ writer.close();
+ updateCacheState();
+ CacheState cacheState = testFile.getCacheState();
+ assertEquals(CacheState.conflict, cacheState);
+ Thread.sleep(5000L);
+ }
+}

Back to the top