use of mondrian.olap.MondrianServer in project mondrian by pentaho.
the class MondrianServerTest method testEmbedded.
/**
* Tests an embedded server.
*/
public void testEmbedded() {
TestContext testContext = TestContext.instance();
final MondrianServer server = MondrianServer.forConnection(testContext.getConnection());
final int id = server.getId();
assertNotNull(id);
server.shutdown();
}
use of mondrian.olap.MondrianServer in project mondrian by pentaho.
the class XmlaExtraTest method testGetDataSourceDoesntLeakPassword.
/**
* This test makes sure that the value of
* {@link RolapConnectionProperties#JdbcPassword} isn't leaked through
* the XmlaExtra interface.
*/
public void testGetDataSourceDoesntLeakPassword() throws Exception {
final List<Map<String, Object>> expectedList = new ArrayList<Map<String, Object>>();
final Map<String, Object> expectedMap = new HashMap<String, Object>();
expectedMap.put("DataSourceInfo", "Provider=Mondrian;Jdbc=foo;JdbcPassword=bar;JdbcUser=bacon");
expectedList.add(expectedMap);
final MondrianServer server = mock(MondrianServer.class);
final RolapConnection rConn = mock(RolapConnection.class);
final MondrianOlap4jConnection conn = mock(MondrianOlap4jConnection.class);
final MondrianOlap4jExtra extra = mock(MondrianOlap4jExtra.class);
doReturn(expectedList).when(server).getDatabases(rConn);
doReturn(server).when(rConn).getServer();
doReturn(rConn).when(conn).getMondrianConnection();
doCallRealMethod().when(extra).getDataSources(conn);
for (Map<String, Object> ds : extra.getDataSources(conn)) {
final PropertyList props = Util.parseConnectString(String.valueOf(ds.get("DataSourceInfo")));
assertNull(props.get(RolapConnectionProperties.Jdbc.name()));
assertNull(props.get(RolapConnectionProperties.JdbcUser.name()));
assertNull(props.get(RolapConnectionProperties.JdbcPassword.name()));
}
}
use of mondrian.olap.MondrianServer in project mondrian by pentaho.
the class FileRepositoryTest method testDiscoverDatasourceLegacyNameMatch.
public void testDiscoverDatasourceLegacyNameMatch() throws Exception {
final String contentStub = "<?xml version=\"1.0\"" + " encoding=\"UTF-8\"?>\n" + "<DataSources>\n" + "<DataSource>\n" + "<DataSourceName>Pentaho Mondrian</DataSourceName>\n" + "<DataSourceDescription>Pentaho BI Platform Datasources</DataSourceDescription>\n" + "<URL>/pentaho/Xmla</URL>\n" + "<DataSourceInfo>Provider=mondrian;Jdbc=SomethingAwfulWhichPeopleCantSee</DataSourceInfo>\n" + "<ProviderName>PentahoXMLA</ProviderName>\n" + "<ProviderType>MDP</ProviderType>\n" + "<AuthenticationMode>Unauthenticated</AuthenticationMode>\n" + "<Catalogs>\n" + "<Catalog name=\"SampleData\">\n" + "<DataSourceInfo>Jdbc=example.com;EnableXmla=false;Provider=mondrian;Datasource=\"SampleData\";overwrite=\"true\"</DataSourceInfo>\n" + "<Definition>mondrian:/SampleData</Definition>\n" + "</Catalog>\n" + "</Catalogs>\n" + "</DataSource>\n" + "</DataSources>\n";
// Mocks.
FileRepository fileRepositoryMock = mock(FileRepository.class);
RepositoryContentFinder repositoryContentFinderMock = mock(RepositoryContentFinder.class);
// Return the content we want from the RCF.
doReturn(repositoryContentFinderMock).when(fileRepositoryMock).getRepositoryContentFinder();
doReturn(contentStub).when(repositoryContentFinderMock).getContent();
// Calling getServerInfo's actual implementation
doCallRealMethod().when(fileRepositoryMock).getServerInfo();
// Give it a try.
final FileRepository.ServerInfo serverInfo = fileRepositoryMock.getServerInfo();
// Some sanity checks.
FileRepository.DatabaseInfo databaseInfo = serverInfo.getDatasourceMap().get("Pentaho Mondrian");
assertNotNull("Database not found by name", databaseInfo);
// Moar mocks.
final Properties mockProps = mock(Properties.class);
final MondrianServer mockServer = mock(MondrianServer.class);
final String databaseName = "Pentaho Mondrian";
final String dsInfo = "Provider=mondrian";
final String catalogName = "SampleData";
final String roleName = null;
final CatalogInfo cInfo = databaseInfo.catalogMap.get("SampleData");
final OlapConnection oc = mock(OlapConnection.class);
// Make sure to short circuit the connection creation internal call...
doReturn(oc).when(fileRepositoryMock).getConnection(cInfo, mockServer, roleName, mockProps);
// We'll try to call into this method with the DS name.
doCallRealMethod().when(fileRepositoryMock).getConnection(mockServer, databaseName, catalogName, roleName, mockProps);
// OK make the call.
OlapConnection ocPrime = fileRepositoryMock.getConnection(mockServer, databaseName, catalogName, roleName, mockProps);
// Check we got a proper output.
assertTrue(ocPrime == oc);
// Make sure the protected call was made
verify(fileRepositoryMock, times(1)).getConnection(cInfo, mockServer, roleName, mockProps);
// *** Now do the same w/ the DS Info name instead. Legacy mode.
// We'll try to call into this method with the DSInfo instead of the
// name of the database.
doCallRealMethod().when(fileRepositoryMock).getConnection(mockServer, dsInfo, catalogName, roleName, mockProps);
// Make the call.
ocPrime = fileRepositoryMock.getConnection(mockServer, dsInfo, catalogName, roleName, mockProps);
// Check we got a proper output.
assertTrue(ocPrime == oc);
// Make sure the protected call was made. 2 calls by now.
verify(fileRepositoryMock, times(2)).getConnection(cInfo, mockServer, roleName, mockProps);
}
Aggregations