cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1404556 - in /cxf/trunk/rt/rs/extensions/search/src/test: java/org/apache/cxf/jaxrs/ext/search/jpa/ resources/META-INF/
Date Thu, 01 Nov 2012 12:25:02 GMT
Author: sergeyb
Date: Thu Nov  1 12:25:01 2012
New Revision: 1404556

URL: http://svn.apache.org/viewvc?rev=1404556&view=rev
Log:
Adding JPA2 test with relationship

Added:
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
  (with props)
Modified:
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book_.java
    cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
    cxf/trunk/rt/rs/extensions/search/src/test/resources/META-INF/persistence.xml

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book.java?rev=1404556&r1=1404555&r2=1404556&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book.java
Thu Nov  1 12:25:01 2012
@@ -21,6 +21,7 @@ package org.apache.cxf.jaxrs.ext.search.
 import javax.persistence.Embedded;
 import javax.persistence.Entity;
 import javax.persistence.Id;
+import javax.persistence.ManyToOne;
 
 @Entity(name = "Book")
 public class Book {
@@ -29,6 +30,9 @@ public class Book {
     private String title;
     private OwnerAddress address;
     private OwnerInfo ownerInfo;
+    @ManyToOne
+    private Library library;
+    
     
     public int getId() {
         return id;
@@ -62,4 +66,12 @@ public class Book {
     public void setOwnerInfo(OwnerInfo ownerInfo) {
         this.ownerInfo = ownerInfo;
     }
+
+    public Library getLibrary() {
+        return library;
+    }
+
+    public void setLibrary(Library library) {
+        this.library = library;
+    }
 }

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book_.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book_.java?rev=1404556&r1=1404555&r2=1404556&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book_.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Book_.java
Thu Nov  1 12:25:01 2012
@@ -28,5 +28,8 @@ public final class Book_ {
     }
     public static volatile SingularAttribute<Book, Integer> id;
     public static volatile SingularAttribute<Book, String> title;
+    public static volatile SingularAttribute<Book, Library> library;
+    public static volatile SingularAttribute<Book, OwnerInfo> ownerInfo;
+    public static volatile SingularAttribute<Book, OwnerAddress> address;
 }
 //CHECKSTYLE:ON
\ No newline at end of file

Modified: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java?rev=1404556&r1=1404555&r2=1404556&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
(original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/JPATypedQueryVisitorTest.java
Thu Nov  1 12:25:01 2012
@@ -68,6 +68,13 @@ public class JPATypedQueryVisitorTest ex
             em = emFactory.createEntityManager();
          
             em.getTransaction().begin();
+            
+            Library lib = new Library();
+            lib.setId(1);
+            lib.setAddress("town");
+            em.persist(lib);
+            assertTrue(em.contains(lib));
+                        
             Book b1 = new Book();
             b1.setId(9);
             b1.setTitle("num9");
@@ -76,6 +83,7 @@ public class JPATypedQueryVisitorTest ex
             info1.setName(new Name("Fred"));
             info1.setDateOfBirth(parseDate("2000-01-01"));
             b1.setOwnerInfo(info1);
+            b1.setLibrary(lib);
             em.persist(b1);
             assertTrue(em.contains(b1));
             Book b2 = new Book();
@@ -86,6 +94,7 @@ public class JPATypedQueryVisitorTest ex
             info2.setName(new Name("Barry"));
             info2.setDateOfBirth(parseDate("2001-01-01"));
             b2.setOwnerInfo(info2);
+            b2.setLibrary(lib);
             em.persist(b2);
             assertTrue(em.contains(b2));
             Book b3 = new Book();
@@ -96,10 +105,10 @@ public class JPATypedQueryVisitorTest ex
             info3.setName(new Name("Bill"));
             info3.setDateOfBirth(parseDate("2002-01-01"));
             b3.setOwnerInfo(info3);
+            b3.setLibrary(lib);
             em.persist(b3);
             assertTrue(em.contains(b3));
             
-            
             em.getTransaction().commit();
         } catch (Exception ex) {
             ex.printStackTrace();
@@ -228,6 +237,7 @@ public class JPATypedQueryVisitorTest ex
         assertEquals("Fred", book.getOwnerInfo().getName().getName());
     }
     
+        
     @Test
     public void testEqualsOwnerNameQuery2() throws Exception {
         List<Book> books = queryBooks("ownerInfo.name==Fred");
@@ -246,6 +256,15 @@ public class JPATypedQueryVisitorTest ex
     }
     
     @Test
+    public void testFindBookInTownLibrary() throws Exception {
+        List<Book> books = queryBooks("libAddress==town;title==num10", null,
+            Collections.singletonMap("libAddress", "library.address"));
+        assertEquals(1, books.size());
+        Book book = books.get(0);
+        assertEquals("Barry", book.getOwnerInfo().getName().getName());
+    }
+    
+    @Test
     public void testEqualsOwnerBirthDate() throws Exception {
         List<Book> books = queryBooks("ownerbdate==2000-01-01", null,
             Collections.singletonMap("ownerbdate", "ownerInfo.dateOfBirth"));

Added: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java?rev=1404556&view=auto
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
(added)
+++ cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
Thu Nov  1 12:25:01 2012
@@ -0,0 +1,45 @@
+/**
+ * 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.cxf.jaxrs.ext.search.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+
+@Entity
+public class Library {
+    @Id
+    private int id;
+    private String address;
+    
+    public int getId() {
+        return id;
+    }
+    
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getAddress() {
+        return address;
+    }
+
+    public void setAddress(String address) {
+        this.address = address;
+    }
+}

Propchange: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/rs/extensions/search/src/test/java/org/apache/cxf/jaxrs/ext/search/jpa/Library.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/rs/extensions/search/src/test/resources/META-INF/persistence.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/rs/extensions/search/src/test/resources/META-INF/persistence.xml?rev=1404556&r1=1404555&r2=1404556&view=diff
==============================================================================
--- cxf/trunk/rt/rs/extensions/search/src/test/resources/META-INF/persistence.xml (original)
+++ cxf/trunk/rt/rs/extensions/search/src/test/resources/META-INF/persistence.xml Thu Nov
 1 12:25:01 2012
@@ -5,6 +5,7 @@
    <persistence-unit name="testUnit" transaction-type="RESOURCE_LOCAL">
     <provider>org.hibernate.ejb.HibernatePersistence</provider>
     <class>org.apache.cxf.jaxrs.ext.search.jpa.Book</class>
+    <class>org.apache.cxf.jaxrs.ext.search.jpa.Library</class>
     <exclude-unlisted-classes>true</exclude-unlisted-classes>
     <properties>
         <property name="hibernate.connection.url" value="jdbc:hsqldb:mem:books-jpa"/>



Mime
View raw message