gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject svn commit: r1510589 - in /gora/trunk: CHANGES.txt gora-core/src/test/java/org/apache/gora/store/DataStoreTestBase.java gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
Date Mon, 05 Aug 2013 16:18:33 GMT
Author: lewismc
Date: Mon Aug  5 16:18:33 2013
New Revision: 1510589

URL: http://svn.apache.org/r1510589
Log:
GORA-232 DataStoreTestBase should delegate all functionality to DataStoreTestUtil 

Modified:
    gora/trunk/CHANGES.txt
    gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestBase.java
    gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java

Modified: gora/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/gora/trunk/CHANGES.txt?rev=1510589&r1=1510588&r2=1510589&view=diff
==============================================================================
--- gora/trunk/CHANGES.txt (original)
+++ gora/trunk/CHANGES.txt Mon Aug  5 16:18:33 2013
@@ -4,6 +4,8 @@
 
 Gora Change Log
 
+* GORA-232 DataStoreTestBase should delegate all functionality to DataStoreTestUtil (Apostolos
Giannakidis via lewismc)
+
 * GORA-259 Removal of the main methods from the test case classes (Apostolos via hsaputra)
 
 * GORA-229 Use @Ignore for unimplemented functionality to identify absent tests (Apostolos
Giannakidis via lewismc)

Modified: gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestBase.java
URL: http://svn.apache.org/viewvc/gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestBase.java?rev=1510589&r1=1510588&r2=1510589&view=diff
==============================================================================
--- gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestBase.java (original)
+++ gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestBase.java Mon Aug
 5 16:18:33 2013
@@ -179,44 +179,13 @@ public abstract class DataStoreTestBase 
   @Test
   public void testPutNested() throws IOException, Exception {
     log.info("test method: testPutNested");
-
-    String revUrl = "foo.com:http/";
-    String url = "http://foo.com/";
-
-    webPageStore.createSchema();
-    WebPage page = webPageStore.newPersistent();
-    Metadata metadata = new Metadata();
-    metadata.setVersion(1);
-    metadata.putToData(new Utf8("foo"), new Utf8("baz"));
-
-    page.setMetadata(metadata);
-    page.setUrl(new Utf8(url));
-
-    webPageStore.put(revUrl, page);
-    webPageStore.flush();
-
-    page = webPageStore.get(revUrl);
-    metadata = page.getMetadata();
-    assertNotNull(metadata);
-    assertEquals(1, metadata.getVersion());
-    assertEquals(new Utf8("baz"), metadata.getData().get(new Utf8("foo")));
+    DataStoreTestUtil.testPutNested(webPageStore);
   }
 
   @Test
   public void testPutArray() throws IOException, Exception {
     log.info("test method: testPutArray");
-    webPageStore.createSchema();
-    WebPage page = webPageStore.newPersistent();
-
-    String[] tokens = {"example", "content", "in", "example.com"};
-
-    for(String token: tokens) {
-      page.addToParsedContent(new Utf8(token));
-    }
-
-    webPageStore.put("com.example/http", page);
-    webPageStore.close();
-
+    DataStoreTestUtil.testPutArray(webPageStore);
     assertPutArray();
   }
 
@@ -226,16 +195,7 @@ public abstract class DataStoreTestBase 
   @Test
   public void testPutBytes() throws IOException, Exception {
     log.info("test method: testPutBytes");
-    webPageStore.createSchema();
-    WebPage page = webPageStore.newPersistent();
-    page.setUrl(new Utf8("http://example.com"));
-    byte[] contentBytes = "example content in example.com".getBytes();
-    ByteBuffer buff = ByteBuffer.wrap(contentBytes);
-    page.setContent(buff);
-
-    webPageStore.put("com.example/http", page);
-    webPageStore.close();
-
+    byte[] contentBytes = DataStoreTestUtil.testPutBytes(webPageStore);
     assertPutBytes(contentBytes);
   }
 
@@ -245,17 +205,7 @@ public abstract class DataStoreTestBase 
   @Test
   public void testPutMap() throws IOException, Exception {
     log.info("test method: testPutMap");
-    webPageStore.createSchema();
-
-    WebPage page = webPageStore.newPersistent();
-
-    page.setUrl(new Utf8("http://example.com"));
-    page.putToOutlinks(new Utf8("http://example2.com"), new Utf8("anchor2"));
-    page.putToOutlinks(new Utf8("http://example3.com"), new Utf8("anchor3"));
-    page.putToOutlinks(new Utf8("http://example3.com"), new Utf8("anchor4"));
-    webPageStore.put("com.example/http", page);
-    webPageStore.close();
-
+    DataStoreTestUtil.testPutMap(webPageStore);
     assertPutMap();
   }
 

Modified: gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java
URL: http://svn.apache.org/viewvc/gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java?rev=1510589&r1=1510588&r2=1510589&view=diff
==============================================================================
--- gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java (original)
+++ gora/trunk/gora-core/src/test/java/org/apache/gora/store/DataStoreTestUtil.java Mon Aug
 5 16:18:33 2013
@@ -821,6 +821,77 @@ public class DataStoreTestUtil {
 
   }
 
+
+  public static void testPutNested(DataStore<String, WebPage> store)
+          throws IOException, Exception {
+    String revUrl = "foo.com:http/";
+    String url = "http://foo.com/";
+
+    store.createSchema();
+    WebPage page = store.newPersistent();
+    Metadata metadata = new Metadata();
+    metadata.setVersion(1);
+    metadata.putToData(new Utf8("foo"), new Utf8("baz"));
+
+    page.setMetadata(metadata);
+    page.setUrl(new Utf8(url));
+
+    store.put(revUrl, page);
+    store.flush();
+
+    page = store.get(revUrl);
+    metadata = page.getMetadata();
+    assertNotNull(metadata);
+    assertEquals(1, metadata.getVersion());
+    assertEquals(new Utf8("baz"), metadata.getData().get(new Utf8("foo")));
+  }
+
+  public static void testPutArray(DataStore<String, WebPage> store)
+          throws IOException, Exception {
+    store.createSchema();
+    WebPage page = store.newPersistent();
+
+    String[] tokens = {"example", "content", "in", "example.com"};
+
+    for(String token: tokens) {
+      page.addToParsedContent(new Utf8(token));
+    }
+
+    store.put("com.example/http", page);
+    store.close();
+  }
+
+  public static byte[] testPutBytes(DataStore<String, WebPage> store)
+          throws IOException, Exception {
+
+    store.createSchema();
+    WebPage page = store.newPersistent();
+    page.setUrl(new Utf8("http://example.com"));
+    byte[] contentBytes = "example content in example.com".getBytes();
+    ByteBuffer buff = ByteBuffer.wrap(contentBytes);
+    page.setContent(buff);
+
+    store.put("com.example/http", page);
+    store.close();
+
+    return contentBytes;
+  }
+
+  public static void testPutMap(DataStore<String, WebPage> store)
+          throws IOException, Exception {
+
+    store.createSchema();
+
+    WebPage page = store.newPersistent();
+
+    page.setUrl(new Utf8("http://example.com"));
+    page.putToOutlinks(new Utf8("http://example2.com"), new Utf8("anchor2"));
+    page.putToOutlinks(new Utf8("http://example3.com"), new Utf8("anchor3"));
+    page.putToOutlinks(new Utf8("http://example3.com"), new Utf8("anchor4"));
+    store.put("com.example/http", page);
+    store.close();
+  }
+
   private static byte[] toByteArray(ByteBuffer buffer) {
     int p = buffer.position();
     int n = buffer.limit() - p;



Mime
View raw message