Search in sources :

Example 11 with FakeTransactionService

use of org.teiid.dqp.internal.datamgr.FakeTransactionService in project teiid by teiid.

the class TestRequest method testValidateEntitlement.

/**
 * Test Request.validateEntitlement().
 * Make sure that this can be called both before and after metadata is initialized.
 * See defect 17209.
 * @throws Exception
 * @since 4.2
 */
@Test
public void testValidateEntitlement() throws Exception {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    Request request = new Request();
    Command command = QueryParser.getQueryParser().parseCommand(QUERY);
    QueryResolver.resolveCommand(command, metadata);
    RequestMessage message = new RequestMessage();
    DQPWorkContext workContext = RealMetadataFactory.buildWorkContext(metadata, RealMetadataFactory.example1VDB());
    request.initialize(message, BufferManagerFactory.getStandaloneBufferManager(), null, new FakeTransactionService(), TEMP_TABLE_STORE, workContext, null);
    request.initMetadata();
    DefaultAuthorizationValidator drav = new DefaultAuthorizationValidator();
    DataRolePolicyDecider drpd = new DataRolePolicyDecider();
    drpd.setAllowCreateTemporaryTablesByDefault(true);
    drpd.setAllowFunctionCallsByDefault(true);
    drav.setPolicyDecider(drpd);
    request.setAuthorizationValidator(drav);
    request.validateAccess(new String[] { QUERY }, command, CommandType.USER);
}
Also used : Command(org.teiid.query.sql.lang.Command) RequestMessage(org.teiid.client.RequestMessage) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) FakeTransactionService(org.teiid.dqp.internal.datamgr.FakeTransactionService) Test(org.junit.Test)

Aggregations

FakeTransactionService (org.teiid.dqp.internal.datamgr.FakeTransactionService)11 RequestMessage (org.teiid.client.RequestMessage)6 RequestID (org.teiid.dqp.message.RequestID)6 ConnectorManagerRepository (org.teiid.dqp.internal.datamgr.ConnectorManagerRepository)4 CacheConfiguration (org.teiid.cache.CacheConfiguration)3 DefaultCacheFactory (org.teiid.cache.DefaultCacheFactory)3 AtomicRequestMessage (org.teiid.dqp.message.AtomicRequestMessage)3 AutoGenDataService (org.teiid.dqp.service.AutoGenDataService)3 HashSet (java.util.HashSet)2 RequestMetadata (org.teiid.adminapi.impl.RequestMetadata)2 FakeBufferService (org.teiid.dqp.service.FakeBufferService)2 Command (org.teiid.query.sql.lang.Command)2 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Before (org.junit.Before)1 Test (org.junit.Test)1 DataPolicy (org.teiid.adminapi.DataPolicy)1 DataPolicyMetadata (org.teiid.adminapi.impl.DataPolicyMetadata)1 BufferManager (org.teiid.common.buffer.BufferManager)1