use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class SimpleTest method run.
@Override
public void run() {
Factory.enableCounters(true, false);
Session s = Factory.getSession(SessionType.CURRENT);
Database d = s.getDatabase("", "names.nsf");
List<String> ids = new ArrayList<String>();
Collection<Document> documents = d.getAllDocuments();
for (Document doc : documents) {
ids.add(doc.getNoteID());
}
// System.out.println("IDS.size " + ids.size());
for (int i = 1; i < 10; i++) {
System.out.println(i + ": " + Factory.dumpCounters(false));
Document doc1 = null;
Document doc2 = null;
Document doc3 = null;
for (String id : ids) {
d = s.getDatabase("", "names.nsf");
doc1 = d.getDocumentByID(id);
doc1 = null;
doc2 = d.getDocumentByID(id);
doc2 = null;
doc3 = d.getDocumentByID(id);
doc3 = null;
int rndIdx = (int) Math.floor(Math.random() * ids.size());
// if (i % 20 == 0 && false) {
// System.gc();
// try {
// Thread.sleep(10);
// } catch (InterruptedException e) {
// e.printStackTrace();
// }
// }
doc2 = d.getDocumentByID(ids.get(rndIdx));
doc2 = null;
d = null;
}
if (doc1 == null && doc2 == null && doc3 == null) {
// NOP - just ensure access to doc1..3
}
// System.out.println(doc1 + "" + doc2 + "" + doc3);
}
}
use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class TestDatabasePropertyWrapper method getNewSessionDesign.
public DatabaseDesign getNewSessionDesign() {
try {
lotus.domino.Session newSess = NotesFactory.createSession();
Session sess = Factory.getWrapperFactory().fromLotus(AllTests.lotusSession, Session.SCHEMA, null);
Database db = sess.getDatabase("", AllTests.EMPTY_DB);
return db.getDesign();
} catch (Exception e) {
return null;
}
}
use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class DeferredDocumentTest method testIdentity.
// public static void main(final String[] args) {
// Factory.startup();
//
// DominoExecutor executor = new DominoExecutor(50);
// XotsDaemon.start(executor);
//
// for (int i = 0; i < THREAD_COUNT; i++) {
// XotsDaemon.queue(new DeferredDocumentTest());
// }
//
// Factory.shutdown();
// }
/**
* Test if deferred will not recycle each other.
*/
@Test
public void testIdentity() throws NotesException {
Session session = Factory.getSession(SessionType.CURRENT);
assertNotNull(session);
Database db = session.getDatabase("", "log.nsf");
assertNotNull(db);
NoteCollection nc = db.createNoteCollection(false);
nc.selectAllDataNotes(true);
nc.buildCollection();
int[] nids = nc.getNoteIDs();
int nid1 = nids[0];
int nid2 = nids[1];
Document doc1 = db.getDocumentByID(nid1, true);
Document doc2 = db.getDocumentByID(nid1, true);
Document doc3 = db.getDocumentByID(nid2, true);
Document doc4 = db.getDocumentByID(nid2, true);
doc2.replaceItemValue("testfield", "testvalue");
doc4.replaceItemValue("testfield", "testvalue2");
assertEquals(doc1, doc2);
assertFalse(doc1 == doc2);
assertEquals(doc3, doc4);
assertFalse(doc3 == doc4);
assertEquals("testvalue", doc1.getItemValueString("testfield"));
assertEquals("testvalue", doc2.getItemValueString("testfield"));
assertEquals("testvalue2", doc3.getItemValueString("testfield"));
assertEquals("testvalue2", doc4.getItemValueString("testfield"));
// doc2 = null;
for (int i = 0; i < 1000; i++) {
doc1 = null;
doc3 = null;
System.gc();
doc1 = db.getDocumentByID(Integer.toHexString(nid1));
doc3 = db.getDocumentByID(Integer.toHexString(nid2));
if (i % 100 == 0)
System.out.println("Test complete: " + i / 10 + "%");
// doc2.recycle();
// assertEquals("testvalue", doc2.getItemValueString("testfield"));
doc4 = db.getDocumentByID(nid2, true);
assertEquals("testvalue", doc1.getItemValueString("testfield"));
assertEquals("testvalue", doc2.getItemValueString("testfield"));
assertEquals("testvalue2", doc3.getItemValueString("testfield"));
assertEquals("testvalue2", doc4.getItemValueString("testfield"));
}
}
use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class DeferredDocumentTest method testDeferredDocuments.
@Test
public void testDeferredDocuments() throws InterruptedException, ExecutionException {
Session session = Factory.getSession(SessionType.CURRENT);
assertNotNull(session);
List<Future<?>> tasks = new ArrayList<Future<?>>();
for (int i = 0; i < THREAD_COUNT; i++) {
tasks.add(Xots.submit(new DeferredDocumentTest()));
}
for (Future<?> f : tasks) {
// to catch the exceptions!
f.get();
}
System.out.println("DONE");
}
use of org.openntf.domino.Session in project org.openntf.domino by OpenNTF.
the class DominoIndexDbTest method run.
@Override
public void run() {
Session session = Factory.getSession(SessionType.CURRENT);
session.setConvertMIME(false);
session.setFixEnable(Fixes.APPEND_ITEM_VALUE, true);
session.setFixEnable(Fixes.FORCE_JAVA_DATES, true);
session.setFixEnable(Fixes.CREATE_DB, true);
DbDirectory dir = session.getDbDirectory("");
Database indexDb = dir.createDatabase("index.nsf", true);
// Database indexDb = session.getDatabase("", "index.nsf", true);
// indexDb.open();
IndexDatabase index = new org.openntf.domino.big.impl.IndexDatabase(indexDb);
index.setCaseSensitive(true);
index.scanServer(session, "");
System.out.println("Complete");
}
Aggregations