cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject git commit: Minor systests refactorings
Date Sun, 03 Aug 2014 16:50:14 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 7ec0f0807 -> 43aa45546


Minor systests refactorings


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/43aa4554
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/43aa4554
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/43aa4554

Branch: refs/heads/master
Commit: 43aa455461fb8a33b0e5844512b263a262c2420c
Parents: 7ec0f08
Author: reta <drreta@gmail.com>
Authored: Sun Aug 3 12:49:56 2014 -0400
Committer: reta <drreta@gmail.com>
Committed: Sun Aug 3 12:49:56 2014 -0400

----------------------------------------------------------------------
 .../java/org/apache/cxf/systest/jaxrs/Book.java | 54 --------------
 .../org/apache/cxf/systest/jaxrs/BookStore.java | 75 -------------------
 .../jaxrs/BookStoreCustomApplication.java       |  1 +
 .../cxf/systest/jaxrs/BookStoreService.java     |  2 +
 .../cxf/systest/jaxrs/cdi/AbstractCDITest.java  |  1 -
 .../org/apache/cxf/systest/jaxrs/cdi/Book.java  | 54 ++++++++++++++
 .../apache/cxf/systest/jaxrs/cdi/BookStore.java | 77 ++++++++++++++++++++
 .../systest/jaxrs/extraction/BookCatalog.java   | 17 +++--
 8 files changed, 145 insertions(+), 136 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/43aa4554/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/Book.java b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
