Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2008-2013 jOpenDocument, by ILM Informatique. All rights reserved.
*
* The contents of this file are subject to the terms of the GNU
* General Public License Version 3 only ("GPL").
* You may not use this file except in compliance with the License.
* You can obtain a copy of the License at http://www.gnu.org/licenses/gpl-3.0.html
* See the License for the specific language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each file.
*
*/
package org.jopendocument.util.cache;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.lang.Thread.State;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.Vector;
import java.util.concurrent.CountDownLatch;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class ICacheTest {
private final ThreadGroup thg = new ThreadGroup("testjunit") {
public void uncaughtException(Thread t, Throwable e) {
ICacheTest.this.threadException = e;
}
};
private Thread launch(String name, Runnable runnable) {
final Thread res = new Thread(this.thg, runnable, name);
res.start();
// really let res start...
Thread.yield();
return res;
}
private void join(final Thread t) throws Throwable {
t.join();
if (this.threadException != null) {
final Throwable thw = this.threadException;
this.threadException = null;
throw thw;
}
}
private static final int delay = 1;
private ICache cache;
protected Throwable threadException;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Before
public void setUp() throws Exception {
this.cache = new ICache(delay);
}
@After
public void tearDown() throws Exception {
this.cache = null;
}
@Test
public void testWatcher() throws NoSuchMethodException {
class BogusCacheWatcher extends CacheWatcher {
public BogusCacheWatcher(ICache c, D d) {
super(c, d);
}
public void clear() {
this.clearCache();
}
}
final ICache, String> cache = new ICache, String>(delay);
cache.setWatcherFactory(new CacheWatcherFactory() {
public CacheWatcher createWatcher(ICache cache, String obj) throws Exception {
return new BogusCacheWatcher(cache, obj);
}
});
final String sel = "SELECT * FROM CONTACT";
final String sel2 = "SELECT NOM FROM CONTACT";
final List