mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 03:43:52 +00:00
the fix for 968 broke the test verdict of testDistanceTraveledOnSmoothenedTrackThenAddingOutlier which was too strict; relaxed
This commit is contained in:
1 parent
36ac9e6892
commit
efc0ac2959
2 files changed
+30
-3
No files matched your search
+26
-1
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.domain.test;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -8,10 +9,34 @@ import com.sap.sailing.util.impl.NamedReentrantReadWriteLock;
|
||||
|
||||
public class LockTraceTest {
|
||||
@Test
|
||||
public void testLockTrace() throws InterruptedException {
|
||||
public void testLockTraceForMultipleReaders() throws InterruptedException {
|
||||
NamedReentrantReadWriteLock lock1 = new NamedReentrantReadWriteLock("Lock1", /* fair */ true);
|
||||
lock1.readLock().lock();
|
||||
Object o = createAndStartLockingThreadReturningObjectToNotifyInOrderToReleaseLockAndTerminateThread(lock1.readLock());
|
||||
boolean itWorked = lock1.writeLock().tryLock(10, TimeUnit.MILLISECONDS);
|
||||
System.out.println(itWorked);
|
||||
lock1.readLock().unlock();
|
||||
synchronized (o) {
|
||||
o.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
private Object createAndStartLockingThreadReturningObjectToNotifyInOrderToReleaseLockAndTerminateThread(final Lock lock) {
|
||||
final Thread thread = new Thread("Thread to lock "+lock) {
|
||||
public void run() {
|
||||
lock.lock();
|
||||
synchronized (Thread.currentThread()) {
|
||||
try {
|
||||
Thread.currentThread().wait();
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
lock.unlock();
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
return thread;
|
||||
}
|
||||
}
|
||||
@@ -483,7 +483,8 @@ public class TrackTest {
|
||||
GPSFix outlier = new GPSFixImpl(outlierPosition, timePointForOutlier);
|
||||
track.addGPSFix(outlier);
|
||||
assertEquals(1, invalidationCalls.size());
|
||||
assertEquals(timePointForOutlier, invalidationCalls.iterator().next()); // outlier doesn't turn its preceding element into an outlier
|
||||
TimePoint timePointOfLastFixBeforeOutlier = track.getLastFixBefore(timePointForOutlier).getTimePoint();
|
||||
assertTrue(invalidationCalls.iterator().next().after(timePointOfLastFixBeforeOutlier)); // outlier doesn't turn its preceding element into an outlier
|
||||
assertNull(distanceCache.getEarliestFromAndDistanceAtOrAfterFrom(now, start)); // no more entry for "to"-value start in cache
|
||||
invalidationCalls.clear();
|
||||
final TimePoint timePointOfLastOriginalFix = track.getLastRawFix().getTimePoint();
|
||||
@@ -499,7 +500,8 @@ public class TrackTest {
|
||||
GPSFix lateOutlier = new GPSFixImpl(lateOutlierPosition, timePointForLateOutlier);
|
||||
track.addGPSFix(lateOutlier);
|
||||
assertEquals(1, invalidationCalls.size());
|
||||
assertEquals(timePointForLateOutlier, invalidationCalls.iterator().next());
|
||||
TimePoint timePointOfLastFixBeforeLateOutlier = track.getLastFixBefore(timePointForLateOutlier).getTimePoint();
|
||||
assertTrue(invalidationCalls.iterator().next().after(timePointOfLastFixBeforeLateOutlier));
|
||||
invalidationCalls.clear();
|
||||
// expect the invalidation to have started after the single cache entry, so the cache entry still has to be there:
|
||||
final Pair<TimePoint, Pair<TimePoint, Distance>> stillPresentFullIntervalCacheEntry = distanceCache
|
||||
|
||||
Reference in new issue
Block a user