incubator-connectors-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kwri...@apache.org
Subject svn commit: r1205763 - in /incubator/lcf/branches/CONNECTORS-286/warthog: ./ lib/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/warthog/ src/test/java/org/apache/warthog/tests/
Date Thu, 24 Nov 2011 09:15:58 GMT
Author: kwright
Date: Thu Nov 24 09:15:57 2011
New Revision: 1205763

URL: http://svn.apache.org/viewvc?rev=1205763&view=rev
Log:
Add testing infrastructure, to be fleshed out as I build the tests.

Added:
    incubator/lcf/branches/CONNECTORS-286/warthog/lib/junit-4.7.jar   (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicKeyValueStore.java
  (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
  (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java
  (with props)
    incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java
  (with props)
Modified:
    incubator/lcf/branches/CONNECTORS-286/warthog/build.xml

Modified: incubator/lcf/branches/CONNECTORS-286/warthog/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/build.xml?rev=1205763&r1=1205762&r2=1205763&view=diff
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/build.xml (original)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/build.xml Thu Nov 24 09:15:57 2011
@@ -32,6 +32,37 @@
         </javac>
     </target>
 
+    <target name="compile-tests" depends="compile">
+        <mkdir dir="build/test-classes"/>
+        <javac srcdir="src/test/java" destdir="build/test-classes" target="1.5" source="1.5"
debug="true" debuglevel="lines,vars,source">
+            <classpath>
+                 <fileset dir="lib"> 
+                    <include name="*.jar"/> 
+                </fileset>
+                <pathelement location="build/classes"/>
+            </classpath>
+        </javac>
+    </target>
+
+
+    <target name="run-tests" depends="compile-tests">
+        <mkdir dir="build/test-output"/>
+        <junit fork="true" maxmemory="512m" dir="build/test-output" outputtoformatters="true"
showoutput="true" haltonfailure="true">
+            <classpath>
+                <fileset dir="lib">
+                    <include name="*.jar"/>
+                </fileset>
+                <pathelement location="build/classes"/>
+                <pathelement location="build/test-classes"/>
+            </classpath>
+            <formatter type="brief" usefile="false"/>
+
+            <test name="org.apache.warthog.tests.SanityTest" todir="build/test-output"/>
+            <!-- MHL -->
+            
+        </junit>
+    </target>
+
     <target name="all" depends="compile"/>
     
 </project>

Added: incubator/lcf/branches/CONNECTORS-286/warthog/lib/junit-4.7.jar
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/lib/junit-4.7.jar?rev=1205763&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/lib/junit-4.7.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicKeyValueStore.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicKeyValueStore.java?rev=1205763&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicKeyValueStore.java
(added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicKeyValueStore.java
Thu Nov 24 09:15:57 2011
@@ -0,0 +1,64 @@
+/* $Id$ */
+
+/**
+* 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.warthog.tests;
+
+import org.apache.warthog.interfaces.*;
+import java.util.*;
+
+/** In-memory key value store, for testing.
+*/
+public class InMemAtomicKeyValueStore implements WHAtomicKeyValueStore
+{
+  /** Constructor */
+  public InMemAtomicKeyValueStore()
+  {
+  }
+  
+  /** Get a value */
+  public WHValue get(WHKey key)
+    throws WHException
+  {
+    // MHL
+    return null;
+  }
+  
+  /** Check a bunch of values atomically for consistency.
+  *@param checkValues is a map of keys/values that must be unchanged.  If any value is
+  * changed, a WHDeadlockException is thrown.
+  */
+  public void check(WHKeyMap checkValues)
+    throws WHException
+  {
+    // MHL
+  }
+  
+  /** Set a bunch of values atomically.
+  *@param checkValues is a map of keys/values that must be unchanged in order for the
+  * commit to proceed.  If these values are detected to have been changed, a WHDeadlockException
+  * will be thrown.  Null values are permitted.
+  *@param setValues is a map of keys to set to specified new values.  A null value implies
removal of
+  * the key.
+  */
+  public void setAll(WHKeyMap checkValues, WHKeyMap setValues)
+    throws WHException
+  {
+    // MHL
+  }
+}

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicKeyValueStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemAtomicKeyValueStore.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java?rev=1205763&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
(added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
Thu Nov 24 09:15:57 2011
@@ -0,0 +1,159 @@
+/* $Id$ */
+
+/**
+* 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.warthog.tests;
+
+import org.apache.warthog.interfaces.*;
+import java.util.*;
+
+/** This class implements a transaction that is in progress, completely in memory.
+*/
+public class InMemTransactionImpl implements WHTransaction
+{
+  protected WHAtomicKeyValueStore underlyingStore;
+  
+  protected KeyMap checkData = new KeyMap();
+  protected KeyMap localData = null;
+
+  /** Constructor */
+  public InMemTransactionImpl(WHAtomicKeyValueStore underlyingStore)
+  {
+    this.underlyingStore = underlyingStore;
+  }
+  
+  /** Set a value.  May be null. */
+  public void put(WHKey key, WHValue value)
+    throws WHException
+  {
+    if (localData == null)
+      localData = new KeyMap();
+    localData.put(key,value);
+  }
+
+  /** Get a value.  Null returned if no value. */
+  public WHValue get(WHKey key)
+    throws WHException
+  {
+    if (localData != null)
+    {
+      if (localData.containsKey(key))
+        return localData.get(key);
+    }
+    if (checkData.containsKey(key))
+      return checkData.get(key);
+    WHValue value = underlyingStore.get(key);
+    checkData.put(key,value);
+    return value;
+  }
+
+  /** Check to see if this transaction has become inconsistent.
+  * If so, a WHDeadlockException is thrown.
+  */
+  public void check()
+    throws WHException
+  {
+    underlyingStore.check(checkData);
+  }
+
+  /** Commit this transaction */
+  public void commit()
+    throws WHException
+  {
+    underlyingStore.setAll(checkData,localData);
+  }
+  
+  /** Abandon this transaction.
+  * This is called as a nicety to free any resources associated with the
+  * transaction.  The implementation should also be robust as far as
+  * freeing resources if this method is NOT called, but might perform
+  * the necessary logic in a finalizer at an arbitrary time.
+  */
+  public void abandon()
+  {
+    // Does nothing so long as the entire temporary transaction is in
+    // memory.
+  }
+
+  /** Local implementation of WHKey/WHValue map */
+  protected static class KeyMap implements WHKeyMap
+  {
+    protected Map<WHKey,WHValue> map = new HashMap<WHKey,WHValue>();
+    
+    public KeyMap()
+    {
+    }
+    
+    /** Get a value from the map.
+    */
+    public WHValue get(WHKey key)
+      throws WHException
+    {
+      return map.get(key);
+    }
+    
+    /** Iterate over the keys in the map.
+    */
+    public WHKeyIterator iterator()
+      throws WHException
+    {
+      return new KeyIterator(map.keySet().iterator());
+    }
+    
+    /** Check if the map contains the specified key.
+    */
+    public boolean containsKey(WHKey key)
+    {
+      return map.containsKey(key);
+    }
+
+    /** Put a value.
+    */
+    public void put(WHKey key, WHValue value)
+    {
+      map.put(key,value);
+    }
+  }
+  
+  /** Key iterator for KeyMap */
+  protected static class KeyIterator implements WHKeyIterator
+  {
+    protected Iterator<WHKey> iterator;
+    
+    public KeyIterator(Iterator<WHKey> iterator)
+    {
+      this.iterator = iterator;
+    }
+    
+    /** Check if there is another value */
+    public boolean hasNext()
+      throws WHException
+    {
+      return iterator.hasNext();
+    }
+    
+    /** Get the next value */
+    public WHKey next()
+      throws WHException
+    {
+      return iterator.next();
+    }
+
+  }
+  
+}

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java?rev=1205763&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java
(added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java
Thu Nov 24 09:15:57 2011
@@ -0,0 +1,44 @@
+/* $Id$ */
+
+/**
+* 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.warthog.tests;
+
+import org.apache.warthog.interfaces.*;
+
+/** Class implementing a transactional key/value store completely in memory.
+*/
+public class InMemTransactionalStoreImpl implements WHTransactionalStore
+{
+  /** Underlying atomic key/value store */
+  protected WHAtomicKeyValueStore underlyingStore;
+  
+  /** Constructor. */
+  public InMemTransactionalStoreImpl(WHAtomicKeyValueStore underlyingStore)
+  {
+    this.underlyingStore = underlyingStore;
+  }
+  
+  /** Create a transaction. */
+  public WHTransaction createTransaction()
+    throws WHException
+  {
+    return new InMemTransactionImpl(this.underlyingStore);
+  }
+
+}

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/InMemTransactionalStoreImpl.java
------------------------------------------------------------------------------
    svn:keywords = Id

Added: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java
URL: http://svn.apache.org/viewvc/incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java?rev=1205763&view=auto
==============================================================================
--- incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java
(added)
+++ incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java
Thu Nov 24 09:15:57 2011
@@ -0,0 +1,36 @@
+/* $Id$ */
+
+/**
+* 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.warthog.tests;
+
+import org.apache.warthog.interfaces.*;
+import org.junit.*;
+import static org.junit.Assert.*;
+
+public class SanityTest
+{
+
+  @Test
+  public void writeAndQuery()
+    throws Exception
+  {
+    // MHL
+    //assertEquals(resolved.toASCIIString(),"http://bar.com");
+  }
+
+}
\ No newline at end of file

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/lcf/branches/CONNECTORS-286/warthog/src/test/java/org/apache/warthog/tests/SanityTest.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message