use of org.pentaho.commons.connection.IPentahoConnection in project pentaho-platform by pentaho.
the class MDXBaseComponentTest method testGetConnectionOrig.
@Test
public void testGetConnectionOrig() throws Exception {
doReturn(connAction).when(mdxBaseComponent).getActionDefinition();
when(connAction.getMdxConnectionString()).thenReturn(connectionStringAction);
when(connectionStringAction.getStringValue()).thenReturn("mdx:localhost:8080");
when(connAction.getConnectionProps()).thenReturn(actionInput);
when(actionInput.getValue()).thenReturn(new Properties());
when(connAction.getConnection()).thenReturn(jdbcAction);
when(jdbcAction.getStringValue()).thenReturn("psql://localhost:5432");
when(connAction.getJndi()).thenReturn(jndiAction);
when(jndiAction.getStringValue()).thenReturn("jndi string");
when(connAction.getLocation()).thenReturn(locationAction);
when(locationAction.getStringValue()).thenReturn("location string");
when(connAction.getRole()).thenReturn(roleAction);
when(roleAction.getStringValue()).thenReturn("role string");
when(connAction.getCatalog()).thenReturn(catalog);
// when( catalog.getStringValue() ).thenReturn( "<catalog></catalog>" );
when(catalog.getStringValue()).thenReturn(null);
when(connAction.getCatalogResource()).thenReturn(catalogResource);
when(catalogResource.getName()).thenReturn("catalog name");
when(connAction.getUserId()).thenReturn(userAction);
when(connAction.getPassword()).thenReturn(userAction);
when(userAction.getStringValue()).thenReturn("user/pass");
PentahoSystem.registerObject(mdxConnection);
PentahoSystem.registerPrimaryObjectFactory(objFactory);
PentahoSessionHolder.setSession(session);
when(objFactory.get(any(Class.class), anyString(), any(IPentahoSession.class))).thenReturn(mdxConnection);
mdxBaseComponent.setRuntimeContext(runtimeContext);
when(runtimeContext.getResourceDefintion("catalog name")).thenReturn(catalogActionSeqRes);
when(catalogActionSeqRes.getSourceType()).thenReturn(IActionSequenceResource.URL_RESOURCE);
when(catalogActionSeqRes.getAddress()).thenReturn("sampledata");
when(connAction.getExtendedColumnNames()).thenReturn(ActionInputConstant.NULL_INPUT);
IPentahoConnection connectionOrig = mdxBaseComponent.getConnectionOrig();
assertNotNull(connectionOrig);
assertEquals(mdxConnection, connectionOrig);
}
use of org.pentaho.commons.connection.IPentahoConnection in project pentaho-platform by pentaho.
the class MDXBaseComponentTest method testGetDatasourceConnection_waitForTimeout.
@Test
public void testGetDatasourceConnection_waitForTimeout() throws Exception {
// first try
doThrow(new RuntimeException()).doThrow(// second try
new RuntimeException()).doThrow(// third try
new RuntimeException()).doReturn(conn).when(mdxBaseComponent).getConnection();
doNothing().when(mdxBaseComponent).waitFor(anyInt());
IPentahoConnection datasourceConnection = mdxBaseComponent.getDatasourceConnection();
assertEquals(conn, datasourceConnection);
verify(conn).clearWarnings();
verify(mdxBaseComponent).waitFor(200);
verify(mdxBaseComponent).waitFor(500);
verify(mdxBaseComponent).waitFor(2000);
}
use of org.pentaho.commons.connection.IPentahoConnection in project pentaho-platform by pentaho.
the class MDXBaseComponentTest method testGetConnectionOrig_nullConnectionProps_noConnString2.
@Test
public void testGetConnectionOrig_nullConnectionProps_noConnString2() throws Exception {
doReturn(connAction).when(mdxBaseComponent).getActionDefinition();
when(connAction.getMdxConnectionString()).thenReturn(connectionStringAction);
when(connectionStringAction.getStringValue()).thenReturn(null);
when(connAction.getConnectionProps()).thenReturn(actionInput);
when(actionInput.getValue()).thenReturn(null);
when(connAction.getConnection()).thenReturn(jdbcAction);
when(jdbcAction.getStringValue()).thenReturn("psql://localhost:5432");
when(connAction.getJndi()).thenReturn(jndiAction);
when(jndiAction.getStringValue()).thenReturn("jndi string");
when(connAction.getLocation()).thenReturn(locationAction);
when(locationAction.getStringValue()).thenReturn("location string");
when(connAction.getRole()).thenReturn(roleAction);
when(roleAction.getStringValue()).thenReturn("role string");
when(connAction.getCatalog()).thenReturn(catalog);
// when( catalog.getStringValue() ).thenReturn( "<catalog></catalog>" );
when(catalog.getStringValue()).thenReturn(null);
when(connAction.getCatalogResource()).thenReturn(catalogResource);
when(catalogResource.getName()).thenReturn("catalog name");
when(connAction.getUserId()).thenReturn(userAction);
when(connAction.getPassword()).thenReturn(userAction);
when(userAction.getStringValue()).thenReturn("user/pass");
PentahoSystem.registerObject(mdxConnection);
PentahoSystem.registerPrimaryObjectFactory(objFactory);
PentahoSessionHolder.setSession(session);
when(objFactory.get(any(Class.class), anyString(), any(IPentahoSession.class))).thenReturn(mdxConnection);
mdxBaseComponent.setRuntimeContext(runtimeContext);
when(runtimeContext.getResourceDefintion("catalog name")).thenReturn(catalogActionSeqRes);
when(catalogActionSeqRes.getSourceType()).thenReturn(IActionSequenceResource.URL_RESOURCE);
final String urlFileExists = (new File(TestResourceLocation.TEST_RESOURCES + "/MDXBaseComponentTest/SampleData.mondrian.xml")).toURL().toString();
when(catalogActionSeqRes.getAddress()).thenReturn(urlFileExists);
when(connAction.getExtendedColumnNames()).thenReturn(ActionInputConstant.NULL_INPUT);
IPentahoConnection connectionOrig = mdxBaseComponent.getConnectionOrig();
assertNotNull(connectionOrig);
assertEquals(mdxConnection, connectionOrig);
}
use of org.pentaho.commons.connection.IPentahoConnection in project pentaho-platform by pentaho.
the class MDXBaseComponentTest method testGetConnectionOrig_nullConnectionProps_noConnString.
@Test
public void testGetConnectionOrig_nullConnectionProps_noConnString() throws Exception {
doReturn(connAction).when(mdxBaseComponent).getActionDefinition();
when(connAction.getMdxConnectionString()).thenReturn(connectionStringAction);
when(connectionStringAction.getStringValue()).thenReturn(null);
when(connAction.getConnectionProps()).thenReturn(actionInput);
when(actionInput.getValue()).thenReturn(null);
when(connAction.getConnection()).thenReturn(jdbcAction);
when(jdbcAction.getStringValue()).thenReturn("psql://localhost:5432");
when(connAction.getJndi()).thenReturn(jndiAction);
when(jndiAction.getStringValue()).thenReturn("jndi string");
when(connAction.getLocation()).thenReturn(locationAction);
when(locationAction.getStringValue()).thenReturn("location string");
when(connAction.getRole()).thenReturn(roleAction);
when(roleAction.getStringValue()).thenReturn("role string");
when(connAction.getCatalog()).thenReturn(catalog);
// when( catalog.getStringValue() ).thenReturn( "<catalog></catalog>" );
when(catalog.getStringValue()).thenReturn(null);
when(connAction.getCatalogResource()).thenReturn(catalogResource);
when(catalogResource.getName()).thenReturn("catalog name");
when(connAction.getUserId()).thenReturn(userAction);
when(connAction.getPassword()).thenReturn(userAction);
when(userAction.getStringValue()).thenReturn("user/pass");
PentahoSystem.registerObject(mdxConnection);
PentahoSystem.registerPrimaryObjectFactory(objFactory);
PentahoSessionHolder.setSession(session);
when(objFactory.get(any(Class.class), anyString(), any(IPentahoSession.class))).thenReturn(mdxConnection);
mdxBaseComponent.setRuntimeContext(runtimeContext);
when(runtimeContext.getResourceDefintion("catalog name")).thenReturn(catalogActionSeqRes);
when(catalogActionSeqRes.getSourceType()).thenReturn(IActionSequenceResource.URL_RESOURCE);
when(catalogActionSeqRes.getAddress()).thenReturn("sampledata");
when(connAction.getExtendedColumnNames()).thenReturn(ActionInputConstant.NULL_INPUT);
IPentahoConnection connectionOrig = mdxBaseComponent.getConnectionOrig();
assertNotNull(connectionOrig);
assertEquals(mdxConnection, connectionOrig);
}
use of org.pentaho.commons.connection.IPentahoConnection in project pentaho-platform by pentaho.
the class MDXBaseComponentTest method testGetConnectionOrig_null.
@Test
public void testGetConnectionOrig_null() throws Exception {
IPentahoConnection connectionOrig = mdxBaseComponent.getConnectionOrig();
assertNull(connectionOrig);
}
Aggregations