Author: shawkins
Date: 2012-05-31 15:00:50 -0400 (Thu, 31 May 2012)
New Revision: 4152
Added:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestVDBReuse.java
Modified:
trunk/admin/src/main/java/org/teiid/adminapi/AdminException.java
trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
trunk/admin/src/test/resources/vdb-describe.txt
trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
trunk/common-core/src/main/java/org/teiid/core/TeiidException.java
trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java
trunk/common-core/src/main/java/org/teiid/core/util/ExceptionUtil.java
trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java
trunk/common-core/src/test/java/org/teiid/core/util/TestMetaMatrixExceptionUtil.java
trunk/common-core/src/test/java/org/teiid/core/util/TestPropertiesUtils.java
trunk/documentation/pom.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestDeepGroupCollectorVisitor.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/DQPCoreService.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
trunk/pom.xml
trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDynamicViewDefinition.java
trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java
trunk/test-integration/common/src/test/resources/dynamicview-vdb.xml
trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java
Log:
TEIID-1366 TEIID-2022 adding arquillian tests for reuse and misc fixes including refining
exception handling
Modified: trunk/admin/src/main/java/org/teiid/adminapi/AdminException.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/AdminException.java 2012-05-30 15:39:59
UTC (rev 4151)
+++ trunk/admin/src/main/java/org/teiid/adminapi/AdminException.java 2012-05-31 19:00:50
UTC (rev 4152)
@@ -45,7 +45,7 @@
private static final long serialVersionUID = -4446936145500241358L;
// List of Admin exceptions in
// case of multiple failure
- private List children;
+ private List<AdminException> children;
/**
* No-arg ctor.
@@ -110,8 +110,11 @@
* @return The non-null list of failures.
* @since 4.3
*/
- public List getChildren() {
- return (children != null ? children : Collections.EMPTY_LIST);
+ public List<AdminException> getChildren() {
+ if (children == null) {
+ return Collections.emptyList();
+ }
+ return children;
}
/**
@@ -123,7 +126,7 @@
*/
public void addChild(AdminException child) {
if ( children == null ) {
- children = new ArrayList();
+ children = new ArrayList<AdminException>();
}
children.add(child);
}
Modified: trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2012-05-30 15:39:59 UTC
(rev 4151)
+++ trunk/admin/src/main/java/org/teiid/adminapi/AdminFactory.java 2012-05-31 19:00:50 UTC
(rev 4152)
@@ -67,6 +67,7 @@
@SuppressWarnings("nls")
public class AdminFactory {
private static final Logger LOGGER = Logger.getLogger(AdminFactory.class.getName());
+ private static Set<String> optionalProps = new
HashSet<String>(Arrays.asList("connection-url", "password",
"check-valid-connection-sql", "pool-prefill",
"max-pool-size", "min-pool-size"));
private static AdminFactory INSTANCE = new AdminFactory();
public static AdminFactory getInstance() {
@@ -398,21 +399,15 @@
builder.addProperty("driver-name", templateName);
builder.addProperty("pool-name", deploymentName);
- builder.addProperty("pool-prefill", "false");
- builder.addProperty("max-pool-size", "20");
- builder.addProperty("min-pool-size", "10");
if (properties != null) {
builder.addProperty("connection-url",
properties.getProperty("connection-url"));
- if (properties.getProperty("user-name") != null) {
- builder.addProperty("user-name",
properties.getProperty("user-name"));
+ for (String prop : optionalProps) {
+ String value = properties.getProperty(prop);
+ if (value != null) {
+ builder.addProperty(prop, value);
+ }
}
- if (properties.getProperty("password") != null) {
- builder.addProperty("password",
properties.getProperty("password"));
- }
- if (properties.getProperty("check-valid-connection-sql") != null)
{
- builder.addProperty("check-valid-connection-sql",
properties.getProperty("check-valid-connection-sql"));
- }
}
else {
throw new AdminProcessingException(AdminPlugin.Event.TEIID70005,
AdminPlugin.Util.gs(AdminPlugin.Event.TEIID70005));
Modified: trunk/admin/src/main/java/org/teiid/adminapi/VDB.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/VDB.java 2012-05-30 15:39:59 UTC (rev
4151)
+++ trunk/admin/src/main/java/org/teiid/adminapi/VDB.java 2012-05-31 19:00:50 UTC (rev
4152)
@@ -40,7 +40,22 @@
*/
public interface VDB extends AdminObject, DomainAware {
- public static enum Status{INACTIVE, ACTIVE};
+ public static enum Status{
+ //loaded | valid
+ INCOMPLETE(true), //f f
+ LOADING(true), //f t
+ INVALID(false), //t f
+ ACTIVE(false), //t t
+ REMOVED(false);
+
+ private boolean loading;
+ private Status(boolean loading) {
+ this.loading = loading;
+ }
+
+ public boolean isLoading() {
+ return loading;
+ }};
public enum ConnectionType {NONE, BY_VERSION, ANY}
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-05-30 15:39:59
UTC (rev 4151)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetaData.java 2012-05-31 19:00:50
UTC (rev 4152)
@@ -79,33 +79,15 @@
protected String description;
private boolean dynamic = false;
- private VDB.Status status = VDB.Status.INACTIVE;
+ private volatile VDB.Status status = VDB.Status.ACTIVE;
private ConnectionType connectionType = VDB.ConnectionType.BY_VERSION;
- private boolean removed;
private long queryTimeout = Long.MIN_VALUE;
private Set<String> importedModels = Collections.emptySet();
- public String getName() {
- return super.getName();
- }
-
public String getFullName() {
return getName() + VERSION_DELIM + getVersion();
}
- // This needed by JAXB marshaling
- public void setName(String name) {
- super.setName(name);
- }
-
- public boolean isRemoved() {
- return removed;
- }
-
- public void setRemoved(boolean removed) {
- this.removed = removed;
- }
-
@Override
public ConnectionType getConnectionType() {
return this.connectionType;
@@ -124,12 +106,20 @@
return this.status;
}
- public void setStatus(Status s) {
+ public boolean isLoading() {
+ return this.status.isLoading();
+ }
+
+ public synchronized void setStatus(Status s) {
+ this.notifyAll();
+ if (this.status == Status.REMOVED) {
+ return;
+ }
this.status = s;
}
public void setStatus(String s) {
- this.status = Status.valueOf(s);
+ setStatus(Status.valueOf(s));
}
@Override
Modified: trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java
===================================================================
--- trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/admin/src/main/java/org/teiid/adminapi/impl/VDBMetadataMapper.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -211,7 +211,10 @@
ModelNode statusAllowed = new ModelNode();
statusAllowed.add(Status.ACTIVE.toString());
- statusAllowed.add(Status.INACTIVE.toString());
+ statusAllowed.add(Status.LOADING.toString());
+ statusAllowed.add(Status.INVALID.toString());
+ statusAllowed.add(Status.REMOVED.toString());
+ statusAllowed.add(Status.INCOMPLETE.toString());
addAttribute(node, STATUS, ModelType.STRING, true);
node.get(STATUS).get(ALLOWED).set(statusAllowed);
Modified: trunk/admin/src/test/resources/vdb-describe.txt
===================================================================
--- trunk/admin/src/test/resources/vdb-describe.txt 2012-05-30 15:39:59 UTC (rev 4151)
+++ trunk/admin/src/test/resources/vdb-describe.txt 2012-05-31 19:00:50 UTC (rev 4152)
@@ -26,7 +26,10 @@
"required" : true,
"allowed" : [
"ACTIVE",
- "INACTIVE"
+ "LOADING",
+ "INVALID",
+ "REMOVED",
+ "INCOMPLETE"
]
},
"vdb-version" : {
Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2012-05-30 15:39:59
UTC (rev 4151)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2012-05-31 19:00:50
UTC (rev 4152)
@@ -22,6 +22,7 @@
package org.teiid.metadata;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
@@ -42,7 +43,7 @@
* TODO: add support for datatype import
* TODO: add support for unique constraints
*/
-public class MetadataFactory {
+public class MetadataFactory implements Serializable {
private static final long serialVersionUID = 8590341087771685630L;
private String vdbName;
Modified: trunk/common-core/src/main/java/org/teiid/core/TeiidException.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/TeiidException.java 2012-05-30 15:39:59
UTC (rev 4151)
+++ trunk/common-core/src/main/java/org/teiid/core/TeiidException.java 2012-05-31 19:00:50
UTC (rev 4152)
@@ -23,7 +23,6 @@
package org.teiid.core;
import java.sql.SQLException;
-import java.util.Iterator;
import org.teiid.core.util.ExceptionUtil;
@@ -54,14 +53,29 @@
public TeiidException(BundleUtil.Event code, Throwable t, final String message) {
super(message, t);
- setCode(code.toString());
+ if (message != null && message.equals(t.getMessage())) {
+ setCode(code, t);
+ } else {
+ setCode(code.toString());
+ }
}
public TeiidException(BundleUtil.Event code, Throwable t) {
super(t);
- setCode(code.toString());
- }
+ setCode(code, t);
+ }
+ private void setCode(BundleUtil.Event code, Throwable t) {
+ String codeStr = code.toString();
+ if (t instanceof TeiidException) {
+ TeiidException te = (TeiidException)t;
+ if (te.getCode() != null) {
+ codeStr = te.getCode();
+ }
+ }
+ setCode(codeStr);
+ }
+
public TeiidException(Throwable e) {
this(e, e != null? e.getMessage() : null);
}
@@ -107,62 +121,15 @@
}
/**
- * Returns the error message, formatted for output. <P>
- *
- * The default formatting provided by this method is to prepend the
- * error message with the level and the name of the class, and to
- * append the error code on the end if a non-zero code is defined. <P>
- *
- * This method provides a hook for subclasses to override the default
- * formatting of any one exception.
- *
- * @param throwable The exception to print
- * @param level The depth of the exception in the chain of exceptions
- * @return A formatted string for the exception
- */
- static String getFormattedMessage(final Throwable throwable, final int level) {
- String code;
- if (throwable instanceof TeiidException) {
- code = ((TeiidException) throwable).getCode();
- } else if (throwable instanceof TeiidRuntimeException) {
- code = ((TeiidRuntimeException) throwable).getCode();
- } else {
- code = null;
- }
- return ((level != 0) ? ("\n" + level + " ") : "")
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- + "[" + throwable.getClass().getSimpleName() + "]"
//$NON-NLS-1$ //$NON-NLS-2$
- + ((code != null) ? (' ' + code + ": ") : "")
//$NON-NLS-1$ //$NON-NLS-2$
- + (throwable.getMessage() == null ? "" :
throwable.getMessage()); //$NON-NLS-1$
- }
-
- /**
* Get the full error message, including any message(s) from child
- * exceptions. Messages of any exceptions chained to this exception are
- * prepended with their "level" in the chain.
+ * exceptions.
*
* @return The full error message
*
* @see #getFormattedMessage
*/
public String getFullMessage() {
- int level = 0;
- StringBuffer buf = new StringBuffer();
- buf.append(getFormattedMessage(this,level));
- Iterator children = ExceptionUtil.getChildrenIterator(this);
- while ( children.hasNext() ){
- level++;
- Throwable exception = (Throwable)children.next();
- buf.append(getFormattedMessage(exception,level));
- }
- return buf.toString();
+ return ExceptionUtil.getLinkedMessagesVerbose(this);
}
- /**
- * Returns a string representation of this class.
- *
- * @return String representation of instance
- */
- public String toString() {
- return getFullMessage();
- }
}
Modified: trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/common-core/src/main/java/org/teiid/core/TeiidRuntimeException.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -154,8 +154,16 @@
*
* @return String representation of instance
*/
- public String toString() {
- return ExceptionUtil.getLinkedMessages(this);
+ public String getFullMessage() {
+ return ExceptionUtil.getLinkedMessagesVerbose(this);
}
+
+ public String getMessage() {
+ String message = super.getMessage();
+ if (code == null || code.length() == 0 || message.startsWith(code)) {
+ return message;
+ }
+ return code+" "+message; //$NON-NLS-1$
+ }
}
Modified: trunk/common-core/src/main/java/org/teiid/core/util/ExceptionUtil.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/ExceptionUtil.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/common-core/src/main/java/org/teiid/core/util/ExceptionUtil.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -22,16 +22,13 @@
package org.teiid.core.util;
-import java.io.PrintStream;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.NoSuchElementException;
import javax.naming.ConfigurationException;
-import org.teiid.core.TeiidRuntimeException;
-
/**
* Utility class that provides some useful things for users of the
* com.metamatrix.api.exception package. Also provides package-level
@@ -46,49 +43,22 @@
super();
}
- /**
- * Convenience method that takes any Throwable and returns an appropriate
- * Iterator over any nested exceptions in that Throwable. Currently,
- * only instances of MetaMatrixException and MetaMatrixRuntimeException
- * are capable of nesting Throwables - calling this method in that case
- * is equivalent to calling
- * {@link TeiidException#getChildren MetaMatrixException.getChildren()}
- * or
- * {@link TeiidRuntimeException#getChildren
MetaMatrixRuntimeException.getChildren()}.
- * Otherwise, a non-null "empty" Iterator is returned, one that simply has
- * no Objects in it.
- * @param e any Throwable
- * @return an appropriate Iterator over any nested children Throwables;
- */
- public static Iterator getChildrenIterator(Throwable e){
+ static Iterator<Throwable> getChildrenIterator(Throwable e){
return new NestedExceptionIterator(e);
}
- public static void printNestedStackTrace(Throwable exception, PrintStream output) {
- if (exception != null){
- exception.printStackTrace(output);
-
- Iterator children = getChildrenIterator(exception);
- while ( children.hasNext() ){
- exception = (Throwable)children.next();
- output.print(TeiidRuntimeException.CAUSED_BY_STRING);
- exception.printStackTrace(output);
- }
- }
- }
-
public static String getLinkedMessagesVerbose(Throwable exception) {
return getLinkedMessagesVerbose(exception, 0);
}
- public static String getLinkedMessagesVerbose( Throwable exception, int level ) {
+ static String getLinkedMessagesVerbose( Throwable exception, int level ) {
if (exception != null){
StringBuffer buf = new StringBuffer();
String lastMessage = appendMessage("", buf, null, exception);
//$NON-NLS-1$
- Iterator children = getChildrenIterator(exception);
+ Iterator<Throwable> children = getChildrenIterator(exception);
while ( children.hasNext() ){
level++;
- exception = (Throwable)children.next();
+ exception = children.next();
lastMessage = appendMessage("->", buf, lastMessage,
exception); //$NON-NLS-1$
}
return buf.toString();
@@ -96,49 +66,10 @@
return ""; //$NON-NLS-1$
}
- public static String getLinkedMessages(Throwable exception) {
- return getLinkedMessages(exception, 0);
- }
-
- /**
- * Get the chain of messages, starting with the specified exception. The
- * level number in the chain is prepended. <P>
- *
- * This method calls the <CODE>getMessage</CODE> method for the
exception
- * passed in, and appends on the result returned from a recursive call to
- * this method for the child of the passed in exception. The passed in
- * exception is updated on each recursive call to be the child of the
- * original exception, and the level is incremented on each call.
- *
- * @param exception The exception to print the chained message list of
- * @param level (zero-based) The depth of the exception parameter in
- * the chain of exceptions.
- * @param messageFormatter the formatter of the message; may not be null
- * @return A string of chained messages, each prepended by its level
- * in the chain, and each followed by a newline (blank string if
- * the exception passed in is null)
- *
- * @see Throwable#getMessage()
- */
- public static String getLinkedMessages( Throwable exception, int level ) {
- if (exception != null){
- StringBuffer buf = new StringBuffer();
- buf.append(exception.getMessage());
- Iterator children = getChildrenIterator(exception);
- while ( children.hasNext() ){
- level++;
- exception = (Throwable)children.next();
- buf.append(exception.getMessage());
- }
- return buf.toString();
- }
- return ""; //$NON-NLS-1$
- }
-
private static final String appendMessage(String prefix, StringBuffer buffer, String
lastMessage, Throwable exception) {
String message = exception.getMessage();
buffer.append(prefix);
- buffer.append(getClassName(exception));
+ buffer.append(exception.getClass().getSimpleName());
if (message != null && !message.equals(lastMessage)) {
buffer.append('-');
buffer.append(message);
@@ -146,15 +77,6 @@
return message;
}
- private static final String getClassName(Throwable exception) {
- String className = exception.getClass().getName();
- int index = className.lastIndexOf('.');
- if (index >= 0 && index < className.length()-1) {
- return className.substring(index+1);
- }
- return className;
- }
-
/**
* <p>An Iterator over any nested children <code>Throwable</code>s
* of either a MetaMatrixException or a MetaMatrixRuntimeException.
@@ -168,7 +90,7 @@
* <code>MetaMatrixException</code> or
<code>MetaMatrixRuntimeException</code>
* whose {@link #getChild} method will return the same Object A.</p>
*/
- public static class NestedExceptionIterator implements Iterator{
+ public static class NestedExceptionIterator implements Iterator<Throwable>{
Throwable exception;
Throwable child;
@@ -177,25 +99,12 @@
exception = e;
}
- /**
- * Returns <tt>true</tt> if the iteration has more elements. (In
other
- * words, returns <tt>true</tt> if <tt>next</tt> would
return an element
- * rather than throwing an exception.)
- *
- * @return <tt>true</tt> if the iterator has more elements.
- */
public boolean hasNext(){
check();
return (child != null);
}
- /**
- * Returns the next element in the iteration.
- *
- * @return the next element in the iteration.
- * @exception NoSuchElementException iteration has no more elements.
- */
- public Object next(){
+ public Throwable next(){
if (!hasNext()) {
throw new NoSuchElementException();
}
@@ -222,22 +131,6 @@
}
}
- /**
- *
- * Removes from the underlying collection the last element returned by the
- * iterator (optional operation). This method can be called only once per
- * call to <tt>next</tt>. The behavior of an iterator is unspecified
if
- * the underlying collection is modified while the iteration is in
- * progress in any way other than by calling this method.
- *
- * @exception UnsupportedOperationException if the <tt>remove</tt>
- * operation is not supported by this Iterator.
-
- * @exception IllegalStateException if the <tt>next</tt> method has
not
- * yet been called, or the <tt>remove</tt> method has already
- * been called after the last call to the <tt>next</tt>
- * method.
- */
public void remove(){
throw new UnsupportedOperationException();
}
Modified:
trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java
===================================================================
---
trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/common-core/src/test/java/org/teiid/core/TestMetaMatrixRuntimeException.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -26,8 +26,6 @@
*/
package org.teiid.core;
-import org.teiid.core.TeiidRuntimeException;
-
import junit.framework.TestCase;
@@ -82,7 +80,7 @@
final TeiidRuntimeException err = new TeiidRuntimeException(code,
"Test"); //$NON-NLS-1$
assertNull(err.getCause());
assertEquals(code, err.getCode());
- assertEquals("Test", err.getMessage()); //$NON-NLS-1$
+ assertEquals("1234 Test", err.getMessage()); //$NON-NLS-1$
}
@@ -92,7 +90,7 @@
final TeiidRuntimeException err = new TeiidRuntimeException(child,
"Test"); //$NON-NLS-1$
assertSame(child, err.getCause());
assertEquals(code, err.getCode());
- assertEquals("Test", err.getMessage()); //$NON-NLS-1$
+ assertEquals("1234 Test", err.getMessage()); //$NON-NLS-1$
}
public static enum Event implements BundleUtil.Event {
@@ -104,7 +102,7 @@
final TeiidRuntimeException err = new TeiidRuntimeException(Event.Code,
child,"Test"); //$NON-NLS-1$
assertSame(child, err.getCause());
assertEquals("Code", err.getCode()); //$NON-NLS-1$
- assertEquals("Test", err.getMessage()); //$NON-NLS-1$
+ assertEquals("Code Test", err.getMessage()); //$NON-NLS-1$
}
}
\ No newline at end of file
Modified:
trunk/common-core/src/test/java/org/teiid/core/util/TestMetaMatrixExceptionUtil.java
===================================================================
---
trunk/common-core/src/test/java/org/teiid/core/util/TestMetaMatrixExceptionUtil.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/common-core/src/test/java/org/teiid/core/util/TestMetaMatrixExceptionUtil.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -24,12 +24,11 @@
import javax.naming.ConfigurationException;
+import junit.framework.TestCase;
+
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
-import org.teiid.core.util.ExceptionUtil;
-import junit.framework.TestCase;
-
public class TestMetaMatrixExceptionUtil extends TestCase {
public TestMetaMatrixExceptionUtil(String name) {
@@ -40,14 +39,12 @@
NullPointerException npe = new NullPointerException();
TeiidRuntimeException e = new TeiidRuntimeException(npe);
assertEquals("TeiidRuntimeException->NullPointerException",
ExceptionUtil.getLinkedMessagesVerbose(e)); //$NON-NLS-1$
- assertEquals("nullnull", ExceptionUtil.getLinkedMessages(e)); //$NON-NLS-1$
}
public void testWithMessage() {
NullPointerException npe = new NullPointerException("problem");
//$NON-NLS-1$
TeiidRuntimeException e = new TeiidRuntimeException(npe);
assertEquals("TeiidRuntimeException-problem->NullPointerException",
ExceptionUtil.getLinkedMessagesVerbose(e)); //$NON-NLS-1$
- assertEquals("problemproblem", ExceptionUtil.getLinkedMessages(e));
//$NON-NLS-1$
}
public void testWithAndWithoutMessage() {
@@ -55,7 +52,6 @@
TeiidException ce = new TeiidException(npe, "problem"); //$NON-NLS-1$
TeiidRuntimeException e = new TeiidRuntimeException(ce);
assertEquals("TeiidRuntimeException-problem->TeiidException->NullPointerException",
ExceptionUtil.getLinkedMessagesVerbose(e)); //$NON-NLS-1$
- assertEquals("problemproblemnull", ExceptionUtil.getLinkedMessages(e));
//$NON-NLS-1$
}
public void testConfigurationException() {
@@ -64,6 +60,5 @@
configException.setRootCause(npe);
TeiidException e = new TeiidException(configException, "problem3");
//$NON-NLS-1$
assertEquals("TeiidException-problem3->ConfigurationException-problem2->NullPointerException-problem1",
ExceptionUtil.getLinkedMessagesVerbose(e)); //$NON-NLS-1$
- assertEquals("problem3problem2problem1", ExceptionUtil.getLinkedMessages(e));
//$NON-NLS-1$
}
}
Modified: trunk/common-core/src/test/java/org/teiid/core/util/TestPropertiesUtils.java
===================================================================
---
trunk/common-core/src/test/java/org/teiid/core/util/TestPropertiesUtils.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/common-core/src/test/java/org/teiid/core/util/TestPropertiesUtils.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -23,23 +23,13 @@
package org.teiid.core.util;
import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
+import java.util.*;
-import org.teiid.core.util.PropertiesUtils;
-import org.teiid.core.util.PropertiesUtils.InvalidPropertyException;
-
import junit.framework.TestCase;
+import org.teiid.core.util.PropertiesUtils.InvalidPropertyException;
+
/**
* Tests primarily the various cloning scenarios available with PropertiesUtils
*/
@@ -496,7 +486,7 @@
PropertiesUtils.getIntProperty(p, "x", 1); //$NON-NLS-1$
fail("expected exception"); //$NON-NLS-1$
} catch (InvalidPropertyException e) {
- assertEquals("Property 'x' with value 'y' is not a valid
Integer.", e.getMessage()); //$NON-NLS-1$
+ assertEquals("TEIID10037 Property 'x' with value 'y' is not a
valid Integer.", e.getMessage()); //$NON-NLS-1$
}
}
Modified: trunk/documentation/pom.xml
===================================================================
--- trunk/documentation/pom.xml 2012-05-30 15:39:59 UTC (rev 4151)
+++ trunk/documentation/pom.xml 2012-05-31 19:00:50 UTC (rev 4152)
@@ -11,12 +11,6 @@
<name>Documents</name>
<description>Teiid Documentation Aggregator</description>
<modules>
- <module>admin-guide</module>
- <module>reference</module>
- <module>developer-guide</module>
- <module>quick-start-example</module>
- <module>client-developers-guide</module>
- <module>caching-guide</module>
<module>javadocs</module>
</modules>
</project>
\ No newline at end of file
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -316,8 +316,9 @@
return results;
}
- public ResultsFuture<ResultsMessage> executeRequest(long reqID,RequestMessage
requestMsg) {
+ public ResultsFuture<ResultsMessage> executeRequest(long reqID,RequestMessage
requestMsg) throws TeiidProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ checkLoading(workContext);
RequestID requestID = workContext.getRequestID(reqID);
requestMsg.setFetchSize(Math.min(requestMsg.getFetchSize(),
this.config.getMaxRowsFetchSize()));
Request request = null;
@@ -690,7 +691,12 @@
RequestMessage request = new RequestMessage(command);
request.setParameterValues(parameters);
request.setStatementType(StatementType.PREPARED);
- ResultsFuture<ResultsMessage> result = executeRequest(0, request);
+ ResultsFuture<ResultsMessage> result;
+ try {
+ result = executeRequest(0, request);
+ } catch (TeiidProcessingException e) {
+ throw new TeiidRuntimeException(e);
+ }
result.addCompletionListener(new
ResultsFuture.CompletionListener<ResultsMessage>() {
@Override
@@ -868,9 +874,17 @@
boolean allowDoubleQuotedVariable)
throws TeiidComponentException, TeiidProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
+ checkLoading(workContext);
MetaDataProcessor processor = new MetaDataProcessor(this, this.prepPlanCache,
workContext.getVdbName(), workContext.getVdbVersion());
return processor.processMessage(workContext.getRequestID(requestID), workContext,
preparedSql, allowDoubleQuotedVariable);
}
+
+ private void checkLoading(DQPWorkContext workContext)
+ throws TeiidProcessingException {
+ if (workContext.getVDB().isLoading()) {
+ throw new TeiidProcessingException(QueryPlugin.Event.TEIID31099,
QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31099, workContext.getVDB()));
+ }
+ }
public boolean isExceptionOnMaxSourceRows() {
return this.config.isExceptionOnMaxSourceRows();
Modified: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-05-30 15:39:59 UTC
(rev 4151)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2012-05-31 19:00:50 UTC
(rev 4152)
@@ -559,5 +559,6 @@
TEIID31096,
TEIID31097,
TEIID31098, //alter imported
+ TEIID31099, //vdb loading
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -235,7 +235,7 @@
}
}
- private static Datatype getDataType(Collection<Datatype> dataTypes, Class clazz)
{
+ private static Datatype getDataType(Collection<Datatype> dataTypes, Class<?>
clazz) {
for (Datatype type:dataTypes) {
if (type.getJavaClassName().equals(clazz.getName())) {
return type;
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-05-30 15:39:59
UTC (rev 4151)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2012-05-31 19:00:50
UTC (rev 4152)
@@ -1046,4 +1046,6 @@
TEIID30601=User defined aggregate function "{0}" class "{1}" does not
implement {2}
TEIID30602=User defined aggregate function "{0}" class "{1}" does not
provide a public no-arg constructor.
-TEIID31096=Canceling query {0} since it has exceeded the timeout of {1} milliseconds.
\ No newline at end of file
+TEIID31096=Canceling query {0} since it has exceeded the timeout of {1} milliseconds.
+
+TEIID31099=VDB {0} is still loading. Resubmit your query after loading has completed.
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -42,8 +42,8 @@
import org.teiid.cache.CacheConfiguration;
import org.teiid.cache.DefaultCacheFactory;
import org.teiid.client.RequestMessage;
+import org.teiid.client.ResultsMessage;
import org.teiid.client.RequestMessage.StatementType;
-import org.teiid.client.ResultsMessage;
import org.teiid.client.lob.LobChunk;
import org.teiid.client.util.ResultsFuture;
import org.teiid.common.buffer.BufferManagerFactory;
@@ -458,7 +458,7 @@
}
private void helpTestPlanInvalidation(String query) throws InterruptedException,
- ExecutionException, TimeoutException {
+ ExecutionException, TimeoutException, TeiidProcessingException {
String sql = "insert into #temp select * FROM vqt.SmallB"; //$NON-NLS-1$
String userName = "1"; //$NON-NLS-1$
int sessionid = 1; //$NON-NLS-1$
@@ -627,7 +627,7 @@
}
private ResultsMessage execute(String userName, int sessionid, RequestMessage reqMsg)
- throws InterruptedException, ExecutionException, TimeoutException {
+ throws InterruptedException, ExecutionException, TimeoutException,
TeiidProcessingException {
DQPWorkContext.getWorkContext().getSession().setSessionId(String.valueOf(sessionid));
DQPWorkContext.getWorkContext().getSession().setUserName(userName);
Modified:
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -72,7 +72,7 @@
Object actualValue = helpEval(expr, elementList, valueList, dataMgr,
context);
assertEquals("Did not get expected result", expectedValue,
actualValue); //$NON-NLS-1$
} catch(TeiidException e) {
- fail("Received unexpected exception: " + e.getFullMessage());
//$NON-NLS-1$
+ throw new RuntimeException(e);
}
}
Modified:
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestDeepGroupCollectorVisitor.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestDeepGroupCollectorVisitor.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestDeepGroupCollectorVisitor.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -25,15 +25,14 @@
import java.util.Collection;
import java.util.Iterator;
+import junit.framework.TestCase;
+
import org.teiid.core.TeiidException;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.symbol.GroupSymbol;
-import org.teiid.query.sql.visitor.GroupCollectorVisitor;
-import junit.framework.TestCase;
-
public class TestDeepGroupCollectorVisitor extends TestCase {
public TestDeepGroupCollectorVisitor(String name) {
super(name);
@@ -42,10 +41,9 @@
public void helpTestVisitor(String sql, String[] expectedGroups) {
LanguageObject obj = null;
try {
- QueryParser parser = new QueryParser();
- obj = parser.parseCommand(sql);
+ obj = QueryParser.getQueryParser().parseCommand(sql);
} catch(TeiidException e) {
- fail("Unexpected exception while parsing: " + e.getFullMessage());
//$NON-NLS-1$
+ throw new RuntimeException(e);
}
Collection actualGroups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(obj,
false);
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/DQPCoreService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/DQPCoreService.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/DQPCoreService.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -95,7 +95,7 @@
// add vdb life cycle listeners
getVdbRepository().addListener(new VDBLifeCycleListener() {
- private Set<VDBKey> recentlyRemoved = Collections.newSetFromMap(new
LRUCache<VDBKey, Boolean>(10000));
+ private Set<VDBKey> recentlyRemoved =
Collections.synchronizedSet(Collections.newSetFromMap(new LRUCache<VDBKey,
Boolean>(10000)));
@Override
public void removed(String name, int version, CompositeVDB vdb) {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/TranslatorDeployer.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -46,7 +46,9 @@
*/
public final class TranslatorDeployer implements DeploymentUnitProcessor {
- @Override
+ private static final String DEPLOYMENT_NAME = "deployment-name";
//$NON-NLS-1$
+
+ @Override
public void deploy(final DeploymentPhaseContext phaseContext) throws
DeploymentUnitProcessingException {
final DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
final ServiceTarget target = phaseContext.getServiceTarget();
@@ -66,6 +68,7 @@
if (metadata == null) {
throw new
DeploymentUnitProcessingException(IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50070,
moduleName));
}
+ metadata.addProperty(DEPLOYMENT_NAME, deploymentUnit.getName());
metadata.addAttchment(ClassLoader.class, translatorLoader);
LogManager.logInfo(LogConstants.CTX_RUNTIME,
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50006, metadata.getName()));
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/TransportService.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -102,6 +102,16 @@
public ClientServiceRegistry getValue() throws IllegalStateException,
IllegalArgumentException {
return this;
}
+
+ @Override
+ public void waitForFinished(String vdbName, int vdbVersion) {
+ VDBRepository repo = this.vdbRepositoryInjector.getValue();
+ try {
+ repo.waitForFinished(vdbName, vdbVersion);
+ } catch (InterruptedException e) {
+ return; //just allow the thread to continue/error
+ }
+ }
@Override
public void start(StartContext context) throws StartException {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBDeployer.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -72,6 +72,7 @@
class VDBDeployer implements DeploymentUnitProcessor {
+ private static final String DEPLOYMENT_NAME = "deployment-name";
//$NON-NLS-1$
private static final String JAVA_CONTEXT = "java:/"; //$NON-NLS-1$
private TranslatorRepository translatorRepository;
private String asyncThreadPoolName;
@@ -89,7 +90,7 @@
return;
}
final VDBMetaData deployment =
deploymentUnit.getAttachment(TeiidAttachments.VDB_METADATA);
-
+ deployment.addProperty(DEPLOYMENT_NAME, deploymentUnit.getName());
// check to see if there is old vdb already deployed.
final ServiceController<?> controller =
context.getServiceRegistry().getService(TeiidServiceNames.vdbServiceName(deployment.getName(),
deployment.getVersion()));
if (controller != null) {
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java
===================================================================
---
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBParserDeployer.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -35,6 +35,7 @@
import org.jboss.msc.service.ServiceController;
import org.jboss.vfs.VirtualFile;
import org.teiid.adminapi.Model;
+import org.teiid.adminapi.VDB.Status;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBMetadataParser;
@@ -115,6 +116,7 @@
if (serializer.buildVdbXml(vdb).exists()) {
vdb = VDBMetadataParser.unmarshell(new
FileInputStream(serializer.buildVdbXml(vdb)));
}
+ vdb.setStatus(Status.LOADING);
deploymentUnit.putAttachment(TeiidAttachments.VDB_METADATA, vdb);
LogManager.logDetail(LogConstants.CTX_RUNTIME,"VDB "+file.getName()+"
has been parsed."); //$NON-NLS-1$ //$NON-NLS-2$
return vdb;
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/VDBService.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -33,6 +33,7 @@
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Executor;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.xml.stream.XMLStreamException;
@@ -160,8 +161,6 @@
getVDBRepository().addListener(this.vdbListener);
- boolean preview = this.vdb.isPreview();
-
MetadataStore store = new MetadataStore();
try {
@@ -174,6 +173,7 @@
this.vdb.removeAttachment(UDFMetaData.class);
// load metadata from the models
+ AtomicInteger loadCount = new
AtomicInteger(this.vdb.getModelMetaDatas().values().size());
for (ModelMetaData model: this.vdb.getModelMetaDatas().values()) {
MetadataRepository metadataRepository =
model.getAttachment(MetadataRepository.class);
if (metadataRepository == null) {
@@ -181,19 +181,13 @@
}
model.addAttchment(MetadataRepository.class, metadataRepository);
if (model.getModelType() == Model.Type.PHYSICAL || model.getModelType() ==
Model.Type.VIRTUAL) {
- loadMetadata(this.vdb, model, cmr, metadataRepository, store);
+ loadMetadata(this.vdb, model, cmr, metadataRepository, store, loadCount);
LogManager.logTrace(LogConstants.CTX_RUNTIME, "Model ", model.getName(),
"in VDB ", vdb.getName(), " was being loaded from its repository in
separate thread"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
else {
LogManager.logTrace(LogConstants.CTX_RUNTIME, "Model ", model.getName(),
"in VDB ", vdb.getName(), " skipped being loaded because of its type
", model.getModelType()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
-
- synchronized (this.vdb) {
- if (preview) {
- vdb.setStatus(VDB.Status.ACTIVE);
- }
- }
}
private ServiceBuilder<Void> addVDBFinishedService(StartContext context) {
@@ -230,8 +224,10 @@
this.objectReplicatorInjector.getValue().stop(gts);
}
getVDBRepository().removeListener(this.vdbListener);
- getVDBRepository().removeVDB(this.vdb.getName(), this.vdb.getVersion());
- this.vdb.setRemoved(true);
+ VDBMetaData runtimeMetadata = getVDBRepository().removeVDB(this.vdb.getName(),
this.vdb.getVersion());
+ if (runtimeMetadata != null) {
+ runtimeMetadata.setStatus(VDB.Status.REMOVED);
+ }
final ServiceController<?> controller =
context.getController().getServiceContainer().getService(TeiidServiceNames.vdbFinishedServiceName(vdb.getName(),
vdb.getVersion()));
if (controller != null) {
controller.setMode(ServiceController.Mode.REMOVE);
@@ -320,7 +316,7 @@
}
- private boolean loadMetadata(final VDBMetaData vdb, final ModelMetaData model, final
ConnectorManagerRepository cmr, final MetadataRepository metadataRepo, final MetadataStore
vdbMetadataStore) {
+ private boolean loadMetadata(final VDBMetaData vdb, final ModelMetaData model, final
ConnectorManagerRepository cmr, final MetadataRepository metadataRepo, final MetadataStore
vdbMetadataStore, final AtomicInteger loadCount) {
String msg =
IntegrationPlugin.Util.gs(IntegrationPlugin.Event.TEIID50029,vdb.getName(),
vdb.getVersion(), model.getName(), SimpleDateFormat.getInstance().format(new Date()));
model.addError(ModelMetaData.ValidationError.Severity.ERROR.toString(), msg);
@@ -385,7 +381,7 @@
model.clearErrors();
- if (vdb.isValid()) {
+ if (loadCount.decrementAndGet() == 0) {
getVDBRepository().finishDeployment(vdb.getName(), vdb.getVersion());
}
}
@@ -428,7 +424,7 @@
// if is not dynamic always cache; else check for the flag (this may need to be
revisited with index vdb)
private void cacheMetadataStore(final VDBMetaData vdb, MetadataFactory schema) {
boolean cache = !vdb.isDynamic();
- if (!vdb.isDynamic()) {
+ if (vdb.isDynamic()) {
cache =
"cached".equalsIgnoreCase(vdb.getPropertyValue("UseConnectorMetadata"));
//$NON-NLS-1$ //$NON-NLS-2$
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2012-05-30 15:39:59 UTC (rev 4151)
+++ trunk/pom.xml 2012-05-31 19:00:50 UTC (rev 4152)
@@ -123,6 +123,10 @@
This is to enable faster build for development time.
-->
<id>dev</id>
+ <properties>
+ <maven.javadoc.skip>true</maven.javadoc.skip>
+ <skipTests>true</skipTests>
+ </properties>
<modules>
<module>build</module>
</modules>
Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-05-30 15:39:59
UTC (rev 4151)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2012-05-31 19:00:50
UTC (rev 4152)
@@ -144,7 +144,11 @@
}
newMergedVDB.getImportedModels().add(m.getName());
}
- mergedRepo.getConnectorManagers().putAll(importedVDB.cmr.getConnectorManagers());
+ for (Map.Entry<String, ConnectorManager> entry :
importedVDB.cmr.getConnectorManagers().entrySet()) {
+ if (mergedRepo.getConnectorManagers().put(entry.getKey(), entry.getValue()) != null)
{
+ throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40086,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40086, vdb.getName(), vdb.getVersion(),
vdbImport.getName(), vdbImport.getVersion(), entry.getKey()));
+ }
+ }
}
this.mergedVDB = newMergedVDB;
}
@@ -180,6 +184,9 @@
return mergedUDF;
}
+ /**
+ * TODO: we are not checking for collisions here.
+ */
private LinkedHashMap<String, Resource> getVisibilityMap() {
if (this.children == null || this.children.isEmpty()) {
return this.visibilityMap;
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-05-30 15:39:59
UTC (rev 4151)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2012-05-31 19:00:50
UTC (rev 4152)
@@ -24,6 +24,7 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
@@ -31,6 +32,8 @@
import java.util.NavigableMap;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.concurrent.locks.Condition;
+import java.util.concurrent.locks.ReentrantLock;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.ModelMetaData;
@@ -57,6 +60,9 @@
* Repository for VDBs
*/
public class VDBRepository implements Serializable{
+ private static final int DEPLOY_TIMEOUT = 60000;
+ private static final int LOAD_TIMEOUT = 600000;
+
private static final long serialVersionUID = 312177538191772674L;
private NavigableMap<VDBKey, CompositeVDB> vdbRepo = new
ConcurrentSkipListMap<VDBKey, CompositeVDB>();
@@ -66,12 +72,11 @@
private List<VDBLifeCycleListener> listeners = new
CopyOnWriteArrayList<VDBLifeCycleListener>();
private SystemFunctionManager systemFunctionManager;
private Map<String, Datatype> datatypeMap = new HashMap<String,
Datatype>();
+ private ReentrantLock lock = new ReentrantLock();
+ private Condition vdbAdded = lock.newCondition();
-
public void addVDB(VDBMetaData vdb, MetadataStore metadataStore,
LinkedHashMap<String, Resource> visibilityMap, UDFMetaData udf,
ConnectorManagerRepository cmr) throws VirtualDatabaseException {
- if (getVDB(vdb.getName(), vdb.getVersion()) != null) {
- throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40035,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40035, vdb.getName(), vdb.getVersion()));
- }
+ VDBKey key = vdbId(vdb);
// get the system VDB metadata store
if (this.systemStore == null) {
@@ -90,9 +95,41 @@
}
CompositeVDB cvdb = new CompositeVDB(vdb, metadataStore, visibilityMap, udf,
this.systemFunctionManager.getSystemFunctions(), cmr, stores);
cvdb.buildCompositeState(this);
- this.vdbRepo.put(vdbId(vdb), cvdb);
+ lock.lock();
+ try {
+ if (vdbRepo.containsKey(key)) {
+ throw new VirtualDatabaseException(RuntimePlugin.Event.TEIID40035,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40035, vdb.getName(), vdb.getVersion()));
+ }
+ this.vdbRepo.put(key, cvdb);
+ vdbAdded.signalAll();
+ } finally {
+ lock.unlock();
+ }
notifyAdd(vdb.getName(), vdb.getVersion(), cvdb);
}
+
+ public void waitForFinished(String vdbName, int vdbVersion) throws InterruptedException
{
+ CompositeVDB cvdb = null;
+ VDBKey key = new VDBKey(vdbName, vdbVersion);
+ Date toWait = new Date(System.currentTimeMillis() + DEPLOY_TIMEOUT);
+ lock.lock();
+ try {
+ while (cvdb == null) {
+ cvdb = this.vdbRepo.get(key);
+ if (cvdb == null && !vdbAdded.awaitUntil(toWait)) {
+ return; //TODO: should there be a message/exception
+ }
+ }
+ } finally {
+ lock.unlock();
+ }
+ VDBMetaData vdb = cvdb.getVDB();
+ synchronized (vdb) {
+ while (vdb.isLoading()) {
+ vdb.wait(LOAD_TIMEOUT);
+ }
+ }
+ }
CompositeVDB getCompositeVDB(String name, int version) {
return this.vdbRepo.get(new VDBKey(name, version));
@@ -211,14 +248,14 @@
this.odbcEnabled = true;
}
- public boolean removeVDB(String vdbName, int vdbVersion) {
+ public VDBMetaData removeVDB(String vdbName, int vdbVersion) {
VDBKey key = new VDBKey(vdbName, vdbVersion);
CompositeVDB removed = this.vdbRepo.remove(key);
if (removed == null) {
- return false;
+ return null;
}
notifyRemove(key.getName(), key.getVersion(), removed);
- return true;
+ return removed.getVDB();
}
public Map<String, Datatype> getBuiltinDatatypes() {
@@ -259,7 +296,7 @@
metdataAwareVDB.setStatus(VDB.Status.ACTIVE);
}
else {
- metdataAwareVDB.setStatus(VDB.Status.INACTIVE);
+ metdataAwareVDB.setStatus(VDB.Status.INVALID);
}
LogManager.logInfo(LogConstants.CTX_RUNTIME, (VDB.Status.ACTIVE ==
metdataAwareVDB.getStatus())?RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,name,
version):RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40006,name, version));
notifyFinished(name, version, v);
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStatusChecker.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -27,6 +27,7 @@
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.VDB.Status;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
@@ -83,7 +84,7 @@
boolean dsReplaced = false;
if (!cm.getConnectionName().equals(dsName)){
- vdb.setStatus(VDB.Status.INACTIVE);
+ markInvalid(vdb);
String msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40076, vdb.getName(),
vdb.getVersion(), model.getSourceTranslatorName(sourceName), dsName);
model.addError(ModelMetaData.ValidationError.Severity.ERROR.name(), msg);
cm = new ConnectorManager(translatorName, dsName);
@@ -117,10 +118,18 @@
}
}
}
+
+ private void markInvalid(VDBMetaData vdb) {
+ if (vdb.getStatus() == Status.LOADING) {
+ vdb.setStatus(Status.INCOMPLETE);
+ } else if (vdb.getStatus() == Status.ACTIVE){
+ vdb.setStatus(Status.INVALID);
+ }
+ }
public void resourceAdded(String resourceName, boolean translator) {
for (VDBMetaData vdb:getVDBRepository().getVDBs()) {
- if (vdb.getStatus() == VDB.Status.ACTIVE || vdb.isPreview()) {
+ if (vdb.getStatus() == VDB.Status.ACTIVE) {
continue;
}
LinkedList<Runnable> runnables = new LinkedList<Runnable>();
@@ -167,7 +176,11 @@
getExecutor().execute(runnable);
}
} else if (valid) {
- vdb.setStatus(VDB.Status.ACTIVE);
+ if (vdb.getStatus() == Status.INVALID) {
+ vdb.setStatus(VDB.Status.ACTIVE);
+ } else {
+ vdb.setStatus(VDB.Status.LOADING);
+ }
LogManager.logInfo(LogConstants.CTX_RUNTIME,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40003,vdb.getName(), vdb.getVersion()));
}
}
@@ -176,16 +189,13 @@
public void resourceRemoved(String resourceName, boolean translator) {
for (VDBMetaData vdb:getVDBRepository().getVDBs()) {
- if (vdb.isPreview()) {
- continue;
- }
synchronized (vdb) {
for (Model m:vdb.getModels()) {
ModelMetaData model = (ModelMetaData)m;
String sourceName = getSourceName(resourceName, model, translator);
if (sourceName != null) {
- vdb.setStatus(VDB.Status.INACTIVE);
+ markInvalid(vdb);
String msg = null;
if (translator) {
msg = RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40005, vdb.getName(),
vdb.getVersion(), model.getSourceTranslatorName(sourceName));
Modified: trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-05-30 15:39:59
UTC (rev 4151)
+++ trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2012-05-31 19:00:50
UTC (rev 4152)
@@ -48,7 +48,6 @@
TEIID40016, // pg ssl error
TEIID40017, // unexpected exp for session
TEIID40018,
- TEIID40019,
TEIID40020,
TEIID40021,
TEIID40022,
@@ -78,8 +77,6 @@
TEIID40046,
TEIID40047,
TEIID40048,
- TEIID40049,
- TEIID40050,
TEIID40051,
TEIID40052,
TEIID40053,
@@ -115,5 +112,6 @@
TEIID40083, //vdb import does not exist
TEIID40084, //imported role conflict
TEIID40085, //imported model conflict
+ TEIID40086, //imported connector manager conflict
}
}
Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -44,7 +44,6 @@
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
-import org.teiid.adminapi.VDB;
import org.teiid.adminapi.VDB.ConnectionType;
import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
@@ -118,13 +117,7 @@
@Override
public void closeSession(String sessionID) throws InvalidSessionException {
LogManager.logDetail(LogConstants.CTX_SECURITY, new Object[] {"closeSession",
sessionID}); //$NON-NLS-1$
- if (sessionID == null) {
- throw new InvalidSessionException(RuntimePlugin.Event.TEIID40041,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40041, sessionID));
- }
- SessionMetadata info = this.sessionCache.remove(sessionID);
- if (info == null) {
- throw new InvalidSessionException(RuntimePlugin.Event.TEIID40042,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40042, sessionID));
- }
+ SessionMetadata info = getSessionInfo(sessionID, true);
if (info.getVDBName() != null) {
try {
dqp.terminateSession(info.getSessionId());
@@ -226,21 +219,15 @@
} catch (NumberFormatException e) {
throw new SessionServiceException(RuntimePlugin.Event.TEIID40045, e,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40045, vdbVersion));
}
-
if (vdb == null) {
throw new SessionServiceException(RuntimePlugin.Event.TEIID40046,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40046, vdbName, vdbVersion));
}
-
- if (vdb.getStatus() != VDB.Status.ACTIVE) {
- throw new SessionServiceException(RuntimePlugin.Event.TEIID40047,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40047, vdbName, vdbVersion));
- }
if (vdb.getConnectionType() == ConnectionType.NONE) {
throw new SessionServiceException(RuntimePlugin.Event.TEIID40048,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40048, vdbName, vdbVersion));
}
return vdb;
}
-
@Override
public LoginContext createLoginContext(final String securityDomain, final String user,
final String password) throws LoginException{
CallbackHandler handler = new CallbackHandler() {
@@ -297,7 +284,7 @@
@Override
public void pingServer(String sessionID) throws InvalidSessionException {
- SessionMetadata info = getSessionInfo(sessionID);
+ SessionMetadata info = getSessionInfo(sessionID, false);
info.setLastPingTime(System.currentTimeMillis());
this.sessionCache.put(sessionID, info);
LogManager.logDetail(LogConstants.CTX_SECURITY, "Keep-alive ping received for
session:", sessionID); //$NON-NLS-1$
@@ -311,25 +298,25 @@
closeSession(terminatedSessionID);
return true;
} catch (InvalidSessionException e) {
- LogManager.logWarning(LogConstants.CTX_SECURITY,e,RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40019,
new Object[] {e.getMessage()}));
+ LogManager.logWarning(LogConstants.CTX_SECURITY,e,e.getMessage());
return false;
}
}
@Override
public SessionMetadata validateSession(String sessionID) throws InvalidSessionException,
SessionServiceException {
- SessionMetadata info = getSessionInfo(sessionID);
+ SessionMetadata info = getSessionInfo(sessionID, false);
return info;
}
- private SessionMetadata getSessionInfo(String sessionID)
+ private SessionMetadata getSessionInfo(String sessionID, boolean remove)
throws InvalidSessionException {
if (sessionID == null) {
- throw new InvalidSessionException(RuntimePlugin.Event.TEIID40049,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40049, sessionID));
+ throw new InvalidSessionException(RuntimePlugin.Event.TEIID40041,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40041));
}
- SessionMetadata info = this.sessionCache.get(sessionID);
+ SessionMetadata info =
remove?this.sessionCache.remove(sessionID):this.sessionCache.get(sessionID);
if (info == null) {
- throw new InvalidSessionException(RuntimePlugin.Event.TEIID40050,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40050, sessionID));
+ throw new InvalidSessionException(RuntimePlugin.Event.TEIID40042,
RuntimePlugin.Util.gs(RuntimePlugin.Event.TEIID40042, sessionID));
}
return info;
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -39,4 +39,6 @@
AuthenticationType getAuthenticationType();
+ void waitForFinished(String vdbName, int vdbVersion);
+
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
===================================================================
---
trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -103,5 +103,10 @@
public AuthenticationType getAuthenticationType() {
return authenticationType;
}
+
+ @Override
+ public void waitForFinished(String vdbName, int vdbVersion) {
+ }
+
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -61,6 +61,18 @@
public LocalServerConnection(Properties connectionProperties, boolean useCallingThread)
throws CommunicationException, ConnectionException{
this.connectionProperties = connectionProperties;
this.csr = getClientServiceRegistry();
+
+ String vdbVersion = connectionProperties.getProperty(TeiidURL.JDBC.VDB_VERSION);
+ String vdbName = connectionProperties.getProperty(TeiidURL.JDBC.VDB_NAME);
+ int firstIndex = vdbName.indexOf('.');
+ int lastIndex = vdbName.lastIndexOf('.');
+ if (firstIndex != -1 && firstIndex == lastIndex) {
+ vdbVersion = vdbName.substring(firstIndex+1);
+ vdbName = vdbName.substring(0, firstIndex);
+ }
+ if (vdbVersion != null) {
+ this.csr.waitForFinished(connectionProperties.getProperty(TeiidURL.JDBC.VDB_NAME),
Integer.valueOf(vdbVersion));
+ }
workContext.setSecurityHelper(csr.getSecurityHelper());
workContext.setUseCallingThread(useCallingThread);
authenticate();
Modified: trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties
===================================================================
--- trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-05-30 15:39:59
UTC (rev 4151)
+++ trunk/runtime/src/main/resources/org/teiid/runtime/i18n.properties 2012-05-31 19:00:50
UTC (rev 4152)
@@ -28,7 +28,6 @@
TEIID40045=Invalid VDB version \"{0}\" - must be a positive integer.
# session service
-TEIID40019=The specified session ID "{0}" is invalid. It cannot be found in the
userbase.
TEIID40043=The server has reached the maximum number of sessions of {0} as defined by the
property "session-max-limit". If more sessions are required, modify this
property value in the "standalone-teiid.xml" file.
TEIID40008 = Expiring session {0}
TEIID40007 = Keepalive failed for session {0}
@@ -84,8 +83,6 @@
TEIID40014=Kerberos context login failed
TEIID40018=Exception terminitating session
TEIID40020=Error occurred
-TEIID40049=Invalid Session. Session may have been terminated. Re-connect and try again.
-TEIID40050=Invalid Session. Session may have been terminated. Re-connect and try again.
TEIID40034=The description field = {0} does not end with \"}\""
TEIID40023=System.vdb needs to be loaded before any other VDBs.
TEIID40022=System.vdb needs to be loaded before any other VDBs.
@@ -93,11 +90,12 @@
TEIID40030=TranslatorProperty annotation should be placed on valid getter or setter
method, {0} is not valid.
TEIID40031=TranslatorProperty annotation should not both be advanced and required
TEIID40032=Translator {2} not found in repository for VDB {0}.{1}
-TEIID40041=Invalid Session. Session may have been terminated. Re-connect and try again.
-TEIID40042=Invalid Session. Session may have been terminated. Re-connect and try again.
+TEIID40041=Invalid null Session
+TEIID40042=Invalid Session {0}. Session may have already been terminated.
TEIID40072=Model {0} is defined as VIRTUAL model, however it is defined with source
mappings! check your vdb.xml file.
TEIID40073=The metadata for the VDB {0}.{1} is loaded, however it is not valid. Check
models for errors. Correct the metadata and re-deploy.
TEIID40083={0}.{1} imports a non-existent VDB {2}.{3}
TEIID40084={0}.{1} imports a conflicting role {4} from {2}.{3}
-TEIID40085={0}.{1} imports a conflicting model {4} from {2}.{3}
\ No newline at end of file
+TEIID40085={0}.{1} imports a conflicting model {4} from {2}.{3}
+TEIID40086={0}.{1} imports a duplicate source {4} from {2}.{3}
\ No newline at end of file
Added: trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
(rev 0)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -0,0 +1,81 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.arquillian;
+
+import java.util.Properties;
+
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.VDB;
+
+@SuppressWarnings("nls")
+public class AdminUtil {
+
+ static void cleanUp(Admin admin) throws AdminException {
+ //TODO: cleanup when as supports it
+ /*for (String name : admin.getDataSourceNames()) {
+ admin.deleteDataSource(name);
+ }*/
+ for (VDB vdb : admin.getVDBs()) {
+ String deploymentName = vdb.getPropertyValue("deployment-name");
+ if (deploymentName != null) {
+ admin.undeploy(deploymentName);
+ }
+ }
+ }
+
+ //TODO: this should not be needed, but cli doesn't currently support delete
+ static boolean createDataSource(Admin admin, String deploymentName, String templateName,
Properties properties) throws AdminException {
+ if (admin.getDataSourceNames().contains(deploymentName)) {
+ return false;
+ }
+ admin.createDataSource(deploymentName, templateName, properties);
+ return true;
+ }
+
+ static boolean waitForVDBLoad(Admin admin, String vdbName, int vdbVersion,
+ int timeoutInSecs) throws AdminException {
+ long waitUntil = System.currentTimeMillis() + timeoutInSecs*1000;
+ if (timeoutInSecs < 0) {
+ waitUntil = Long.MAX_VALUE;
+ }
+ boolean first = true;
+ do {
+ if (!first) {
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ break;
+ }
+ } else {
+ first = false;
+ }
+ VDB vdb = admin.getVDB(vdbName, vdbVersion);
+ if (vdb != null && !vdb.getStatus().isLoading()) {
+ return true;
+ }
+ } while (System.currentTimeMillis() < waitUntil);
+ return false;
+ }
+
+}
Property changes on:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/AdminUtil.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -1,12 +1,28 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
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 static org.junit.Assert.*;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -28,16 +44,7 @@
import org.junit.Before;
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.*;
import org.teiid.adminapi.VDB.ConnectionType;
import org.teiid.adminapi.VDB.Status;
import org.teiid.adminapi.impl.VDBTranslatorMetaData;
@@ -56,57 +63,54 @@
}
@After
- public void teardown() {
+ public void teardown() throws AdminException {
+ AdminUtil.cleanUp(admin);
admin.close();
}
@Test
public void testVDBDeployment() throws Exception {
- try {
- Collection<?> vdbs = admin.getVDBs();
- assertTrue(vdbs.isEmpty());
-
- Collection<String> dsNames = admin.getDataSourceNames();
- if (dsNames.contains("Oracle11_PushDS")) {
- admin.deleteDataSource("Oracle11_PushDS");
- }
-
- admin.deploy("bqt.vdb",new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
+ Collection<?> vdbs = admin.getVDBs();
+ assertTrue(vdbs.isEmpty());
+
+ Collection<String> dsNames = admin.getDataSourceNames();
+ if (dsNames.contains("Oracle11_PushDS")) {
+ admin.deleteDataSource("Oracle11_PushDS");
+ }
+
+ admin.deploy("bqt.vdb",new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
- vdbs = admin.getVDBs();
- assertFalse(vdbs.isEmpty());
+ vdbs = admin.getVDBs();
+ assertFalse(vdbs.isEmpty());
- VDB vdb = admin.getVDB("bqt", 1);
- assertFalse(vdb.isValid());
- assertTrue(vdb.getStatus().equals(Status.INACTIVE));
+ VDB vdb = admin.getVDB("bqt", 1);
+ assertFalse(vdb.isValid());
+ assertTrue(AdminUtil.waitForVDBLoad(admin, "bqt", 1, 3));
+ assertEquals(Status.INVALID, vdb.getStatus());
- Properties props = new Properties();
- props.setProperty("connection-url","jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
- props.setProperty("user-name", "sa");
- props.setProperty("password", "sa");
-
- admin.createDataSource("Oracle11_PushDS", "h2", props);
- Thread.sleep(2000);
- vdb = admin.getVDB("bqt", 1);
- assertTrue(vdb.isValid());
- assertTrue(vdb.getStatus().equals(Status.ACTIVE));
-
- dsNames = admin.getDataSourceNames();
- assertTrue(dsNames.contains("Oracle11_PushDS"));
+ Properties props = new Properties();
+ props.setProperty("connection-url","jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
+ props.setProperty("user-name", "sa");
+ props.setProperty("password", "sa");
+
+ admin.createDataSource("Oracle11_PushDS", "h2", props);
+
+ vdb = admin.getVDB("bqt", 1);
+ assertTrue(vdb.isValid());
+ assertTrue(vdb.getStatus().equals(Status.ACTIVE));
+
+ dsNames = admin.getDataSourceNames();
+ assertTrue(dsNames.contains("Oracle11_PushDS"));
- admin.deleteDataSource("Oracle11_PushDS");
- vdb = admin.getVDB("bqt", 1);
- assertFalse(vdb.isValid());
- assertTrue(vdb.getStatus().equals(Status.INACTIVE));
- } finally {
- undeploy();
- }
+ admin.deleteDataSource("Oracle11_PushDS");
+ vdb = admin.getVDB("bqt", 1);
+ assertFalse(vdb.isValid());
+ assertEquals(Status.INVALID, vdb.getStatus());
}
@Test
public void testTraslators() throws Exception {
Collection<? extends Translator> translators = admin.getTranslators();
- System.out.println(translators);
assertEquals(30, translators.size());
JavaArchive jar = getLoopyArchive();
@@ -138,61 +142,52 @@
@Test
public void testVDBConnectionType() throws Exception {
+ admin.deploy("bqt.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
+
+ 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());
+
try {
-
- admin.deploy("bqt.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
-
- 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());
-
- 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");
- }
-
- admin.changeVDBConnectionType("bqt", 1, ConnectionType.NONE);
+ 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");
+ }
+
+ 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
- }
+ 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");
-
- 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 {
- undeploy();
- if(admin.getVDB("bqt", 2) != null){
- admin.undeploy("bqt2.vdb");
- }
+ admin.deploy("bqt2.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
+ admin.assignToModel("bqt", 2, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
+
+ 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());
}
@Test
@@ -204,46 +199,33 @@
@Test
public void testSessions() throws Exception {
- try {
- deployVdb();
+ 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();
+ Collection<? extends Session> sessions = admin.getSessions();
+ assertEquals (0, sessions.size());
+
+ 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();
+
+ conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user;ApplicationName=test",
null);
+ sessions = admin.getSessions();
+ assertEquals (1, sessions.size());
+ 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 {
- undeploy();
- }
+ admin.terminateSession(s.getSessionId());
+ sessions = admin.getSessions();
+ assertEquals (0, sessions.size());
+ conn.close();
}
private boolean deployVdb() throws AdminException, FileNotFoundException {
@@ -257,13 +239,6 @@
return vdbOneDeployed;
}
- private void undeploy() throws Exception {
- VDB vdb = admin.getVDB("bqt", 1);
- if (vdb != null) {
- admin.undeploy("bqt.vdb");
- }
- }
-
@Test
public void testGetRequests() throws Exception {
JavaArchive jar = getLoopyArchive();
@@ -314,118 +289,97 @@
} finally {
admin.undeploy("loopy.jar");
- undeploy();
}
}
@Test
public void getDatasourceTemplateNames() throws Exception {
String[] array = {"teiid-connector-file.rar", "teiid-local",
"teiid", "teiid-connector-salesforce.rar",
"teiid-connector-ldap.rar", "teiid-connector-ws.rar",
"h2"};
- try {
- deployVdb();
- Set<String> templates = admin.getDataSourceTemplateNames();
- System.out.println(templates);
- assertArrayEquals(array, templates.toArray(new String[templates.size()]));
- } finally {
- undeploy();
- }
+ deployVdb();
+ Set<String> templates = admin.getDataSourceTemplateNames();
+ assertArrayEquals(array, templates.toArray(new String[templates.size()]));
}
@Test
public void getTemplatePropertyDefinitions() throws Exception{
- try {
- HashSet<String> props = new HashSet<String>();
-
- 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 {
- undeploy();
- }
+ HashSet<String> props = new HashSet<String>();
+
+ 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"));
}
@Test
public void getWorkerPoolStats() throws Exception{
- try {
- deployVdb();
- assertNotNull(admin.getWorkerPoolStats());
- } finally {
- undeploy();
- }
+ deployVdb();
+ assertNotNull(admin.getWorkerPoolStats());
}
@Test
public void testDataRoleMapping() throws Exception{
- try {
- admin.deploy("bqt2.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
-
- 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 (admin.getVDB("bqt", 2) != null) {
- admin.undeploy("bqt2.vdb");
- }
- }
+ admin.deploy("bqt2.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
+
+ 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());
}
@Test
Modified:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDynamicViewDefinition.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDynamicViewDefinition.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDynamicViewDefinition.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -1,5 +1,29 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
package org.teiid.arquillian;
+import static org.junit.Assert.*;
+
import java.io.FileInputStream;
import java.util.Properties;
@@ -9,6 +33,7 @@
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.core.util.UnitTestUtil;
import org.teiid.jdbc.AbstractMMQueryTestCase;
@@ -26,10 +51,11 @@
}
@After
- public void teardown() {
+ public void teardown() throws AdminException {
+ AdminUtil.cleanUp(admin);
admin.close();
}
-
+
@Test
public void testViewDefinition() throws Exception {
@@ -40,18 +66,13 @@
props.setProperty("AllowParentPaths", "true");
props.setProperty("class-name",
"org.teiid.resource.adapter.file.FileManagedConnectionFactory");
- admin.createDataSource("marketdata-file",
"teiid-connector-file.rar", props);
-
- Thread.sleep(3000);
+ AdminUtil.createDataSource(admin, "marketdata-file",
"teiid-connector-file.rar", props);
+ assertTrue(AdminUtil.waitForVDBLoad(admin, "dynamic", 1, 3));
+
this.internalConnection =
TeiidDriver.getInstance().connect("jdbc:teiid:dynamic@mm://localhost:31000;user=user;password=user",
null);
execute("SELECT * FROM Sys.Columns WHERE tablename='stock'");
//$NON-NLS-1$
- //TestMMDatabaseMetaData.compareResultSet("TestDymamicImportedMetaData/columns",
this.internalResultSet);
-
- admin.undeploy("dynamicview-vdb.xml");
-
- admin.deleteDataSource("marketdata-file");
}
}
Added:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestVDBReuse.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestVDBReuse.java
(rev 0)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestVDBReuse.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -0,0 +1,89 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.arquillian;
+
+import static org.junit.Assert.*;
+
+import java.io.FileInputStream;
+import java.util.Properties;
+
+import org.jboss.arquillian.junit.Arquillian;
+import org.junit.After;
+import org.junit.Before;
+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.core.util.UnitTestUtil;
+import org.teiid.jdbc.AbstractMMQueryTestCase;
+import org.teiid.jdbc.TeiidDriver;
+
+(a)RunWith(Arquillian.class)
+@SuppressWarnings("nls")
+public class IntegrationTestVDBReuse extends AbstractMMQueryTestCase {
+
+ private Admin admin;
+
+ @Before
+ public void setup() throws Exception {
+ admin = AdminFactory.getInstance().createAdmin("localhost",
9999, "admin", "admin".toCharArray());
+ }
+
+ @After
+ public void teardown() throws AdminException {
+ AdminUtil.cleanUp(admin);
+ admin.close();
+ }
+
+ @Test
+ public void testReuse() throws Exception {
+ admin.deploy("dynamicview-vdb.xml",new
FileInputStream(UnitTestUtil.getTestDataFile("dynamicview-vdb.xml")));
+
+ Properties props = new Properties();
+ props.setProperty("ParentDirectory",
"../docs/teiid/examples/dynamicvdb-portfolio/data");
+ props.setProperty("AllowParentPaths", "true");
+ props.setProperty("class-name",
"org.teiid.resource.adapter.file.FileManagedConnectionFactory");
+
+ AdminUtil.createDataSource(admin, "marketdata-file",
"teiid-connector-file.rar", props);
+
+ assertTrue(AdminUtil.waitForVDBLoad(admin, "dynamic", 1, 3));
+
+ this.internalConnection =
TeiidDriver.getInstance().connect("jdbc:teiid:dynamic@mm://localhost:31000;user=user;password=user",
null);
+
+ execute("SELECT count(*) FROM Sys.Columns"); //$NON-NLS-1$
+ this.internalResultSet.next();
+ int cols = this.internalResultSet.getInt(1);
+
+ admin.deploy("reuse-vdb.xml",new
FileInputStream(UnitTestUtil.getTestDataFile("reuse-vdb.xml")));
+
+ assertTrue(AdminUtil.waitForVDBLoad(admin, "reuse", 1, 3));
+
+ this.internalConnection =
TeiidDriver.getInstance().connect("jdbc:teiid:reuse@mm://localhost:31000;user=user;password=user",
null);
+
+ execute("SELECT count(*) FROM Sys.Columns"); //$NON-NLS-1$
+ this.internalResultSet.next();
+ assertTrue(this.internalResultSet.getInt(1) > cols);
+ }
+
+}
Property changes on:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestVDBReuse.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
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 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/SampleExecutionFactory.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
package org.teiid.arquillian;
import org.teiid.translator.loopback.LoopbackExecutionFactory;
Modified: trunk/test-integration/common/src/test/resources/dynamicview-vdb.xml
===================================================================
--- trunk/test-integration/common/src/test/resources/dynamicview-vdb.xml 2012-05-30
15:39:59 UTC (rev 4151)
+++ trunk/test-integration/common/src/test/resources/dynamicview-vdb.xml 2012-05-31
19:00:50 UTC (rev 4152)
@@ -3,7 +3,7 @@
<source name="text-connector" translator-name="file"
connection-jndi-name="java:/marketdata-file"/>
</model>
<model visible = "true" type = "VIRTUAL" name =
"portfolio">
- <metadata import-type = "DDL"><![CDATA[
+ <metadata type = "DDL"><![CDATA[
CREATE VIEW stock (
symbol varchar,
price decimal
Modified:
trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java
===================================================================
---
trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java 2012-05-30
15:39:59 UTC (rev 4151)
+++
trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java 2012-05-31
19:00:50 UTC (rev 4152)
@@ -3,7 +3,6 @@
*/
package org.teiid.test.framework.exception;
-import java.io.Serializable;
import java.util.List;
import org.teiid.core.TeiidRuntimeException;
@@ -22,8 +21,7 @@
* Subclasses of this exception typically only need to implement whatever
* constructors they need. <p>
*/
-public class QueryTestFailedException extends Exception
- implements Serializable{
+public class QueryTestFailedException extends Exception {
//############################################################################################################################
//# Static Methods
#
//############################################################################################################################
@@ -187,7 +185,7 @@
* @see #getFormattedMessage
*/
public String getFullMessage() {
- return ExceptionUtil.getLinkedMessages(this, 0 );
+ return ExceptionUtil.getLinkedMessagesVerbose(this);
}
/* (non-Javadoc)