Search in sources :

Example 1 with UrlRepositoryContentFinder

use of mondrian.server.UrlRepositoryContentFinder in project mondrian by pentaho.

the class MondrianServerTest method testRepository.

/**
 * Tests a server that reads its repository from a file URL.
 */
public void testRepository() throws MalformedURLException, SQLException {
    final XmlaTestContext xmlaTestContext = new XmlaTestContext();
    final MondrianServer server = MondrianServer.createWithRepository(new UrlRepositoryContentFinder("inline:" + xmlaTestContext.getDataSourcesString()), null);
    final int id = server.getId();
    assertNotNull(id);
    OlapConnection connection = server.getConnection("FoodMart", "FoodMart", null);
    final NamedList<Catalog> catalogs = connection.getOlapCatalogs();
    assertEquals(1, catalogs.size());
    assertEquals("FoodMart", catalogs.get(0).getName());
    server.shutdown();
}
Also used : MondrianServer(mondrian.olap.MondrianServer) OlapConnection(org.olap4j.OlapConnection) UrlRepositoryContentFinder(mondrian.server.UrlRepositoryContentFinder) Catalog(org.olap4j.metadata.Catalog) XmlaTestContext(mondrian.xmla.test.XmlaTestContext)

Example 2 with UrlRepositoryContentFinder

use of mondrian.server.UrlRepositoryContentFinder in project mondrian by pentaho.

the class MondrianServerTest method testRepositoryWithBadCatalog.

/**
 * Tests a server that reads its repository from a file URL.
 */
public void testRepositoryWithBadCatalog() throws Exception {
    final XmlaTestContext xmlaTestContext = new XmlaTestContext() {

        Util.PropertyList connectProperties = Util.parseConnectString(getConnectString());

        String catalogUrl = connectProperties.get(RolapConnectionProperties.Catalog.name());

        public String getDataSourcesString() {
            return super.getDataSourcesString().replace("</Catalog>", "</Catalog>\n" + "<Catalog name='__1'>\n" + "<DataSourceInfo>Provider=mondrian;Jdbc='jdbc:derby:non-existing-db'</DataSourceInfo>\n" + "<Definition>" + catalogUrl + "</Definition>\n" + "</Catalog>\n");
        }
    };
    final MondrianServer server = MondrianServer.createWithRepository(new UrlRepositoryContentFinder("inline:" + xmlaTestContext.getDataSourcesString()), null);
    final int id = server.getId();
    assertNotNull(id);
    OlapConnection connection = server.getConnection("FoodMart", "FoodMart", null);
    final NamedList<Catalog> catalogs = connection.getOlapCatalogs();
    assertEquals(1, catalogs.size());
    assertEquals("FoodMart", catalogs.get(0).getName());
    server.shutdown();
}
Also used : MondrianServer(mondrian.olap.MondrianServer) OlapConnection(org.olap4j.OlapConnection) UrlRepositoryContentFinder(mondrian.server.UrlRepositoryContentFinder) Catalog(org.olap4j.metadata.Catalog) XmlaTestContext(mondrian.xmla.test.XmlaTestContext)

Aggregations

MondrianServer (mondrian.olap.MondrianServer)2 UrlRepositoryContentFinder (mondrian.server.UrlRepositoryContentFinder)2 XmlaTestContext (mondrian.xmla.test.XmlaTestContext)2 OlapConnection (org.olap4j.OlapConnection)2 Catalog (org.olap4j.metadata.Catalog)2