Methods Summary |
---|
private java.lang.Thread | getDelThread(org.apache.lucene.gdata.storage.Storage s, org.apache.lucene.gdata.data.ServerBaseEntry e, boolean conflictExpected)
Thread t1 = new Thread(new Runner(s, e, conflictExpected,
StorageOperation.DELETE));
t1.setPriority(Thread.MAX_PRIORITY);
return t1;
|
private org.apache.lucene.gdata.utils.Visitor | getMonitorVisitor(java.lang.Object monitor, java.util.concurrent.atomic.AtomicBoolean reached)
/*
* The executing thread stops at a defined position while holding the semaphore inside the storageImpl
*/
return new Visitor(){
public void execute(Object[] o){
synchronized (monitor) {
try {
reached.set(true);
monitor.wait();
reached.set(false);
} catch (InterruptedException e) {
//
}
}
}
};
|
private java.lang.Thread | getUpdThread(org.apache.lucene.gdata.storage.Storage s, org.apache.lucene.gdata.data.ServerBaseEntry e, boolean conflictExpected)
Thread t1 = new Thread(new Runner(s, e, conflictExpected,
StorageOperation.UPDATE));
t1.setPriority(Thread.MAX_PRIORITY);
return t1;
|
protected void | setUp()
if (reg == null) {
reg = GDataServerRegistry.getRegistry();
if(reg.lookup(StorageController.class,ComponentType.STORAGECONTROLLER)!= null);
reg.destroy();
reg.registerComponent(StorageCoreControllerStub.class,null);
}
this.storage = reg.lookup(StorageController.class,
ComponentType.STORAGECONTROLLER).getStorage();
|
protected void | tearDown()
this.storage.close();
fail = false;
|
public void | testClose()
|
public void | testDeleteAccount()
|
public void | testDeleteEntry()
try {
this.storage.storeEntry(null);
fail("entry is null");
} catch (StorageException e) {
//
}
ServerBaseEntry entry = new ServerBaseEntry();
entry.setServiceConfig(new ProvidedServiceStub());
entry.setId("someID");
entry.setFeedId("someID");
try {
this.storage.storeEntry(entry);
} catch (StorageException e) {
fail("unexpected exception");
//
}
entry.setFeedId(null);
try {
this.storage.deleteEntry(entry);
fail("feed is null");
} catch (StorageException e) {
//
}
entry.setFeedId("someID");
try {
this.storage.deleteEntry(entry);
} catch (StorageException e1) {
e1.printStackTrace();
fail("unexpected exception");
}
entry.setFeedId("someID");
try {
this.storage.deleteEntry(entry);
} catch (StorageException e1) {
e1.printStackTrace();
fail("unexpected exception");
}
Object monitor = new Object();
AtomicBoolean reached = new AtomicBoolean(false);
MultiThreadEntryStub concuEntry = new MultiThreadEntryStub();
concuEntry.setId(System.currentTimeMillis() + "");
ProvidedService conf = new ProvidedServiceStub();
concuEntry.setServiceConfig(conf);
concuEntry.setUpdated(DateTime.now());
concuEntry.setFeedId("feed");
this.storage.storeEntry(concuEntry);
storage.close();
concuEntry.acceptGetVersionVisitor(getMonitorVisitor(monitor,reached));
Thread t1 = getDelThread(storage, concuEntry, false);
Thread t2 = getDelThread(storage, concuEntry, true);
t1.start();
/*
* Wait active -- not nice but works fine here
* wait until thread parked
*/
while (true) {
synchronized (monitor) {
if (reached.get())
break;
monitor.wait(10);
}
}
t2.start();
t2.join(800);
/*
* Wait active -- not nice but works fine here
* wake up the waiting thread
*/
while (true) {
synchronized (monitor) {
if (!reached.get())
break;
monitor.notifyAll();
}
}
t1.join(300);
if (fail)
fail("thread failed -- see stacktrace");
|
public void | testDeleteFeed()
|
public void | testGetAccount()
|
public void | testGetAccountNameForFeedId()
|
public void | testGetEntry()
|
public void | testGetEntryLastModified()
|
public void | testGetFeed()
|
public void | testGetFeedLastModified()
|
public void | testGetServiceForFeed()
|
public void | testStoreAccount()
|
public void | testStoreEntry()
try {
this.storage.storeEntry(null);
fail("entry is null");
} catch (StorageException e) {
//
}
ServerBaseEntry entry = new ServerBaseEntry();
entry.setServiceConfig(new ProvidedServiceStub());
try {
this.storage.storeEntry(entry);
fail("feed is null");
} catch (StorageException e) {
//
}
entry.setFeedId("someID");
try {
this.storage.storeEntry(entry);
} catch (StorageException e1) {
fail("unexpected exception");
}
entry.setServiceConfig(null);
try {
this.storage.storeEntry(entry);
fail("no service config");
} catch (StorageException e) {
}
entry.setVersion(5);
try {
this.storage.storeEntry(entry);
fail("version is greater than 1");
} catch (StorageException e) {
}
|
public void | testStoreFeed()
|
public void | testUpdateAccount()
|
public void | testUpdateEntry()
Object monitor = new Object();
AtomicBoolean reached = new AtomicBoolean(false);
MultiThreadEntryStub concuEntry = new MultiThreadEntryStub();
concuEntry.setId(System.currentTimeMillis() + "");
ProvidedService conf = new ProvidedServiceStub();
concuEntry.setServiceConfig(conf);
concuEntry.setUpdated(DateTime.now());
concuEntry.setFeedId("feed");
this.storage.storeEntry(concuEntry);
storage.close();
concuEntry.acceptGetEntryVisitor(getMonitorVisitor(monitor,reached));
Thread t1 = getUpdThread(storage, concuEntry, false);
Thread t2 = getUpdThread(storage, concuEntry, true);
t1.start();
/*
* Wait active -- not nice but works fine here
* wait until thread parked
*/
while (true) {
synchronized (monitor) {
if (reached.get())
break;
monitor.wait(10);
}
}
t2.start();
t2.join(800);
/*
* Wait active -- not nice but works fine here
* wake up the waiting thread
*/
while (true) {
synchronized (monitor) {
if (!reached.get())
break;
monitor.notifyAll();
}
}
t1.join(300);
if (fail)
fail("thread failed -- see stacktrace");
|
public void | testUpdateFeed()
|