gora-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lewi...@apache.org
Subject svn commit: r1366777 - in /gora/branches/goraamazon/gora-dynamodb/src: main/java/org/apache/gora/dynamodb/store/ test/conf/ test/java/org/apache/gora/dynamodb/
Date Sat, 28 Jul 2012 22:42:37 GMT
Author: lewismc
Date: Sat Jul 28 22:42:37 2012
New Revision: 1366777

URL: http://svn.apache.org/viewvc?rev=1366777&view=rev
Log:
various updates for testing

Modified:
    gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBStore.java
    gora/branches/goraamazon/gora-dynamodb/src/test/conf/AwsCredentials.properties
    gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/GoraDynamoDBTestDriver.java
    gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/TestDynamoDBStore.java

Modified: gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBStore.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBStore.java?rev=1366777&r1=1366776&r2=1366777&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBStore.java
(original)
+++ gora/branches/goraamazon/gora-dynamodb/src/main/java/org/apache/gora/dynamodb/store/DynamoDBStore.java
Sat Jul 28 22:42:37 2012
@@ -21,6 +21,7 @@ package org.apache.gora.dynamodb.store;
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.IOException;
+import java.io.InputStream;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -66,9 +67,6 @@ public class DynamoDBStore<K, T extends 
 	
   public static final Logger LOG = LoggerFactory.getLogger(DynamoDBStore.class);
 
-  // TODO this should be loaded from the class path
-  private static final String MAPPING_FILE_PATH = "gora-dynamodb/conf/";
-  
   private static String preferredSchema;
   
   /**
@@ -160,8 +158,8 @@ public class DynamoDBStore<K, T extends 
 
     try {
       SAXBuilder builder = new SAXBuilder();
-      //Document doc = builder.build(getClass().getClassLoader() .getResourceAsStream(MAPPING_FILE_PATH
+ MAPPING_FILE));
-      Document doc = builder.build(new File(MAPPING_FILE_PATH + MAPPING_FILE));
+      Document doc = builder.build(getClass().getClassLoader().getResourceAsStream(MAPPING_FILE));
+      //Document doc = builder.build(new File(MAPPING_FILE_PATH + MAPPING_FILE));
       
       Element root = doc.getRootElement();
 
@@ -219,13 +217,17 @@ public class DynamoDBStore<K, T extends 
    * @throws IllegalArgumentException
    * @throws IOException
    */
-  private AWSCredentials getCredentials() throws FileNotFoundException, IllegalArgumentException,
IOException{
-	  // TODO this should be done using a class loader, and reading it as a stream
-	  File file = new File(MAPPING_FILE_PATH + awsCredentialsProperties);
-	  AWSCredentials credentials = new PropertiesCredentials(file);
-	  setConf(credentials);
-	  return credentials;
-  }
+  private AWSCredentials getCredentials() throws FileNotFoundException, 
+    IllegalArgumentException, IOException {
+    
+    //File file = new File(MAPPING_FILE_PATH + awsCredentialsProperties);
+    InputStream awsCredInpStr = getClass().getClassLoader().getResourceAsStream(awsCredentialsProperties);
+    if (awsCredInpStr == null)
+      LOG.info("AWS Credentials File was not found on the classpath!");
+      AWSCredentials credentials = new PropertiesCredentials(awsCredInpStr);
+      setConf(credentials);
+      return credentials;
+  }  
 
   private DynamoDBQuery<K, T> buildDynamoDBQuery(Query<K, T> query){
 	  if(getSchemaName() == null)

Modified: gora/branches/goraamazon/gora-dynamodb/src/test/conf/AwsCredentials.properties
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-dynamodb/src/test/conf/AwsCredentials.properties?rev=1366777&r1=1366776&r2=1366777&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-dynamodb/src/test/conf/AwsCredentials.properties (original)
+++ gora/branches/goraamazon/gora-dynamodb/src/test/conf/AwsCredentials.properties Sat Jul
28 22:42:37 2012
@@ -1,4 +1,21 @@
+# 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.
+
 #Insert your AWS Credentials from http://aws.amazon.com/security-credentials
-#Thu Jun 07 15:36:04 PET 2012
-secretKey=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
-accessKey=xxxxxxxxxxxxxxxxxxxx
\ No newline at end of file
+#The secretKey should contain 40 characters
+#The accessKey should contain 20 characters
+
+secretKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
+accessKey=XXXXXXXXXXXXXXXXXXXX

Modified: gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/GoraDynamoDBTestDriver.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/GoraDynamoDBTestDriver.java?rev=1366777&r1=1366776&r2=1366777&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/GoraDynamoDBTestDriver.java
(original)
+++ gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/GoraDynamoDBTestDriver.java
Sat Jul 28 22:42:37 2012
@@ -52,7 +52,7 @@ public class GoraDynamoDBTestDriver exte
   
   static String awsCredentialsFile = "AwsCredentials.properties";
   
-  static String awsCredentialsPath = "gora-dynamodb/conf/";
+  static String awsCredentialsPath = "target/test-classes/";
   
   protected Object auth;
   

Modified: gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/TestDynamoDBStore.java
URL: http://svn.apache.org/viewvc/gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/TestDynamoDBStore.java?rev=1366777&r1=1366776&r2=1366777&view=diff
==============================================================================
--- gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/TestDynamoDBStore.java
(original)
+++ gora/branches/goraamazon/gora-dynamodb/src/test/java/org/apache/gora/dynamodb/TestDynamoDBStore.java
Sat Jul 28 22:42:37 2012
@@ -38,7 +38,6 @@ import org.apache.gora.store.DataStoreFa
 import org.apache.gora.store.DataStoreTestBase;
 import org.apache.gora.store.DataStoreTestUtil;
 import org.apache.gora.store.ws.impl.WSDataStoreFactory;
-import org.apache.hadoop.conf.Configuration;
 import org.junit.After;
 import org.junit.Test;
 
@@ -65,15 +64,13 @@ public class TestDynamoDBStore extends D
   
   private static DynamoDBStore<String,person> personStore;
   
-  private Configuration conf;
-
   static {
     setTestDriver(new GoraDynamoDBTestDriver());
   }
   
   @Override
   public void setUp() throws Exception {
-    //super.setUp();
+    super.setUp();
     auth = getTestDriver().getAuth();
     createDataStore();
     setUpResources();
@@ -82,15 +79,15 @@ public class TestDynamoDBStore extends D
   @Override
   protected DataStore<String, Employee> createEmployeeDataStore()
       throws IOException {
-    return DataStoreFactory.createDataStore(DynamoDBStore.class, String.class, 
-        Employee.class, conf);
+    return WSDataStoreFactory.createDataStore(DynamoDBStore.class, String.class, 
+        Employee.class, auth);
   }
 
   @Override
   protected DataStore<String, WebPage> createWebPageDataStore()
       throws IOException {
-    return DataStoreFactory.createDataStore(DynamoDBStore.class, String.class, 
-        WebPage.class, conf);
+    return WSDataStoreFactory.createDataStore(DynamoDBStore.class, String.class, 
+        WebPage.class, auth);
   }
   
   private void setUpResources(){



Mime
View raw message