You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jdo-commits@db.apache.org by an...@apache.org on 2016/10/28 17:32:21 UTC

svn commit: r1767044 - in /db/jdo/trunk/tck/src: conf/query.conf java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java

Author: andyj
Date: Fri Oct 28 17:32:21 2016
New Revision: 1767044

URL: http://svn.apache.org/viewvc?rev=1767044&view=rev
Log:
JDO-757 apply test for use of @Repeatable annotations

Added:
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java
    db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java
Modified:
    db/jdo/trunk/tck/src/conf/query.conf

Modified: db/jdo/trunk/tck/src/conf/query.conf
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/conf/query.conf?rev=1767044&r1=1767043&r2=1767044&view=diff
==============================================================================
--- db/jdo/trunk/tck/src/conf/query.conf (original)
+++ db/jdo/trunk/tck/src/conf/query.conf Fri Oct 28 17:32:21 2016
@@ -37,6 +37,7 @@ org.apache.jdo.tck.query.api.GetPersiste
 org.apache.jdo.tck.query.api.InvalidNamedQuery \
 org.apache.jdo.tck.query.api.MetadataSearchOrder \
 org.apache.jdo.tck.query.api.NamedQueryNotFound \
+org.apache.jdo.tck.query.api.NamedQueryRepeatableAnnotations \
 org.apache.jdo.tck.query.api.NewNamedQuery \
 org.apache.jdo.tck.query.api.NewQueryFromExistingQueryBoundToPMFromSameVendor \
 org.apache.jdo.tck.query.api.NewQueryFromRestoredSerializedQuery \

Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java?rev=1767044&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java (added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/pc/query/NamedQueriesSample.java Fri Oct 28 17:32:21 2016
@@ -0,0 +1,53 @@
+/*
+ * 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.jdo.tck.pc.query;
+
+import javax.jdo.annotations.Query;
+import javax.jdo.annotations.PersistenceCapable;
+import javax.jdo.annotations.PrimaryKey;
+
+import java.io.Serializable;
+
+/**
+ * Test for use of annotations, where we are relying on the Repeatable
+ * nature of the @Query annotation (java 8).
+ */
+@PersistenceCapable
+@Query(name="NameIsJohn", value="SELECT FROM org.apache.jdo.tck.pc.query.NamedQueriesSample WHERE name == 'John'")
+@Query(name="NameIsFred", value="SELECT FROM org.apache.jdo.tck.pc.query.NamedQueriesSample WHERE name == 'Fred'")
+public class NamedQueriesSample implements Serializable {
+    @PrimaryKey
+	long id;
+
+    String name;
+
+	public long getId() {
+		return id;
+	}
+
+	public void setId(long id) {
+		this.id = id;
+	}
+
+	public String getName() {
+		return name;
+	}
+
+	public void setName(String name) {
+		this.name = name;
+	}
+}

Added: db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java
URL: http://svn.apache.org/viewvc/db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java?rev=1767044&view=auto
==============================================================================
--- db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java (added)
+++ db/jdo/trunk/tck/src/java/org/apache/jdo/tck/query/api/NamedQueryRepeatableAnnotations.java Fri Oct 28 17:32:21 2016
@@ -0,0 +1,64 @@
+/*
+ * 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.jdo.tck.query.api;
+
+import javax.jdo.Query;
+import javax.jdo.JDOUserException;
+
+import org.apache.jdo.tck.JDO_Test;
+import org.apache.jdo.tck.pc.query.NamedQueriesSample;
+import org.apache.jdo.tck.query.QueryTest;
+import org.apache.jdo.tck.util.BatchTestRunner;
+
+/**
+ *<B>Title:</B> NamedQueryRepeatableAnnotations
+ *<BR>
+ *<B>Keywords:</B> query
+ *<BR>
+ *<B>Assertion ID:</B> Unknown
+ *<BR>
+ *<B>Assertion Description: </B>
+ * We test use of @Query where multiple have been defined in a class, so reliant on Java 8 @Repeatable.
+ */
+public class NamedQueryRepeatableAnnotations extends QueryTest {
+
+    private static final String ASSERTION_FAILED = 
+        "Assertion A19.?? (NamedQueryRepeatableAnnotations) failed: ";
+    
+    /**
+     * The <code>main</code> is called when the class
+     * is directly executed from the command line.
+     * @param args The arguments passed to the program.
+     */
+    public static void main(String[] args) {
+        BatchTestRunner.run(NamedQueryRepeatableAnnotations.class);
+    }
+
+    /** */
+    public void testPositive() {
+        try {
+            Query query = getPM().newNamedQuery(NamedQueriesSample.class, "NameIsJohn");
+        } catch (JDOUserException e) {
+            fail(ASSERTION_FAILED + "Lookup of query failed but should have been found");
+        }
+        try {
+            Query query = getPM().newNamedQuery(NamedQueriesSample.class, "NameIsFred");
+        } catch (JDOUserException e) {
+            fail(ASSERTION_FAILED + "Lookup of query failed but should have been found");
+        }
+    }
+}