Author: rareddy
Date: 2011-12-05 14:12:03 -0500 (Mon, 05 Dec 2011)
New Revision: 3718
Added:
trunk/test-integration/common/src/test/resources/bqt2.vdb
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
trunk/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidConfiguration.java
trunk/pom.xml
trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
trunk/test-integration/common/pom.xml
trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java
trunk/test-integration/common/src/test/java/org/teiid/arquillian/TestDeployment.java
trunk/test-integration/common/src/test/resources/arquillian.xml
trunk/test-integration/pom.xml
Log:
TEIID-1720: Fixing some regressions based on the tests, added arquillian based test to
test admin api.
Modified: trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-12-05 16:29:37 UTC
(rev 3717)
+++ trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2011-12-05 19:12:03 UTC
(rev 3718)
@@ -172,14 +172,7 @@
@Override
public void clearCache(String cacheType) throws AdminException {
final ModelNode request = buildRequest("teiid",
"clear-cache", "cache-type", cacheType);//$NON-NLS-1$ //$NON-NLS-2$
- try {
- ModelNode outcome = this.connection.execute(request);
- if (!Util.isSuccess(outcome)) {
- throw new AdminProcessingException(Util.getFailureDescription(outcome));
- }
- } catch (Exception e) {
- throw new AdminProcessingException(e);
- }
+ execute(request);
}
@Override
@@ -188,14 +181,7 @@
"cache-type", cacheType,
"vdb-name", vdbName,
"vdb-version", String.valueOf(vdbVersion));//$NON-NLS-1$
//$NON-NLS-2$
- try {
- ModelNode outcome = this.connection.execute(request);
- if (!Util.isSuccess(outcome)) {
- throw new AdminProcessingException(Util.getFailureDescription(outcome));
- }
- } catch (Exception e) {
- throw new AdminProcessingException(e);
- }
+ execute(request);
}
@Override
@@ -233,14 +219,7 @@
throw new IllegalStateException("Failed to build operation", e);
//$NON-NLS-1$
}
- try {
- ModelNode outcome = this.connection.execute(request);
- if (!Util.isSuccess(outcome)) {
- throw new
AdminProcessingException(Util.getFailureDescription(outcome));
- }
- } catch (IOException e) {
- throw new AdminProcessingException(e);
- }
+ execute(request);
// add all the config properties
Enumeration keys = properties.propertyNames();
@@ -266,14 +245,7 @@
throw new IllegalStateException("Failed to build operation", e);
//$NON-NLS-1$
}
- try {
- ModelNode outcome = this.connection.execute(request);
- if (!Util.isSuccess(outcome)) {
- throw new
AdminProcessingException(Util.getFailureDescription(outcome));
- }
- } catch (IOException e) {
- throw new AdminProcessingException(e);
- }
+ execute(request);
}
//
/subsystem=resource-adapters/resource-adapter=teiid-connector-ws.rar:add(archive=teiid-connector-ws.rar,
transaction-support=NoTransaction)
@@ -292,14 +264,7 @@
throw new IllegalStateException("Failed to build operation", e);
//$NON-NLS-1$
}
- try {
- ModelNode outcome = this.connection.execute(request);
- if (!Util.isSuccess(outcome)) {
- throw new
AdminProcessingException(Util.getFailureDescription(outcome));
- }
- } catch (IOException e) {
- throw new AdminProcessingException(e);
- }
+ execute(request);
}
class AbstractMetadatMapper implements MetadataMapper<String>{
@@ -371,7 +336,7 @@
}
DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder();
- final ModelNode request;
+ ModelNode request;
try {
builder.addNode("subsystem", "datasources");
//$NON-NLS-1$ //$NON-NLS-2$
builder.addNode("data-source", deploymentName); //$NON-NLS-1$
@@ -407,14 +372,32 @@
throw new IllegalStateException("Failed to build operation", e);
//$NON-NLS-1$
}
+ // execute request
+ execute(request);
+
+ // issue the "enable" operation
+ builder = new DefaultOperationRequestBuilder();
try {
+ builder.addNode("subsystem", "datasources");
//$NON-NLS-1$ //$NON-NLS-2$
+ builder.addNode("data-source", deploymentName); //$NON-NLS-1$
+ builder.setOperationName("enable");
+ request = builder.buildRequest();
+ } catch (OperationFormatException e) {
+ throw new IllegalStateException("Failed to build operation", e);
//$NON-NLS-1$
+ }
+
+ execute(request);
+ }
+
+ private void execute(final ModelNode request) throws AdminProcessingException {
+ try {
ModelNode outcome = this.connection.execute(request);
if (!Util.isSuccess(outcome)) {
throw new
AdminProcessingException(Util.getFailureDescription(outcome));
}
} catch (IOException e) {
throw new AdminProcessingException(e);
- }
+ }
}
@Override
@@ -486,18 +469,13 @@
@Override
public void undeploy(String deployedName) throws AdminException {
- try {
- ModelNode request = buildUndeployRequest(deployedName);
-
- ModelNode outcome = this.connection.execute(request);
- if (!Util.isSuccess(outcome)) {
- throw new
AdminProcessingException(Util.getFailureDescription(outcome));
- }
+ ModelNode request;
+ try {
+ request = buildUndeployRequest(deployedName);
} catch (OperationFormatException e) {
throw new AdminProcessingException(e);
- } catch (IOException e) {
- throw new AdminProcessingException(e);
}
+ execute(request);
}
public ModelNode buildUndeployRequest(String name) throws OperationFormatException
{
@@ -539,14 +517,7 @@
@Override
public void deploy(String deployName, InputStream vdb) throws AdminException {
ModelNode request = buildDeployVDBRequest(deployName, vdb);
- try {
- ModelNode outcome = this.connection.execute(request);
- if (!Util.isSuccess(outcome)) {
- throw new
AdminProcessingException(Util.getFailureDescription(outcome));
- }
- } catch (Exception e) {
- throw new AdminProcessingException(e);
- }
+ execute(request);
}
private ModelNode buildDeployVDBRequest(String fileName, InputStream vdb) throws
AdminProcessingException {
@@ -620,7 +591,11 @@
@Override
public Collection<String> getCacheTypes() throws AdminException {
final ModelNode request = buildRequest("teiid",
"cache-types");//$NON-NLS-1$ //$NON-NLS-2$
- try {
+ return executeList(request);
+ }
+
+ private Collection<String> executeList(final ModelNode request) throws
AdminProcessingException {
+ try {
ModelNode outcome = this.connection.execute(request);
if (Util.isSuccess(outcome)) {
return Util.getList(outcome);
@@ -814,7 +789,7 @@
@Override
public Collection<? extends Request> getRequestsForSession(String sessionId)
throws AdminException {
- final ModelNode request = buildRequest("teiid",
"requests-per-session", "session", sessionId);//$NON-NLS-1$
+ final ModelNode request = buildRequest("teiid",
"list-requests-per-session", "session", sessionId);//$NON-NLS-1$
if (request != null) {
try {
ModelNode outcome = this.connection.execute(request);
@@ -873,7 +848,7 @@
}
else {
result = new ModelNode();
- result.add(buildProperty("connection-url", "connection
URL", ModelType.STRING, "connection url", true));
+ result.add(buildProperty("connection-url", "Connection
URL", ModelType.STRING, "connection url to database", true));
result.add(buildProperty("user-name", "User Name",
ModelType.STRING, "user name", false));
result.add(buildProperty("password", "Password",
ModelType.STRING, "password", false));
result.add(buildProperty("check-valid-connection-sql",
"Connection Validate SQL", ModelType.STRING, "SQL to be used to validate
the connection", false));
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2011-12-05
16:29:37 UTC (rev 3717)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidAdd.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -341,7 +341,7 @@
processorTarget.addDeploymentProcessor(Phase.STRUCTURE,
Phase.STRUCTURE_WAR_DEPLOYMENT_INIT|0x0001,new VDBStructureDeployer());
processorTarget.addDeploymentProcessor(Phase.PARSE,
Phase.PARSE_WEB_DEPLOYMENT|0x0001, new VDBParserDeployer());
processorTarget.addDeploymentProcessor(Phase.DEPENDENCIES,
Phase.DEPENDENCIES_WAR_MODULE|0x0001, new VDBDependencyDeployer());
- processorTarget.addDeploymentProcessor(Phase.INSTALL,
Phase.INSTALL_WAR_DEPLOYMENT|0x1000, new VDBDeployer(translatorRepo, asyncThreadPoolName,
statusChecker));
+ processorTarget.addDeploymentProcessor(Phase.INSTALL,
Phase.INSTALL_WAR_DEPLOYMENT|0x1000, new VDBDeployer(translatorRepo, asyncThreadPoolName,
statusChecker, shutdownListener));
// translator deployers
processorTarget.addDeploymentProcessor(Phase.STRUCTURE,
Phase.STRUCTURE_JDBC_DRIVER|0x0001,new TranslatorStructureDeployer());
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-12-05
16:29:37 UTC (rev 3717)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidExtension.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -135,9 +135,9 @@
new RemoveAnyAuthenticatedDataRole().register(teiidSubsystem);
new ListRequests().register(teiidSubsystem);
new ListSessions().register(teiidSubsystem);
- new RequestsPerSession().register(teiidSubsystem);
- new RequestsPerVDB().register(teiidSubsystem);
- new GetLongRunningQueries().register(teiidSubsystem);
+ new ListRequestsPerSession().register(teiidSubsystem);
+ new ListRequestsPerVDB().register(teiidSubsystem);
+ new ListLongRunningRequests().register(teiidSubsystem);
new TerminateSession().register(teiidSubsystem);
new CancelRequest().register(teiidSubsystem);
new WorkerPoolStatistics().register(teiidSubsystem);
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2011-12-05
16:29:37 UTC (rev 3717)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidOperationHandler.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -93,10 +93,15 @@
}
@Override
- protected DQPCore getService(OperationContext context, PathAddress pathAddress,
ModelNode operation) throws OperationFailedException {
+ protected DQPCore getService(OperationContext context, PathAddress pathAddress,
ModelNode operation) throws OperationFailedException {
+
+ this.transports.clear();
+ this.vdbRepo = null;
+ this.engine = null;
+
List<ServiceName> services =
context.getServiceRegistry(false).getServiceNames();
for (ServiceName name:services) {
- if (name.isParentOf(TeiidServiceNames.TRANSPORT_BASE)) {
+ if (TeiidServiceNames.TRANSPORT_BASE.isParentOf(name)) {
ServiceController<?> transport =
context.getServiceRegistry(false).getService(name);
if (transport != null) {
this.transports.add(Transport.class.cast(transport.getValue()));
@@ -187,9 +192,9 @@
}
}
-class RequestsPerSession extends TeiidOperationHandler{
- protected RequestsPerSession() {
- super("requests-per-session"); //$NON-NLS-1$
+class ListRequestsPerSession extends TeiidOperationHandler{
+ protected ListRequestsPerSession() {
+ super("list-requests-per-session"); //$NON-NLS-1$
}
@Override
protected void executeOperation(OperationContext context, DQPCore engine, ModelNode
operation) throws OperationFailedException{
@@ -233,9 +238,9 @@
}
}
-class RequestsPerVDB extends TeiidOperationHandler{
- protected RequestsPerVDB() {
- super("requests-per-vdb"); //$NON-NLS-1$
+class ListRequestsPerVDB extends TeiidOperationHandler{
+ protected ListRequestsPerVDB() {
+ super("list-requests-per-vdb"); //$NON-NLS-1$
}
@Override
protected void executeOperation(OperationContext context, DQPCore engine, ModelNode
operation) throws OperationFailedException{
@@ -272,9 +277,9 @@
}
}
-class GetLongRunningQueries extends TeiidOperationHandler{
- protected GetLongRunningQueries() {
- super("long-running-queries"); //$NON-NLS-1$
+class ListLongRunningRequests extends TeiidOperationHandler{
+ protected ListLongRunningRequests() {
+ super("list-long-running-requests"); //$NON-NLS-1$
}
@Override
protected void executeOperation(OperationContext context, DQPCore engine, ModelNode
operation) throws OperationFailedException{
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-12-05
16:29:37 UTC (rev 3717)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/TeiidServiceNames.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -29,6 +29,7 @@
public static ServiceName VDB_REPO = ServiceName.JBOSS.append("teiid",
"vdb-repository");//$NON-NLS-1$ //$NON-NLS-2$
public static ServiceName TRANSLATOR_BASE = ServiceName.JBOSS.append("teiid",
"translator");//$NON-NLS-1$ //$NON-NLS-2$
public static ServiceName TRANSPORT_BASE = ServiceName.JBOSS.append("teiid",
"transport");//$NON-NLS-1$ //$NON-NLS-2$
+ private static ServiceName EMBEDDED_TRANSPORT_BASE =
ServiceName.JBOSS.append("teiid", "embedded",
"transport");//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
public static ServiceName BUFFER_DIR = ServiceName.JBOSS.append("teiid",
"buffer.dir");//$NON-NLS-1$ //$NON-NLS-2$
public static ServiceName DATA_DIR = ServiceName.JBOSS.append("teiid",
"data.dir");//$NON-NLS-1$ //$NON-NLS-2$
public static ServiceName BUFFER_MGR = ServiceName.JBOSS.append("teiid",
"buffer-mgr");//$NON-NLS-1$ //$NON-NLS-2$
@@ -58,7 +59,11 @@
return ServiceName.of(TRANSPORT_BASE, name);
}
- public static ServiceName dsListenerServiceName(String name) {
- return ServiceName.of(DS_LISTENER_BASE, name);
+ public static ServiceName embeddedTransportServiceName(String name) {
+ return EMBEDDED_TRANSPORT_BASE.append(name);
+ }
+
+ public static ServiceName dsListenerServiceName(String vdbName, int version, String
name) {
+ return ServiceName.of(DS_LISTENER_BASE, vdbName, String.valueOf(version), name);
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java 2011-12-05
16:29:37 UTC (rev 3717)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorAdd.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -113,6 +113,7 @@
throw new OperationFailedException( new
ModelNode().set(IntegrationPlugin.Util.getString("error_adding_translator",
translatorName))); //$NON-NLS-1$
}
+ metadata.addAttchment(ClassLoader.class, translatorLoader);
if (translatorName.equalsIgnoreCase(metadata.getName())) {
LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("translator.added", metadata.getName()));
//$NON-NLS-1$
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java 2011-12-05
16:29:37 UTC (rev 3717)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -62,10 +62,11 @@
final ServiceLoader<ExecutionFactory> serviceLoader =
ServiceLoader.load(ExecutionFactory.class, translatorLoader);
if (serviceLoader != null) {
for (ExecutionFactory ef:serviceLoader) {
- VDBTranslatorMetaData metadata = TranslatorUtil.buildTranslatorMetadata(ef,
moduleName);
+ VDBTranslatorMetaData metadata = TranslatorUtil.buildTranslatorMetadata(ef,
moduleName);
if (metadata == null) {
throw new
DeploymentUnitProcessingException(IntegrationPlugin.Util.getString("error_adding_translator_deployment",
moduleName)); //$NON-NLS-1$
}
+ metadata.addAttchment(ClassLoader.class, translatorLoader);
LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.getString("translator.added", metadata.getName()));
//$NON-NLS-1$
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2011-12-05
16:29:37 UTC (rev 3717)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportAdd.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -199,7 +199,7 @@
// register a JNDI name, this looks hard.
if (transport.isEmbedded() && !isEmbeddedRegistered()) {
final CSRReferenceFactoryService referenceFactoryService = new
CSRReferenceFactoryService();
- final ServiceName referenceFactoryServiceName
=TeiidServiceNames.transportServiceName(transportName).append("reference-factory");
//$NON-NLS-1$
+ final ServiceName referenceFactoryServiceName
=TeiidServiceNames.embeddedTransportServiceName(transportName).append("reference-factory");
//$NON-NLS-1$
final ServiceBuilder<?> referenceBuilder =
target.addService(referenceFactoryServiceName,referenceFactoryService);
referenceBuilder.addDependency(TeiidServiceNames.transportServiceName(transportName),
ClientServiceRegistry.class, referenceFactoryService.getCSRInjector());
referenceBuilder.setInitialMode(ServiceController.Mode.ACTIVE);
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-12-05
16:29:37 UTC (rev 3717)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -43,6 +43,7 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
+import org.teiid.deployers.ContainerLifeCycleListener;
import org.teiid.deployers.UDFMetaData;
import org.teiid.deployers.VDBRepository;
import org.teiid.deployers.VDBStatusChecker;
@@ -60,11 +61,13 @@
private TranslatorRepository translatorRepository;
private String asyncThreadPoolName;
private VDBStatusChecker vdbStatusChecker;
+ private ContainerLifeCycleListener shutdownListener;
- public VDBDeployer (TranslatorRepository translatorRepo, String poolName,
VDBStatusChecker vdbStatusChecker) {
+ public VDBDeployer (TranslatorRepository translatorRepo, String poolName,
VDBStatusChecker vdbStatusChecker, ContainerLifeCycleListener shutdownListener) {
this.translatorRepository = translatorRepo;
this.asyncThreadPoolName = poolName;
this.vdbStatusChecker = vdbStatusChecker;
+ this.shutdownListener = shutdownListener;
}
public void deploy(final DeploymentPhaseContext context) throws
DeploymentUnitProcessingException {
@@ -122,7 +125,7 @@
// build a VDB service
ArrayList<String> unAvailableDS = new ArrayList<String>();
- VDBService vdb = new VDBService(deployment);
+ VDBService vdb = new VDBService(deployment, this.shutdownListener);
final ServiceBuilder<VDBMetaData> vdbService =
context.getServiceTarget().addService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()), vdb);
for (ModelMetaData model:deployment.getModelMetaDatas().values()) {
for (String sourceName:model.getSourceNames()) {
@@ -137,7 +140,7 @@
@Override
public void dependentService(final String dsName, final ServiceName svcName) {
DataSourceListener dsl = new DataSourceListener(dsName, svcName,
vdbStatusChecker);
- ServiceBuilder<DataSourceListener> sb =
context.getServiceTarget().addService(TeiidServiceNames.dsListenerServiceName(dsName),
dsl);
+ ServiceBuilder<DataSourceListener> sb =
context.getServiceTarget().addService(TeiidServiceNames.dsListenerServiceName(deployment.getName(),
deployment.getVersion(), dsName), dsl);
sb.addDependency(svcName);
sb.setInitialMode(Mode.PASSIVE).install();
}
@@ -258,24 +261,6 @@
if (!TeiidAttachments.isVDBDeployment(deploymentUnit)) {
return;
}
-
- final VDBMetaData deployment =
deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
- final ServiceController<?> controller =
deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()));
- if (controller != null) {
- VDBService vdbService = (VDBService)controller.getService();
- vdbService.undeployInProgress();
-
- dataSourceDependencies(deployment, new DependentServices() {
- @Override
- public void dependentService(String dsName, ServiceName svcName) {
- ServiceController<?> controller =
deploymentUnit.getServiceRegistry().getService(TeiidServiceNames.dsListenerServiceName(dsName));
- if (controller != null) {
- controller.setMode(ServiceController.Mode.REMOVE);
- }
- }
- });
- controller.setMode(ServiceController.Mode.REMOVE);
- }
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-12-05
16:29:37 UTC (rev 3717)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -55,6 +55,7 @@
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidException;
+import org.teiid.deployers.ContainerLifeCycleListener;
import org.teiid.deployers.MetadataStoreGroup;
import org.teiid.deployers.TranslatorUtil;
import org.teiid.deployers.UDFMetaData;
@@ -86,10 +87,11 @@
private final InjectedValue<ObjectSerializer> serializerInjector = new
InjectedValue<ObjectSerializer>();
private final InjectedValue<BufferServiceImpl> bufferServiceInjector = new
InjectedValue<BufferServiceImpl>();
private final InjectedValue<ObjectReplicator> objectReplicatorInjector = new
InjectedValue<ObjectReplicator>();
- private boolean undeployInProgress = false;
+ private ContainerLifeCycleListener shutdownListener;
- public VDBService(VDBMetaData metadata) {
+ public VDBService(VDBMetaData metadata, ContainerLifeCycleListener shutdownListener) {
this.vdb = metadata;
+ this.shutdownListener = shutdownListener;
}
@Override
@@ -231,7 +233,7 @@
this.vdb.setRemoved(true);
// service stopped not due to shutdown then clean-up the data files
- if (undeployInProgress) {
+ if (!this.shutdownListener.isShutdownInProgress()) {
getSerializer().removeAttachments(vdb);
LogManager.logTrace(LogConstants.CTX_RUNTIME, "VDB "+vdb.getName()+"
metadata removed"); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -488,10 +490,6 @@
return objectReplicatorInjector;
}
- public void undeployInProgress() {
- this.undeployInProgress = true;
- }
-
public void addDataRole(String policyName, String mappedRole) throws
AdminProcessingException{
DataPolicyMetadata policy = vdb.getDataPolicy(policyName);
Modified:
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-12-05
16:29:37 UTC (rev 3717)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -162,7 +162,7 @@
// terminate all the previous sessions
List<ServiceName> services =
context.getController().getServiceContainer().getServiceNames();
for (ServiceName service:services) {
- if (service.isParentOf(TeiidServiceNames.TRANSPORT_BASE)) {
+ if (TeiidServiceNames.TRANSPORT_BASE.isParentOf(service)) {
ServiceController<?> transport =
context.getController().getServiceContainer().getService(service);
if (transport != null) {
Transport t = Transport.class.cast(transport.getValue());
Modified: trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties
===================================================================
--- trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-12-05
16:29:37 UTC (rev 3717)
+++ trunk/jboss-integration/src/main/resources/org/teiid/jboss/i18n.properties 2011-12-05
19:12:03 UTC (rev 3718)
@@ -265,8 +265,8 @@
active-session-count.describe=Number of active sessions
active-session-count.reply=Returns the count of active sessions
-long-running-queries.describe=Long running queries that exceeded the threshold set by the
'query-threshold-in-seconds' configuration property.
-long-running-queries.reply=long running queries
+list-long-running-requests.describe=Long running queries that exceeded the threshold set
by the 'query-threshold-in-seconds' configuration property.
+list-long-running-requests.reply=long running queries
runtime-version.describe = Runtime version of the Teiid subsystem
runtime-version.reply=Teiid runtime version
@@ -317,14 +317,14 @@
remove-data-role.mapped-role.describe=Security domain defined role name
remove-data-role.reply=void
-requests-per-session.describe=Current active requests in progress in the query engine for
a given session identifier
-requests-per-session.session.describe=The session Identifier
-requests-per-session.reply=requests for given session
+list-requests-per-session.describe=Current active requests in progress in the query
engine for a given session identifier
+list-requests-per-session.session.describe=The session Identifier
+list-requests-per-session.reply=requests for given session
-requests-per-vdb.describe=Current active requests in progress in the query engine for a
given VDB name and its version.
-requests-per-vdb.vdb-name.describe=VDB Name
-requests-per-vdb.vdb-version.describe=VDB Version
-requests-per-vdb.reply=list of requests on the given vdb
+list-requests-per-vdb.describe=Current active requests in progress in the query engine
for a given VDB name and its version.
+list-requests-per-vdb.vdb-name.describe=VDB Name
+list-requests-per-vdb.vdb-version.describe=VDB Version
+list-requests-per-vdb.reply=list of requests on the given vdb
terminate-session.describe=Terminate the session
terminate-session.session.describe=The session Identifier of session to be terminated
Modified:
trunk/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidConfiguration.java
===================================================================
---
trunk/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidConfiguration.java 2011-12-05
16:29:37 UTC (rev 3717)
+++
trunk/jboss-integration/src/test/java/org/teiid/jboss/TestTeiidConfiguration.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -240,21 +240,17 @@
List<String> opNames = getList(result);
assertEquals(38, opNames.size());
- String[] ops = { "add", "add-anyauthenticated-role",
"add-data-role",
- "assign-datasource", "cache-statistics",
"cache-types",
- "cancel-request", "change-vdb-connection-type",
"clear-cache",
- "describe", "execute-query", "get-translator",
"get-vdb",
- "list-requests", "list-sessions", "list-transactions",
- "list-translators", "list-vdbs",
"long-running-queries",
- "mark-datasource-available",
- "merge-vdbs", "read-attribute", "read-children-names",
- "read-children-resources", "read-children-types",
- "read-operation-description", "read-operation-names",
"read-rar-description",
- "read-resource", "read-resource-description",
- "remove-anyauthenticated-role", "remove-data-role",
- "requests-per-session", "requests-per-vdb",
- "terminate-session", "terminate-transaction",
- "workerpool-statistics", "write-attribute" };
+ String[] ops = {
"add","add-anyauthenticated-role","add-data-role","assign-datasource",
+ "cache-statistics","cache-types","cancel-request","change-vdb-connection-type",
+ "clear-cache","describe","execute-query","get-translator","get-vdb",
+ "list-long-running-requests","list-requests","list-requests-per-session",
+ "list-requests-per-vdb","list-sessions","list-transactions","list-translators",
+ "list-vdbs","mark-datasource-available","merge-vdbs","read-attribute",
+ "read-children-names","read-children-resources","read-children-types",
+ "read-operation-description","read-operation-names","read-rar-description",
+ "read-resource","read-resource-description","remove-anyauthenticated-role",
+ "remove-data-role","terminate-session","terminate-transaction",
+ "workerpool-statistics","write-attribute", };
assertEquals(Arrays.asList(ops), opNames);
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-12-05 16:29:37 UTC (rev 3717)
+++ trunk/pom.xml 2011-12-05 19:12:03 UTC (rev 3718)
@@ -13,7 +13,7 @@
<jbossas-version>7.1.0.Beta1</jbossas-version>
<version.org.jboss.jboss-common-core>2.2.17.GA</version.org.jboss.jboss-common-core>
<version.org.jboss.staxmapper>1.0.0.Final</version.org.jboss.staxmapper>
-
<version.org.jboss.jboss-dmr>1.0.0.Final</version.org.jboss.jboss-dmr>
+
<version.org.jboss.jboss-dmr>1.1.0.Final</version.org.jboss.jboss-dmr>
<version.org.jboss.msc.jboss-msc>1.0.1.GA</version.org.jboss.msc.jboss-msc>
<version.org.jboss.modules.jboss-modules>1.1.0.CR3</version.org.jboss.modules.jboss-modules>
<version.org.jboss.jboss-vfs>3.1.0.CR1</version.org.jboss.jboss-vfs>
@@ -21,6 +21,16 @@
<version.org.jboss.logging.jboss-logging>3.1.0.CR1</version.org.jboss.logging.jboss-logging>
<version.org.jboss.logging.jboss-logging-tools>1.0.0.CR4</version.org.jboss.logging.jboss-logging-tools>
<version.org.picketbox.jbosssx-client>3.0.0.CR2</version.org.picketbox.jbosssx-client>
+
<version.org.jboss.arquillian.core>1.0.0.CR5</version.org.jboss.arquillian.core>
+
<version.javax.enterprise.cdi-api>1.0-SP4</version.javax.enterprise.cdi-api>
+ <version.org.jboss.netty>3.2.4.Final</version.org.jboss.netty>
+
<version.net.sourceforge.saxon>9.2.1.5</version.net.sourceforge.saxon>
+ <version.json-simple>1.1</version.json-simple>
+ <version.org.jgroups>3.0.0.Final</version.org.jgroups>
+ <version.connector-api>1.5</version.connector-api>
+ <version.jta>1.1</version.jta>
+ <version.sun.jaxb>2.2</version.sun.jaxb>
+ <version.junit>4.8.2</version.junit>
</properties>
<scm>
<
connection>scm:svn:https://anonsvn.jboss.org/repos/teiid/trunk</con...
@@ -121,6 +131,22 @@
<module>build</module>
</modules>
</profile>
+ <profile>
+ <id>arquillian-tests</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>1.0.0.Final</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+
<artifactId>jboss-as-arquillian-container-managed</artifactId>
+ </dependency>
+ </dependencies>
+ </profile>
</profiles>
<build>
<!-- This section defines the default plugin settings inherited by child projects.
-->
@@ -349,13 +375,13 @@
<dependency>
<groupId>javax.resource</groupId>
<artifactId>connector-api</artifactId>
- <version>1.5</version>
+ <version>${version.connector-api}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.transaction</groupId>
<artifactId>jta</artifactId>
- <version>1.1</version>
+ <version>${version.jta}</version>
<scope>provided</scope>
</dependency>
<dependency>
@@ -535,22 +561,38 @@
<dependency>
<groupId>org.jgroups</groupId>
<artifactId>jgroups</artifactId>
- <version>3.0.0.Final</version>
+ <version>${version.org.jgroups}</version>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
<artifactId>jboss-as-subsystem-test</artifactId>
<version>${jbossas-version}</version>
- </dependency>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>${version.org.jboss.arquillian.core}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+
<artifactId>jboss-as-arquillian-container-managed</artifactId>
+ <version>${jbossas-version}</version>
+ </dependency>
<dependency>
<groupId>net.sourceforge.saxon</groupId>
<artifactId>saxonhe</artifactId>
- <version>9.2.1.5</version>
+ <version>${version.net.sourceforge.saxon}</version>
</dependency>
<dependency>
<groupId>org.jboss.netty</groupId>
<artifactId>netty</artifactId>
- <version>3.2.3.Final</version>
+ <version>${version.org.jboss.netty}</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
@@ -560,12 +602,28 @@
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
- <version>1.1</version>
+ <version>${version.json-simple}</version>
</dependency>
<dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>${version.javax.enterprise.cdi-api}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <version>${version.org.jboss.arquillian.core}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
- <version>2.2</version>
+ <version>${version.sun.jaxb}</version>
<exclusions>
<exclusion>
<groupId>javax.xml.bind</groupId>
@@ -573,6 +631,11 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${version.junit}</version>
+ </dependency>
</dependencies>
</dependencyManagement>
<modules>
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2011-12-05
16:29:37 UTC (rev 3717)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -111,7 +111,7 @@
if (t == null) {
throw new
AdminProcessingException(RuntimePlugin.Util.getString("translator_not_found",
vdb.getName(), vdb.getVersion(), translatorName)); //$NON-NLS-1$
}
- ef = TranslatorUtil.buildExecutionFactory(t,
Thread.currentThread().getContextClassLoader());
+ ef = TranslatorUtil.buildExecutionFactory(t, t.getAttachment(ClassLoader.class));
cm.setExecutionFactory(ef);
} catch (TeiidException e) {
throw new AdminProcessingException(e.getCause());
Modified: trunk/test-integration/common/pom.xml
===================================================================
--- trunk/test-integration/common/pom.xml 2011-12-05 16:29:37 UTC (rev 3717)
+++ trunk/test-integration/common/pom.xml 2011-12-05 19:12:03 UTC (rev 3718)
@@ -30,21 +30,19 @@
<artifactId>commons-logging</artifactId>
</dependency>
<dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- <version>1.0.0.CR5</version>
- <scope>test</scope>
- </dependency>
+ <groupId>org.jboss.arquillian.junit</groupId>
+ <artifactId>arquillian-junit-container</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
- <version>1.0</version>
+ <scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.as</groupId>
@@ -52,23 +50,4 @@
<scope>provided</scope>
</dependency>
</dependencies>
- <profiles>
- <profile>
- <id>jbossas-managed-7</id>
- <dependencies>
- <dependency>
- <groupId>org.jboss.spec</groupId>
- <artifactId>jboss-javaee-6.0</artifactId>
- <version>1.0.0.Final</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.as</groupId>
-
<artifactId>jboss-as-arquillian-container-managed</artifactId>
- <version>7.0.2.Final</version>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
</project>
\ No newline at end of file
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java 2011-12-05
16:29:37 UTC (rev 3717)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -1,10 +1,12 @@
package org.teiid.arquillian;
-import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.loopback.LoopbackExecutionFactory;
-(a)org.teiid.translator.Translator(name = "orcl")
-public class SampleExecutionFactory extends ExecutionFactory<Object, Object> {
+(a)org.teiid.translator.Translator(name = "loopy")
+public class SampleExecutionFactory extends LoopbackExecutionFactory {
public SampleExecutionFactory() {
setSupportsSelectDistinct(true);
+ setWaitTime(10);
+ setRowCount(200);
}
}
\ No newline at end of file
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/TestDeployment.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/arquillian/TestDeployment.java 2011-12-05
16:29:37 UTC (rev 3717)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/TestDeployment.java 2011-12-05
19:12:03 UTC (rev 3718)
@@ -1,13 +1,20 @@
package org.teiid.arquillian;
+import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.sql.Connection;
+import java.sql.Statement;
import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
import java.util.Properties;
import java.util.Set;
@@ -17,28 +24,47 @@
import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
import org.jboss.shrinkwrap.api.exporter.ZipExporter;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.After;
+import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
import org.teiid.adminapi.AdminFactory;
+import org.teiid.adminapi.DataPolicy;
import org.teiid.adminapi.Model;
+import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.Session;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.VDB.ConnectionType;
import org.teiid.adminapi.VDB.Status;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.jdbc.TeiidDriver;
@RunWith(Arquillian.class)
@SuppressWarnings("nls")
@Ignore
public class TestDeployment {
+ private Admin admin;
+
+ @Before
+ public void setup() throws Exception {
+ admin = AdminFactory.getInstance().createAdmin("localhost",
9999, "admin", "admin".toCharArray());
+ }
+
+ @After
+ public void teardown() {
+ admin.close();
+ }
+
@Test
public void testVDBDeployment() throws Exception {
boolean deployed = false;
- Admin admin = AdminFactory.getInstance().createAdmin("localhost", 9999, null,
null);
try {
Set<?> vdbs = admin.getVDBs();
assertTrue(vdbs.isEmpty());
@@ -81,61 +107,348 @@
admin.undeploy("bqt.vdb");
}
}
-
- admin.close();
}
@Test
public void testTraslators() throws Exception {
- Admin admin = AdminFactory.getInstance().createAdmin("localhost", 9999, null,
null);
-
Collection<? extends Translator> translators = admin.getTranslators();
+ System.out.println(translators);
+ assertEquals(29, translators.size());
+
+ JavaArchive jar = getLoopyArchive();
- assertEquals(27, translators.size());
-
- JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "orcl.jar")
- .addClasses(SampleExecutionFactory.class)
- .addAsManifestResource(new
ByteArrayAsset(SampleExecutionFactory.class.getName().getBytes()),
-
ArchivePaths.create("services/org.teiid.translator.ExecutionFactory"));
try {
- admin.deploy("orcl.jar", jar.as(ZipExporter.class).exportAsInputStream());
+ admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream());
- VDBTranslatorMetaData t =
(VDBTranslatorMetaData)admin.getTranslator("orcl");
+ VDBTranslatorMetaData t =
(VDBTranslatorMetaData)admin.getTranslator("loopy");
assertNotNull(t);
assertEquals("ANY", t.getPropertyValue("SupportedJoinCriteria"));
assertEquals("true",
t.getPropertyValue("supportsSelectDistinct"));
} finally {
- admin.undeploy("orcl.jar");
+ admin.undeploy("loopy.jar");
}
VDBTranslatorMetaData t =
(VDBTranslatorMetaData)admin.getTranslator("orcl");
assertNull(t);
-
- admin.close();
}
+ private JavaArchive getLoopyArchive() {
+ JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "loopy.jar")
+ .addClasses(SampleExecutionFactory.class)
+ .addAsManifestResource(new
ByteArrayAsset(SampleExecutionFactory.class.getName().getBytes()),
+
ArchivePaths.create("services/org.teiid.translator.ExecutionFactory"));
+ jar.addAsManifestResource(new ByteArrayAsset("Dependencies:
org.jboss.teiid.translator.loopback\n".getBytes()),
+ ArchivePaths.create("MANIFEST.MF"));
+ return jar;
+ }
+
@Test
- public void testVDBOperations() throws Exception {
- Admin admin = AdminFactory.getInstance().createAdmin("localhost", 9999, null,
null);
+ public void testVDBConnectionType() throws Exception {
+ boolean vdbOneDeployed = false;
+ boolean vdbTwoDeployed = false;
try {
- admin.deploy("bqt.vdb",new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
+ admin.deploy("bqt.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
+ vdbOneDeployed = true;
+
VDB vdb = admin.getVDB("bqt", 1);
Model model = vdb.getModels().get(0);
+ admin.assignToModel("bqt", 1, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
assertEquals(ConnectionType.BY_VERSION, vdb.getConnectionType());
- admin.assignToModel("bqt", 1, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
- admin.changeVDBConnectionType("bqt", 1, ConnectionType.ANY);
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ conn.close();
+ } catch (Exception e) {
+ fail("must have succeeded in connection");
+ }
- vdb = admin.getVDB("bqt", 1);
+ admin.changeVDBConnectionType("bqt", 1, ConnectionType.NONE);
+
+ try {
+ TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ fail("should have failed to connect as no new connections allowed");
+ } catch (Exception e) {
+ //pass
+ }
+
+ admin.deploy("bqt2.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
+ admin.assignToModel("bqt", 2, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
+
+ vdbTwoDeployed = true;
+
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ conn.close();
+ } catch (Exception e) {
+ fail("should not have failed to connect");
+ }
+
+ admin.changeVDBConnectionType("bqt", 2, ConnectionType.ANY);
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ conn.close();
+ } catch (Exception e) {
+ fail("should have connected to the second vdb");
+ }
+
+ vdb = admin.getVDB("bqt", 2);
model = vdb.getModels().get(0);
assertEquals(model.getSourceConnectionJndiName("Source"),
"java:jboss/datasources/ExampleDS");
assertEquals(model.getSourceTranslatorName("Source"), "h2");
assertEquals(ConnectionType.ANY, vdb.getConnectionType());
} finally {
- admin.undeploy("bqt.vdb");
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ if (vdbTwoDeployed) {
+ admin.undeploy("bqt2.vdb");
+ }
}
- admin.close();
}
+
+ @Test
+ public void testCacheTypes() throws Exception {
+ String[] array = {Admin.Cache.PREPARED_PLAN_CACHE.toString(),
Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString()};
+ Collection<String> types = admin.getCacheTypes();
+ System.out.println(types);
+ assertArrayEquals(array, types.toArray());
+ }
+
+ @Test
+ public void testSessions() throws Exception {
+ boolean vdbOneDeployed = false;
+ try {
+ vdbOneDeployed = deployVdb();
+
+ Collection<? extends Session> sessions = admin.getSessions();
+ assertEquals (0, sessions.size());
+
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user;ApplicationName=test",
null);
+ sessions = admin.getSessions();
+ assertEquals (1, sessions.size());
+ Session s = sessions.iterator().next();
+
+ assertEquals("user@teiid-security", s.getUserName());
+ assertEquals("test", s.getApplicationName());
+ assertEquals("bqt", s.getVDBName());
+ assertEquals(1, s.getVDBVersion());
+ assertNotNull(s.getSessionId());
+
+ conn.close();
+ } catch (Exception e) {
+ fail("should have connected to the vdb");
+ }
+
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user;ApplicationName=test",
null);
+ sessions = admin.getSessions();
+ assertEquals (1, sessions.size());
+ Session s = sessions.iterator().next();
+
+ admin.terminateSession(s.getSessionId());
+ sessions = admin.getSessions();
+ assertEquals (0, sessions.size());
+ conn.close();
+ } catch (Exception e) {
+ fail("should have connected to the vdb");
+ }
+
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+
+ }
+ }
+
+ private boolean deployVdb() throws AdminException, FileNotFoundException {
+ boolean vdbOneDeployed;
+ admin.deploy("bqt.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
+ vdbOneDeployed = true;
+
+ VDB vdb = admin.getVDB("bqt", 1);
+ Model model = vdb.getModels().get(0);
+ admin.assignToModel("bqt", 1, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
+ return vdbOneDeployed;
+ }
+
+ @Test
+ public void testGetRequests() throws Exception {
+ boolean vdbOneDeployed = false;
+ JavaArchive jar = getLoopyArchive();
+
+ try {
+ admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream());
+ vdbOneDeployed = deployVdb();
+ VDB vdb = admin.getVDB("bqt", 1);
+ Model model = vdb.getModels().get(0);
+ Translator t = admin.getTranslator("loopy");
+ assertNotNull(t);
+
+ admin.assignToModel("bqt", 1, model.getName(), "Source",
"loopy", "java:jboss/datasources/ExampleDS");
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ Collection<? extends Session> sessions = admin.getSessions();
+ assertEquals (1, sessions.size());
+ Session s = sessions.iterator().next();
+
+ Statement stmt = conn.createStatement();
+
+ Collection<? extends Request> requests = admin.getRequests();
+
+ assertEquals(0, requests.size());
+
+ stmt.execute("select * from source.smalla");
+
+ requests = admin.getRequests();
+ assertEquals(1, requests.size());
+
+ Request r = requests.iterator().next();
+ assertEquals("select * from source.smalla", r.getCommand());
+ assertNotNull(r.getExecutionId());
+ assertNotNull(r.getSessionId());
+
+ stmt.execute("select * from source.smalla");
+ Collection<? extends Request> requests2 =
admin.getRequestsForSession(s.getSessionId());
+ assertEquals(1, requests2.size());
+
+ Request r2 = requests.iterator().next();
+ assertEquals("select * from source.smalla", r2.getCommand());
+ assertEquals(s.getSessionId(), r2.getSessionId());
+
+ stmt.close();
+ conn.close();
+
+ requests = admin.getRequests();
+ assertEquals(0, requests.size());
+
+ } finally {
+ admin.undeploy("loopy.jar");
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void getDatasourceTemplateNames() throws Exception {
+ String[] array = {"teiid-connector-file.rar",
"teiid-connector-salesforce.rar", "teiid-connector-ldap.rar",
"teiid-connector-ws.rar", "h2"};
+ boolean vdbOneDeployed = false;
+ try {
+ vdbOneDeployed = deployVdb();
+ Set<String> templates = admin.getDataSourceTemplateNames();
+ assertArrayEquals(array, templates.toArray());
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void getTemplatePropertyDefinitions() throws Exception{
+ boolean vdbOneDeployed = false;
+ try {
+ HashSet<String> props = new HashSet<String>();
+ vdbOneDeployed = deployVdb();
+ Collection<? extends PropertyDefinition> pds =
admin.getTemplatePropertyDefinitions("h2");
+ for(PropertyDefinition pd:pds) {
+ props.add(pd.getName());
+ }
+ assertTrue(props.contains("connection-url"));
+ assertTrue(props.contains("user-name"));
+ assertTrue(props.contains("password"));
+ assertTrue(props.contains("check-valid-connection-sql"));
+
+
+ HashSet<String> rar_props = new HashSet<String>();
+ pds = admin.getTemplatePropertyDefinitions("teiid-connector-file.rar");
+ for(PropertyDefinition pd:pds) {
+ rar_props.add(pd.getName());
+ }
+
+ assertTrue(rar_props.contains("ParentDirectory"));
+ assertTrue(rar_props.contains("FileMapping"));
+ assertTrue(rar_props.contains("AllowParentPaths"));
+
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void getWorkerPoolStats() throws Exception{
+ boolean vdbOneDeployed = false;
+ try {
+ vdbOneDeployed = deployVdb();
+ assertNotNull(admin.getWorkerPoolStats());
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void testDataRoleMapping() throws Exception{
+ boolean vdbOneDeployed = false;
+ try {
+ admin.deploy("bqt2.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
+ vdbOneDeployed = true;
+
+ VDB vdb = admin.getVDB("bqt", 2);
+ Model model = vdb.getModels().get(0);
+ admin.assignToModel("bqt", 2, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
+
+ vdb = admin.getVDB("bqt", 2);
+ assertTrue(vdb.isValid());
+ List<DataPolicy> policies = vdb.getDataPolicies();
+ assertEquals(1, policies.size());
+
+ DataPolicy dp = policies.get(0);
+ assertEquals("roleOne", dp.getName());
+ assertEquals(2, dp.getPermissions().size());
+ assertTrue(dp.isAllowCreateTemporaryTables());
+ assertTrue(dp.isAnyAuthenticated());
+
+ List<String> roleNames = dp.getMappedRoleNames();
+ assertArrayEquals(new String[]{"ROLE1", "ROLE2"},
roleNames.toArray());
+
+ admin.removeDataRoleMapping("bqt", 2, "roleOne",
"ROLE1");
+
+ vdb = admin.getVDB("bqt", 2);
+ policies = vdb.getDataPolicies();
+ dp = policies.get(0);
+
+ roleNames = dp.getMappedRoleNames();
+ assertArrayEquals(new String[]{"ROLE2"}, roleNames.toArray());
+
+ admin.addDataRoleMapping("bqt", 2, "roleOne", "ROLE3");
+
+ vdb = admin.getVDB("bqt", 2);
+ policies = vdb.getDataPolicies();
+ dp = policies.get(0);
+
+ roleNames = dp.getMappedRoleNames();
+ assertArrayEquals(new String[]{"ROLE2", "ROLE3"},
roleNames.toArray());
+
+ admin.setAnyAuthenticatedForDataRole("bqt", 2, "roleOne", false);
+
+ vdb = admin.getVDB("bqt", 2);
+ policies = vdb.getDataPolicies();
+ dp = policies.get(0);
+
+ assertFalse(dp.isAnyAuthenticated());
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt2.vdb");
+ }
+ }
+ }
+
+
}
Modified: trunk/test-integration/common/src/test/resources/arquillian.xml
===================================================================
--- trunk/test-integration/common/src/test/resources/arquillian.xml 2011-12-05 16:29:37
UTC (rev 3717)
+++ trunk/test-integration/common/src/test/resources/arquillian.xml 2011-12-05 19:12:03
UTC (rev 3718)
@@ -8,10 +8,11 @@
<property name="executionType">REMOTE</property>
</protocol>
<configuration>
- <property
name="jbossHome">/home/rareddy/testing/jboss-as-7.1.0.Alpha2-SNAPSHOT</property>
+ <property
name="jbossHome">/home/rareddy/testing/jboss-as-7.1.0.Beta1</property>
<property
name="serverConfig">standalone-teiid.xml</property>
<property
name="managementAddress">127.0.0.1</property>
<property name="managementPort">9999</property>
+ <property name="javaVmArguments">-Xmx512m
-XX:MaxPermSize=128m
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n</property>
</configuration>
</container>
</arquillian>
\ No newline at end of file
Added: trunk/test-integration/common/src/test/resources/bqt2.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/test-integration/common/src/test/resources/bqt2.vdb
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: trunk/test-integration/pom.xml
===================================================================
--- trunk/test-integration/pom.xml 2011-12-05 16:29:37 UTC (rev 3717)
+++ trunk/test-integration/pom.xml 2011-12-05 19:12:03 UTC (rev 3718)
@@ -43,6 +43,11 @@
<artifactId>translator-jdbc</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <artifactId>translator-loopback</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-client</artifactId>