deleted file mode 100644
index 8e6c189..0000000
--- a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/Book.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- * 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.systest.jaxrs;
-
-import javax.validation.constraints.NotNull;
-
-public class Book {
-    @NotNull private String name;
-    private String id;
-    
-    public Book() {
-    }
-    
-    public Book(String id) {
-        this.id = id;
-    }
-    
-    public Book(String name, String id) {
-        this.name = name;
-        this.id = id;
-    }
-    
-    public void setName(String n) {
-        name = n;
-    }
-
-    public String getName() {
-        return name;
-    }
-    
-    public void setId(String i) {
-        id = i;
-    }
- 
-    public String getId() {
-        return id;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/43aa4554/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
deleted file mode 100644
index 755dbff..0000000
--- a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * 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.systest.jaxrs;
-
-import java.util.Collection;
-
-import javax.inject.Inject;
-import javax.validation.Valid;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import javax.ws.rs.FormParam;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-
-@Path("/bookstore/")
-public class BookStore {
-    @Inject private BookStoreService service;
-    @Inject private String version;
-
-    @GET
-    @Path("/version")
-    @Produces(MediaType.TEXT_PLAIN)
-    public String getVersion() {
-        return version;    
-    }
-    
-    @GET
-    @Path("/books/{bookId}")
-    @NotNull
-    @Produces(MediaType.APPLICATION_JSON)
-    public Book getBook(@PathParam("bookId") String id) {
-        return service.get(id);
-    }
-    
-    @GET
-    @Path("/books")
-    @NotNull @Valid
-    @Produces(MediaType.APPLICATION_JSON)
-    public Collection< Book > getBooks() {
-        return service.all();
-    }
-    
-    @POST
-    @Path("/books")
-    @Produces(MediaType.APPLICATION_JSON)
-    public Response addBook(@Context final UriInfo uriInfo, 
-            @NotNull @Size(min = 1, max = 50) @FormParam("id") String id,
-            @NotNull @FormParam("name") String name) {
-        final Book book = service.store(id, name);   
-        return Response.created(uriInfo.getRequestUriBuilder().path(id).build()).entity(book).build();
-    }
-}

http://git-wip-us.apache.org/repos/asf/cxf/blob/43aa4554/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
index 631470d..eeb20f4 100644
--- a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreCustomApplication.java
@@ -29,6 +29,7 @@ import com.google.common.collect.Sets;
 
 import org.apache.cxf.jaxrs.validation.JAXRSBeanValidationFeature;
 import org.apache.cxf.jaxrs.validation.ValidationExceptionMapper;
+import org.apache.cxf.systest.jaxrs.cdi.BookStore;
 
 @ApplicationPath("/custom")
 public class BookStoreCustomApplication extends Application {

http://git-wip-us.apache.org/repos/asf/cxf/blob/43aa4554/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreService.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreService.java
b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreService.java
index f451dd8..38788eb 100644
--- a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreService.java
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/BookStoreService.java
@@ -24,6 +24,8 @@ import java.util.Map;
 
 import javax.inject.Named;
 
+import org.apache.cxf.systest.jaxrs.cdi.Book;
+
 @Named
 public class BookStoreService {
     private Map< String, Book > books = new HashMap< String, Book >();

http://git-wip-us.apache.org/repos/asf/cxf/blob/43aa4554/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractCDITest.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractCDITest.java
b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractCDITest.java
index e58924a..cba800a 100644
--- a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractCDITest.java
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/AbstractCDITest.java
@@ -30,7 +30,6 @@ import javax.ws.rs.core.Response.Status;
 import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
 
 import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.systest.jaxrs.Book;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.junit.Test;
 

http://git-wip-us.apache.org/repos/asf/cxf/blob/43aa4554/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/Book.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/Book.java b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/Book.java
new file mode 100644
index 0000000..7952fce
--- /dev/null
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/Book.java
@@ -0,0 +1,54 @@
+/**
+ * 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.systest.jaxrs.cdi;
+
+import javax.validation.constraints.NotNull;
+
+public class Book {
+    @NotNull private String name;
+    private String id;
+    
+    public Book() {
+    }
+    
+    public Book(String id) {
+        this.id = id;
+    }
+    
+    public Book(String name, String id) {
+        this.name = name;
+        this.id = id;
+    }
+    
+    public void setName(String n) {
+        name = n;
+    }
+
+    public String getName() {
+        return name;
+    }
+    
+    public void setId(String i) {
+        id = i;
+    }
+ 
+    public String getId() {
+        return id;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/43aa4554/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStore.java b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStore.java
new file mode 100644
index 0000000..2b3b8d7
--- /dev/null
+++ b/systests/cdi/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStore.java
@@ -0,0 +1,77 @@
+/**
+ * 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.systest.jaxrs.cdi;
+
+import java.util.Collection;
+
+import javax.inject.Inject;
+import javax.validation.Valid;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import javax.ws.rs.FormParam;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.cxf.systest.jaxrs.BookStoreService;
+
+@Path("/bookstore/")
+public class BookStore {
+    @Inject private BookStoreService service;
+    @Inject private String version;
+
+    @GET
+    @Path("/version")
+    @Produces(MediaType.TEXT_PLAIN)
+    public String getVersion() {
+        return version;    
+    }
+    
+    @GET
+    @Path("/books/{bookId}")
+    @NotNull
+    @Produces(MediaType.APPLICATION_JSON)
+    public Book getBook(@PathParam("bookId") String id) {
+        return service.get(id);
+    }
+    
+    @GET
+    @Path("/books")
+    @NotNull @Valid
+    @Produces(MediaType.APPLICATION_JSON)
+    public Collection< Book > getBooks() {
+        return service.all();
+    }
+    
+    @POST
+    @Path("/books")
+    @Produces(MediaType.APPLICATION_JSON)
+    public Response addBook(@Context final UriInfo uriInfo, 
+            @NotNull @Size(min = 1, max = 50) @FormParam("id") String id,
+            @NotNull @FormParam("name") String name) {
+        final Book book = service.store(id, name);   
+        return Response.created(uriInfo.getRequestUriBuilder().path(id).build()).entity(book).build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/43aa4554/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
index 76785d5..343efce 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/extraction/BookCatalog.java
@@ -65,6 +65,7 @@ public class BookCatalog {
     private final Directory directory = new RAMDirectory();
     private final Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_40);
     private final IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_40, analyzer);
+    private final LuceneQueryVisitor<SearchBean> visitor = createVisitor();
     
     @POST
     @Consumes("multipart/form-data")
@@ -102,13 +103,7 @@ public class BookCatalog {
         IndexSearcher searcher = new IndexSearcher(reader);        
 
         try {
-            final Map< String, Class< ? > > fieldTypes = new HashMap< String,
Class< ? > >();
-            fieldTypes.put("modified", Date.class);
-            
-            LuceneQueryVisitor<SearchBean> visitor = new LuceneQueryVisitor<SearchBean>("ct",
"contents");
-            visitor.setPrimitiveFieldTypeMap(fieldTypes);
             visitor.visit(searchContext.getCondition(SearchBean.class));
-    
             return Arrays.asList(searcher.search(visitor.getQuery(), null, 1000).scoreDocs);
         } finally {
             reader.close();
@@ -128,6 +123,16 @@ public class BookCatalog {
         
         return Response.ok().build();
     }
+    
+    private static LuceneQueryVisitor< SearchBean > createVisitor() {
+        final Map< String, Class< ? > > fieldTypes = new HashMap< String,
Class< ? > >();
+        fieldTypes.put("modified", Date.class);
+        
+        LuceneQueryVisitor<SearchBean> visitor = new LuceneQueryVisitor<SearchBean>("ct",
"contents");
+        visitor.setPrimitiveFieldTypeMap(fieldTypes);
+        return visitor;
+    }
+
 }
 
 


Mime
View raw message