Examples of StandaloneObjectFactory


Examples of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory

  }

  public void testThreadObject2() throws Exception {

    StandaloneObjectFactory factory = new StandaloneObjectFactory();

    factory.defineObject( Object2.class.getSimpleName(), Object2.class.getName(), Scope.THREAD );

    IPentahoSession session1 = new StandaloneSession( "test user 1" ); //$NON-NLS-1$

    Object2 obj1 = factory.get( Object2.class, session1 );
    assertNotNull( "Object is null", obj1 ); //$NON-NLS-1$

    Object2 obj2 = factory.get( Object2.class, session1 );
    assertNotNull( "Object is null", obj2 ); //$NON-NLS-1$

    assertTrue( "Objects are not same", obj1 == obj2 ); //$NON-NLS-1$

    Object2 obj3 = factory.get( Object2.class, session1 );
    assertTrue( "Objects are not same", obj1 == obj3 ); //$NON-NLS-1$

  }
View Full Code Here

Examples of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory

  }

  public void testThreadObjectFail1() throws Exception {

    StandaloneObjectFactory factory = new StandaloneObjectFactory();

    factory.defineObject( Object1.class.getSimpleName(), "bogus", Scope.THREAD ); //$NON-NLS-1$

    IPentahoSession session1 = new StandaloneSession( "test user 1" ); //$NON-NLS-1$

    try {
      factory.get( Object1.class, session1 );
      assertFalse( "exception expected", true ); //$NON-NLS-1$
    } catch ( ObjectFactoryException e ) {
      assertTrue( "exception expected", true ); //$NON-NLS-1$
    }
View Full Code Here

Examples of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory

@SuppressWarnings( { "all" } )
public class SimpleOutputHandlerTest extends TestCase {

  public void test1() throws Exception {

    StandaloneObjectFactory factory = new StandaloneObjectFactory();

    TestOutputHandler.contentItem = new SimpleContentItem();
    factory.defineObject( "testoutut", TestOutputHandler.class.getName(), StandaloneObjectFactory.Scope.LOCAL );
    PentahoSystem.registerObjectFactory( factory );

    StandaloneSession session = new StandaloneSession();

    ByteArrayOutputStream out = new ByteArrayOutputStream();
View Full Code Here

Examples of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory

  public void testGetOutputContentItemObjectNameImportant() throws Exception {
    OutputStream out = new ByteArrayOutputStream();
    TestOutputHandler.contentItem = new SimpleContentItem( out );
    SimpleOutputHandler handler = new SimpleOutputHandler( out, false );

    StandaloneObjectFactory factory = new StandaloneObjectFactory();
    factory.defineObject( "contentrepo", TestOutputHandler.class.getName(), StandaloneObjectFactory.Scope.GLOBAL );
    PentahoSystem.registerObjectFactory( factory );

    IContentItem contentItem = handler.getOutputContentItem( "contentrepo", "myreport:contentrepo", null, null );
    assertNotNull( contentItem );
    assertEquals( out, contentItem.getOutputStream( null ) );
View Full Code Here

Examples of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory

@SuppressWarnings( { "all" } )
public class AuditEntryTest extends TestCase {

  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 );
View Full Code Here

Examples of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory

  @Before
  public void setUp() throws Exception {
    MockitoAnnotations.initMocks( this );
    session = new StandaloneSession( SESSION_NAME );
    factory = new StandaloneObjectFactory();
    PentahoSystem.registerObjectFactory( factory );
    factory.defineObject( IAuditEntry.class.getSimpleName(), TestAuditEntry.class.getName(),
        StandaloneObjectFactory.Scope.GLOBAL );
  }
View Full Code Here

Examples of org.pentaho.platform.engine.core.system.objfac.StandaloneObjectFactory

    setFilePath( userFilePath != null ? userFilePath : new File( "." ).getAbsolutePath() ); //$NON-NLS-1$

    setFullyQualifiedServerUrl( userFullyQualifiedServerUrl != null ? userFullyQualifiedServerUrl
        : "http://localhost:8080/pentaho/" ); //$NON-NLS-1$

    setFactory( userFactory != null ? userFactory : new StandaloneObjectFactory() );

    PentahoSystem.setSystemListeners( lifecycleListeners );
    PentahoSystem.setSessionStartupActions( startupActions );
    PentahoSystem.setAdministrationPlugins( adminActions );
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.