use of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory in project pentaho-platform by pentaho.
the class StandaloneObjectFactoryTest method testThreadObject2.
public void testThreadObject2() throws Exception {
StandaloneObjectFactory factory = new StandaloneObjectFactory();
factory.defineObject(Object2.class.getSimpleName(), Object2.class.getName(), Scope.THREAD);
// $NON-NLS-1$
IPentahoSession session1 = new StandaloneSession("test user 1");
Object2 obj1 = factory.get(Object2.class, session1);
// $NON-NLS-1$
assertNotNull("Object is null", obj1);
Object2 obj2 = factory.get(Object2.class, session1);
// $NON-NLS-1$
assertNotNull("Object is null", obj2);
// $NON-NLS-1$
assertTrue("Objects are not same", obj1 == obj2);
Object2 obj3 = factory.get(Object2.class, session1);
// $NON-NLS-1$
assertTrue("Objects are not same", obj1 == obj3);
}
use of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory in project pentaho-platform by pentaho.
the class AuditEntryTest method testAuditEntry.
public void testAuditEntry() throws Exception {
StandaloneObjectFactory factory = new StandaloneObjectFactory();
PentahoSystem.registerObjectFactory(factory);
String jobId = "testjobid";
String instId = "testinstid";
String objId = "testobjid";
String objType = "testobjtype";
String actor = "testactor";
String messageType = "testtype";
String messageName = "testname";
String messageTxtValue = MessageTypes.INSTANCE_END;
BigDecimal messageNumValue = new BigDecimal(99);
float duration = (float) 1.23;
// this should not complain
AuditEntry.auditJobDuration(jobId, instId, objId, objType, actor, messageType, messageName, messageTxtValue, duration);
TestOutputHandler.contentItem = new SimpleContentItem();
factory.defineObject(IAuditEntry.class.getSimpleName(), TestAuditEntry.class.getName(), StandaloneObjectFactory.Scope.GLOBAL);
// this should not complain
AuditEntry.auditJobDuration(jobId, instId, objId, objType, actor, messageType, messageName, messageTxtValue, duration);
TestAuditEntry entry = (TestAuditEntry) factory.get(IAuditEntry.class, null);
assertEquals(jobId, entry.jobId);
assertEquals("1.23", Double.toString(entry.duration).substring(0, 4));
assertEquals(null, entry.messageNumValue);
assertEquals(messageType, entry.messageType);
assertEquals(messageName, entry.messageName);
assertEquals(messageTxtValue, entry.messageTxtValue);
AuditEntry.auditJobNumValue(jobId, instId, objId, objType, actor, messageType, messageName, messageNumValue);
assertEquals("0", Double.toString(entry.duration).substring(0, 1));
assertEquals(messageNumValue, entry.messageNumValue);
assertEquals(null, entry.messageTxtValue);
AuditEntry.auditJobTxtValue(jobId, instId, objId, objType, actor, messageType, messageName, messageTxtValue);
assertEquals("0", Double.toString(entry.duration).substring(0, 1));
assertEquals(null, entry.messageNumValue);
assertEquals(messageTxtValue, entry.messageTxtValue);
new MessageTypes();
new AuditHelper();
new AuditEntry();
}
Aggregations