openjpa-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p..@apache.org
Subject svn commit: r627979 [37/39] - in /openjpa/trunk: openjpa-lib/src/test/java/org/apache/openjpa/lib/test/ openjpa-persistence-jdbc/ openjpa-persistence-jdbc/src/test/java/ openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/ openjpa-per...
Date Fri, 15 Feb 2008 09:20:40 GMT
Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest2.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class RuntimeTest2
+    extends RuntimeTest1 {
+
+    private int intField2;
+
+    public RuntimeTest2() {
+    }
+
+    public RuntimeTest2(String str, int i) {
+        super(str, i);
+    }
+
+    public int getIntField2() {
+        return this.intField2;
+    }
+
+    public void setIntField2(int intField2) {
+        this.intField2 = intField2;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest3.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest3.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest3.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/RuntimeTest3.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class RuntimeTest3
+    extends RuntimeTest2 {
+
+    private int intField3;
+
+    public RuntimeTest3() {
+    }
+
+    public RuntimeTest3(String str, int i) {
+        super(str, i);
+    }
+
+    public int getIntField3() {
+        return this.intField3;
+    }
+
+    public void setIntField3(int intField3) {
+        this.intField3 = intField3;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class SequenceAssigned {
+
+    private long pk;
+    private SequenceAssigned other;
+
+    public void setPK(long l) {
+        pk = l;
+    }
+
+    public long getPK() {
+        return pk;
+    }
+
+    public void setOther(SequenceAssigned other) {
+        this.other = other;
+    }
+
+    public SequenceAssigned getOther() {
+        return other;
+    }
+
+    public static class Id implements java.io.Serializable {
+
+        public long pk;
+
+        public Id() {
+        }
+
+        public Id(String str) {
+            pk = Long.parseLong(str);
+        }
+
+        public int hashCode() {
+            return (int) (pk % (long) Integer.MAX_VALUE);
+        }
+
+        public String toString() {
+            return pk + "";
+        }
+
+        public boolean equals(Object o) {
+            if (o == null || !(o instanceof Id))
+                return false;
+            return pk == ((Id) o).pk;
+        }
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned2.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned2.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned2.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned2.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class SequenceAssigned2 extends SequenceAssigned {
+
+    private int foo;
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned3.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned3.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned3.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/SequenceAssigned3.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class SequenceAssigned3 {
+
+    private Long pk;
+
+    public void setPK(Long l) {
+        pk = l;
+    }
+
+    public Long getPK() {
+        return pk;
+    }
+
+    public static class Id implements java.io.Serializable {
+
+        public Long pk;
+
+        public Id() {
+        }
+
+        public Id(String str) {
+            pk = Long.valueOf(str);
+        }
+
+        public int hashCode() {
+            return (int) (pk == null ? 0 : pk.longValue()
+                % (long) Integer.MAX_VALUE);
+        }
+
+        public String toString() {
+            return pk + "";
+        }
+
+        public boolean equals(Object o) {
+            if (o == null || !(o instanceof Id))
+                return false;
+            return pk == ((Id) o).pk;
+        }
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/TransactionalClassPC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/TransactionalClassPC.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/TransactionalClassPC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/TransactionalClassPC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+/**
+ * <p>Persitent type used in testing.</p>
+ *
+ * @author Abe White
+ */
+
+@Entity
+public class TransactionalClassPC {
+
+    private int intField;
+
+    public int getIntField() {
+        return this.intField;
+    }
+
+    public void setIntField(int intField) {
+        this.intField = intField;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/ValueStrategyPC.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/ValueStrategyPC.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/ValueStrategyPC.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/meta/common/apps/ValueStrategyPC.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.meta.common.apps;
+
+import javax.persistence.Entity;
+
+@Entity
+public class ValueStrategyPC {
+
+    private String uuid;
+    private String uuidHex;
+    private String name;
+    private int ignoreUpdate;
+    private int restrictUpdate;
+    private int version;
+    private int sequence;
+
+    public String getName() {
+        return this.name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getIgnoreUpdate() {
+        return this.ignoreUpdate;
+    }
+
+    public void setIgnoreUpdate(int ignoreUpdate) {
+        this.ignoreUpdate = ignoreUpdate;
+    }
+
+    public int getRestrictUpdate() {
+        return this.restrictUpdate;
+    }
+
+    public void setRestrictUpdate(int restrictUpdate) {
+        this.restrictUpdate = restrictUpdate;
+    }
+
+    public String getUUID() {
+        return this.uuid;
+    }
+
+    public void setUUID(String uuid) {
+        this.uuid = uuid;
+    }
+
+    public String getUUIDHex() {
+        return this.uuidHex;
+    }
+
+    public void setUUIDHex(String uuidHex) {
+        this.uuidHex = uuidHex;
+    }
+
+    public int getVersion() {
+        return this.version;
+    }
+
+    public void setVersion(int version) {
+        this.version = version;
+    }
+
+    public int getSequence() {
+        return this.sequence;
+    }
+
+    public void setSequence(int sequence) {
+        this.sequence = sequence;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/BaseQueryTest.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/BaseQueryTest.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/BaseQueryTest.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/BaseQueryTest.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,146 @@
+/*
+ * BaseKernelTest.java
+ *
+ * Created on October 9, 2006, 12:56 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import javax.persistence.EntityManager;
+
+
+
+
+import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.OpenJPAStateManager;
+import org.apache.openjpa.kernel.jpql.JPQLParser;
+import org.apache.openjpa.lib.conf.ConfigurationProvider;
+import org.apache.openjpa.lib.conf.Configurations;
+import org.apache.openjpa.persistence.JPAFacadeHelper;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+public abstract class BaseQueryTest extends org.apache.openjpa.persistence.common.utils.AbstractTestCase {
+
+    private static Map _sysprops = new HashMap();
+
+    /**
+     * Creates a new instance of BaseQueryTest
+     */
+    public BaseQueryTest(String name) {
+        super(name, "querycactusapp");
+    }
+
+    protected OpenJPAEntityManager getPM() {
+        return (OpenJPAEntityManager) currentEntityManager();
+    }
+
+    protected OpenJPAEntityManager getPM(boolean optimistic,
+        boolean retainValues) {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        em.setNontransactionalRead(true);
+        em.setRetainState(retainValues);
+        em.setOptimistic(optimistic);
+        return em;
+    }
+
+    /**
+     * Delete all instances of the given class.
+     */
+    protected int deleteAll(Broker broker, Class clazz,
+        boolean subclasses) {
+        final boolean useDeleteByQuery = false;
+
+        if (useDeleteByQuery) {
+            org.apache.openjpa.kernel.Query query = broker.newQuery(
+                JPQLParser.LANG_JPQL, clazz, "");
+            query.setCandidateType(clazz, subclasses);
+            return (int) query.deleteAll();
+        } else {
+            org.apache.openjpa.kernel.Extent extent =
+                broker.newExtent(clazz, subclasses);
+            List list = extent.list();
+            int size = list.size();
+            broker.deleteAll(list, null);
+            return size;
+        }
+    }
+
+    protected Object persist(Object ob) {
+        Broker broker = getBrokerFactory().newBroker();
+        broker.begin();
+        broker.persist(ob, null);
+        Object id = broker.getObjectId(ob);
+        broker.commit();
+        broker.close();
+        return id;
+    }
+
+    protected Properties getProperties() {
+        return getProperties(null);
+    }
+
+    /**
+     * Return the runtime properties, optionally overriding or setting
+     * some via the given array, which should be in the form
+     * { key, val, key, val, ... }.
+     */
+    protected synchronized Properties getProperties(String[] props) {
+        Properties p = new Properties(System.getProperties());
+        String str = p.getProperty("openjpa.properties", "kodo.properties");
+        if (str != null && str.length() > 0) {
+            // cache system properties to reduce load on file system
+            Properties loaded = (Properties) _sysprops.get(str);
+            if (loaded == null) {
+                loaded = new Properties();
+                ConfigurationProvider cp =
+                    (ConfigurationProvider) Configurations
+                        .getProperty(str, null);
+                if (cp != null)
+                    loaded.putAll(cp.getProperties());
+                _sysprops.put(str, loaded);
+            }
+            p.putAll(loaded);
+        }
+
+        for (int i = 0; props != null && i < props.length; i += 2) {
+            if (props[i + 1] != null) {
+                // remove any duplicate kodo/openjpa property so we don't clash
+                if (props[i].startsWith("openjpa."))
+                    p.remove("openjpa." + props[i].substring(5));
+                else if (props[i].startsWith("openjpa."))
+                    p.remove("openjpa." + props[i].substring(8));
+
+                p.setProperty(props[i], props[i + 1]);
+            } else {
+                p.remove(props[i]);
+            }
+        }
+        return p;
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestAccessPathsOfSubqueries.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestAccessPathsOfSubqueries.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestAccessPathsOfSubqueries.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestAccessPathsOfSubqueries.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,90 @@
+/*
+ * TestAccessPathsOfSubqueries.java
+ *
+ * Created on October 17, 2006, 2:51 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest1;
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest4;
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest5;
+import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.Query;
+import org.apache.openjpa.kernel.jpql.JPQLParser;
+import org.apache.openjpa.meta.ClassMetaData;
+
+public class TestAccessPathsOfSubqueries extends BaseQueryTest {
+
+    /**
+     * Creates a new instance of TestAccessPathsOfSubqueries
+     */
+
+    public TestAccessPathsOfSubqueries(String name) {
+        super(name);
+    }
+
+    public void testSimpleSubqueryAccessPath() {
+        Broker broker = getBrokerFactory().newBroker();
+        Query q = broker.newQuery(JPQLParser.LANG_JPQL,
+            "SELECT o FROM RuntimeTest1 o WHERE EXISTS (SELECT rt5.name FROM RuntimeTest5 rt5 WHERE rt5.name IS NOT NULL)");
+        ClassMetaData[] metas = q.getAccessPathMetaDatas();
+        Collection c = Arrays.asList(metas);
+        ClassMetaData rt1 = broker.getConfiguration().
+            getMetaDataRepositoryInstance().getMetaData(RuntimeTest1.class,
+            broker.getClassLoader(), true);
+        ClassMetaData rt5 = broker.getConfiguration().
+            getMetaDataRepositoryInstance().getMetaData(RuntimeTest5.class,
+            broker.getClassLoader(), true);
+        assertTrue(c.contains(rt1));
+        assertTrue(c.contains(rt5));
+        assertEquals(2, c.size());
+    }
+
+    public void testRelationTraversalSubqueryAccessPath() {
+        Broker broker = getBrokerFactory().newBroker();
+        Query q = broker.newQuery(JPQLParser.LANG_JPQL,
+            "SELECT o FROM RuntimeTest1 o WHERE EXISTS (SELECT rt5.runtimeTest4.name FROM RuntimeTest5 rt5 WHERE rt5.name IS NOT NULL)");
+
+        ClassMetaData[] metas = q.getAccessPathMetaDatas();
+        Collection c = Arrays.asList(metas);
+        ClassMetaData rt1 = broker.getConfiguration().
+            getMetaDataRepositoryInstance().getMetaData(RuntimeTest1.class,
+            broker.getClassLoader(), true);
+        ClassMetaData rt4 = broker.getConfiguration().
+            getMetaDataRepositoryInstance().getMetaData(RuntimeTest4.class,
+            broker.getClassLoader(), true);
+        ClassMetaData rt5 = broker.getConfiguration().
+            getMetaDataRepositoryInstance().getMetaData(RuntimeTest5.class,
+            broker.getClassLoader(), true);
+        assertTrue(c.contains(rt1));
+        assertTrue(c.contains(rt4));
+        assertTrue(c.contains(rt5));
+        assertEquals(3, c.size());
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestComplexQueries.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestComplexQueries.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestComplexQueries.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestComplexQueries.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,422 @@
+/*
+ * TestComplexQueries.java
+ *
+ * Created on October 17, 2006, 2:59 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+
+import java.util.List;
+
+import org.apache.openjpa.persistence.query.common.apps.ComplexA;
+import org.apache.openjpa.persistence.query.common.apps.ComplexB;
+import org.apache.openjpa.persistence.query.common.apps.ComplexC;
+import org.apache.openjpa.persistence.query.common.apps.ComplexD;
+import org.apache.openjpa.persistence.query.common.apps.ComplexE;
+import org.apache.openjpa.persistence.query.common.apps.ComplexF;
+import org.apache.openjpa.persistence.query.common.apps.ComplexG;
+import junit.framework.AssertionFailedError;
+import org.apache.openjpa.kernel.Broker;
+import org.apache.openjpa.kernel.jpql.JPQLParser;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+public class TestComplexQueries extends BaseQueryTest {
+
+    /**
+     * Creates a new instance of TestComplexQueries
+     */
+
+    public TestComplexQueries(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        clear();
+    }
+
+    public void clear() {
+        deleteAll(ComplexA.class);
+        deleteAll(ComplexB.class);
+        deleteAll(ComplexC.class);
+        deleteAll(ComplexD.class);
+        deleteAll(ComplexE.class);
+        deleteAll(ComplexF.class);
+        deleteAll(ComplexG.class);
+    }
+
+    public void complexQuery(int size, Object ob, String filter, Class c) {
+
+//        PersistenceManager pm = getPM();
+        Broker broker = getBrokerFactory().newBroker();
+        broker.setIgnoreChanges(false);
+        broker.begin();
+
+        broker.persist(ob, null);
+        // test in-memory
+        // assertSize (size, pm.newQuery (c, filter));
+        broker.commit();
+
+        broker.begin();
+        // test against database
+//        OpenJPAQuery q = pm.createQuery("SELECT o FROM "+c.getSimpleName()+"o WHERE o."+filter);
+        String qstrng =
+            "SELECT o FROM " + c.getSimpleName() + " o WHERE o." + filter;
+        assertSize(size,
+            (List) broker.newQuery(JPQLParser.LANG_JPQL, c, qstrng).execute());
+
+        broker.commit();
+        broker.close();
+
+        broker = getBrokerFactory().newBroker();
+        broker.begin();
+        // test again against a new PM, for good measure
+        assertSize(size,
+            (List) broker.newQuery(JPQLParser.LANG_JPQL, c, qstrng).execute());
+        broker.rollback();
+
+        broker.close();
+    }
+
+    public void testComplex1() {
+        complexQuery(1,
+            new ComplexA("test", 0, null, null),
+            "stringA = \'test\'",
+            ComplexA.class);
+    }
+
+    public void testComplex2() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "stringG = \'testg\'",
+            ComplexG.class);
+    }
+
+    public void testComplex3() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.e.d.c.b.a.stringA = \'testa\'",
+            ComplexG.class);
+    }
+
+    public void testComplex4() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.e.d.c.b.a.stringA = \'testa\'"
+                + " AND o.f.e.d.c.b.stringB = \'testb\'",
+            ComplexG.class);
+    }
+
+    public void testComplex5() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.e.d.c.b.a.stringA = \'testa\'"
+                + " AND o.f.e.d.c.b.stringB = \'testb\'"
+                + " AND o.f.e.d.c.stringC = \'testc\'",
+            ComplexG.class);
+    }
+
+    public void testComplex6() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.e.d.c.b.a.stringA = \'testa\'"
+                + " AND o.f.e.d.c.b.stringB = \'testb\'"
+                + " AND o.f.e.d.c.stringC = \'testc\'"
+                + " AND o.f.e.d.stringD = \'testd\'",
+            ComplexG.class);
+    }
+
+    public void testComplex7() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.e.d.c.b.a.stringA = \'testa\'"
+                + " AND o.f.e.d.c.b.stringB = \'testb\'"
+                + " AND o.f.e.d.c.stringC = \'testc\'"
+                + " AND o.f.e.d.stringD = \'testd\'"
+                + " AND o.f.e.stringE = \'teste\'",
+            ComplexG.class);
+    }
+
+    public void testComplex8() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.e.d.c.b.a.stringA = \'testa\'"
+                + " AND o.f.e.d.c.b.stringB = \'testb\'"
+                + " AND o.f.e.d.c.stringC = \'testc\'"
+                + " AND o.f.e.d.stringD = \'testd\'"
+                + " AND o.f.e.stringE = \'teste\'"
+                + " AND o.f.stringF = \'testf\'",
+            ComplexG.class);
+    }
+
+    public void testComplex9() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.e.d.c.b.a.stringA = \'testa\'"
+                + " AND o.f.e.d.c.b.stringB = \'testb\'"
+                + " AND o.f.e.d.c.stringC = \'testc\'"
+                + " AND o.f.e.d.stringD = \'testd\'"
+                + " AND o.f.e.stringE = \'teste\'"
+                + " AND o.f.stringF = \'testf\'"
+                + " AND o.f.e.d.intD < 1"
+                + " AND o.f.e.d.intD > -1",
+            ComplexG.class);
+    }
+
+    public void testComplex10() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.stringF = \'testf\'",
+            ComplexG.class);
+    }
+
+    public void testComplex11() {
+        complexQuery(1,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.stringF = \'testf\' AND o.stringG = \'testg\'",
+            ComplexG.class);
+    }
+
+    public void testComplex12() {
+        try {
+            complexQuery(1,
+                new ComplexG("testg", 0, null,
+                    new ComplexF("testf", 0, null, null,
+                        new ComplexE("teste", 0, null, null,
+                            new ComplexD("testd", 0, null, null,
+                                new ComplexC("testc", 0, null, null,
+                                    new ComplexB("testb", 0, null, null,
+                                        new ComplexA("testa", 0, null,
+                                            null))))))),
+                "f.stringF = \'testf\'OR o.stringG = \'testg\'",
+                ComplexG.class);
+        } catch (junit.framework.AssertionFailedError afe) {
+            bug(449, afe, "ORs and relational queries");
+        }
+    }
+
+    public void testComplex13() {
+        complexQuery(0,
+            new ComplexG("testg", 0, null,
+                new ComplexF("testf", 0, null, null,
+                    new ComplexE("teste", 0, null, null,
+                        new ComplexD("testd", 0, null, null,
+                            new ComplexC("testc", 0, null, null,
+                                new ComplexB("testb", 0, null, null,
+                                    new ComplexA("testa", 0, null, null))))))),
+            "f.stringF = \'testfXXX\'",
+            ComplexG.class);
+    }
+
+    public void testRelationsIgnoreCache() {
+        try {
+            relationsIgnoreCacheTest();
+        } catch (AssertionFailedError afe) {
+            bug(631, afe, "IgnoreCache=false queries do not detect "
+                + "all relationship changed");
+        }
+    }
+
+    public void relationsIgnoreCacheTest() {
+        OpenJPAEntityManager pm;
+        ComplexC c = new ComplexC();
+        ComplexB b = new ComplexB();
+        ComplexA a = new ComplexA();
+
+        c.setB(b);
+        b.setA(a);
+
+        a.setStringA("Foo");
+        pm = getPM();
+        startTx(pm);
+        pm.persist(c);
+        endTx(pm);
+
+        assertSize(1,
+            getPM().createNativeQuery("b.a.stringA = \'Foo\'", ComplexC.class));
+        assertSize(0, getPM().createNativeQuery("b.a.stringA = \'FooX\'",
+            ComplexC.class));
+
+        pm = getPM();
+        startTx(pm);
+        ComplexA pca = (ComplexA) pm.createExtent(ComplexA.class, false)
+            .iterator().next();
+        ComplexB pcb = (ComplexB) pm.createExtent(ComplexB.class, false)
+            .iterator().next();
+        ComplexC pcc = (ComplexC) pm.createExtent(ComplexC.class, false)
+            .iterator().next();
+
+        pcc.getB().getA().setStringA("Foo2"); // change the value for
+
+        final OpenJPAQuery q;
+
+        q = pm.createNativeQuery("b.a.stringA = \'Foo\'", ComplexC.class);
+        //FIXME jthomas
+        //q.setIgnoreCache(true);
+        assertEquals(1, q.getMaxResults());
+
+        //FIXME jthomas
+        //q.setIgnoreCache(false);
+        assertEquals(0, q.getMaxResults());
+
+        // now see if the ignore cache change picks up the current object
+        //FIXME jthomas
+        //q.setFilter("b.a.stringA = \'Foo2\'");
+        //q.setIgnoreCache(false);
+        assertEquals(1, q.getMaxResults());
+
+        /*
+         Query query = pm.newQuery (C.class, "b.a = param");
+         query.declareParameters ("A param");
+
+         query.setIgnoreCache (true);
+         assertSize (1, query.execute (pca));
+
+         query.setIgnoreCache (false);
+         assertSize (1, query.execute (pca));
+
+         // now change the instance of b.a and see if we fail (as expected)
+         pcb.setA (new A ());
+
+         query.setIgnoreCache (true);
+         assertSize (1, query.execute (pca));
+
+         query.setIgnoreCache (false);
+         // the bug is that the following line will fail: 1 object is returned
+         assertSize (0, query.execute (pca));
+        */
+
+        final OpenJPAQuery q2;
+
+        q2 = pm.createNativeQuery("b.a = param", ComplexC.class);
+        //FIXME jthomas
+        /*
+        q2.declareParameters("ComplexA param");
+        
+        q2.setIgnoreCache(true);
+        assertSize(1, q2.execute(pca));
+        
+        q2.setIgnoreCache(false);
+        assertSize(1, q2.execute(pca));
+        
+        // now change the instance of b.a to null and see if we fail
+        pcb.setA(null);
+        q2.setIgnoreCache(true);
+        assertSize(1, q2.execute(pca));
+        q2.setIgnoreCache(false);
+        assertSize(0, q2.execute(pca));
+        
+        int fbq = ((FetchPlan) q2.getFetchPlan()).
+                getFlushBeforeQueries();
+        boolean isFlushing =
+                fbq = FetchPlanImpl.FLUSH_TRUEOR
+                (fbq = FetchPlanImpl.FLUSH_WITH_CONNECTION AND
+                KodoJDOHelper.toBroker(pm).hasConnection());
+        
+        // now change the instance of b.a and see if we fail (as expected)
+        pcb.setA(new ComplexA());
+        q2.setIgnoreCache(true);
+        if (isFlushing)
+            assertSize(0, q2.execute(pca)); // we've already flushed earlier
+        else
+            assertSize(1, q2.execute(pca));
+        q2.setIgnoreCache(false);
+        assertSize(0, q2.execute(pca));
+        
+        // now change the instance of b.a back to the orig value
+        pcb.setA(pca);
+        q2.setIgnoreCache(true);
+        if (isFlushing)
+            assertSize(0, q2.execute(pca)); // we've already flushed earlier
+        else
+            assertSize(1, q2.execute(pca));
+        q2.setIgnoreCache(false);
+        assertSize(1, q2.execute(pca));
+        
+        endTx(pm);
+         */
+    }
+
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBDeleteUpdateImpl.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBDeleteUpdateImpl.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBDeleteUpdateImpl.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBDeleteUpdateImpl.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+import javax.persistence.Query;
+
+
+import org.apache.openjpa.persistence.query.common.apps.Entity1;
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest1;
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest2;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+
+public class TestEJBDeleteUpdateImpl extends BaseQueryTest {
+
+    RuntimeTest1 runt1;
+    RuntimeTest2 runt2;
+    Entity1 ent;
+
+    public TestEJBDeleteUpdateImpl(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        deleteAll(RuntimeTest1.class);
+        deleteAll(RuntimeTest2.class);
+        deleteAll(Entity1.class);
+
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        runt1 = new RuntimeTest1(1);
+        runt1.setStringField("runt1");
+        runt1.setSelfOneOne(new RuntimeTest1(2));
+        runt2 = new RuntimeTest2(3);
+        runt2.setStringField("runt2");
+
+        ent = new Entity1(23, "UPDATEST", 100);
+
+        em.persist(runt1);
+        em.persist(runt2);
+        em.persist(ent);
+
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testUpdate1() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        RuntimeTest1 ret = em.find(RuntimeTest1.class, em.getObjectId(runt1));
+
+        assertNotNull(ret);
+        assertEquals("runt1", ret.getStringField());
+        assertNotNull(ret.getSelfOneOne());
+
+        String ejbqlUpdate =
+            "UPDATE RuntimeTest1 x SET x.stringField = :strngfld WHERE x.stringField = :stdfield";
+        int updatedEntities = em.createQuery(ejbqlUpdate)
+            .setParameter("strngfld", "runner13")
+            .setParameter("stdfield", "runt1")
+            .executeUpdate();
+
+        assertEquals(1, updatedEntities);
+
+        endTx(em);
+
+        RuntimeTest1 ret2 = em.find(RuntimeTest1.class, em.getObjectId(runt1));
+        em.refresh(ret2);
+
+        assertNotNull(ret2);
+        assertEquals("runner13", ret2.getStringField());
+
+        endEm(em);
+    }
+
+    public void testUpdate2() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        RuntimeTest1 run = em.find(RuntimeTest1.class, em.getObjectId(runt1));
+        assertNotNull(run);
+        assertEquals("runt1", run.getStringField());
+        assertNotNull(run.getSelfOneOne());
+
+        String ejbqlUpdate = "UPDATE RuntimeTest1 x " +
+            "SET x.stringField = :strngfld " +
+            "WHERE x.stringField = :field";
+        int upEntities = em.createQuery(ejbqlUpdate)
+            .setParameter("strngfld", "upd")
+            .setParameter("field", "runt1")
+            .executeUpdate();
+
+        assertEquals(1, upEntities);
+
+        endTx(em);
+
+        em = (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        RuntimeTest1 inst = em.find(RuntimeTest1.class, em.getObjectId(runt1));
+        em.refresh(inst);
+
+        assertNotNull(inst);
+        assertEquals("upd", inst.getStringField());
+
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testDelete1() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        RuntimeTest1 run = em.find(RuntimeTest1.class, em.getObjectId(runt1));
+        assertNotNull(run);
+        assertEquals("runt1", run.getStringField());
+        assertNotNull(run.getSelfOneOne());
+
+        String ejbdelUpdate = "DELETE  FROM RuntimeTest1 s " +
+            "WHERE s.stringField = :strngfld";
+        int delEntity = em.createQuery(ejbdelUpdate)
+            .setParameter("strngfld", "runt1")
+            .executeUpdate();
+
+        assertEquals(1, delEntity);
+
+        RuntimeTest1 del = em.find(RuntimeTest1.class, em.getObjectId(runt1));
+        assertNull(del);
+
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testDelete2() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        RuntimeTest1 run = em.find(RuntimeTest1.class, em.getObjectId(runt1));
+        assertNotNull(run);
+        assertEquals("runt1", run.getStringField());
+        assertNotNull(run.getSelfOneOne());
+
+        String ejbdelUpdate =
+            "DELETE  FROM RuntimeTest1 r WHERE r.stringField = ?1";
+        Query query = em.createQuery(ejbdelUpdate);
+
+        query.setParameter(1, "runt1");
+        int ok = query.executeUpdate();
+
+        assertEquals(1, ok);
+
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testUpdate3() {
+        OpenJPAEntityManager em =
+            (OpenJPAEntityManager) currentEntityManager();
+        startTx(em);
+
+        Entity1 ent = em.find(Entity1.class, 23);
+
+        assertNotNull(ent);
+        assertEquals("UPDATEST", ent.getStringField());
+
+        int upd = em.createQuery(
+            "UPDATE Entity1 e SET e.stringField = \'UPDATEFAILED\' WHERE " +
+                "e.pk = 23").executeUpdate();
+
+        assertEquals(1, upd);
+
+        endTx(em);
+        endEm(em);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBPolymorphicQuery.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBPolymorphicQuery.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBPolymorphicQuery.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBPolymorphicQuery.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,88 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+import java.util.List;
+import javax.persistence.EntityManager;
+
+
+
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest1;
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest2;
+
+public class TestEJBPolymorphicQuery extends BaseQueryTest {
+
+    public TestEJBPolymorphicQuery(String name) {
+        super(name);
+    }
+
+    public void setUp() {
+        deleteAll(RuntimeTest1.class);
+        deleteAll(RuntimeTest2.class);
+
+        EntityManager em = currentEntityManager();
+        startTx(em);
+
+        int run1 = 10;
+        int run2 = 15;
+
+        for (int i = 0; i < run1; i++) {
+            RuntimeTest1 rt = new RuntimeTest1(i);
+            rt.setStringField("foo " + i);
+            em.persist(rt);
+        }
+
+        for (int i = 10; i < run2; i++) {
+            em.persist(new RuntimeTest2(i));
+        }
+
+        endTx(em);
+        endEm(em);
+    }
+
+    /**
+     * Ensures that when a select query is ran against an entity at the top of the hierarchy
+     * that the result is its instances and that of all its subclass.
+     */
+    public void testPolymorphicSelect() {
+        EntityManager em = currentEntityManager();
+
+        List l = em.createQuery("Select object(o) from RuntimeTest1 o")
+            .getResultList();
+
+        assertNotNull(l);
+        assertEquals(15, l.size());
+
+        endEm(em);
+    }
+
+    public void testPolymorphicDelete() {
+        EntityManager em = currentEntityManager();
+        startTx(em);
+
+        int l = em.createQuery("Delete from RuntimeTest1")
+            .executeUpdate();
+
+        assertNotNull(l);
+        assertEquals(15, l);
+
+        endTx(em);
+        endEm(em);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBQueryInterface.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBQueryInterface.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBQueryInterface.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestEJBQueryInterface.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,151 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+import java.util.List;
+import javax.persistence.EntityManager;
+
+
+
+import org.apache.openjpa.persistence.query.common.apps.Entity1;
+import org.apache.openjpa.persistence.query.common.apps.Entity2;
+
+public class TestEJBQueryInterface extends BaseQueryTest {
+
+    public TestEJBQueryInterface(String name) {
+        super(name);
+    }
+
+    public void setUp() {
+        deleteAll(Entity1.class);
+
+        int instNum = 10;
+
+        EntityManager em = currentEntityManager();
+        startTx(em);
+
+        //create and persist multiple entity1 instances
+        for (int i = 0; i < instNum; i++) {
+            Entity1 ent = new Entity1(i, "string" + i, i + 2);
+            Entity2 ent2 = new Entity2(i * 2, "ent2" + i, i);
+            ent.setEntity2Field(ent2);
+            em.persist(ent);
+        }
+
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testResultList() {
+        EntityManager em = currentEntityManager();
+        List list = em.createQuery("Select object(o) from Entity1 o")
+            .getResultList();
+
+        assertEquals(10, list.size());
+
+        endEm(em);
+    }
+
+    public void testGetSingleList() {
+        EntityManager em = currentEntityManager();
+
+        Entity1 ret =
+            (Entity1) em.createQuery("SELECT o FROM Entity1 o WHERE o.pk = 2")
+                .getSingleResult();
+
+        assertNotNull(ret);
+        assertEquals("string2", ret.getStringField());
+        assertEquals(4, ret.getIntField());
+
+        endEm(em);
+    }
+
+    public void testExecuteUpdate() {
+        EntityManager em = currentEntityManager();
+        startTx(em);
+        int ret = em.createQuery("DELETE FROM Entity1 o WHERE o.pk = 2")
+            .executeUpdate();
+
+        assertEquals(ret, 1);
+
+        int ret2 = em.createQuery("DELETE FROM Entity1 o WHERE o.pk = 22")
+            .executeUpdate();
+
+        assertEquals(ret2, 0);
+
+        endTx(em);
+        endEm(em);
+    }
+
+    public void testSetMaxResults() {
+        EntityManager em = currentEntityManager();
+
+        List l = em.createQuery("Select object(o) from Entity1 o")
+            .setMaxResults(5)
+            .getResultList();
+
+        assertNotNull(l);
+        assertEquals(5, l.size());
+
+        endEm(em);
+    }
+
+    public void testSetFirstResults() {
+        EntityManager em = currentEntityManager();
+
+        List l = em.createQuery("Select object(o) from Entity1 o")
+            .setFirstResult(3)
+            .getResultList();
+
+        Entity1 ent = (Entity1) l.get(0);
+
+        assertNotNull(ent);
+        assertEquals("string3", ent.getStringField());
+        assertEquals(5, ent.getIntField());
+
+        endEm(em);
+    }
+
+    // Tests Binding an argument to a named parameter.
+    // pk, the named parameter --Not working yet--
+    public void testSetParameter1() {
+        EntityManager em = currentEntityManager();
+        startTx(em);
+
+        List ret =
+            em.createQuery("SELECT o FROM Entity1 o WHERE o.stringField = :fld")
+                .setParameter("fld", "string1")
+                .getResultList();
+
+        assertNotNull(ret);
+        assertEquals(1, ret.size());
+
+        ret = em.createNamedQuery("setParam1")
+            .setParameter("fld", "string1")
+            .getResultList();
+
+        assertNotNull(ret);
+        assertEquals(1, ret.size());
+
+        endTx(em);
+        endEm(em);
+    }
+
+    //rest of the interface is tested by the CTS
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJPAQuerySubclassFunc.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJPAQuerySubclassFunc.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJPAQuerySubclassFunc.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestJPAQuerySubclassFunc.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+import java.util.List;
+
+
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest1;
+import org.apache.openjpa.persistence.query.common.apps.RuntimeTest3;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+public class TestJPAQuerySubclassFunc extends BaseQueryTest {
+
+    public TestJPAQuerySubclassFunc(String name) {
+        super(name);
+    }
+
+    public void setUp() {
+        deleteAll(RuntimeTest1.class);
+
+        OpenJPAEntityManager pm = getPM();
+        startTx(pm);
+
+        pm.persist(new RuntimeTest1("TestQueryResults1", 10));
+        pm.persist(new RuntimeTest1("TestQueryResults3", 10));
+        pm.persist(new RuntimeTest1("TestQueryResults5", 10));
+
+        pm.persist(new RuntimeTest3("TestQueryResults2", 10));
+        pm.persist(new RuntimeTest3("TestQueryResults4", 10));
+        pm.persist(new RuntimeTest3("TestQueryResults6", 10));
+
+        endTx(pm);
+        endEm(pm);
+    }
+
+    public void testSubClassIsTrueFunction() {
+        OpenJPAEntityManager pm = getPM();
+        startTx(pm);
+
+        OpenJPAQuery query =
+            pm.createQuery("SELECT r.stringField FROM RuntimeTest1 r");
+        query.setSubclasses(true);
+
+        List list = query.getResultList();
+
+        assertEquals("I expect size to be 6 since subclasses are included", 6,
+            list.size());
+        assertTrue(list.contains("TestQueryResults1"));
+        assertTrue(list.contains("TestQueryResults2"));
+
+        endTx(pm);
+        endEm(pm);
+    }
+
+    public void testSubClassIsFalseFunction() {
+        OpenJPAEntityManager pm = getPM();
+        startTx(pm);
+
+        OpenJPAQuery query =
+            pm.createQuery("SELECT r.stringField FROM RuntimeTest1 r");
+        query.setSubclasses(false);
+
+        List list = query.getResultList();
+
+        assertEquals("I expect size to be 3 since subclasses are not included",
+            3, list.size());
+        assertTrue(list.contains("TestQueryResults1"));
+        assertTrue(list.contains("TestQueryResults3"));
+        assertTrue(list.contains("TestQueryResults5"));
+
+        endTx(pm);
+        endEm(pm);
+    }
+}
\ No newline at end of file

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestMathQueries.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestMathQueries.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestMathQueries.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestMathQueries.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,86 @@
+/*
+ * TestMathQueries.java
+ *
+ * Created on October 18, 2006, 1:06 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+import java.util.List;
+
+
+import org.apache.openjpa.persistence.query.common.apps.QueryTest1;
+import org.apache.openjpa.persistence.common.utils.AbstractTestCase;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+public class TestMathQueries extends BaseQueryTest {
+
+    /**
+     * Creates a new instance of TestMathQueries
+     */
+
+    public TestMathQueries(String name) {
+        super(name);
+    }
+
+    public void setUp() {
+        deleteAll(QueryTest1.class);
+        OpenJPAEntityManager pm = getPM();
+        startTx(pm);
+
+        for (int i = 0; i <= 100; i++) {
+            QueryTest1 ob = new QueryTest1();
+            ob.setNum(i);
+            pm.persist(ob);
+        }
+        endTx(pm);
+
+        for (long i = 0; i < 100; i++) {
+            OpenJPAQuery q =
+                pm.createQuery("SELECT q FROM QueryTest1 q WHERE q.numb = :ind")
+                    .setParameter("ind", i);
+            List l = q.getResultList();
+            assertSize(1, l);
+        }
+    }
+
+    public void testMultipleQuery() {
+        try {
+
+            OpenJPAQuery q1, q2;
+            q1 = getPM().createQuery(
+                "SELECT q FROM QueryTest1 q WHERE q.numb * q.numb = 25");
+            q2 = getPM().createQuery(
+                "SELECT q FROM QueryTest1 q WHERE q.numb * q.numb > 25");
+
+            assertSize(95, q2.getResultList());
+            assertSize(1, q1.getResultList());
+        }
+        catch (Exception e) {
+            bug(AbstractTestCase.Platform.EMPRESS, 890, e,
+                "Empress cannot handle certain "
+                    + "aggregate functions");
+        }
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestNamedQueries.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestNamedQueries.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestNamedQueries.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestNamedQueries.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,114 @@
+/*
+ * TestNamedQueries.java
+ *
+ * Created on October 18, 2006, 1:17 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+import java.util.Collection;
+
+
+
+import org.apache.openjpa.persistence.query.common.apps.QueryTest1;
+
+import org.apache.openjpa.meta.QueryMetaData;
+import org.apache.openjpa.persistence.OpenJPAEntityManager;
+import org.apache.openjpa.persistence.OpenJPAEntityManagerSPI;
+import org.apache.openjpa.persistence.OpenJPAQuery;
+
+public class TestNamedQueries extends BaseQueryTest {
+
+    /**
+     * Creates a new instance of TestNamedQueries
+     */
+
+    public TestNamedQueries(String test) {
+        super(test);
+    }
+
+    public void setUp() {
+        deleteAll(QueryTest1.class);
+
+        OpenJPAEntityManager pm = getPM();
+        startTx(pm);
+        QueryTest1 pc = null;
+        for (int i = 0; i < 10; i++) {
+            pc = new QueryTest1();
+            if (i < 5)
+                pc.setNum(4);
+            else
+                pc.setNum(i + 10);
+            pm.persist(pc);
+        }
+        endTx(pm);
+        endEm(pm);
+    }
+
+    public void testNamedClassQuery() {
+        OpenJPAEntityManager pm = getPM();
+
+        OpenJPAQuery query = pm.createQuery("SELECT o FROM QueryTest1 o");
+        query.setResultClass(QueryTest1.class);
+
+        assertEquals(QueryTest1.class, query.getResultClass());
+        assertEquals("SELECT o FROM QueryTest1 o", query.getQueryString());
+        assertEquals(QueryTest1.class, query.getResultClass());
+        //FIXME jthomas
+        /*
+        assertEquals("import java.util.*", query.getImports());
+        assertEquals("int pnum", query.getParameters());
+        assertEquals("QueryTest4 v4", query.getVariables());
+        assertEquals("sum(num)", query.getResult());
+        assertEquals("num", query.getGrouping());
+        */
+        QueryMetaData meta = ((OpenJPAEntityManagerSPI) pm).getConfiguration().
+            getMetaDataRepositoryInstance().getQueryMetaData(null,
+            "named", pm.getClassLoader(), true);
+        assertNotNull(meta);
+        assertEquals("SELECT o FROM QueryTest1 o", meta.getQueryString());
+        assertEquals(null, meta.getResultType());
+
+        endEm(pm);
+    }
+
+    public void testNamespace() {
+        OpenJPAEntityManager pm = getPM();
+        OpenJPAQuery query = (OpenJPAQuery) pm.createNamedQuery("named");
+        assertEquals("SELECT o FROM QueryTest1 o", query.getQueryString());
+        query.closeAll();
+        endEm(pm);
+    }
+
+    public void testSystemJDOQL() {
+        // make sure local query metadata is parsed
+        OpenJPAEntityManager pm = getPM();
+
+        OpenJPAQuery query = (OpenJPAQuery) pm.createNamedQuery("named");
+        assertEquals("SELECT o FROM QueryTest1 o", query.getQueryString());
+        assertEquals(QueryTest1.class, query.getResultClass());
+        assertEquals(10, ((Collection) query.getResultList()).size());
+        query.closeAll();
+        endEm(pm);
+    }
+}

Added: openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryExpressionSplit.java
URL: http://svn.apache.org/viewvc/openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryExpressionSplit.java?rev=627979&view=auto
==============================================================================
--- openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryExpressionSplit.java (added)
+++ openjpa/trunk/openjpa-persistence-jdbc/src/test/java/org/apache/openjpa/persistence/query/TestQueryExpressionSplit.java Fri Feb 15 01:19:55 2008
@@ -0,0 +1,80 @@
+/*
+ * TestQueryExpressionSplit.java
+ *
+ * Created on October 18, 2006, 1:57 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.    
+ */
+package org.apache.openjpa.persistence.query;
+
+import java.util.Arrays;
+import java.util.List;
+
+
+
+
+import org.apache.openjpa.kernel.Filters;
+
+public class TestQueryExpressionSplit extends BaseQueryTest {
+
+    /**
+     * Creates a new instance of TestQueryExpressionSplit
+     */
+
+    public TestQueryExpressionSplit(String test) {
+        super(test);
+    }
+
+    public void testSimple() {
+        assertEquals(new String[]{ "foo() bar(boo)" },
+            Filters.splitExpressions("foo() bar(boo)", ',', 3));
+        assertEquals(new String[]{ "foo() bar(boo)", "biz()", "baz(boo)" },
+            Filters.splitExpressions("foo() bar(boo), bizbaz(boo)",
+                ',', 3));
+    }
+
+    public void testCommaInString() {
+        assertEquals(new String[]{ "foo \"bar(),biz)\"" },
+            Filters.splitExpressions("foo \"bar(),biz)\"", ',', 3));
+        assertEquals(new String[]{ "foo 'bar(),\"biz)'", "boo" },
+            Filters.splitExpressions("foo 'bar(),\"biz)', boo", ',', 3));
+    }
+
+    public void testCommaInFunction() {
+        assertEquals(new String[]{ "(foo(bar, biz))",
+            "boo(biz, baz('xxx,yyy'))" },
+            Filters.splitExpressions("(foo(bar, biz)), "
+                + "boo(biz, baz('xxx,yyy'))", ',', 3));
+    }
+
+    public void testEscapedString() {
+        assertEquals(new String[]{ "foo \"bar\\\", biz(\"",
+            "\"baz\\\", boo\"" },
+            Filters.splitExpressions("foo \"bar\\\", biz(\", "
+                + "\"baz\\\", boo\"", ',', 3));
+    }
+
+    private void assertEquals(String[] ans, List test) {
+        List l = Arrays.asList(ans);
+        assertEquals(l + " != " + test, l, test);
+    }
+}



Mime
View raw message