Author: veithen
Date: Sat May 19 19:59:09 2012
New Revision: 1340552

URL: http://svn.apache.org/viewvc?rev=1340552&view=rev
Log:
Increase test coverage for JiBXDataSource.

Modified:
    
axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/LibraryTest.java
    
axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/service/LibraryImpl.java

Modified: 
axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/LibraryTest.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/LibraryTest.java?rev=1340552&r1=1340551&r2=1340552&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/LibraryTest.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/LibraryTest.java
 Sat May 19 19:59:09 2012
@@ -18,9 +18,13 @@
  */
 package org.apache.axis2.jibx.library.unwrapped;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
 import org.apache.axis2.Constants;
 import org.apache.axis2.description.AxisService;
 import org.apache.axis2.jibx.UtilServer;
+import org.apache.axis2.jibx.beans.Book;
 import org.apache.axis2.jibx.library.unwrapped.client.LibraryStub;
 import org.apache.axis2.jibx.library.unwrapped.service.LibraryImpl;
 import org.junit.AfterClass;
@@ -33,6 +37,7 @@ public class LibraryTest {
         UtilServer.start(System.getProperty("basedir", ".") + 
"/target/repo/library-unwrapped");
         AxisService service = 
UtilServer.getConfigurationContext().getAxisConfiguration().getService("library");
         
service.getParameter(Constants.SERVICE_CLASS).setValue(LibraryImpl.class.getName());
+        service.setScope(Constants.SCOPE_APPLICATION);
     }
     
     @AfterClass
@@ -44,5 +49,13 @@ public class LibraryTest {
     public void test() throws Exception {
         LibraryStub stub = new 
LibraryStub("http://127.0.0.1:5555/axis2/services/library";);
         stub.addBook("Paperback", "0618918248", new String[] { "Richard 
Dawkins" }, "The God Delusion");
+        Book book = stub.getBook("0618918248");
+        assertNotNull(book);
+        assertEquals("Paperback", book.getType());
+        assertEquals("0618918248", book.getIsbn());
+        assertEquals("The God Delusion", book.getTitle());
+        String[] authors = book.getAuthors();
+        assertEquals(1, authors.length);
+        assertEquals("Richard Dawkins", authors[0]);
     }
 }

Modified: 
axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/service/LibraryImpl.java
URL: 
http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/service/LibraryImpl.java?rev=1340552&r1=1340551&r2=1340552&view=diff
==============================================================================
--- 
axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/service/LibraryImpl.java
 (original)
+++ 
axis/axis2/java/core/trunk/modules/jibx/src/test/java/org/apache/axis2/jibx/library/unwrapped/service/LibraryImpl.java
 Sat May 19 19:59:09 2012
@@ -18,18 +18,22 @@
  */
 package org.apache.axis2.jibx.library.unwrapped.service;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.axis2.jibx.beans.Book;
 import org.apache.axis2.jibx.beans.Type;
 
 public class LibraryImpl implements LibrarySkeletonInterface {
+    private final Map<String,Book> books = new HashMap<String,Book>();
+    
     public Type[] getTypes() {
         // TODO Auto-generated method stub
         return null;
     }
 
     public Book getBook(String isbn) {
-        // TODO Auto-generated method stub
-        return null;
+        return books.get(isbn);
     }
 
     public void addBookInstance(Book book) {
@@ -42,8 +46,8 @@ public class LibraryImpl implements Libr
         return null;
     }
 
-    public boolean addBook(String type, String isbn, String[] author, String 
title) {
-        // TODO Auto-generated method stub
-        return false;
+    public boolean addBook(String type, String isbn, String[] authors, String 
title) {
+        books.put(isbn, new Book(type, isbn, title, authors));
+        return true;
     }
 }


Reply via email to