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);
}
Aggregations