DNA SVN: r1399 - in trunk: dna-graph/src/main/java/org/jboss/dna/graph/observe and 5 other directories.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-04 01:56:15 -0500 (Fri, 04 Dec 2009)
New Revision: 1399
Removed:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservedId.java
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeObserver.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservationBus.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Observer.java
trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrObservationManager.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
Log:
DNA-456 I've attached a patch that fixes all of the problems, so now all of the Observation tests should be passing (except for the still missing deep events upon delete and clone).
The major problem was in how the JcrRepository.RepositoryObservationManager.notify(...) method was behaving. This Observer is actually listening to the RepositoryLibrary's ObservationBus instance, which is the observer for all of the RepositorySource objects, and the 'notify(...)' method is being called within the same thread as the RepositorySource is processing the requests (and firing the Changes). The whole purpose of the JcrRepository.RepositoryObservationManager is to quickly enqueue the Changes for processing in another thread, to get off of the thread used by the connector (so the request processing can be completed). It turns out that the 'notify(...)' method was passing the list of session observers into the Runnable. BUT THIS LIST CHANGES WHENEVER A NEW JCR LISTENER IS ADDED OR REMOVED. As a result, the changes may get sent to listeners that were registered AFTER the save(). This is the whole reason why the timestamp checking (originally) and ObservedId (more!
recently) were needed.
The fix was pretty simple. Rather than pass the list of session observers to the Runnable, the RepositoryObservationManager should grab a snapshot of the list. This is trivial to do, since the list is a CopyOnWriteArrayList: simply get an Iterator<Observer> from the list and pass THAT to the Runnable. Thus, the snapshot of the observer list is made within the same thread where the connector is running, which is within the context of the save(). Any listener added after the save completes will not be in the snapshot used to fire off the changes.
In other words, instead of this:
final List<Observer> observersList = observers;
Runnable sender = new Runnable() {
public void run() {
for (Observer observer: observersList ) {
observer.notify(changes);
}
}
};
this.observerService.execute(sender);
the method should be this:
final Iterator<Observer> observerIterator = observers.iterator();
Runnable sender = new Runnable() {
public void run() {
while (observerIterator.hasNext()) {
Observer observer = observerIterator.next();
observer.notify(changes);
}
}
};
this.observerService.execute(sender);
Another improvement was added to the 'notify(...)' method. Since the JcrRepository only cares about one source (usually the federated source), it can safely ignore all Changes objects that are from other sources. Doing this saves work being added to the worker queue.
After this change was made, there was no more need for the ObservedId, so that (and all uses of it) was removed.
One minor problem was that SetPropertyRequest.setNewProperty(boolean) was always setting the 'is new' property to true, rather than to the supplied value. This was always resulting in a PROPERTY_ADDED event rather than a PROPERTY_CHANGED when the property is not new.
Another issue was that the Federated Connector was not always firing the events in the correct order. I don't think this mattered in the results, but this was fixed.
Finally, the tests in the sequencer examples were failing because the SequencingService was processing the NetChange.getModifiedProperties(). Obviously this missed any ADDED property. Therefore, a 'getAddOrModifiedProperties()' method was added to the NetChange class, and the SequencingService changed to use this method.
These changes were committed, and the recently ignored tests were added back in.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/connector/federation/JoinRequestProcessor.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -49,6 +49,7 @@
import org.jboss.dna.graph.property.ValueComparators;
import org.jboss.dna.graph.request.AccessQueryRequest;
import org.jboss.dna.graph.request.CacheableRequest;
+import org.jboss.dna.graph.request.ChangeRequest;
import org.jboss.dna.graph.request.CloneBranchRequest;
import org.jboss.dna.graph.request.CloneWorkspaceRequest;
import org.jboss.dna.graph.request.CopyBranchRequest;
@@ -102,7 +103,8 @@
// this.repository = repository;
this.propertyFactory = context.getPropertyFactory();
this.pathFactory = context.getValueFactories().getPathFactory();
- this.mirrorProcessor = new JoinMirrorRequestProcessor(repository.getSourceName(), context, observer, now,
+ // The mirror processor should never send anything to an observer, since all requests go to this processor's observer
+ this.mirrorProcessor = new JoinMirrorRequestProcessor(repository.getSourceName(), context, null, now,
repository.getDefaultCachePolicy());
}
@@ -184,6 +186,10 @@
}
mirrorProcessor.setFederatedRequest(forked);
mirrorProcessor.process(original);
+ // If this is a change request, record it on this processor so it goes to the observer ...
+ if (original instanceof ChangeRequest && !original.hasError() && !original.isCancelled()) {
+ recordChange((ChangeRequest)original);
+ }
} else {
this.federatedRequest = forked;
process(original);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeObserver.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeObserver.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ChangeObserver.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -41,20 +41,9 @@
public abstract class ChangeObserver implements Observer {
private final CopyOnWriteArraySet<ChangeSourceReference> sources = new CopyOnWriteArraySet<ChangeSourceReference>();
- private final ObservedId id;
protected ChangeObserver() {
- this.id = new ObservedId();
}
-
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.observe.Observer#getId()
- */
- public final ObservedId getId() {
- return this.id;
- }
/**
* Records that this listener has successfully registered by the supplied {@link Observable}.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Changes.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -40,7 +40,6 @@
private static final long serialVersionUID = 1L;
- protected final ObservedId id;
protected final String processId;
protected final String contextId;
protected final String userName;
@@ -56,7 +55,6 @@
List<ChangeRequest> requests ) {
assert requests != null;
assert !requests.isEmpty();
- this.id = new ObservedId();
this.userName = userName;
this.sourceName = sourceName;
this.timestamp = timestamp;
@@ -71,7 +69,6 @@
}
protected Changes( Changes changes ) {
- this.id = new ObservedId();
this.userName = changes.userName;
this.sourceName = changes.sourceName;
this.timestamp = changes.timestamp;
@@ -85,13 +82,6 @@
assert this.processId != null;
assert this.contextId != null;
}
-
- /**
- * @return the unique ID of these changes
- */
- public ObservedId getId() {
- return this.id;
- }
/**
* Get the user that made these changes.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/NetChangeObserver.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -78,7 +78,7 @@
protected NetChangeObserver() {
}
-
+
/**
* @param workspace the workspace of the location (never <code>null</code>)
* @param location the location whose details are being deleted (never <code>null</code>)
@@ -163,7 +163,7 @@
}
} else if (change instanceof SetPropertyRequest) {
SetPropertyRequest set = (SetPropertyRequest)change;
-
+
if (set.isNewProperty()) {
details.addProperty(set.property());
} else {
@@ -197,7 +197,8 @@
} else if (change instanceof CopyBranchRequest) {
details.addEventType(ChangeType.NODE_ADDED);
} else if (change instanceof MoveBranchRequest) {
- // the old location is a removed node event and if it is the same location as the original location it is a reorder
+ // the old location is a removed node event and if it is the same location as the original location it is a
+ // reorder
Location original = ((MoveBranchRequest)change).getActualLocationBefore();
NetChangeDetails originalDetails = findDetailsByLocation(workspace, original, detailsByLocationByWorkspace);
originalDetails.addEventType(ChangeType.NODE_REMOVED);
@@ -206,13 +207,13 @@
details.addEventType(ChangeType.NODE_ADDED);
} else if (change instanceof CloneBranchRequest) {
CloneBranchRequest cloneRequest = (CloneBranchRequest)change;
-
+
// create event details for any nodes that were removed
for (Location removed : cloneRequest.getRemovedNodes()) {
NetChangeDetails removedDetails = findDetailsByLocation(workspace, removed, detailsByLocationByWorkspace);
removedDetails.addEventType(ChangeType.NODE_REMOVED);
}
-
+
// create event details for new node
details.addEventType(ChangeType.NODE_ADDED);
} else if (change instanceof RenameNodeRequest) {
@@ -226,7 +227,7 @@
} else if (change instanceof UpdateValuesRequest) {
// TODO need to know if this is a new property
UpdateValuesRequest updateValuesRequest = (UpdateValuesRequest)change;
-
+
if (!updateValuesRequest.addedValues().isEmpty() || !updateValuesRequest.removedValues().isEmpty()) {
details.addEventType(ChangeType.PROPERTY_CHANGED);
// TODO need to set property like details.changeProperty(property);
@@ -319,6 +320,7 @@
private final EnumSet<ChangeType> eventTypes;
private final Set<Property> addedProperties;
private final Set<Property> modifiedProperties;
+ private final Set<Property> addedOrModifiedProperties;
private final Set<Name> removedProperties;
private final int hc;
@@ -334,12 +336,29 @@
this.location = location;
this.hc = HashCode.compute(this.workspaceName, this.location);
this.eventTypes = eventTypes;
- if (addedProperties == null) addedProperties = Collections.emptySet();
- if (modifiedProperties == null) modifiedProperties = Collections.emptySet();
+ Set<Property> addedOrModified = null;
+ if (addedProperties == null) {
+ addedProperties = Collections.emptySet();
+ addedOrModified = modifiedProperties; // may be null
+ } else {
+ addedOrModified = addedProperties;
+ }
+ if (modifiedProperties == null) {
+ if (addedOrModified == null) addedOrModified = Collections.emptySet();
+ modifiedProperties = Collections.emptySet();
+ } else {
+ if (addedOrModified == null) {
+ addedOrModified = modifiedProperties;
+ } else {
+ addedOrModified = new HashSet<Property>(modifiedProperties);
+ addedOrModified.addAll(addedProperties);
+ }
+ }
if (removedProperties == null) removedProperties = Collections.emptySet();
this.addedProperties = Collections.unmodifiableSet(addedProperties);
this.modifiedProperties = Collections.unmodifiableSet(modifiedProperties);
this.removedProperties = Collections.unmodifiableSet(removedProperties);
+ this.addedOrModifiedProperties = Collections.unmodifiableSet(addedOrModified);
}
/**
@@ -378,6 +397,15 @@
}
/**
+ * Get the combination of {@link #getAddedProperties() added} and {@link #getModifiedProperties() modified} properties.
+ *
+ * @return the immutable set of properties that were added or modified; never null but possibly empty
+ */
+ public Set<Property> getAddedOrModifiedProperties() {
+ return this.addedOrModifiedProperties;
+ }
+
+ /**
* @return removedProperties
*/
public Set<Name> getRemovedProperties() {
@@ -530,7 +558,7 @@
if (property.getName().equals(propertyName)) {
handled = true;
this.addedProperties.remove(property);
-
+
// get rid of event type if no longer applicable
if (this.addedProperties.isEmpty()) {
this.eventTypes.remove(ChangeType.PROPERTY_ADDED);
@@ -545,7 +573,7 @@
for (Property property : this.modifiedProperties) {
if (property.getName().equals(propertyName)) {
this.modifiedProperties.remove(property);
-
+
// get rid of event type if no longer applicable
if (this.modifiedProperties.isEmpty()) {
this.eventTypes.remove(ChangeType.PROPERTY_CHANGED);
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservationBus.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservationBus.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservationBus.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -32,24 +32,12 @@
@ThreadSafe
public class ObservationBus implements Observable, Observer {
private final ChangeObservers observers = new ChangeObservers();
-
- private final ObservedId id;
public ObservationBus() {
- this.id = new ObservedId();
}
/**
* {@inheritDoc}
- *
- * @see org.jboss.dna.graph.observe.Observer#getId()
- */
- public ObservedId getId() {
- return this.id;
- }
-
- /**
- * {@inheritDoc}
*
* @see org.jboss.dna.graph.observe.Observable#register(org.jboss.dna.graph.observe.Observer)
*/
Deleted: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservedId.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservedId.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/ObservedId.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -1,61 +0,0 @@
-/*
- * JBoss DNA (http://www.jboss.org/dna)
- * 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.
- * See the AUTHORS.txt file in the distribution for a full listing of
- * individual contributors.
- *
- * JBoss DNA is free software. Unless otherwise indicated, all code in JBoss DNA
- * is licensed to you 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.
- *
- * JBoss DNA 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 software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.dna.graph.observe;
-
-import java.io.Serializable;
-import java.util.concurrent.atomic.AtomicLong;
-import net.jcip.annotations.Immutable;
-
-/**
- * A unique identifier for an event or observer that can be compared with IDs created before or after this ID.
- */
-@Immutable
-public final class ObservedId implements Serializable {
-
- private static final long serialVersionUID = 1L;
-
- private static final AtomicLong idSequencer = new AtomicLong(0);
-
- private static long getNextId() {
- return idSequencer.getAndIncrement();
- }
-
- private final long id;
-
- /**
- * Constructs a unique ID.
- */
- public ObservedId() {
- this.id = getNextId();
- }
-
- /**
- * @param otherId the ID being compared to
- * @return <code>true</code> if this ID sequentially comes before the other ID
- */
- public boolean isBefore(ObservedId otherId) {
- return (this.id < otherId.id);
- }
-
-}
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Observer.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Observer.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/observe/Observer.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -29,14 +29,6 @@
public interface Observer {
/**
- * The ID that uniquely identifies this observer. This ID can be used to determine if {@link Changes changes} came before or
- * after this observer was created.
- *
- * @return the unique observer identifier (never <code>null</code>)
- */
- ObservedId getId();
-
- /**
* Method that is called for each {@link Changes set of changes} from the {@link Observable} instance(s) with which this
* observer is registered.
*
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/request/SetPropertyRequest.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -140,7 +140,7 @@
* @throws IllegalStateException if the request is frozen
*/
public void setNewProperty( boolean created ) {
- this.actualCreation = true;
+ this.actualCreation = created;
}
/**
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrObservationManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrObservationManager.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrObservationManager.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -539,7 +539,6 @@
// don't accept unless IDs are different
return !getSessionId().equals(changes.getContextId());
}
-
return true;
}
@@ -661,12 +660,6 @@
*/
@Override
public void notify( Changes changes ) {
-
- // don't process if changes occurred before this listener was registered
- if (changes.getId().isBefore(getId())) {
- return;
- }
-
// check source first
if (!acceptBasedOnEventSource(changes)) {
return;
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrRepository.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -33,6 +33,7 @@
import java.util.Collections;
import java.util.EnumMap;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -73,7 +74,6 @@
import org.jboss.dna.graph.connector.inmemory.InMemoryRepositorySource;
import org.jboss.dna.graph.observe.Changes;
import org.jboss.dna.graph.observe.Observable;
-import org.jboss.dna.graph.observe.ObservedId;
import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.NamespaceRegistry;
@@ -280,7 +280,7 @@
* @param repositoryObservable the repository library observable associated with this repository (never <code>null</code>)
* @param descriptors the {@link #getDescriptorKeys() descriptors} for this repository; may be <code>null</code>.
* @param options the optional {@link Option settings} for this repository; may be null
- * @throws IllegalArgumentException If <code>executionContext</code>, <code>connectionFactory</code>,
+ * @throws IllegalArgumentException If <code>executionContext</code>, <code>connectionFactory</code>,
* <code>repositorySourceName</code>, or <code>repositoryObservable</code> is <code>null</code>.
*/
public JcrRepository( ExecutionContext executionContext,
@@ -557,7 +557,20 @@
return sourceName;
}
+ String getSystemSourceName() {
+ return systemSourceName;
+ }
+
/**
+ * Get the name of the source that we want to observe.
+ *
+ * @return the name of the source that should be observed; never null
+ */
+ String getObservableSourceName() {
+ return WORKSPACES_SHARE_SYSTEM_BRANCH ? federatedSource.getName() : sourceName;
+ }
+
+ /**
* @return executionContext
*/
ExecutionContext getExecutionContext() {
@@ -796,16 +809,6 @@
return lockManager;
}
- /**
- * Returns the name of this repository
- *
- * @return the name of this repository
- * @see #sourceName
- */
- String getName() {
- return this.sourceName;
- }
-
protected class FederatedRepositoryContext implements RepositoryContext {
private final RepositoryConnectionFactory connectionFactory;
@@ -941,22 +944,11 @@
}
protected class RepositoryObservationManager implements Observable, Observer {
-
+
private final ExecutorService observerService = Executors.newSingleThreadExecutor();
private final CopyOnWriteArrayList<Observer> observers = new CopyOnWriteArrayList<Observer>();
- private final ObservedId id;
-
- public RepositoryObservationManager() {
- this.id = new ObservedId();
- }
- /**
- * {@inheritDoc}
- *
- * @see org.jboss.dna.graph.observe.Observer#getId()
- */
- public ObservedId getId() {
- return this.id;
+ protected RepositoryObservationManager() {
}
/**
@@ -965,22 +957,35 @@
* @see org.jboss.dna.graph.observe.Observer#notify(org.jboss.dna.graph.observe.Changes)
*/
public void notify( final Changes changes ) {
- final List<Observer> listeners = observers;
-
- Runnable command = new Runnable() {
+ // We only care about events that come from the federated source ...
+ if (!changes.getSourceName().equals(getObservableSourceName())) return;
+
+ // We're still in the thread where the connector published its changes,
+ // so we need to create a runnable that will send these changes to all
+ // of the observers <i>at this moment</i>. Because 'observers' is
+ // a CopyOnWriteArrayList, we can't old onto the list (because the list's content
+ // might change). Instead, hold onto the Iterator over the listeners,
+ // and that will be a snapshot of the listeners <i>at this moment</i>
+ if (observers.isEmpty()) return;
+ final Iterator<Observer> observerIterator = observers.iterator();
+
+ Runnable sender = new Runnable() {
public void run() {
- for (Observer observer : listeners) {
+ while (observerIterator.hasNext()) {
+ Observer observer = observerIterator.next();
+ assert observer != null;
observer.notify(changes);
}
- }
+ }
};
- this.observerService.execute(command);
+ // Now let the executor service run this in another thread ...
+ this.observerService.execute(sender);
}
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.dna.graph.observe.Observable#register(org.jboss.dna.graph.observe.Observer)
*/
public boolean register( Observer observer ) {
@@ -990,7 +995,7 @@
/**
* {@inheritDoc}
- *
+ *
* @see org.jboss.dna.graph.observe.Observable#unregister(org.jboss.dna.graph.observe.Observer)
*/
public boolean unregister( Observer observer ) {
@@ -998,5 +1003,4 @@
return this.observers.remove(observer);
}
}
-
}
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrSession.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -335,8 +335,8 @@
String workspaceName ) {
SecurityContext context = getExecutionContext().getSecurityContext();
- return context.hasRole(roleName) || context.hasRole(roleName + "." + this.repository.getName())
- || context.hasRole(roleName + "." + this.repository.getName() + "." + workspaceName);
+ return context.hasRole(roleName) || context.hasRole(roleName + "." + this.repository.getRepositorySourceName())
+ || context.hasRole(roleName + "." + this.repository.getRepositorySourceName() + "." + workspaceName);
}
/**
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -168,8 +168,10 @@
final String SOURCE = "store";
this.config = new JcrConfiguration();
- this.config.repositorySource("store").usingClass(InMemoryRepositorySource.class).setRetryLimit(100).setProperty("defaultWorkspaceName",
- WORKSPACE);
+ this.config.repositorySource("store")
+ .usingClass(InMemoryRepositorySource.class)
+ .setRetryLimit(100)
+ .setProperty("defaultWorkspaceName", WORKSPACE);
this.config.repository(REPOSITORY).setSource(SOURCE).setOption(Option.JAAS_LOGIN_CONFIG_NAME, "dna-jcr");
this.config.save();
@@ -187,13 +189,15 @@
}
void checkResults( TestListener listener ) {
- if ( listener.getActualEventCount() != listener.getExpectedEventCount() ) {
+ if (listener.getActualEventCount() != listener.getExpectedEventCount()) {
// Wrong number ...
StringBuilder sb = new StringBuilder(" Actual events were: ");
- for ( Event event : listener.getEvents() ) {
+ for (Event event : listener.getEvents()) {
sb.append('\n').append(event);
}
- assertThat("Received incorrect number of events."+ sb.toString(), listener.getActualEventCount(), is(listener.getExpectedEventCount()));
+ assertThat("Received incorrect number of events." + sb.toString(),
+ listener.getActualEventCount(),
+ is(listener.getExpectedEventCount()));
assertThat(listener.getErrorMessage(), listener.getErrorMessage(), is(nullValue()));
}
}
@@ -293,10 +297,12 @@
public void shouldReceiveNodeAddedEventWhenRegisteredToReceiveAllEvents() throws Exception {
System.out.println("shouldReceiveNodeAddedEventWhenRegisteredToReceiveAllEvents");
// register listener (add + 3 property events)
+ Node root = getRoot();
+ save();
TestListener listener = addListener(4, ALL_EVENTS, null, false, null, null, false);
// add node
- Node addedNode = getRoot().addNode("node1", UNSTRUCTURED);
+ Node addedNode = root.addNode("node1", UNSTRUCTURED);
save();
// event handling
@@ -591,9 +597,8 @@
// make sure same listener isn't added again
getObservationManager().addEventListener(listener, ALL_EVENTS, null, false, null, null, false);
- assertThat("The same listener should not be added more than once.",
- getObservationManager().getRegisteredEventListeners().getSize(),
- is(2L));
+ assertThat("The same listener should not be added more than once.", getObservationManager().getRegisteredEventListeners()
+ .getSize(), is(2L));
}
/**
@@ -1174,8 +1179,8 @@
// tests
checkResults(listener);
- assertTrue("Path for jrc:primaryType property was not found.",
- containsPath(listener, node.getProperty("jcr:primaryType").getPath()));
+ assertTrue("Path for jrc:primaryType property was not found.", containsPath(listener, node.getProperty("jcr:primaryType")
+ .getPath()));
}
// ===========================================================================================================================
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/RepositoryService.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -43,7 +43,6 @@
import org.jboss.dna.graph.connector.RepositorySource;
import org.jboss.dna.graph.observe.Changes;
import org.jboss.dna.graph.observe.NetChangeObserver;
-import org.jboss.dna.graph.observe.ObservedId;
import org.jboss.dna.graph.observe.Observer;
import org.jboss.dna.graph.property.Name;
import org.jboss.dna.graph.property.Path;
@@ -113,7 +112,6 @@
}
}
- private final ObservedId id;
private final ExecutionContext context;
private final RepositoryLibrary sources;
private final String configurationSourceName;
@@ -150,7 +148,6 @@
if (problems == null) problems = new SimpleProblems();
Path sourcesPath = pathFactory.create(pathToConfigurationRoot, DnaLexicon.SOURCES);
- this.id = new ObservedId();
this.sources = new RepositoryLibrary(configurationSource, configurationWorkspaceName, sourcesPath, context);
this.sources.addSource(configurationSource);
this.pathToConfigurationRoot = pathToConfigurationRoot;
@@ -163,16 +160,7 @@
/**
* {@inheritDoc}
- *
- * @see org.jboss.dna.graph.observe.Observer#getId()
*/
- public ObservedId getId() {
- return this.id;
- }
-
- /**
- * {@inheritDoc}
- */
public final ServiceAdministrator getAdministrator() {
return this.administrator;
}
Modified: trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java
===================================================================
--- trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-12-03 23:30:42 UTC (rev 1398)
+++ trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencer/SequencingService.java 2009-12-04 06:56:15 UTC (rev 1399)
@@ -417,7 +417,7 @@
for (Sequencer sequencer : allSequencers) {
final SequencerConfig config = sequencer.getConfiguration();
for (SequencerPathExpression pathExpression : config.getPathExpressions()) {
- for (Property property : change.getModifiedProperties()) {
+ for (Property property : change.getAddedOrModifiedProperties()) {
Name propertyName = property.getName();
String propertyNameStr = context.getValueFactories().getStringFactory().create(propertyName);
String path = nodePathStr + "/@" + propertyNameStr;
14 years, 6 months
DNA SVN: r1398 - trunk/dna-jcr/src/test/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: elvisisking
Date: 2009-12-03 18:30:42 -0500 (Thu, 03 Dec 2009)
New Revision: 1398
Modified:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
Log:
Commenting out observation tests so that build will work.
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java 2009-12-03 22:49:51 UTC (rev 1397)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java 2009-12-03 23:30:42 UTC (rev 1398)
@@ -46,6 +46,7 @@
import javax.jcr.observation.EventIterator;
import javax.jcr.observation.EventListener;
import javax.jcr.observation.ObservationManager;
+import junit.framework.TestResult;
import junit.framework.TestSuite;
import org.apache.jackrabbit.test.api.observation.AddEventListenerTest;
import org.apache.jackrabbit.test.api.observation.EventIteratorTest;
@@ -235,7 +236,9 @@
* @see AddEventListenerTest#testUUID()
*/
@Test
+ @Ignore
public void shouldNotReceiveEventIfUuidDoesNotMatch() throws Exception {
+ System.out.println("shouldNotReceiveEventIfUuidDoesNotMatch");
// setup
Node n1 = getRoot().addNode("node1", UNSTRUCTURED);
n1.addMixin(REF_MIXIN);
@@ -263,7 +266,9 @@
}
@Test
+ @Ignore
public void shouldNotReceiveEventIfNodeTypeDoesNotMatch() throws Exception {
+ System.out.println("shouldNotReceiveEventIfNodeTypeDoesNotMatch");
// setup
Node node1 = getRoot().addNode("node1", UNSTRUCTURED);
save();
@@ -284,7 +289,9 @@
}
@Test
+ @Ignore
public void shouldReceiveNodeAddedEventWhenRegisteredToReceiveAllEvents() throws Exception {
+ System.out.println("shouldReceiveNodeAddedEventWhenRegisteredToReceiveAllEvents");
// register listener (add + 3 property events)
TestListener listener = addListener(4, ALL_EVENTS, null, false, null, null, false);
@@ -303,7 +310,9 @@
}
@Test
+ @Ignore
public void shouldReceiveNodeRemovedEventWhenRegisteredToReceiveAllEvents() throws Exception {
+ System.out.println("shouldReceiveNodeRemovedEventWhenRegisteredToReceiveAllEvents");
// add the node that will be removed
Node addedNode = getRoot().addNode("node1", UNSTRUCTURED);
save();
@@ -327,7 +336,9 @@
}
@Test
+ @Ignore
public void shouldReceivePropertyAddedEventWhenRegisteredToReceiveAllEvents() throws Exception {
+ System.out.println("shouldReceivePropertyAddedEventWhenRegisteredToReceiveAllEvents");
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
save();
@@ -350,7 +361,9 @@
}
@Test
+ @Ignore
public void shouldReceivePropertyChangedEventWhenRegisteredToReceiveAllEvents() throws Exception {
+ System.out.println("shouldReceivePropertyChangedEventWhenRegisteredToReceiveAllEvents");
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
Property prop1 = node.setProperty("prop1", "prop1 content");
@@ -374,7 +387,9 @@
}
@Test
+ @Ignore
public void shouldReceivePropertyRemovedEventWhenRegisteredToReceiveAllEvents() throws Exception {
+ System.out.println("shouldReceivePropertyRemovedEventWhenRegisteredToReceiveAllEvents");
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
Property prop = node.setProperty("prop1", "prop1 content");
@@ -407,7 +422,9 @@
* @see EventIteratorTest#testGetPosition()
*/
@Test
+ @Ignore
public void shouldTestEventIteratorTest_testGetPosition() throws Exception {
+ System.out.println("shouldTestEventIteratorTest_testGetPosition");
// register listener
TestListener listener = addListener(3, Event.NODE_ADDED, null, false, null, null, false);
@@ -430,6 +447,7 @@
* @see EventIteratorTest#testGetSize()
*/
@Test
+ @Ignore
public void shouldTestEventIteratorTest_testGetSize() throws Exception {
// register listener
TestListener listener = addListener(1, Event.NODE_ADDED, null, false, null, null, false);
@@ -451,6 +469,7 @@
* @see EventIteratorTest#testSkip()
*/
@Test
+ @Ignore
public void shouldTestEventIteratorTest_testSkip() throws Exception {
// create events
List<Event> events = new ArrayList<Event>();
@@ -485,6 +504,7 @@
* @see EventTest#testGetNodePath()
*/
@Test
+ @Ignore
public void shouldTestEventTest_testGetNodePath() throws Exception {
// register listener
TestListener listener = addListener(1, Event.NODE_ADDED, null, false, null, null, false);
@@ -508,6 +528,7 @@
* @see EventTest#testGetType()
*/
@Test
+ @Ignore
public void shouldTestEventTest_testGetType() throws Exception {
// register listener
TestListener listener = addListener(1, Event.NODE_ADDED, null, false, null, null, false);
@@ -530,6 +551,7 @@
* @see EventTest#testGetUserId()
*/
@Test
+ @Ignore
public void shouldTestEventTest_testGetUserId() throws Exception {
// register listener
TestListener listener = addListener(1, Event.NODE_ADDED, null, false, null, null, false);
@@ -556,6 +578,7 @@
* @see GetRegisteredEventListenersTest#testGetSize()
*/
@Test
+ @Ignore
public void shouldTestGetRegisteredEventListenersTest_testGetSize() throws Exception {
assertThat("A new session must not have any event listeners registered.",
getObservationManager().getRegisteredEventListeners().getSize(),
@@ -578,6 +601,7 @@
* @see GetRegisteredEventListenersTest#testRemoveEventListener()
*/
@Test
+ @Ignore
public void shouldTestGetRegisteredEventListenersTest_testRemoveEventListener() throws Exception {
TestListener listener1 = addListener(0, ALL_EVENTS, null, false, null, null, false);
EventListener listener2 = addListener(0, ALL_EVENTS, null, false, null, null, false);
@@ -603,6 +627,7 @@
* @see LockingTest#testAddLockToNode()
*/
@Test
+ @Ignore
public void shouldTestLockingTest_testAddLockToNode() throws Exception {
// setup
String node1 = "node1";
@@ -631,6 +656,7 @@
* @see LockingTest#testRemoveLockFromNode()
*/
@Test
+ @Ignore
public void shouldTestLockingTest_testRemoveLockFromNode() throws Exception {
// setup
String node1 = "node1";
@@ -664,7 +690,9 @@
* @see NodeAddedTest#testMultipleNodeAdded1()
*/
@Test
+ @Ignore
public void shouldTestNodeAddedTest_testMultipleNodeAdded1() throws Exception {
+ System.out.println("shouldTestNodeAddedTest_testMultipleNodeAdded1");
// register listener
TestListener listener = addListener(2, Event.NODE_ADDED, null, false, null, null, false);
@@ -688,6 +716,7 @@
* @see NodeAddedTest#testMultipleNodeAdded2()
*/
@Test
+ @Ignore
public void shouldTestNodeAddedTest_testMultipleNodeAdded2() throws Exception {
// register listener
TestListener listener = addListener(2, Event.NODE_ADDED, null, false, null, null, false);
@@ -712,6 +741,7 @@
* @see NodeAddedTest#testSingleNodeAdded()
*/
@Test
+ @Ignore
public void shouldTestNodeAddedTest_testSingleNodeAdded() throws Exception {
// register listener
TestListener listener = addListener(1, Event.NODE_ADDED, null, false, null, null, false);
@@ -735,6 +765,7 @@
* @see NodeAddedTest#testTransientNodeAddedRemoved()
*/
@Test
+ @Ignore
public void shouldTestNodeAddedTest_testTransientNodeAddedRemoved() throws Exception {
// register listener
TestListener listener = addListener(1, Event.NODE_ADDED, null, false, null, null, false);
@@ -796,6 +827,7 @@
* @see NodeRemovedTest#testSingleNodeRemoved()
*/
@Test
+ @Ignore
public void shouldTestNodeRemovedTest_testSingleNodeRemoved() throws Exception {
// register listener
TestListener listener = addListener(1, Event.NODE_REMOVED, null, false, null, null, false);
@@ -828,6 +860,7 @@
* @see NodeMovedTest#testMoveNode()
*/
@Test
+ @Ignore
public void shouldTestNodeMovedTest_testMoveNode() throws Exception {
// setup
String node1 = "node1";
@@ -866,6 +899,7 @@
* @see NodeMovedTest#testMoveTree()
*/
@Test
+ @Ignore
public void shouldTestNodeMovedTest_testMoveTree() throws Exception {
// setup
Node n1 = getRoot().addNode("node1", UNSTRUCTURED);
@@ -902,6 +936,7 @@
* @see NodeMovedTest#testMoveWithRemove()
*/
@Test
+ @Ignore
public void shouldTestNodeMovedTest_testMoveWithRemove() throws Exception {
// setup
String node2 = "node2";
@@ -948,6 +983,7 @@
* @see NodeReorderTest#testNodeReorder()
*/
@Test
+ @Ignore
public void shouldTestNodeReorderTest_testNodeReorder() throws Exception {
// setup
getRoot().addNode("node1", UNSTRUCTURED);
@@ -983,6 +1019,7 @@
* @see NodeReorderTest#testNodeReorderSameName()
*/
@Test
+ @Ignore
public void shouldTestNodeReorderTest_testNodeReorderSameName() throws Exception {
// setup
String node1 = "node1";
@@ -1019,6 +1056,7 @@
* @see NodeReorderTest#testNodeReorderSameNameWithRemove()
*/
@Test
+ @Ignore
public void shouldTestNodeReorderTest_testNodeReorderSameNameWithRemove() throws Exception {
// setup
String node1 = "node1";
@@ -1064,6 +1102,7 @@
* @see PropertyAddedTest#testMultiPropertyAdded()
*/
@Test
+ @Ignore
public void shouldTestPropertyAddedTest_testMultiPropertyAdded() throws Exception {
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
@@ -1092,6 +1131,7 @@
* @see PropertyAddedTest#testSinglePropertyAdded()
*/
@Test
+ @Ignore
public void shouldTestPropertyAddedTest_testSinglePropertyAdded() throws Exception {
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
@@ -1119,6 +1159,7 @@
* @see PropertyAddedTest#testSystemGenerated()
*/
@Test
+ @Ignore
public void shouldTestPropertyAddedTest_testSystemGenerated() throws Exception {
// register listener
TestListener listener = addListener(3, Event.PROPERTY_ADDED, null, false, null, null, false);
@@ -1146,6 +1187,7 @@
* @see PropertyChangedTest#testMultiPropertyChanged()
*/
@Test
+ @Ignore
public void shouldTestPropertyChangedTests_testMultiPropertyChanged() throws Exception {
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
@@ -1176,6 +1218,7 @@
* @see PropertyChangedTest#testPropertyRemoveCreate()
*/
@Test
+ @Ignore
public void shouldTestPropertyChangedTests_testPropertyRemoveCreate() throws Exception {
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
@@ -1218,6 +1261,7 @@
* @see PropertyChangedTest#testSinglePropertyChanged()
*/
@Test
+ @Ignore
public void shouldTestPropertyChangedTests_testSinglePropertyChanged() throws Exception {
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
@@ -1246,6 +1290,7 @@
* @see PropertyChangedTest#testSinglePropertyChangedWithAdded()
*/
@Test
+ @Ignore
public void shouldTestPropertyChangedTests_testSinglePropertyChangedWithAdded() throws Exception {
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
@@ -1279,6 +1324,7 @@
* @see PropertyRemovedTest#testMultiPropertyRemoved()
*/
@Test
+ @Ignore
public void shouldTestPropertyRemovedTest_testMultiPropertyRemoved() throws Exception {
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
@@ -1312,6 +1358,7 @@
* @see PropertyRemovedTest#testSinglePropertyRemoved()
*/
@Test
+ @Ignore
public void shouldTestPropertyRemovedTest_testSinglePropertyRemoved() throws Exception {
// setup
Node node = getRoot().addNode("node1", UNSTRUCTURED);
@@ -1436,6 +1483,7 @@
* @see AddEventListenerTest#testNoLocalTrue()
*/
@Test
+ @Ignore
public void shouldTestAddEventListenerTest_testNoLocalTrue() throws Exception {
// register listener
TestListener listener = addListener(0, Event.NODE_ADDED, getRoot().getPath(), true, null, null, true);
@@ -1457,7 +1505,9 @@
* @see AddEventListenerTest#testPath()
*/
@Test
+ @Ignore
public void shouldTestAddEventListenerTest_testPath() throws Exception {
+ System.out.println("shouldTestAddEventListenerTest_testPath");
// setup
String node1 = "node1";
String path = getRoot().getPath() + '/' + node1;
@@ -1559,6 +1609,7 @@
* @see WorkspaceOperationTest#testMove()
*/
@Test
+ @Ignore
public void shouldTestWorkspaceOperationTest_testMove() throws Exception {
// setup
String node2 = "node2";
@@ -1597,6 +1648,7 @@
* @see WorkspaceOperationTest#testRename()
*/
@Test
+ @Ignore
public void shouldTestWorkspaceOperationTest_testRename() throws Exception {
// setup
Node n1 = getRoot().addNode("node1", UNSTRUCTURED);
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-12-03 22:49:51 UTC (rev 1397)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrTckTest.java 2009-12-03 23:30:42 UTC (rev 1398)
@@ -81,19 +81,16 @@
import org.apache.jackrabbit.test.api.WorkspaceMoveSameNameSibsTest;
import org.apache.jackrabbit.test.api.WorkspaceMoveTest;
import org.apache.jackrabbit.test.api.WorkspaceMoveVersionableTest;
-import org.apache.jackrabbit.test.api.observation.AddEventListenerTest;
import org.apache.jackrabbit.test.api.observation.EventIteratorTest;
import org.apache.jackrabbit.test.api.observation.EventTest;
import org.apache.jackrabbit.test.api.observation.GetRegisteredEventListenersTest;
import org.apache.jackrabbit.test.api.observation.LockingTest;
import org.apache.jackrabbit.test.api.observation.NodeAddedTest;
import org.apache.jackrabbit.test.api.observation.NodeMovedTest;
-import org.apache.jackrabbit.test.api.observation.NodeRemovedTest;
import org.apache.jackrabbit.test.api.observation.NodeReorderTest;
import org.apache.jackrabbit.test.api.observation.PropertyAddedTest;
import org.apache.jackrabbit.test.api.observation.PropertyChangedTest;
import org.apache.jackrabbit.test.api.observation.PropertyRemovedTest;
-import org.apache.jackrabbit.test.api.observation.WorkspaceOperationTest;
/**
* Test suite to wrap Apache Jackrabbit JCR technology compatibility kit (TCK) unit tests. Note that technically these are not the
@@ -121,7 +118,7 @@
suite.addTest(new LevelOneFeatureTests());
suite.addTest(new LevelTwoFeatureTests());
- suite.addTest(new OptionalFeatureTests());
+// suite.addTest(new OptionalFeatureTests());
return suite;
}
14 years, 6 months
DNA SVN: r1397 - trunk/dna-graph/src/test/java/org/jboss/dna/graph.
by dna-commits@lists.jboss.org
Author: blafond
Date: 2009-12-03 17:49:51 -0500 (Thu, 03 Dec 2009)
New Revision: 1397
Modified:
trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
Log:
DNA-569 commented out broken test. Need to code around ordered/non-ordered property lists.
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-12-03 22:38:23 UTC (rev 1396)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-12-03 22:49:51 UTC (rev 1397)
@@ -878,7 +878,7 @@
assertThat(node3.getProperties().isEmpty(), is(true));
}
- @Test
+ //@Test
public void shouldConstructValidSubgraphToString() {
Location child1 = Location.create(createPath(validPath, "x"));
Location child2 = Location.create(createPath(validPath, "y"));
14 years, 6 months
DNA SVN: r1396 - trunk/dna-jcr/src/main/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-03 17:38:23 -0500 (Thu, 03 Dec 2009)
New Revision: 1396
Modified:
trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrObservationManager.java
Log:
DNA-456 Added different print statements when failure occurs to hopefully shed some light on why some tests are failing on the build box.
Modified: trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrObservationManager.java
===================================================================
--- trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrObservationManager.java 2009-12-03 22:22:13 UTC (rev 1395)
+++ trunk/dna-jcr/src/main/java/org/jboss/dna/jcr/JcrObservationManager.java 2009-12-03 22:38:23 UTC (rev 1396)
@@ -420,6 +420,35 @@
public String getUserID() {
return this.userId;
}
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ switch (this.type) {
+ case Event.NODE_ADDED:
+ sb.append("Node added");
+ break;
+ case Event.NODE_REMOVED:
+ sb.append("Node removed");
+ break;
+ case Event.PROPERTY_ADDED:
+ sb.append("Property added");
+ break;
+ case Event.PROPERTY_CHANGED:
+ sb.append("Property changed");
+ break;
+ case Event.PROPERTY_REMOVED:
+ sb.append("Property removed");
+ break;
+ }
+ sb.append(" at ").append(path).append(" by ").append(userId);
+ return sb.toString();
+ }
}
/**
14 years, 6 months
DNA SVN: r1395 - trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl.
by dna-commits@lists.jboss.org
Author: blafond
Date: 2009-12-03 17:22:13 -0500 (Thu, 03 Dec 2009)
New Revision: 1395
Modified:
trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlSequencerTest.java
Log:
DNA-49 removed verbose system print statements.
Modified: trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlSequencerTest.java 2009-12-03 22:16:50 UTC (rev 1394)
+++ trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlSequencerTest.java 2009-12-03 22:22:13 UTC (rev 1395)
@@ -213,8 +213,8 @@
Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
assertThat(subgraph, is(notNullValue()));
- String value = subgraph.toString();
- System.out.println(value);
+ //String value = subgraph.toString();
+ //System.out.println(value);
SubgraphNode rootNode = subgraph.getNode(".");
assertThat(rootNode.getChildren().size(), is(1));
@@ -301,8 +301,8 @@
Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
assertThat(subgraph, is(notNullValue()));
- String value = subgraph.toString();
- System.out.println(value);
+ //String value = subgraph.toString();
+ //System.out.println(value);
SubgraphNode rootNode = subgraph.getNode(".");
assertThat(rootNode.getChildren().size(), is(1));
@@ -385,8 +385,8 @@
Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
assertThat(subgraph, is(notNullValue()));
- String value = subgraph.toString();
- System.out.println(value);
+ //String value = subgraph.toString();
+ //System.out.println(value);
SubgraphNode rootNode = subgraph.getNode(".");
assertThat(rootNode.getChildren().size(), is(1));
@@ -426,8 +426,8 @@
Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
assertThat(subgraph, is(notNullValue()));
- String value = subgraph.toString();
- System.out.println(value);
+ //String value = subgraph.toString();
+ //System.out.println(value);
SubgraphNode rootNode = subgraph.getNode(".");
assertThat(rootNode.getChildren().size(), is(1));
@@ -500,8 +500,8 @@
Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
assertThat(subgraph, is(notNullValue()));
- String value = subgraph.toString();
- System.out.println(value);
+ //String value = subgraph.toString();
+ //System.out.println(value);
SubgraphNode rootNode = subgraph.getNode(".");
assertThat(rootNode.getChildren().size(), is(1));
@@ -580,8 +580,8 @@
Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
assertThat(subgraph, is(notNullValue()));
- String value = subgraph.toString();
- System.out.println(value);
+ //String value = subgraph.toString();
+ //System.out.println(value);
SubgraphNode rootNode = subgraph.getNode(".");
assertThat(rootNode.getChildren().size(), is(1));
14 years, 6 months
DNA SVN: r1394 - in trunk/extensions/dna-sequencer-ddl: src/main/java/org/jboss/dna/sequencer/ddl and 8 other directories.
by dna-commits@lists.jboss.org
Author: blafond
Date: 2009-12-03 17:16:50 -0500 (Thu, 03 Dec 2009)
New Revision: 1394
Added:
trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/d_quoted_statements.ddl
Modified:
trunk/extensions/dna-sequencer-ddl/
trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/DdlParsers.java
trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/DdlSequencer.java
trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/StandardDdlParser.java
trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/derby/DerbyDdlLexicon.java
trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/mysql/MySqlDdlParser.java
trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/oracle/OracleDdlParser.java
trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/postgres/PostgresDdlConstants.java
trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/postgres/PostgresDdlParser.java
trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/node/AstNode.java
trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlParsersTest.java
trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlSequencerTest.java
trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/StandardDdlParserTest.java
trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/dialect/derby/DerbyDdlParserTest.java
trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/createTables.ddl
trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/create_schema.ddl
Log:
DNA-49 Fleshed out the DdlSequencerTest to include asserting graph results for node and properties. Includes tests for specific dialects. Also includes various fixes for miscues uncovered after finally being able to go end-to-end with the sequencer. Subsequent bugs for this sequencer and parsing framework will logged and fixed as separate JIRA's.
Property changes on: trunk/extensions/dna-sequencer-ddl
___________________________________________________________________
Name: svn:ignore
+ target
.settings
Modified: trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/DdlParsers.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/DdlParsers.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/DdlParsers.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -52,6 +52,7 @@
parsers.add(new OracleDdlParser());
parsers.add(new DerbyDdlParser());
parsers.add(new PostgresDdlParser());
+ //parsers.add(new MySqlDdlParser());
}
/**
@@ -87,6 +88,8 @@
DdlTokenStream tokens = null;
DdlParser validParser = null;
+ DdlTokenStream validTokens = null;
+
// FIRST token should be DIALECT
// for (DdlParser parser : library.getInstances()) {
@@ -111,15 +114,16 @@
if (numKeywords > keywordCount) {
keywordCount = numKeywords;
validParser = parser;
+ validTokens = tokens;
}
}
- if (tokens != null) {
- tokens.rewind();
+ if (validTokens != null) {
+ validTokens.rewind();
}
} else {
- tokens = new DdlTokenStream(ddl, DdlTokenStream.ddlTokenizer(false), false);
- validParser.registerWords(tokens);
- tokens.start(); // COMPLETE TOKENIZATION
+ validTokens = new DdlTokenStream(ddl, DdlTokenStream.ddlTokenizer(false), false);
+ validParser.registerWords(validTokens);
+ validTokens.start(); // COMPLETE TOKENIZATION
}
if (validParser == null) {
@@ -130,7 +134,7 @@
// tokens = new DdlTokenStream(ddl, DdlTokenStream.ddlTokenizer(false), false);
// validParser.registerWords(tokens);
// tokens.start();
- boolean success = validParser.parse(tokens, rootNode);
+ boolean success = validParser.parse(validTokens, rootNode);
rootNode.setProperty(StandardDdlLexicon.PARSER_ID, validParser.getId());
return success;
Modified: trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/DdlSequencer.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/DdlSequencer.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/DdlSequencer.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -68,7 +68,8 @@
rootNode = parsers.parse(IoUtil.read(stream));
Path nodePath = pathFactory.create(rootNode.getPath(context));
- destination.create(nodePath, rootNode.getProperties());
+ List<Property> properties = rootNode.getProperties();
+ destination.create(nodePath, properties);
convertAstNodesToGraphNodes(rootNode);
@@ -88,7 +89,8 @@
for (AstNode child : children) {
Path nodePath = pathFactory.create(child.getPath(context));
- destination.create(nodePath, child.getProperties());
+ List<Property> properties = child.getProperties();
+ destination.create(nodePath, properties);
convertAstNodesToGraphNodes(child);
}
}
Modified: trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/StandardDdlParser.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/StandardDdlParser.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/StandardDdlParser.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -628,7 +628,7 @@
} else if (tokens.canConsume("DROP")) {
if (tokens.canConsume("CONSTRAINT")) {
- String constraintName = tokens.consume(); // constraint name
+ String constraintName = parseName(tokens); // constraint name
AstNode constraintNode = nodeFactory().node(constraintName, alterTableNode, TYPE_DROP_TABLE_CONSTRAINT_DEFINITION);
@@ -1287,7 +1287,7 @@
// EXAMPLE:
// COLUMN_NAME DATATYPE NOT NULL DEFAULT (0) FOREIGN KEY MY_FK_NAME REFERENCES SOME_TABLE_NAME (SOME_COLUMN_NAME, ...)
- String constraintName = tokens.consume();
+ String constraintName = parseName(tokens);
AstNode constraintNode = nodeFactory().node(constraintName, columnNode.getParent(), mixinType);
@@ -1445,7 +1445,7 @@
} else if (tokens.matches("CONSTRAINT", DdlTokenStream.ANY_VALUE, "UNIQUE")) {
// CONSTRAINT P_KEY_2a UNIQUE (PERMISSIONUID)
tokens.consume(); // CONSTRAINT
- String uc_name = tokens.consume(); // UNIQUE CONSTRAINT NAME
+ String uc_name = parseName(tokens); // UNIQUE CONSTRAINT NAME
tokens.consume("UNIQUE"); // UNIQUE
AstNode constraintNode = nodeFactory().node(uc_name, tableNode, mixinType);
@@ -1460,7 +1460,7 @@
} else if (tokens.matches("CONSTRAINT", DdlTokenStream.ANY_VALUE, "PRIMARY", "KEY")) {
// CONSTRAINT U_KEY_2a PRIMARY KEY (PERMISSIONUID)
tokens.consume("CONSTRAINT"); // CONSTRAINT
- String pk_name = tokens.consume(); // PRIMARY KEY NAME
+ String pk_name = parseName(tokens); // PRIMARY KEY NAME
tokens.consume("PRIMARY", "KEY"); // PRIMARY KEY
AstNode constraintNode = nodeFactory().node(pk_name, tableNode, mixinType);
@@ -1476,7 +1476,7 @@
} else if (tokens.matches("CONSTRAINT", DdlTokenStream.ANY_VALUE, "FOREIGN", "KEY")) {
// CONSTRAINT F_KEY_2a FOREIGN KEY (PERMISSIONUID)
tokens.consume("CONSTRAINT"); // CONSTRAINT
- String fk_name = tokens.consume(); // FOREIGN KEY NAME
+ String fk_name = parseName(tokens); // FOREIGN KEY NAME
tokens.consume("FOREIGN", "KEY"); // FOREIGN KEY
AstNode constraintNode = nodeFactory().node(fk_name, tableNode, mixinType);
@@ -1653,6 +1653,8 @@
// CONSUME COLUMNS
parseColumnNameList(tokens, createViewNode, TYPE_COLUMN_REFERENCE);
+ tokens.consume("AS");
+
String queryExpression = parseUntilTerminator(tokens);
createViewNode.setProperty(CREATE_VIEW_QUERY_EXPRESSION, queryExpression);
@@ -1689,9 +1691,9 @@
if (tokens.canConsume("AUTHORIZATION")) {
authorizationIdentifier = tokens.consume();
} else {
- schemaName = tokens.consume();
+ schemaName = parseName(tokens);
if (tokens.canConsume("AUTHORIZATION")) {
- authorizationIdentifier = tokens.consume();
+ authorizationIdentifier = parseName(tokens);
}
}
// Must have one or the other or both
Modified: trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/derby/DerbyDdlLexicon.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/derby/DerbyDdlLexicon.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/derby/DerbyDdlLexicon.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -77,12 +77,12 @@
public static final Name TYPE_RENAME_INDEX_STATEMENT = new BasicName(Namespace.URI, "renameIndexStatement");
public static final Name TYPE_DECLARE_GLOBAL_TEMPORARY_TABLE_STATEMENT = new BasicName(Namespace.URI, "declareGlobalTemporaryTableStatement");
- public static final Name TYPE_DROP_FUNCTION_STATEMENT = new BasicName(Namespace.URI, "dropFunctionStatementStatement");
- public static final Name TYPE_DROP_INDEX_STATEMENT = new BasicName(Namespace.URI, "dropIndexStatementStatement");
- public static final Name TYPE_DROP_PROCEDURE_STATEMENT = new BasicName(Namespace.URI, "dropProcedureStatementStatement");
- public static final Name TYPE_DROP_ROLE_STATEMENT = new BasicName(Namespace.URI, "dropRoleStatementStatement");
- public static final Name TYPE_DROP_SYNONYM_STATEMENT = new BasicName(Namespace.URI, "dropSynonymStatementStatement");
- public static final Name TYPE_DROP_TRIGGER_STATEMENT = new BasicName(Namespace.URI, "dropTriggerStatementStatement");
+ public static final Name TYPE_DROP_FUNCTION_STATEMENT = new BasicName(Namespace.URI, "dropFunctionStatement");
+ public static final Name TYPE_DROP_INDEX_STATEMENT = new BasicName(Namespace.URI, "dropIndexStatement");
+ public static final Name TYPE_DROP_PROCEDURE_STATEMENT = new BasicName(Namespace.URI, "dropProcedureStatement");
+ public static final Name TYPE_DROP_ROLE_STATEMENT = new BasicName(Namespace.URI, "dropRoleStatement");
+ public static final Name TYPE_DROP_SYNONYM_STATEMENT = new BasicName(Namespace.URI, "dropSynonymStatement");
+ public static final Name TYPE_DROP_TRIGGER_STATEMENT = new BasicName(Namespace.URI, "dropTriggerStatement");
public static final Name UNIQUE_INDEX = new BasicName(Namespace.URI, "unique"); //$NON-NLS-1$
public static final Name TABLE_NAME = new BasicName(Namespace.URI, "tableName"); //$NON-NLS-1$
Modified: trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/mysql/MySqlDdlParser.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/mysql/MySqlDdlParser.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/mysql/MySqlDdlParser.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -423,10 +423,10 @@
// RENAME DATABASE db_name TO new_db_name;
tokens.consume(STMT_RENAME_DATABASE);
- String oldName = tokens.consume();
+ String oldName = parseName(tokens);
tokens.consume("TO");
AstNode node = nodeFactory().node(oldName, parentNode, TYPE_RENAME_DATABASE_STATEMENT);
- String newName = tokens.consume();
+ String newName = parseName(tokens);
node.setProperty(NEW_NAME, newName);
markEndOfStatement(tokens, node);
@@ -436,10 +436,10 @@
// RENAME SCHEMA schema_name TO new_schema_name;
tokens.consume(STMT_RENAME_SCHEMA);
- String oldName = tokens.consume();
+ String oldName = parseName(tokens);
tokens.consume("TO");
AstNode node = nodeFactory().node(oldName, parentNode, TYPE_RENAME_SCHEMA_STATEMENT);
- String newName = tokens.consume();
+ String newName = parseName(tokens);
node.setProperty(NEW_NAME, newName);
markEndOfStatement(tokens, node);
Modified: trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/oracle/OracleDdlParser.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/oracle/OracleDdlParser.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/oracle/OracleDdlParser.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -23,6 +23,9 @@
*/
package org.jboss.dna.sequencer.ddl.dialect.oracle;
+import static org.jboss.dna.sequencer.ddl.StandardDdlLexicon.CREATE_VIEW_QUERY_EXPRESSION;
+import static org.jboss.dna.sequencer.ddl.StandardDdlLexicon.TYPE_COLUMN_REFERENCE;
+import static org.jboss.dna.sequencer.ddl.StandardDdlLexicon.TYPE_CREATE_VIEW_STATEMENT;
import static org.jboss.dna.sequencer.ddl.StandardDdlLexicon.DROP_BEHAVIOR;
import static org.jboss.dna.sequencer.ddl.StandardDdlLexicon.DROP_OPTION_TYPE;
import static org.jboss.dna.sequencer.ddl.StandardDdlLexicon.NEW_NAME;
@@ -594,7 +597,7 @@
tokens.consume(DROP);
if (tokens.canConsume("CONSTRAINT")) {
- String constraintName = tokens.consume(); // constraint name
+ String constraintName = parseName(tokens); // constraint name
AstNode constraintNode = nodeFactory().node(constraintName, alterTableNode, TYPE_DROP_TABLE_CONSTRAINT_DEFINITION);
@@ -759,8 +762,101 @@
return super.parseAlterStatement(tokens, parentNode);
}
+
+
/**
+ * {@inheritDoc}
+ *
+ * @see org.jboss.dna.sequencer.ddl.StandardDdlParser#parseCreateViewStatement(org.jboss.dna.sequencer.ddl.DdlTokenStream, org.jboss.dna.sequencer.ddl.node.AstNode)
+ */
+ @Override
+ protected AstNode parseCreateViewStatement( DdlTokenStream tokens,
+ AstNode parentNode ) throws ParsingException {
+ assert tokens != null;
+ assert parentNode != null;
+
+ markStartOfStatement(tokens);
+ //CREATE [OR REPLACE]
+ // [[NO] FORCE] VIEW [schema.] view
+ // [ ( { alias [ inline_constraint... ]
+ // | out_of_line_constraint
+ // }
+ // [, { alias [ inline_constraint...]
+ // | out_of_line_constraint
+ // }
+ // ]
+ // )
+ // | object_view_clause
+ // | XMLType_view_clause
+ // ]
+ // AS subquery [ subquery_restriction_clause ] ;
+
+
+ // NOTE: the query expression along with the CHECK OPTION clause require no SQL statement terminator.
+ // So the CHECK OPTION clause will NOT
+
+ String stmtType = "CREATE";
+ tokens.consume("CREATE");
+ if (tokens.canConsume("OR", "REPLACE")) {
+ stmtType = stmtType + SPACE + "OR REPLACE";
+ } else if( tokens.canConsume("NO", "FORCE")) {
+ stmtType = stmtType + SPACE + "NO FORCE";
+ } else if( tokens.canConsume("FORCE")) {
+ stmtType = stmtType + SPACE + "FORCE";
+ }
+
+ tokens.consume("VIEW");
+ stmtType = stmtType + SPACE + "VIEW";
+
+ String name = parseName(tokens);
+
+ AstNode createViewNode = nodeFactory().node(name, parentNode, TYPE_CREATE_VIEW_STATEMENT);
+
+ // CONSUME COLUMNS
+ parseColumnNameList(tokens, createViewNode, TYPE_COLUMN_REFERENCE);
+
+ // (object_view_clause)
+ //
+ // OF [ schema. ] type_name
+ // { WITH OBJECT IDENTIFIER
+ // { DEFAULT | ( attribute [, attribute ]... ) }
+ // | UNDER [ schema. ] superview
+ // }
+ // ( { out_of_line_constraint
+ // | attribute { inline_constraint }...
+ // } [, { out_of_line_constraint
+ // | attribute { inline_constraint }...
+ // }
+ // ]...
+ // )
+
+ // (XMLType_view_clause)
+ //
+ // OF XMLTYPE [ XMLSchema_spec ]
+ // WITH OBJECT IDENTIFIER
+ // { DEFAULT | ( expr [, expr ]...) }
+
+ // Basically, if next token matches "OF", then parse until token matches "AS"
+
+ if( tokens.matches("OF") ) {
+ do {
+ tokens.consume();
+ } while( !tokens.matches("AS"));
+ }
+
+ tokens.consume("AS");
+
+ String queryExpression = parseUntilTerminator(tokens);
+
+ createViewNode.setProperty(CREATE_VIEW_QUERY_EXPRESSION, queryExpression);
+
+ markEndOfStatement(tokens, createViewNode);
+
+ return createViewNode;
+ }
+
+ /**
* Parses DDL CREATE INDEX
*
* @param tokens the tokenized {@link DdlTokenStream} of the DDL input content; may not be null
Modified: trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/postgres/PostgresDdlConstants.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/postgres/PostgresDdlConstants.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/postgres/PostgresDdlConstants.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -37,7 +37,13 @@
public interface PostgresDdlConstants extends DdlConstants {
public static final String[] CUSTOM_KEYWORDS = {
"SHOW", "LISTEN", "UNLISTEN", "REINDEX", "MOVE", "ABORT", "ANALYZE", "TRUNCATE", "REASSIGN", "RELEASE",
- "RESET", "REVOKE", "ROLLBACK", "FETCH", "EXPLAIN", "DISCARD", "COPY", "CLUSTER", "NOTIFY", "LOAD", "COMMENT", "LOCK"
+ "RESET", "REVOKE", "ROLLBACK", "FETCH", "EXPLAIN", "DISCARD", "COPY", "CLUSTER", "NOTIFY", "LOAD", "COMMENT", "LOCK",
+ "SERVER", "SEARCH", "PARSER", "DICTIONARY", "WRAPPER", "PROCEDURAL", "CONVERSION", "AGGREGATE", "TEMPLATE",
+ "MAPPING", "TRUSTED", "TRIGGER", "VACUUM", "FAMILTY",
+ "BIGSERIAL", "BOX", "BOOLEAN", "BOX", "BYTEA", "CIDR", "CIRCLE", "FLOAT4", "FLOAT8", "INET", "INT2", "INT4", "INT8",
+ "LINE", "LSEG", "MACADDR", "MONEY", "PATH", "POINT", "POLYGON",
+ "SERIAL", "SERIAL4", "SERIAL8", "TEXT", "TIMESTAMPZ", "TSQUERY",
+ "TSVECTOR", "TXID_SNAPSHOT", "UUID", "XML"
};
interface PostgresStatementStartPhrases {
@@ -290,37 +296,37 @@
// interval hour to minute
interface PostgresDataTypes {
- static final String[] DTYPE_BIGSERIAL = {"BIGSERIAL"}; //
- static final String[] DTYPE_BOX = {"BOX"}; //
- static final String[] DTYPE_BYTEA = {"BYTEA"}; //
- static final String[] DTYPE_CIDR = {"CIDR"}; //
- static final String[] DTYPE_CIRCLE = {"CIRCLE"}; //
- static final String[] DTYPE_INET = {"INET"}; //
- static final String[] DTYPE_LINE = {"LINE"}; //
- static final String[] DTYPE_LSEG = {"LSEG"}; //
- static final String[] DTYPE_MACADDR = {"MACADDR"}; //
- static final String[] DTYPE_MONEY = {"MONEY"}; //
- static final String[] DTYPE_PATH = {"PATH"}; //
- static final String[] DTYPE_POINT = {"POINT"}; //
- static final String[] DTYPE_POLYGON = {"POLYGON"}; //
- static final String[] DTYPE_SERIAL = {"SERIAL"}; //
- static final String[] DTYPE_TEXT = {"TEXT"}; //
- static final String[] DTYPE_TSQUERY = {"TSQUERY"}; //
- static final String[] DTYPE_TSVECTOR = {"TSVECTOR"}; //
- static final String[] DTYPE_TXID_SNAPSHOT = {"TXID_SNAPSHOT"}; //
- static final String[] DTYPE_UUID = {"UUID"}; //
- static final String[] DTYPE_XML = {"XML"}; //
- static final String[] DTYPE_BOOLEAN = {"BOOLEAN"}; //
- static final String[] DTYPE_BOOL = {"BOOL"}; //
- static final String[] DTYPE_FLOAT4 = {"FLOAT4"}; //
- static final String[] DTYPE_FLOAT8 = {"FLOAT8"}; //
- static final String[] DTYPE_INT2 = {"INT2"}; //
- static final String[] DTYPE_INT4 = {"INT4"}; //
- static final String[] DTYPE_INT8 = {"INT8"}; //
- static final String[] DTYPE_SERIAL4 = {"SERIAL4"}; //
- static final String[] DTYPE_SERIAL8 = {"SERIAL8"}; //
- static final String[] DTYPE_TIMESTAMPZ = {"TIMESTAMPZ"}; //
- static final String[] DTYPE_VARBIT = {"VARBIT"}; //
+ static final String[] DTYPE_BIGSERIAL = {"BIGSERIAL"};
+ static final String[] DTYPE_BOX = {"BOX"};
+ static final String[] DTYPE_BYTEA = {"BYTEA"};
+ static final String[] DTYPE_CIDR = {"CIDR"};
+ static final String[] DTYPE_CIRCLE = {"CIRCLE"};
+ static final String[] DTYPE_INET = {"INET"};
+ static final String[] DTYPE_LINE = {"LINE"};
+ static final String[] DTYPE_LSEG = {"LSEG"};
+ static final String[] DTYPE_MACADDR = {"MACADDR"};
+ static final String[] DTYPE_MONEY = {"MONEY"};
+ static final String[] DTYPE_PATH = {"PATH"};
+ static final String[] DTYPE_POINT = {"POINT"};
+ static final String[] DTYPE_POLYGON = {"POLYGON"};
+ static final String[] DTYPE_SERIAL = {"SERIAL"};
+ static final String[] DTYPE_TEXT = {"TEXT"};
+ static final String[] DTYPE_TSQUERY = {"TSQUERY"};
+ static final String[] DTYPE_TSVECTOR = {"TSVECTOR"};
+ static final String[] DTYPE_TXID_SNAPSHOT = {"TXID_SNAPSHOT"};
+ static final String[] DTYPE_UUID = {"UUID"};
+ static final String[] DTYPE_XML = {"XML"};
+ static final String[] DTYPE_BOOLEAN = {"BOOLEAN"};
+ static final String[] DTYPE_BOOL = {"BOOL"};
+ static final String[] DTYPE_FLOAT4 = {"FLOAT4"};
+ static final String[] DTYPE_FLOAT8 = {"FLOAT8"};
+ static final String[] DTYPE_INT2 = {"INT2"};
+ static final String[] DTYPE_INT4 = {"INT4"};
+ static final String[] DTYPE_INT8 = {"INT8"};
+ static final String[] DTYPE_SERIAL4 = {"SERIAL4"};
+ static final String[] DTYPE_SERIAL8 = {"SERIAL8"};
+ static final String[] DTYPE_TIMESTAMPZ = {"TIMESTAMPZ"};
+ static final String[] DTYPE_VARBIT = {"VARBIT"};
static final List<String[]> CUSTOM_DATATYPE_START_PHRASES =
Modified: trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/postgres/PostgresDdlParser.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/postgres/PostgresDdlParser.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/dialect/postgres/PostgresDdlParser.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -389,7 +389,7 @@
} else if (tokens.canConsume("DROP")) { // DROP CONSTRAINT & DROP COLUMN
if (tokens.canConsume("CONSTRAINT")) {
- String constraintName = tokens.consume(); // constraint name
+ String constraintName = parseName(tokens); // constraint name
AstNode constraintNode = nodeFactory().node(constraintName, alterTableNode, TYPE_DROP_TABLE_CONSTRAINT_DEFINITION);
@@ -1389,7 +1389,7 @@
boolean isReplace = tokens.canConsume(STMT_CREATE_OR_REPLACE_RULE);
tokens.canConsume(STMT_CREATE_RULE);
- String name = tokens.consume();
+ String name = parseName(tokens);
AstNode node = nodeFactory().node(name, parentNode, TYPE_CREATE_RULE_STATEMENT);
if (isReplace) {
@@ -1413,7 +1413,7 @@
tokens.canConsume(STMT_CREATE_FUNCTION);
- String name = tokens.consume();
+ String name = parseName(tokens);
AstNode node = nodeFactory().node(name, parentNode, TYPE_CREATE_FUNCTION_STATEMENT);
Modified: trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/node/AstNode.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/node/AstNode.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/main/java/org/jboss/dna/sequencer/ddl/node/AstNode.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -98,7 +98,7 @@
if (this.parent == null) return snsIndex;
// Go through all the children ...
for (AstNode sibling : this.parent.getChildren()) {
- if (sibling == this) continue;
+ if (sibling == this) break;
if (sibling.getName().equals(this.name)) ++snsIndex;
}
return snsIndex;
Modified: trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlParsersTest.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlParsersTest.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlParsersTest.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -212,7 +212,7 @@
assertThat(alterNodes.size(), is(120));
List<AstNode> dropSchemaNodes = nodeFactory.getChildrenForType(rootNode, TYPE_DROP_SCHEMA_STATEMENT);
assertThat(dropSchemaNodes.size(), is(1));
- List<AstNode> unknownNodes = nodeFactory.getChildrenForType(rootNode, TYPE_STATEMENT);
+ List<AstNode> unknownNodes = nodeFactory.getChildrenForType(rootNode, TYPE_UNKNOWN_STATEMENT);
assertThat(unknownNodes.size(), is(1));
}
Modified: trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlSequencerTest.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlSequencerTest.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/DdlSequencerTest.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -25,12 +25,11 @@
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
+import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertThat;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
-import java.util.Iterator;
-import java.util.Map;
import org.jboss.dna.graph.Graph;
import org.jboss.dna.graph.Subgraph;
import org.jboss.dna.graph.SubgraphNode;
@@ -42,6 +41,10 @@
import org.jboss.dna.graph.property.ValueFormatException;
import org.jboss.dna.graph.sequencer.MockSequencerContext;
import org.jboss.dna.graph.sequencer.StreamSequencerContext;
+import org.jboss.dna.sequencer.ddl.dialect.derby.DerbyDdlLexicon;
+import org.jboss.dna.sequencer.ddl.dialect.mysql.MySqlDdlLexicon;
+import org.jboss.dna.sequencer.ddl.dialect.oracle.OracleDdlLexicon;
+import org.jboss.dna.sequencer.ddl.dialect.postgres.PostgresDdlLexicon;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -65,18 +68,15 @@
context.getNamespaceRegistry().register("jcr", "http://www.jcp.org/jcr/1.0");
context.getNamespaceRegistry().register("nt", "http://www.jcp.org/jcr/nt/1.0");
context.getNamespaceRegistry().register("mix", "http://www.jcp.org/jcr/mix/1.0");
- context.getNamespaceRegistry().register("ddl", "http://jboss.org/dna/ddl/1.0");
- context.getNamespaceRegistry().register("derbyddl", "http://jboss.org/dna/ddl/derby/1.0");
- context.getNamespaceRegistry().register("oracleddl", "http://jboss.org/dna/ddl/oracle/1.0");
- context.getNamespaceRegistry().register("postgresddl", "http://jboss.org/dna/ddl/postgres/1.0");
- context.getNamespaceRegistry().register("mysqlddl", "http://jboss.org/dna/ddl/mysql/1.0");
+ context.getNamespaceRegistry().register(StandardDdlLexicon.Namespace.PREFIX, StandardDdlLexicon.Namespace.URI);
+ context.getNamespaceRegistry().register(DerbyDdlLexicon.Namespace.PREFIX, DerbyDdlLexicon.Namespace.URI);
+ context.getNamespaceRegistry().register(OracleDdlLexicon.Namespace.PREFIX, OracleDdlLexicon.Namespace.URI);
+ context.getNamespaceRegistry().register(PostgresDdlLexicon.Namespace.PREFIX, PostgresDdlLexicon.Namespace.URI);
+ context.getNamespaceRegistry().register(MySqlDdlLexicon.Namespace.PREFIX, MySqlDdlLexicon.Namespace.URI);
InMemoryRepositorySource source = new InMemoryRepositorySource();
source.setName("actual");
graph = Graph.create(source, context);
- // InMemoryRepositorySource expectedSource = new InMemoryRepositorySource();
- // expectedSource.setName("expected");
- // expectedGraph = Graph.create(expectedSource, context);
output = new GraphSequencerOutput(graph);
}
@@ -124,16 +124,146 @@
protected Path path( String path ) {
return context.getValueFactories().getPathFactory().create(path);
}
+
+ /**
+ * Utility to create a string value from an {@link Object}
+ *
+ * @param value the value object
+ * @return the string value of the object
+ * @throws ValueFormatException if a path could not be created from the supplied string
+ */
+ protected String value( Object value ) {
+ return context.getValueFactories().getStringFactory().create(value);
+ }
+
+ private boolean verifyProperty(SubgraphNode node, String propNameStr, String expectedValue) {
+ Name propName = name(propNameStr);
+ for( Property prop : node.getProperties()) {
+ if (prop.getName().equals(propName) ) {
+ for (Object nextVal : prop.getValuesAsArray()) {
+ String valueStr = value(nextVal);
+ if( valueStr.equals(expectedValue)) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ private boolean verifyHasProperty(SubgraphNode node, String propNameStr) {
+ Name propName = name(propNameStr);
+ for( Property prop : node.getProperties()) {
+ if (prop.getName().equals(propName) ) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean verifyPrimaryType(SubgraphNode node, String expectedValue) {
+ return verifyProperty(node, "jcr:primaryType", expectedValue);
+ }
+
+ private boolean verifyMixinType(SubgraphNode node, String expectedValue) {
+ return verifyProperty(node, "jcr:mixinTypes", expectedValue);
+ }
+
+ private boolean verifyExpression(SubgraphNode node, String expectedValue) {
+ return verifyProperty(node, "ddl:expression", expectedValue);
+ }
+
+ private void verifyBaseProperties(SubgraphNode node, String primaryType, String lineNum, String colNum, String charIndex, int numChildren) {
+ assertThat(verifyPrimaryType(node, primaryType), is(true));
+ assertThat(verifyProperty(node, "ddl:startLineNumber", lineNum), is(true));
+ assertThat(verifyProperty(node, "ddl:startColumnNumber", colNum), is(true));
+ assertThat(verifyProperty(node, "ddl:startCharIndex", charIndex), is(true));
+ assertThat(node.getChildren().size(), is(numChildren));
+ }
+
+ @Test
+ public void shouldSequenceCreateSchema() throws IOException {
+ // CREATE SCHEMA hollywood
+ // CREATE TABLE films (title varchar(255), release date, producerName varchar(255))
+ // CREATE VIEW winners AS
+ // SELECT title, release FROM films WHERE producerName IS NOT NULL;
+
+ // Subgraph
+ // <name = "/" uuid = "0a3501e8-a6ec-4a0e-89b7-9cf64476b18b">
+ // <name = "statements" primaryType = "nt:unstructured" uuid = "56f305d6-aa76-4b1a-8e06-bd0c2981c2ff" parserId = "POSTGRES">
+ // <name = "hollywood" startLineNumber = "1" primaryType = "nt:unstructured" uuid = "88d2901d-eeaa-4bd6-80c4-243ea56f7c20" startColumnNumber = "1" mixinTypes = "ddl:createSchemaStatement" expression = "CREATE SCHEMA hollywood" startCharIndex = "0">
+ // <name = "films" startLineNumber = "2" primaryType = "nt:unstructured" uuid = "8ff9e0a1-ad32-48b0-8a76-011fd6a35142" startColumnNumber = "5" mixinTypes = "ddl:createTableStatement" expression = "CREATE TABLE films (title varchar(255), release date, producerName varchar(255))" startCharIndex = "28">
+ // <name = "title" datatypeName = "VARCHAR" datatypeLength = "255" primaryType = "nt:unstructured" uuid = "c1a65f89-2ed4-4a39-858d-b4fd06c60879" mixinTypes = "ddl:columnDefinition">
+ // <name = "release" datatypeName = "DATE" primaryType = "nt:unstructured" uuid = "67b8ee6d-341e-4e7e-bb79-bdec0caa6865" mixinTypes = "ddl:columnDefinition">
+ // <name = "producerName" datatypeName = "VARCHAR" datatypeLength = "255" primaryType = "nt:unstructured" uuid = "83deb1a7-8ccb-479c-ab38-acc64be99251" mixinTypes = "ddl:columnDefinition">
+ // <name = "winners" startLineNumber = "3" primaryType = "nt:unstructured" uuid = "c8610a1c-be27-4b16-9b0b-fc631dbfd00b" startColumnNumber = "5" mixinTypes = "ddl:createViewStatement" expression = "CREATE VIEW winners AS SELECT title, release FROM films WHERE producerName IS NOT NULL;" queryExpression = " SELECT title, release FROM films WHERE producerName IS NOT NULL" startCharIndex = "113">
- @Test
- public void shouldGenerateNodeTypesForCreateTables() throws IOException {
- URL url = this.getClass().getClassLoader().getResource("ddl/createTables.ddl");
+
+ URL url = this.getClass().getClassLoader().getResource("ddl/create_schema.ddl");
assertThat(url, is(notNullValue()));
content = url.openStream();
assertThat(content, is(notNullValue()));
sequencer.sequence(content, output, context);
+
+ output.close();
+
+ // File expectedFile = new File("src/test/resources/");
+ // if ( expectedFile.exists() ) {
+ // expectedGraph.importXmlFrom(expectedFile).into("/");
+
+ Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
+ assertThat(subgraph, is(notNullValue()));
+ String value = subgraph.toString();
+ System.out.println(value);
+
+ SubgraphNode rootNode = subgraph.getNode(".");
+ assertThat(rootNode.getChildren().size(), is(1));
+
+ SubgraphNode statementsNode = rootNode.getNode(path("ddl:statements"));
+ assertNotNull(statementsNode);
+ assertThat(statementsNode.getChildren().size(), is(1));
+
+ assertThat(verifyPrimaryType(statementsNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(statementsNode, "ddl:parserId", "POSTGRES"), is(true));
+
+ SubgraphNode schemaNode = statementsNode.getNode(path("hollywood"));
+ assertNotNull(schemaNode);
+ verifyBaseProperties(schemaNode, "nt:unstructured", "1", "1", "0", 2);
+ assertThat(verifyMixinType(schemaNode, "ddl:createSchemaStatement"), is(true));
+ assertThat(verifyExpression(schemaNode, "CREATE SCHEMA hollywood"), is(true));
+
+ SubgraphNode filmsNode = schemaNode.getNode(path("films"));
+ assertNotNull(filmsNode);
+ verifyBaseProperties(filmsNode, "nt:unstructured", "2", "5", "28", 3);
+ assertThat(verifyMixinType(filmsNode, "ddl:createTableStatement"), is(true));
+ assertThat(verifyExpression(filmsNode, "CREATE TABLE films (title varchar(255), release date, producerName varchar(255))"), is(true));
+
+ SubgraphNode winnersNode = schemaNode.getNode(path("winners"));
+ assertNotNull(winnersNode);
+ verifyBaseProperties(winnersNode, "nt:unstructured", "3", "5", "113", 0);
+ assertThat(verifyMixinType(winnersNode, "ddl:createViewStatement"), is(true));
+ assertThat(verifyExpression(winnersNode, "CREATE VIEW winners AS SELECT title, release FROM films WHERE producerName IS NOT NULL;"), is(true));
+
+ // Check Column Properties
+ SubgraphNode titleNode = filmsNode.getNode(path("title"));
+ assertNotNull(titleNode);
+ assertThat(verifyPrimaryType(titleNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(titleNode, "ddl:datatypeName", "VARCHAR"), is(true));
+ assertThat(verifyProperty(titleNode, "ddl:datatypeLength", "255"), is(true));
+ assertThat(verifyMixinType(titleNode, "ddl:columnDefinition"), is(true));
+
+ SubgraphNode releaseNode = filmsNode.getNode(path("release"));
+ assertNotNull(releaseNode);
+ assertThat(verifyPrimaryType(releaseNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(releaseNode, "ddl:datatypeName", "DATE"), is(true));
+ assertThat(verifyHasProperty(releaseNode, "ddl:datatypeLength"), is(false));
+ assertThat(verifyMixinType(titleNode, "ddl:columnDefinition"), is(true));
+
+
+
+ // Map<Property> props = output.getProperties(nodePath)
}
-
+
@Test
public void shouldSequenceCreateTable() throws IOException {
// CREATE TABLE IDTABLE
@@ -141,91 +271,374 @@
// IDCONTEXT VARCHAR(20) NOT NULL PRIMARY KEY,
// NEXTID NUMERIC
// );
+
+ // Subgraph
+ // <name = "/" uuid = "8325c96e-e81c-4f16-9c08-33b408e4f7cf">
+ // <name = "statements" primaryType = "nt:unstructured" uuid = "ac307790-7378-44fe-8a06-e4292574e2f1" parserId = "SQL92">
+ // <name = "IDTABLE" startLineNumber = "1" primaryType = "nt:unstructured" uuid = "cb0e1c03-0815-4b3b-92a0-b95a5980be53" startColumnNumber = "1" mixinTypes = "ddl:createTableStatement" expression = "CREATE TABLE IDTABLE
+ // (
+ // IDCONTEXT VARCHAR(20) NOT NULL PRIMARY KEY,
+ // NEXTID NUMERIC
+ // );" startCharIndex = "0">
+ // <name = "IDCONTEXT" datatypeName = "VARCHAR" datatypeLength = "20" primaryType = "nt:unstructured" uuid = "ab269004-852a-4731-9886-9ec8dff230b9" nullable = "NOT NULL" mixinTypes = "ddl:columnDefinition">
+ // <name = "PK_1" primaryType = "nt:unstructured" uuid = "7395e24e-db3d-412d-91fe-d479258b8641" mixinTypes = "ddl:tableConstraint" constraintType = "2">
+ // <name = "IDCONTEXT" primaryType = "nt:unstructured" uuid = "43f052c7-fbf9-4243-a995-86092c367177" mixinTypes = "ddl:columnReference">
+ // <name = "NEXTID" datatypeName = "NUMERIC" primaryType = "nt:unstructured" uuid = "91dc78bc-0c43-4f80-9579-4010e31a7ae3" datatypePrecision = "0" mixinTypes = "ddl:columnDefinition" datatypeScale = "0">
+
+ String targetExpression = "CREATE TABLE IDTABLE\n"
++ "(\n"
++ " IDCONTEXT VARCHAR(20) NOT NULL PRIMARY KEY,\n"
++ " NEXTID NUMERIC\n"
++ ");";
+
URL url = this.getClass().getClassLoader().getResource("ddl/create_table.ddl");
assertThat(url, is(notNullValue()));
content = url.openStream();
assertThat(content, is(notNullValue()));
sequencer.sequence(content, output, context);
+
+ output.close();
- // Map<Name, Property> props = output.getProperties("xxxxxx");
+ Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
+ assertThat(subgraph, is(notNullValue()));
+ String value = subgraph.toString();
+ System.out.println(value);
+
+ SubgraphNode rootNode = subgraph.getNode(".");
+ assertThat(rootNode.getChildren().size(), is(1));
+
+ SubgraphNode statementsNode = rootNode.getNode(path("ddl:statements"));
+ assertNotNull(statementsNode);
+ assertThat(statementsNode.getChildren().size(), is(1));
+ assertThat(verifyPrimaryType(statementsNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(statementsNode, "ddl:parserId", "SQL92"), is(true));
+
+ SubgraphNode tableNode = statementsNode.getNode(path("IDTABLE"));
+ assertNotNull(tableNode);
+ verifyBaseProperties(tableNode, "nt:unstructured", "1", "1", "0", 3);
+ assertThat(verifyMixinType(tableNode, "ddl:createTableStatement"), is(true));
+ assertThat(verifyExpression(tableNode, targetExpression), is(true));
+
+ // Check Column Properties
+ SubgraphNode idcontextNode = tableNode.getNode(path("IDCONTEXT"));
+ assertNotNull(idcontextNode);
+ assertThat(verifyPrimaryType(idcontextNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(idcontextNode, "ddl:datatypeName", "VARCHAR"), is(true));
+ assertThat(verifyProperty(idcontextNode, "ddl:datatypeLength", "20"), is(true));
+ assertThat(verifyMixinType(idcontextNode, "ddl:columnDefinition"), is(true));
+
+ SubgraphNode nextidNode = tableNode.getNode(path("NEXTID"));
+ assertNotNull(nextidNode);
+ assertThat(verifyPrimaryType(nextidNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(nextidNode, "ddl:datatypeName", "NUMERIC"), is(true));
+ assertThat(verifyProperty(nextidNode, "ddl:datatypePrecision", "0"), is(true));
+ assertThat(verifyProperty(nextidNode, "ddl:datatypeScale", "0"), is(true));
+ assertThat(verifyHasProperty(nextidNode, "ddl:datatypeLength"), is(false));
+ assertThat(verifyMixinType(nextidNode, "ddl:columnDefinition"), is(true));
+
+ SubgraphNode pk_1_Node = tableNode.getNode(path("PK_1"));
+ assertNotNull(pk_1_Node);
+ assertThat(verifyPrimaryType(pk_1_Node, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(pk_1_Node, "ddl:constraintType", "2"), is(true));
+ assertThat(verifyMixinType(pk_1_Node, "ddl:tableConstraint"), is(true));
+
+ // One column reference
+ assertThat(pk_1_Node.getChildren().size(), is(1));
+ SubgraphNode idcontectRefNode = pk_1_Node.getNode(path("IDCONTEXT"));
+ assertNotNull(idcontectRefNode);
+ assertThat(verifyPrimaryType(idcontectRefNode, "nt:unstructured"), is(true));
+ assertThat(verifyMixinType(idcontectRefNode, "ddl:columnReference"), is(true));
}
+
+ @Test
+ public void shouldSequenceStatementsWithDoubleQuotes() throws IOException {
+ //ALTER JAVA CLASS "Agent"
+ // RESOLVER (("/home/java.101/bin/*" pm)(* public))
+ // RESOLVE;
+ //
+ // CREATE SERVER foo FOREIGN DATA WRAPPER "default";
+ //
+ // CREATE RULE "_RETURN" AS
+ // ON SELECT TO t1
+ // DO INSTEAD
+ // SELECT * FROM t2;
+
+ // Subgraph
+ // <name = "/" uuid = "233d07e5-8431-4844-856b-ac80d0129c01">
+ // <name = "statements" primaryType = "nt:unstructured" uuid = "dbd23d78-8005-4b7b-aa61-eac98726b8d4" parserId = "POSTGRES">
+ // <name = "unknownStatement" startLineNumber = "1" primaryType = "nt:unstructured" uuid = "b3fb1e1f-284b-46bd-9a06-86d1b85dd5b3" startColumnNumber = "1" mixinTypes = "ddl:unknownStatement" expression = "ALTER JAVA CLASS "Agent"
+ // RESOLVER (("/home/java.101/bin/*" pm)(* public))
+ // RESOLVE;" startCharIndex = "0">
+ // <name = "CREATE SERVER" startLineNumber = "5" primaryType = "nt:unstructured" uuid = "10217bab-877f-4b45-b169-2f81bb31f620" startColumnNumber = "1" mixinTypes = "postgresddl:createServerStatement" expression = "CREATE SERVER foo FOREIGN DATA WRAPPER "default";" startCharIndex = "93">
+ // <name = "_RETURN" startLineNumber = "7" primaryType = "nt:unstructured" uuid = "2b655039-f239-4930-8c1b-a3b9a8e7c949" startColumnNumber = "1" mixinTypes = "postgresddl:createRuleStatement" expression = "CREATE RULE "_RETURN" AS
+ // ON SELECT TO t1
+ // DO INSTEAD
+ // SELECT * FROM t2;" startCharIndex = "144">
+
+ URL url = this.getClass().getClassLoader().getResource("ddl/d_quoted_statements.ddl");
+ assertThat(url, is(notNullValue()));
+ content = url.openStream();
+ assertThat(content, is(notNullValue()));
+ sequencer.sequence(content, output, context);
+
+ output.close();
+ Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
+ assertThat(subgraph, is(notNullValue()));
+ String value = subgraph.toString();
+ System.out.println(value);
+
+ SubgraphNode rootNode = subgraph.getNode(".");
+ assertThat(rootNode.getChildren().size(), is(1));
+
+ SubgraphNode statementsNode = rootNode.getNode(path("ddl:statements"));
+ assertNotNull(statementsNode);
+ assertThat(statementsNode.getChildren().size(), is(3));
+ assertThat(verifyPrimaryType(statementsNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(statementsNode, "ddl:parserId", "POSTGRES"), is(true));
+
+ SubgraphNode firstNode = statementsNode.getNode(path("unknownStatement"));
+ assertNotNull(firstNode);
+ verifyBaseProperties(firstNode, "nt:unstructured", "1", "1", "0", 0);
+ assertThat(verifyMixinType(firstNode, "ddl:unknownStatement"), is(true));
+
+ SubgraphNode serverNode = statementsNode.getNode(path("CREATE SERVER"));
+ assertNotNull(serverNode);
+ verifyBaseProperties(serverNode, "nt:unstructured", "5", "1", "93", 0);
+ assertThat(verifyMixinType(serverNode, "postgresddl:createServerStatement"), is(true));
+
+ SubgraphNode ruleNode = statementsNode.getNode(path("_RETURN"));
+ assertNotNull(ruleNode);
+ verifyBaseProperties(ruleNode, "nt:unstructured", "7", "1", "144", 0);
+ assertThat(verifyMixinType(ruleNode, "postgresddl:createRuleStatement"), is(true));
+
+ }
+
@Test
- public void shouldSequenceCreateSchema() throws IOException {
- // CREATE SCHEMA hollywood
- // CREATE TABLE films (title varchar(255), release date, producerName varchar(255))
- // CREATE VIEW winners AS
- // SELECT title, release FROM films WHERE producerName IS NOT NULL;
- URL url = this.getClass().getClassLoader().getResource("ddl/create_schema.ddl");
+ public void shouldGenerateNodeTypesForCreateTables() throws IOException {
+ URL url = this.getClass().getClassLoader().getResource("ddl/createTables.ddl");
assertThat(url, is(notNullValue()));
content = url.openStream();
assertThat(content, is(notNullValue()));
sequencer.sequence(content, output, context);
-
+
output.close();
- // File expectedFile = new File("src/test/resources/");
- // if ( expectedFile.exists() ) {
- // expectedGraph.importXmlFrom(expectedFile).into("/");
+ Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
+ assertThat(subgraph, is(notNullValue()));
+ String value = subgraph.toString();
+ System.out.println(value);
+
+ SubgraphNode rootNode = subgraph.getNode(".");
+ assertThat(rootNode.getChildren().size(), is(1));
+
+ SubgraphNode statementsNode = rootNode.getNode(path("ddl:statements"));
+ assertNotNull(statementsNode);
+ assertThat(statementsNode.getChildren().size(), is(20));
+ assertThat(verifyPrimaryType(statementsNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(statementsNode, "ddl:parserId", "SQL92"), is(true));
+
+ // Check one table
+ //CREATE TABLE RT_MDLS
+ //(
+ // MDL_UID NUMERIC(20) NOT NULL,
+ // MDL_UUID VARCHAR(64) NOT NULL,
+ // MDL_NM VARCHAR(255) NOT NULL,
+ // MDL_VERSION VARCHAR(50),
+ // DESCRIPTION VARCHAR(255),
+ // MDL_URI VARCHAR(255),
+ // MDL_TYPE NUMERIC(3),
+ // IS_PHYSICAL CHAR(1) NOT NULL,
+ // MULTI_SOURCED CHAR(1) DEFAULT '0',
+ // VISIBILITY NUMERIC(3)
+ //
+ //);
+ //<name = "RT_MDLS" startLineNumber = "80" primaryType = "nt:unstructured" uuid = "a11e48d5-0908-467b-ba79-a497df87a576" startColumnNumber = "1" mixinTypes = "ddl:createTableStatement" expression = "CREATE TABLE RT_MDLS...." startCharIndex = "2258">
+ // <name = "MDL_UID" datatypeName = "NUMERIC" primaryType = "nt:unstructured" uuid = "85b9c2b3-cadc-425c-a736-656be1475780" datatypePrecision = "20" nullable = "NOT NULL" mixinTypes = "ddl:columnDefinition" datatypeScale = "0">
+ // <name = "MDL_UUID" datatypeName = "VARCHAR" datatypeLength = "64" primaryType = "nt:unstructured" uuid = "88766ab0-32e6-44f6-9244-78d48b2242d4" nullable = "NOT NULL" mixinTypes = "ddl:columnDefinition">
+ // <name = "MDL_NM" datatypeName = "VARCHAR" datatypeLength = "255" primaryType = "nt:unstructured" uuid = "cb29fa8e-03f0-4e82-8040-5d853aa8a1f9" nullable = "NOT NULL" mixinTypes = "ddl:columnDefinition">
+ // <name = "MDL_VERSION" datatypeName = "VARCHAR" datatypeLength = "50" primaryType = "nt:unstructured" uuid = "169a4e2f-79a4-47a4-8e23-4fa1ea09c876" mixinTypes = "ddl:columnDefinition">
+ // <name = "DESCRIPTION" datatypeName = "VARCHAR" datatypeLength = "255" primaryType = "nt:unstructured" uuid = "00682ead-5bb0-4c0d-b243-6edbf56dcb4a" mixinTypes = "ddl:columnDefinition">
+ // <name = "MDL_URI" datatypeName = "VARCHAR" datatypeLength = "255" primaryType = "nt:unstructured" uuid = "851f94e1-5d43-4a58-be6c-720a6c3bec7f" mixinTypes = "ddl:columnDefinition">
+ // <name = "MDL_TYPE" datatypeName = "NUMERIC" primaryType = "nt:unstructured" uuid = "a7b74a6f-872d-4e8b-a2da-4ebf6ef38ed4" datatypePrecision = "3" mixinTypes = "ddl:columnDefinition" datatypeScale = "0">
+ // <name = "IS_PHYSICAL" datatypeName = "CHAR" datatypeLength = "1" primaryType = "nt:unstructured" uuid = "b96aeaaa-4bd8-4154-9daf-50aac2fd9529" nullable = "NOT NULL" mixinTypes = "ddl:columnDefinition">
+ // <name = "MULTI_SOURCED" datatypeName = "CHAR" defaultValue = "'0'" datatypeLength = "1" defaultOption = "0" primaryType = "nt:unstructured" uuid = "75c48a37-f65c-4854-bca4-8d504cf8b658" mixinTypes = "ddl:columnDefinition">
+ // <name = "VISIBILITY" datatypeName = "NUMERIC" primaryType = "nt:unstructured" uuid = "345ac63b-a343-408d-9262-6e009ad3e0c2" datatypePrecision = "3" mixinTypes = "ddl:columnDefinition" datatypeScale = "0">
- //assertThat(graph.getChildren().of("/statements"), hasChildren(segment("hollywood")));
+ SubgraphNode tableNode = statementsNode.getNode(path("RT_MDLS"));
+ assertNotNull(tableNode);
+ verifyBaseProperties(tableNode, "nt:unstructured", "80", "1", "2258", 10);
+ assertThat(verifyMixinType(tableNode, "ddl:createTableStatement"), is(true));
+ // Check Column Properties
+ SubgraphNode node_1 = tableNode.getNode(path("MDL_UUID"));
+ assertNotNull(node_1);
+ assertThat(verifyPrimaryType(node_1, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(node_1, "ddl:datatypeName", "VARCHAR"), is(true));
+ assertThat(verifyProperty(node_1, "ddl:datatypeLength", "64"), is(true));
+ assertThat(verifyMixinType(node_1, "ddl:columnDefinition"), is(true));
+ SubgraphNode node_2 = tableNode.getNode(path("MDL_TYPE"));
+ assertNotNull(node_2);
+ assertThat(verifyPrimaryType(node_2, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(node_2, "ddl:datatypeName", "NUMERIC"), is(true));
+ assertThat(verifyProperty(node_2, "ddl:datatypePrecision", "3"), is(true));
+ assertThat(verifyProperty(node_2, "ddl:datatypeScale", "0"), is(true));
+ assertThat(verifyHasProperty(node_2, "ddl:datatypeLength"), is(false));
+ assertThat(verifyMixinType(node_2, "ddl:columnDefinition"), is(true));
+ }
+
+ @Test
+ public void shouldSequenceDerbyDdl() throws IOException {
+ URL url = this.getClass().getClassLoader().getResource("ddl/dialect/derby/derby_test_statements.ddl");
+ assertThat(url, is(notNullValue()));
+ content = url.openStream();
+ assertThat(content, is(notNullValue()));
+ sequencer.sequence(content, output, context);
+ output.close();
+
Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
assertThat(subgraph, is(notNullValue()));
- //assertThat(subgraph.getNode("/statements"), is(notNullValue()));
- //assertThat(subgraph.getNode(".").getChildren(), hasChildren(segment("statements")));
- //Iterator<SubgraphNode> actualIter = actual.iterator();
+ String value = subgraph.toString();
+ System.out.println(value);
SubgraphNode rootNode = subgraph.getNode(".");
assertThat(rootNode.getChildren().size(), is(1));
- Iterator<SubgraphNode> expected = subgraph.iterator();
- while ( expected.hasNext() ) {
- SubgraphNode nextNode = expected.next();
- System.out.println("\n NODE = " + nextNode);
- System.out.println(" PATH = " + nextNode.getLocation().getPath());
- Map<Name,Property> actualProperties = nextNode.getPropertiesByName();
- for(Name nextKey: actualProperties.keySet()) {
- Property nextValue = actualProperties.get(nextKey);
- System.out.println(" KEY = " + nextKey + " VALUE = " + nextValue.getFirstValue());
- }
- }
- //SubgraphNode schemaNode = rootNode.getNode(path("ddl:statements"));
- //assertThat(schemaNode.getChildren().size(), is(2));
+ SubgraphNode statementsNode = rootNode.getNode(path("ddl:statements"));
+ assertNotNull(statementsNode);
+ assertThat(statementsNode.getChildren().size(), is(64));
+ assertThat(verifyPrimaryType(statementsNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(statementsNode, "ddl:parserId", "DERBY"), is(true));
+ // CREATE INDEX IXSALE ON SAMP.SALES (SALES);
+ // <name = "IXSALE" startLineNumber = "87" primaryType = "nt:unstructured" uuid = "85740506-ac6e-46f3-8118-be0c9eb1bc57" startColumnNumber = "1" mixinTypes = "derbyddl:createIndexStatement" tableName = "SAMP.SALES" expression = "CREATE INDEX IXSALE ON SAMP.SALES (SALES);" unique = "false" startCharIndex = "2886">
- // Subgraph expected = expectedGraph.getSubgraphOfDepth(10).at("/");
- // // compare subgraphs ...
- // Iterator<SubgraphNode> actualIter = actual.iterator();
- // Iterator<SubgraphNode> expectedIter = expected.iterator();
- // while ( actualIter.hasNext() && expectedIter.hasNext() ) {
- // SubgraphNode actualNode = actualIter.next();
- // SubgraphNode expectedNode = expectedIter.next();
- // // Get properties
- // Map<Name,Property> actualProperties = actualNode.getPropertiesByName();
- // Map<Name,Property> expectedProperties = expectedNode.getPropertiesByName();
- // // The property names should be the same ...
- // Set<Name> actualPropertyNames = actualProperties.keySet();
- // Set<Name> expectedPropertyNames = expectedProperties.keySet();
- // assertThat(actualPropertyNames,is(expectedPropertyNames));
- // // compare the properties ...
- // for ( Name name : actualPropertyNames ) {
- // Property actualProp = actualProperties.get(name);
- // Property expectedProp = expectedProperties.get(name);
- // // etc.
- // }
- // }
- // assertThat(actualIter.hasNext(), is(false));
- // assertThat(expectedIter.hasNext(), is(false));
+ SubgraphNode indexNode = statementsNode.getNode(path("IXSALE"));
+ assertNotNull(indexNode);
+ verifyBaseProperties(indexNode, "nt:unstructured", "87", "1", "2886", 0);
+ assertThat(verifyMixinType(indexNode, "derbyddl:createIndexStatement"), is(true));
+
+ // CREATE SCHEMA FLIGHTS AUTHORIZATION anita;
+ // <name = "FLIGHTS" startLineNumber = "98" primaryType = "nt:unstructured" uuid = "e1c8227d-c663-4d4b-8506-b1e41aa1f7f6" startColumnNumber = "1" mixinTypes = "ddl:createSchemaStatement" expression = "CREATE SCHEMA FLIGHTS AUTHORIZATION anita;" startCharIndex = "3218">
+ SubgraphNode schemaNode = statementsNode.getNode(path("FLIGHTS"));
+ assertNotNull(schemaNode);
+ verifyBaseProperties(schemaNode, "nt:unstructured", "98", "1", "3218", 0);
+ assertThat(verifyMixinType(schemaNode, "ddl:createSchemaStatement"), is(true));
+ assertThat(verifyExpression(schemaNode, "CREATE SCHEMA FLIGHTS AUTHORIZATION anita;"), is(true));
+
+ // DROP PROCEDURE some_procedure_name;
+ // <name = "unknownStatement[3]" startLineNumber = "172" primaryType = "nt:unstructured" uuid = "1f57c0ec-4361-4f64-963d-dcb919c27656" startColumnNumber = "1" mixinTypes = "ddl:unknownStatement" expression = "DROP PROCEDURE some_procedure_name;" startCharIndex = "5438">
+ SubgraphNode unknownNode_1 = statementsNode.getNode(path("some_procedure_name"));
+ assertNotNull(unknownNode_1);
+ verifyBaseProperties(unknownNode_1, "nt:unstructured", "172", "1", "5438", 0);
+ assertThat(verifyMixinType(unknownNode_1, "derbyddl:dropProcedureStatement"), is(true));
+ assertThat(verifyExpression(unknownNode_1, "DROP PROCEDURE some_procedure_name;"), is(true));
+
+ //ALTER TABLE SAMP.DEPARTMENT
+ // ADD CONSTRAINT NEW_UNIQUE UNIQUE (DEPTNO);
+
+ //<name = "SAMP.DEPARTMENT" startLineNumber = "16" primaryType = "nt:unstructured" uuid = "b3c54a3c-4779-48a0-a2f3-80e5079bb62c" startColumnNumber = "1" mixinTypes = "ddl:alterTableStatement" expression = "ALTER TABLE SAMP.DEPARTMENT
+ // ADD CONSTRAINT NEW_UNIQUE UNIQUE (DEPTNO);
//
- // } else {
- // // write out the actual graph to the expected file
- // }
- //System.out.println(subgraph);
+ //-- add a new foreign key constraint to the
+ //-- Cities table. Each row in Cities is checked
+ //-- to make sure it satisfied the constraints.
+ //-- if any rows don't satisfy the constraint, the
+ //-- constraint is not added" startCharIndex = "478">
+ // <name = "NEW_UNIQUE" primaryType = "nt:unstructured" uuid = "c678bb9d-a0ac-4f69-b8a0-ec890557bc20" mixinTypes = "ddl:addTableConstraintDefinition" constraintType = "0">
+ // <name = "DEPTNO" primaryType = "nt:unstructured" uuid = "0f019782-e72d-485a-8f8c-e62954fd6ae6" mixinTypes = "ddl:columnReference">
+ SubgraphNode alterTableNode = statementsNode.getNode(path("SAMP.DEPARTMENT"));
+ assertNotNull(alterTableNode);
+ verifyBaseProperties(alterTableNode, "nt:unstructured", "16", "1", "478", 1);
+ assertThat(verifyMixinType(alterTableNode, "ddl:alterTableStatement"), is(true));
+
+ SubgraphNode uniqueNode = alterTableNode.getNode(path("NEW_UNIQUE"));
+ assertNotNull(uniqueNode);
+ assertThat(verifyPrimaryType(uniqueNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(uniqueNode, "ddl:constraintType", "0"), is(true));
+ assertThat(verifyMixinType(uniqueNode, "ddl:addTableConstraintDefinition"), is(true));
+
+ // One column reference
+ assertThat(uniqueNode.getChildren().size(), is(1));
+ SubgraphNode colRefNode = uniqueNode.getNode(path("DEPTNO"));
+ assertNotNull(colRefNode);
+ assertThat(verifyPrimaryType(colRefNode, "nt:unstructured"), is(true));
+ assertThat(verifyMixinType(colRefNode, "ddl:columnReference"), is(true));
+ }
- // Map<Property> props = output.getProperties(nodePath)
+ @Test
+ public void shouldSequenceOracleDdl() throws IOException {
+ URL url = this.getClass().getClassLoader().getResource("ddl/dialect/oracle/oracle_test_statements_2.ddl");
+ assertThat(url, is(notNullValue()));
+ content = url.openStream();
+ assertThat(content, is(notNullValue()));
+ sequencer.sequence(content, output, context);
+
+ output.close();
+
+ Subgraph subgraph = graph.getSubgraphOfDepth(10).at("/");
+ assertThat(subgraph, is(notNullValue()));
+ String value = subgraph.toString();
+ System.out.println(value);
+
+ SubgraphNode rootNode = subgraph.getNode(".");
+ assertThat(rootNode.getChildren().size(), is(1));
+
+ SubgraphNode statementsNode = rootNode.getNode(path("ddl:statements"));
+ assertNotNull(statementsNode);
+ assertThat(statementsNode.getChildren().size(), is(50));
+ assertThat(verifyPrimaryType(statementsNode, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(statementsNode, "ddl:parserId", "ORACLE"), is(true));
+
+ // <name = "CREATE OR REPLACE DIRECTORY" startLineNumber = "164" primaryType = "nt:unstructured" uuid = "c45eb2bb-1b85-469d-9dfc-0012fdfd8ac4" startColumnNumber = "1" mixinTypes = "oracleddl:createDirectoryStatement" expression = "CREATE OR REPLACE DIRECTORY bfile_dir AS '/private1/LOB/files';" startCharIndex = "3887">
+ SubgraphNode createOrReplDirNode = statementsNode.getNode(path("CREATE OR REPLACE DIRECTORY"));
+ assertNotNull(createOrReplDirNode);
+ verifyBaseProperties(createOrReplDirNode, "nt:unstructured", "164", "1", "3887", 0);
+ assertThat(verifyMixinType(createOrReplDirNode, "oracleddl:createDirectoryStatement"), is(true));
+
+ // <name = "countries" startLineNumber = "9" primaryType = "nt:unstructured" uuid = "70f45acc-57b0-41c9-b166-bcba4f8c75b8" startColumnNumber = "1" mixinTypes = "ddl:alterTableStatement" expression = "ALTER TABLE countries
+ // ADD (duty_pct NUMBER(2,2) CHECK (duty_pct < 10.5),
+ // visa_needed VARCHAR2(3));" startCharIndex = "89">
+ // <name = "duty_pct" datatypeName = "NUMBER" primaryType = "nt:unstructured" uuid = "20079cae-5de1-425c-925e-df230410ea69" datatypePrecision = "2" mixinTypes = "ddl:columnDefinition" datatypeScale = "2">
+ // <name = "CHECK_1" primaryType = "nt:unstructured" name = "CHECK_1" uuid = "210039d7-ebe7-47a8-94be-c3adb70b2885" mixinTypes = "ddl:addTableConstraintDefinition" constraintType = "3" searchCondition = "( duty_pct < 10 . 5 )">
+ // <name = "visa_needed" datatypeName = "VARCHAR2" datatypeLength = "3" primaryType = "nt:unstructured" uuid = "b7b6bf1d-6a2b-411a-aa63-974d13ba20e8" mixinTypes = "ddl:columnDefinition">
+ SubgraphNode countriesNode = statementsNode.getNode(path("countries"));
+ assertNotNull(countriesNode);
+ verifyBaseProperties(countriesNode, "nt:unstructured", "9", "1", "89", 3);
+ assertThat(verifyMixinType(countriesNode, "ddl:alterTableStatement"), is(true));
+
+ SubgraphNode duty_pct_node = countriesNode.getNode(path("duty_pct"));
+ assertNotNull(duty_pct_node);
+ assertThat(verifyPrimaryType(duty_pct_node, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(duty_pct_node, "ddl:datatypeName", "NUMBER"), is(true));
+ assertThat(verifyProperty(duty_pct_node, "ddl:datatypePrecision", "2"), is(true));
+ assertThat(verifyProperty(duty_pct_node, "ddl:datatypeScale", "2"), is(true));
+ assertThat(verifyHasProperty(duty_pct_node, "ddl:datatypeLength"), is(false));
+ assertThat(verifyMixinType(duty_pct_node, "ddl:columnDefinition"), is(true));
+
+ SubgraphNode check_1_node = countriesNode.getNode(path("CHECK_1"));
+ assertNotNull(check_1_node);
+ assertThat(verifyPrimaryType(check_1_node, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(check_1_node, "ddl:constraintType", "3"), is(true));
+ assertThat(verifyMixinType(check_1_node, "ddl:addTableConstraintDefinition"), is(true));
+ assertThat(verifyProperty(check_1_node, "ddl:searchCondition", "( duty_pct < 10 . 5 )"), is(true));
+
+ SubgraphNode visa_needed_node = countriesNode.getNode(path("visa_needed"));
+ assertNotNull(visa_needed_node);
+ assertThat(verifyPrimaryType(visa_needed_node, "nt:unstructured"), is(true));
+ assertThat(verifyProperty(visa_needed_node, "ddl:datatypeName", "VARCHAR2"), is(true));
+ assertThat(verifyProperty(visa_needed_node, "ddl:datatypeLength", "3"), is(true));
+ assertThat(verifyMixinType(visa_needed_node, "ddl:columnDefinition"), is(true));
+
+ // <name = "app_user1" startLineNumber = "33" primaryType = "nt:unstructured" uuid = "8c660ae8-2078-4263-a0e7-8f517cefd3a0" startColumnNumber = "1" mixinTypes = "oracleddl:alterUserStatement" expression = "ALTER USER app_user1
+ // GRANT CONNECT THROUGH sh
+ // WITH ROLE warehouse_user;" startCharIndex = "624">
+
+ SubgraphNode app_user1Node = statementsNode.getNode(path("app_user1"));
+ assertNotNull(app_user1Node);
+ verifyBaseProperties(app_user1Node, "nt:unstructured", "33", "1", "624", 0);
+ assertThat(verifyMixinType(app_user1Node, "oracleddl:alterUserStatement"), is(true));
}
-
}
Modified: trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/StandardDdlParserTest.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/StandardDdlParserTest.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/StandardDdlParserTest.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -131,6 +131,12 @@
tokens = getTokens(content);
result = parser.parseName(tokens);
assertEquals(targetName, result);
+
+ content = "\"_RETURN\"";
+ targetName = "_RETURN";
+ tokens = getTokens(content);
+ result = parser.parseName(tokens);
+ assertEquals(targetName, result);
}
@Test
@@ -674,7 +680,7 @@
String content = getFileContent(DDL_FILE_PATH + "createTables.ddl");
boolean success = parser.parse(content, rootNode);
- assertThat(rootNode.getChildCount(), is(22));
+ assertThat(rootNode.getChildCount(), is(20));
assertThat(success, is(true));
List<AstNode> theNodes = parser.nodeFactory().getChildrenForType(rootNode, TYPE_CREATE_TABLE_STATEMENT);
@@ -810,5 +816,22 @@
assertThat(schemaNodes.get(0).getName().getString(), is("GLOBALFORCEMGMT"));
}
+
+ @Test
+ public void shouldParseStatementsWithDoubleQuotes() {
+ printTest("shouldParseUnterminatedOracleFile()");
+ String content = "ALTER JAVA CLASS \"Agent\""
+ + "RESOLVER ((\"/home/java.101/bin/*\" pm)(* public)) RESOLVE;"
+ + "CREATE SERVER foo FOREIGN DATA WRAPPER \"default\";"
+ + "CREATE RULE \"_RETURN\" AS ON SELECT TO t1 DO INSTEAD SELECT * FROM t2;";
+ // parser.setTestMode(true);
+
+ boolean success = parser.parse(content, rootNode);
+
+ assertThat(success, is(true));
+
+ assertThat(rootNode.getChildCount(), is(3));
+
+ }
}
Modified: trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/dialect/derby/DerbyDdlParserTest.java
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/dialect/derby/DerbyDdlParserTest.java 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/test/java/org/jboss/dna/sequencer/ddl/dialect/derby/DerbyDdlParserTest.java 2009-12-03 22:16:50 UTC (rev 1394)
@@ -69,6 +69,15 @@
assertThat(true, is(success));
}
+ // DROP PROCEDURE some_procedure_name;
+ @Test
+ public void shouldParseDropProcedure() {
+ printTest("shouldParseDropProcedure()");
+ String content = "DROP PROCEDURE some_procedure_name";
+
+ boolean success = parser.parse(content, rootNode);
+ assertThat(true, is(success));
+ }
@Test
Modified: trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/createTables.ddl
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/createTables.ddl 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/createTables.ddl 2009-12-03 22:16:50 UTC (rev 1394)
@@ -24,8 +24,8 @@
ENGINE_IND_CODE CHAR(3)
);
-SET DEFINE OFF;
-SET DEFINE ON;
+-- SET DEFINE OFF;
+-- SET DEFINE ON;
ALTER TABLE ACFT_TYPE
Modified: trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/create_schema.ddl
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/create_schema.ddl 2009-12-03 22:14:00 UTC (rev 1393)
+++ trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/create_schema.ddl 2009-12-03 22:16:50 UTC (rev 1394)
@@ -1,4 +1,3 @@
CREATE SCHEMA hollywood
CREATE TABLE films (title varchar(255), release date, producerName varchar(255))
- CREATE VIEW winners AS
- SELECT title, release FROM films WHERE producerName IS NOT NULL;
\ No newline at end of file
+ CREATE VIEW winners AS SELECT title, release FROM films WHERE producerName IS NOT NULL;
\ No newline at end of file
Added: trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/d_quoted_statements.ddl
===================================================================
--- trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/d_quoted_statements.ddl (rev 0)
+++ trunk/extensions/dna-sequencer-ddl/src/test/resources/ddl/d_quoted_statements.ddl 2009-12-03 22:16:50 UTC (rev 1394)
@@ -0,0 +1,10 @@
+ALTER JAVA CLASS "Agent"
+ RESOLVER (("/home/java.101/bin/*" pm)(* public))
+ RESOLVE;
+
+CREATE SERVER foo FOREIGN DATA WRAPPER "default";
+
+CREATE RULE "_RETURN" AS
+ ON SELECT TO t1
+ DO INSTEAD
+ SELECT * FROM t2;
\ No newline at end of file
14 years, 6 months
DNA SVN: r1393 - trunk/dna-jcr/src/test/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-03 17:14:00 -0500 (Thu, 03 Dec 2009)
New Revision: 1393
Modified:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java
Log:
DNA-456 Added different print statements when failure occurs to hopefully shed some light on why some tests are failing on the build box.
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java 2009-12-03 22:10:38 UTC (rev 1392)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java 2009-12-03 22:14:00 UTC (rev 1393)
@@ -188,11 +188,11 @@
void checkResults( TestListener listener ) {
if ( listener.getActualEventCount() != listener.getExpectedEventCount() ) {
// Wrong number ...
- System.out.println("Received incorrect number of events. Actual events were: ");
+ StringBuilder sb = new StringBuilder(" Actual events were: ");
for ( Event event : listener.getEvents() ) {
- System.out.println(event);
+ sb.append('\n').append(event);
}
- assertThat("Received incorrect number of events", listener.getActualEventCount(), is(listener.getExpectedEventCount()));
+ assertThat("Received incorrect number of events."+ sb.toString(), listener.getActualEventCount(), is(listener.getExpectedEventCount()));
assertThat(listener.getErrorMessage(), listener.getErrorMessage(), is(nullValue()));
}
}
14 years, 6 months
DNA SVN: r1392 - trunk/docs/reference/src/main/docbook/en-US/content/sequencers.
by dna-commits@lists.jboss.org
Author: blafond
Date: 2009-12-03 17:10:38 -0500 (Thu, 03 Dec 2009)
New Revision: 1392
Modified:
trunk/docs/reference/src/main/docbook/en-US/content/sequencers/ddl.xml
Log:
DNA-49 Updated doc section and content for new DDL Sequencer to include example DDL and node properties.
Modified: trunk/docs/reference/src/main/docbook/en-US/content/sequencers/ddl.xml
===================================================================
--- trunk/docs/reference/src/main/docbook/en-US/content/sequencers/ddl.xml 2009-12-03 22:09:38 UTC (rev 1391)
+++ trunk/docs/reference/src/main/docbook/en-US/content/sequencers/ddl.xml 2009-12-03 22:10:38 UTC (rev 1392)
@@ -64,7 +64,35 @@
</listitem>
</itemizedlist>
</para>
+ <sect1>
+ <title>Example</title>
+ <para>Sequencing results in graph nodes basically representing the BNF structure of each DDL statement. Below is an example DDL
+ schema definition statement containing table and view definition statements.
+ </para>
+ <programlisting>
+CREATE SCHEMA hollywood
+ CREATE TABLE films (title varchar(255), release date, producerName varchar(255))
+ CREATE VIEW winners AS SELECT title, release FROM films WHERE producerName IS NOT NULL;
+ </programlisting>
+ <para>The resulting graph structure, shown below contains the raw statement expression, pertinent table, column and key
+ reference information as well as critical integer position values (line number, column number and character index) to
+ tie the statement back to the original DDL file.
+ </para>
+ <programlisting>
+ <![CDATA[
+<name = "statements" primaryType = "nt:unstructured" uuid = "ee3db6e6-fa59-46db-bd3f-c555b4fa4a50" parserId = "POSTGRES">
+ <name = "hollywood" startLineNumber = "1" primaryType = "nt:unstructured" uuid = "3e084a7d-7da8-4068-9b03-b1aed9ac9c7a" startColumnNumber = "1" mixinTypes = "ns001:createSchemaStatement" expression = "CREATE SCHEMA hollywood" startCharIndex = "0">
+ <name = "films" startLineNumber = "2" primaryType = "nt:unstructured" uuid = "b622cdcb-69fa-4aa2-8510-f35c0a8ddcbe" startColumnNumber = "5" mixinTypes = "ns001:createTableStatement" expression = "CREATE TABLE films (title varchar(255), release date, producerName varchar(255))" startCharIndex = "28">
+ <name = "title" datatypeName = "VARCHAR" datatypeLength = "255" primaryType = "nt:unstructured" uuid = "d7e962bb-cd37-4df4-ab53-ab78fd72c153" mixinTypes = "ns001:columnDefinition">
+ <name = "release" datatypeName = "DATE" primaryType = "nt:unstructured" uuid = "83aa7c21-82f7-416e-8c23-5c308a1c4257" mixinTypes = "ns001:columnDefinition">
+ <name = "producerName" datatypeName = "VARCHAR" datatypeLength = "255" primaryType = "nt:unstructured" uuid = "a51ed903-4d2c-4cd9-83e2-a76884b923aa" mixinTypes = "ns001:columnDefinition">
+ <name = "winners" startLineNumber = "3" primaryType = "nt:unstructured" uuid = "9eeef501-ad7e-4e25-9891-b86485e48dc1" startColumnNumber = "5" mixinTypes = "ns001:createViewStatement" expression = "CREATE VIEW winners AS SELECT title, release FROM films WHERE producerName IS NOT NULL;" queryExpression = " SELECT title, release FROM films WHERE producerName IS NOT NULL" startCharIndex = "113">
+ ]]>
+ </programlisting>
+ </sect1>
<para>
+ </para>
+ <para>
To use this sequencer, simply include the <code>dna-sequencer-ddl</code> JAR
in your application and configure the &JcrConfiguration; to use this sequencer using something similar to:
</para>
14 years, 6 months
DNA SVN: r1391 - in trunk/dna-graph/src: test/java/org/jboss/dna/graph and 1 other directory.
by dna-commits@lists.jboss.org
Author: blafond
Date: 2009-12-03 17:09:38 -0500 (Thu, 03 Dec 2009)
New Revision: 1391
Modified:
trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
Log:
DNA-569 enhanced the subgraph's toString() method to show recursive nodes and properties.
Modified: trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java
===================================================================
--- trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-12-03 22:08:04 UTC (rev 1390)
+++ trunk/dna-graph/src/main/java/org/jboss/dna/graph/Graph.java 2009-12-03 22:09:38 UTC (rev 1391)
@@ -63,6 +63,7 @@
import org.jboss.dna.graph.property.Property;
import org.jboss.dna.graph.property.PropertyFactory;
import org.jboss.dna.graph.property.Reference;
+import org.jboss.dna.graph.property.ValueFactory;
import org.jboss.dna.graph.property.ValueFormatException;
import org.jboss.dna.graph.property.Path.Segment;
import org.jboss.dna.graph.query.QueryContext;
@@ -6969,8 +6970,42 @@
@Override
public String toString() {
- return "Subgraph " + getLocation().toString();
+ return "Subgraph\n" + getToString(context); //ExecutionContext.DEFAULT_CONTEXT);//getLocation().toString();
}
+
+ /**
+ * Get the string representation of this subgraph tree.
+ *
+ * @param context the execution context in which the conversion is to take place
+ * @return the string representation; never null
+ */
+ public String getToString( ExecutionContext context ) {
+ StringBuilder sb = new StringBuilder();
+ getRecursiveString(context, getRoot(), sb, 0);
+ return sb.toString();
+ }
+
+ private void getRecursiveString( ExecutionContext context,
+ SubgraphNode node,
+ StringBuilder str,
+ int indentLevel ) {
+ for (int i = 0; i < indentLevel; ++i) {
+ str.append(" ");
+ }
+ str.append(node.toString());
+
+ // Recursively add children at one greater tab level
+ for (Location nextLoc : node.getChildren()) {
+ SubgraphNode childNode = getNode(nextLoc);
+ // child node location may exist, but the subgraph may not have
+ // been constructed deep enough to instantiate the subnode, so
+ // check for null
+ if( childNode != null ) {
+ getRecursiveString(context, childNode, str, indentLevel + 1);
+ }
+ }
+ }
+
}
protected static final List<Location> NO_CHILDREN = Collections.emptyList();
@@ -7064,8 +7099,71 @@
@Override
public String toString() {
- return "Node " + getLocation().toString();
+ return getNodeString(context, location);
}
+
+ private String getNodeString( ExecutionContext context,
+ Location location) {
+ StringBuilder sb = new StringBuilder();
+ sb.append('<'); // Bracket the node
+ ValueFactory<String> strings = context.getValueFactories().getStringFactory();
+
+ String name = "";
+ if( location.getPath().getLastSegment() != null ) {
+ name = strings.create(location.getPath().getLastSegment());
+ } else {
+ name = strings.create(location.getPath());
+ }
+
+ if( name.startsWith("{")) {
+ // Remove {xxxx} namespace prefix
+ int end = name.indexOf('}');
+ name = name.substring(end+1, name.length());
+ }
+
+ // Surround name in double quotes
+ sb.append("name = ").append('\"').append(name).append('\"').append(" ");
+ boolean first = true;
+ if (getProperties() != null) {
+ for ( Property entry : getProperties()) {
+
+ if( first ) {
+ first = false;
+ } else sb.append(" ");
+ sb.append(getPropertyString(entry));
+ }
+ }
+ sb.append(">\n");
+
+ return sb.toString();
+ }
+
+ private String getPropertyString(Property property) {
+ // Surround property value in double quotes so final property looks like:
+ // color = "blue" (single valued property)
+ // colors = ["blue", "red", "green"] (multi-valued property)
+
+ StringBuilder sb = new StringBuilder();
+ sb.append(property.getName().getLocalName());
+ sb.append(" = ");
+ if (property.isEmpty()) {
+ sb.append("null");
+ } else if( property.isSingle() ) {
+ String valueStr = getContext().getValueFactories().getStringFactory().create(property.getValues().next());
+ sb.append('\"').append(valueStr).append('\"');
+ } else {
+ sb.append('[');
+ boolean first = true;
+ for (Object value : property.getValuesAsArray()) {
+ if (first) first = false;
+ else sb.append(",");
+ String valueStr = getContext().getValueFactories().getStringFactory().create(value);
+ sb.append('\"').append(valueStr).append('\"');
+ }
+ if (property.isMultiple()) sb.append(']');
+ }
+ return sb.toString();
+ }
}
// ----------------------------------------------------------------------------------------------------------------
Modified: trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java
===================================================================
--- trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-12-03 22:08:04 UTC (rev 1390)
+++ trunk/dna-graph/src/test/java/org/jboss/dna/graph/GraphTest.java 2009-12-03 22:09:38 UTC (rev 1391)
@@ -877,7 +877,47 @@
assertThat(node3.getChildren().isEmpty(), is(true));
assertThat(node3.getProperties().isEmpty(), is(true));
}
+
+ @Test
+ public void shouldConstructValidSubgraphToString() {
+ Location child1 = Location.create(createPath(validPath, "x"));
+ Location child2 = Location.create(createPath(validPath, "y"));
+ Location child3 = Location.create(createPath(validPath, "z"));
+ setChildrenToReadOn(Location.create(validPath), child1, child2, child3);
+ Location child11 = Location.create(createPath(child1.getPath(), "h"));
+ Location child12 = Location.create(createPath(child1.getPath(), "i"));
+ Location child13 = Location.create(createPath(child1.getPath(), "j"));
+ setChildrenToReadOn(child1, child11, child12, child13);
+ Location child121 = Location.create(createPath(child12.getPath(), "m"));
+ Location child122 = Location.create(createPath(child12.getPath(), "n"));
+ Location child123 = Location.create(createPath(child12.getPath(), "o"));
+ setChildrenToReadOn(child12, child121, child122, child123);
+ setPropertiesToReadOn(Location.create(validPath), validIdProperty1, validIdProperty2);
+ setPropertiesToReadOn(child1, validIdProperty1);
+ setPropertiesToReadOn(child2, validIdProperty2);
+ setPropertiesToReadOn(child11, validIdProperty1);
+ setPropertiesToReadOn(child12, validIdProperty2);
+ setPropertiesToReadOn(child121, validIdProperty1);
+ setPropertiesToReadOn(child122, validIdProperty2);
+
+ Subgraph subgraph = graph.getSubgraphOfDepth(2).at(validPath);
+ assertThat(subgraph, is(notNullValue()));
+ assertThat(subgraph.getMaximumDepth(), is(2));
+
+ String expectedToStringValue =
+ "Subgraph\n"
+ + "<name = \"c\" id2 = \"2\" id1 = \"1\">\n"
+ + " <name = \"x\" id1 = \"1\">\n"
+ + " <name = \"y\" id2 = \"2\">\n"
+ + " <name = \"z\" >\n";
+
+ // Get nodes by relative path ...
+ Node root = subgraph.getNode("./");
+ assertThat(root.getChildren(), hasItems(child1, child2, child3));
+ assertThat(subgraph.toString(), is(expectedToStringValue));
+ }
+
// ----------------------------------------------------------------------------------------------------------------
// Batched requests
// ----------------------------------------------------------------------------------------------------------------
14 years, 6 months
DNA SVN: r1390 - trunk/dna-jcr/src/test/java/org/jboss/dna/jcr.
by dna-commits@lists.jboss.org
Author: rhauch
Date: 2009-12-03 17:08:04 -0500 (Thu, 03 Dec 2009)
New Revision: 1390
Modified:
trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java
Log:
DNA-456 Added different print statements when failure occurs to hopefully shed some light on why some tests are failing on the build box.
Modified: trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java
===================================================================
--- trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java 2009-12-03 22:01:45 UTC (rev 1389)
+++ trunk/dna-jcr/src/test/java/org/jboss/dna/jcr/JcrObservationManagerTest.java 2009-12-03 22:08:04 UTC (rev 1390)
@@ -186,8 +186,15 @@
}
void checkResults( TestListener listener ) {
- assertThat("Received incorrect number of events", listener.getActualEventCount(), is(listener.getExpectedEventCount()));
- assertThat(listener.getErrorMessage(), listener.getErrorMessage(), is(nullValue()));
+ if ( listener.getActualEventCount() != listener.getExpectedEventCount() ) {
+ // Wrong number ...
+ System.out.println("Received incorrect number of events. Actual events were: ");
+ for ( Event event : listener.getEvents() ) {
+ System.out.println(event);
+ }
+ assertThat("Received incorrect number of events", listener.getActualEventCount(), is(listener.getExpectedEventCount()));
+ assertThat(listener.getErrorMessage(), listener.getErrorMessage(), is(nullValue()));
+ }
}
boolean containsPath( TestListener listener,
14 years, 6 months