Author: tpalsulich
Date: Mon Dec 29 18:14:23 2014
New Revision: 1648400

URL: http://svn.apache.org/r1648400
Log:
OODT-762. Migrate cas-catalog test resources.

Added:
    oodt/trunk/catalog/src/test/java/
    oodt/trunk/catalog/src/test/java/org/
    oodt/trunk/catalog/src/test/java/org/apache/
    oodt/trunk/catalog/src/test/java/org/apache/oodt/
    oodt/trunk/catalog/src/test/java/org/apache/oodt/cas/
    oodt/trunk/catalog/src/test/java/org/apache/oodt/cas/catalog/
    oodt/trunk/catalog/src/test/java/org/apache/oodt/cas/catalog/system/
    oodt/trunk/catalog/src/test/java/org/apache/oodt/cas/catalog/system/impl/
    
oodt/trunk/catalog/src/test/java/org/apache/oodt/cas/catalog/system/impl/TestCatalogServiceLocal.java
    oodt/trunk/catalog/src/test/resources/
    oodt/trunk/catalog/src/test/resources/test-index-cat.sql
    oodt/trunk/catalog/src/test/resources/test-mapper-cat.sql
Removed:
    oodt/trunk/catalog/src/test/org/
    oodt/trunk/catalog/src/testdata/
Modified:
    oodt/trunk/catalog/pom.xml

Modified: oodt/trunk/catalog/pom.xml
URL: 
http://svn.apache.org/viewvc/oodt/trunk/catalog/pom.xml?rev=1648400&r1=1648399&r2=1648400&view=diff
==============================================================================
--- oodt/trunk/catalog/pom.xml (original)
+++ oodt/trunk/catalog/pom.xml Mon Dec 29 18:14:23 2014
@@ -20,7 +20,7 @@
   <parent>
     <groupId>org.apache.oodt</groupId>
     <artifactId>oodt-core</artifactId>
-    <version>0.9-SNAPSHOT</version>
+    <version>0.8-SNAPSHOT</version>
     <relativePath>../core/pom.xml</relativePath>
   </parent>
   <artifactId>cas-catalog</artifactId>
@@ -190,7 +190,7 @@
     <dependency>
       <groupId>junit</groupId>
       <artifactId>junit</artifactId>
-      <version>3.8.2</version>
+      <version>4.12</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

Added: 
oodt/trunk/catalog/src/test/java/org/apache/oodt/cas/catalog/system/impl/TestCatalogServiceLocal.java
URL: 
http://svn.apache.org/viewvc/oodt/trunk/catalog/src/test/java/org/apache/oodt/cas/catalog/system/impl/TestCatalogServiceLocal.java?rev=1648400&view=auto
==============================================================================
--- 
oodt/trunk/catalog/src/test/java/org/apache/oodt/cas/catalog/system/impl/TestCatalogServiceLocal.java
 (added)
+++ 
oodt/trunk/catalog/src/test/java/org/apache/oodt/cas/catalog/system/impl/TestCatalogServiceLocal.java
 Mon Dec 29 18:14:23 2014
@@ -0,0 +1,202 @@
+/*
+ * 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.oodt.cas.catalog.system.impl;
+
+//JDK imports
+import java.io.File;
+import java.io.IOException;
+import java.sql.SQLException;
+import java.util.Collections;
+import java.util.List;
+import java.util.Vector;
+
+import junit.framework.TestCase;
+
+//OODT imports
+import org.apache.commons.io.FileUtils;
+import org.apache.oodt.cas.catalog.exception.CatalogServiceException;
+import org.apache.oodt.cas.catalog.mapping.InMemoryIngestMapperFactory;
+import org.apache.oodt.cas.catalog.metadata.TransactionalMetadata;
+import org.apache.oodt.cas.catalog.page.Page;
+import org.apache.oodt.cas.catalog.page.PageInfo;
+import org.apache.oodt.cas.catalog.page.QueryPager;
+import org.apache.oodt.cas.catalog.page.TransactionReceipt;
+import org.apache.oodt.cas.catalog.query.QueryExpression;
+import org.apache.oodt.cas.catalog.query.parser.ParseException;
+import org.apache.oodt.cas.catalog.query.parser.QueryParser;
+import org.apache.oodt.cas.catalog.query.parser.TokenMgrError;
+import 
org.apache.oodt.cas.catalog.repository.MemoryBasedCatalogRepositoryFactory;
+import org.apache.oodt.cas.catalog.struct.impl.index.DataSourceIndexFactory;
+import org.apache.oodt.cas.catalog.struct.impl.index.InMemoryIndexFactory;
+import 
org.apache.oodt.cas.catalog.struct.impl.transaction.UuidTransactionIdFactory;
+import org.apache.oodt.cas.catalog.system.CatalogFactory;
+import org.apache.oodt.cas.metadata.Metadata;
+
+/**
+ * 
+ * @author bfoster
+ * @version $Revision$
+ * 
+ */
+public class TestCatalogServiceLocal extends TestCase {
+
+       private CatalogServiceLocal cs;
+       private File testDir;
+       
+       public void setUp() {
+               try {
+                       File tempFile = File.createTempFile("foo", "bar");
+                       tempFile.deleteOnExit();
+                       testDir = new File(tempFile.getParentFile(), 
"cas-catalog");
+       
+                       CatalogServiceLocalFactory factory = new 
CatalogServiceLocalFactory();
+                       factory
+                                       .setCatalogRepositoryFactory(new 
MemoryBasedCatalogRepositoryFactory());
+                       factory.setIngestMapperFactory(this
+                                       
.getOracleIngestMapperFactory(testDir.getAbsolutePath() + "/mapper"));
+                       factory.setOneCatalogFailsAllFail(true);
+                       factory.setSimplifyQueries(true);
+                       factory.setPluginStorageDir("/dev/null");
+                       factory.setRestrictIngestPermissions(false);
+                       factory.setRestrictQueryPermissions(false);
+                       
factory.setTransactionIdFactory(UuidTransactionIdFactory.class
+                                       .getCanonicalName());
+                       cs = factory.createCatalogService();
+       
+                       CatalogFactory catalogFactory = new CatalogFactory();
+                       catalogFactory.setCatalogId("TestCatalog1");
+                       catalogFactory.setDictionaryFactories(null);
+                       catalogFactory
+                                       
.setIndexFactory(getInMemoryDSFactory(testDir.getAbsolutePath() + "/index/1/"));
+                       catalogFactory.setRestrictIngestPermissions(false);
+                       catalogFactory.setRestrictQueryPermissions(false);
+                       cs.addCatalog(catalogFactory.createCatalog());
+                       catalogFactory.setCatalogId("TestCatalog2");
+                       catalogFactory
+                                       
.setIndexFactory(getInMemoryDSFactory(testDir.getAbsolutePath() + "/index/2/"));
+                       cs.addCatalog(catalogFactory.createCatalog());
+               }catch (Exception e) {
+                       e.printStackTrace();
+                       TestCase.fail(e.getMessage());
+               }
+       }
+       
+       public void tearDown() {
+               try {
+                       FileUtils.forceDelete(this.testDir);
+               } catch (IOException e) {
+                       e.printStackTrace();
+                       TestCase.fail(e.getMessage());
+               }
+       }
+
+       public void testDataSourceCatalogIngestQueryAndDelete()
+                       throws CatalogServiceException, ParseException, 
TokenMgrError {
+               // test ingest
+               Metadata m = new Metadata();
+               m.addMetadata("testkey1", "testval1");
+               TransactionReceipt tr = cs.ingest(m);
+               Vector<TransactionReceipt> receipts = new 
Vector<TransactionReceipt>();
+               receipts.add(tr);
+               List<TransactionalMetadata> metadatas = 
cs.getMetadata(receipts);
+               assertEquals(metadatas.size(), 1);
+               Metadata ingestedMetadata = metadatas.get(0).getMetadata();
+               assertEquals(ingestedMetadata.getMetadata("testkey1"), 
"testval1");
+               
assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);
+
+               // test ingest update
+               m.replaceMetadata(
+                               
CatalogServiceLocal.CATALOG_SERVICE_TRANSACTION_ID_MET_KEY, 
tr.getTransactionId().toString());
+               m.replaceMetadata(CatalogServiceLocal.ENABLE_UPDATE_MET_KEY, 
"true");
+               tr = cs.ingest(m);
+               receipts = new Vector<TransactionReceipt>();
+               receipts.add(tr);
+               metadatas = cs.getMetadata(receipts);
+               assertEquals(metadatas.size(), 1);
+               ingestedMetadata = metadatas.get(0).getMetadata();
+               assertEquals(ingestedMetadata.getMetadata("testkey1"), 
"testval1");
+               
assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);
+
+               // test query using querypager
+               QueryExpression qe = QueryParser
+                               .parseQueryExpression("testkey1 == 'testval1'");
+               QueryPager pager = cs.query(qe);
+               metadatas = cs.getNextPage(pager);
+               assertEquals(metadatas.size(), 1);
+               ingestedMetadata = metadatas.get(0).getMetadata();
+               assertEquals(ingestedMetadata.getMetadata("testkey1"), 
"testval1");
+               
assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);
+
+               // test query using std paging
+               qe = QueryParser.parseQueryExpression("testkey1 == 'testval1'");
+               Page page = cs.getPage(new PageInfo(20, PageInfo.FIRST_PAGE), 
qe);
+               metadatas = cs.getMetadata(page);
+               assertEquals(metadatas.size(), 1);
+               ingestedMetadata = metadatas.get(0).getMetadata();
+               assertEquals(ingestedMetadata.getMetadata("testkey1"), 
"testval1");
+               
assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 2);
+
+               // test query using std paging with catalog restriction
+               qe = QueryParser.parseQueryExpression("testkey1 == 'testval1'");
+               page = cs.getPage(new PageInfo(20, PageInfo.FIRST_PAGE), qe,
+                               Collections.singleton("TestCatalog1"));
+               metadatas = cs.getMetadata(page);
+               assertEquals(metadatas.size(), 1);
+               ingestedMetadata = metadatas.get(0).getMetadata();
+               assertEquals(ingestedMetadata.getMetadata("testkey1"), 
"testval1");
+               
assertEquals(ingestedMetadata.getAllMetadata("testkey1").size(), 1);
+
+               // test delete
+               m = new Metadata();
+               
m.addMetadata(CatalogServiceLocal.CATALOG_SERVICE_TRANSACTION_ID_MET_KEY, 
tr.getTransactionId().toString());
+               cs.delete(m);
+               
assertEquals(cs.getMetadata(Collections.singletonList(tr)).size(), 0);
+       }
+
+       private InMemoryIngestMapperFactory getOracleIngestMapperFactory(
+                       String tmpDirPath) throws SQLException, IOException {
+               String user = "sa";
+               String pass = "";
+               String driver = "org.hsqldb.jdbcDriver";
+               String url = "jdbc:hsqldb:file:" + tmpDirPath + 
";shutdown=true";
+
+               InMemoryIngestMapperFactory factory = new 
InMemoryIngestMapperFactory();
+               factory.setDriver(driver);
+               factory.setJdbcUrl(url);
+               factory.setPass(pass);
+               factory.setUser(user);
+               factory.setTablesFile("src/test/resources/test-mapper-cat.sql");
+               return factory;
+       }
+
+       private DataSourceIndexFactory getInMemoryDSFactory(String tmpDirPath)
+                       throws IOException, SQLException {
+               String user = "sa";
+               String pass = "";
+               String driver = "org.hsqldb.jdbcDriver";
+               String url = "jdbc:hsqldb:file:" + tmpDirPath + 
";shutdown=true";
+
+               InMemoryIndexFactory indexFactory = new InMemoryIndexFactory();
+               indexFactory.setDriver(driver);
+               indexFactory.setJdbcUrl(url);
+               indexFactory.setPass(pass);
+               indexFactory.setUser(user);
+               
indexFactory.setTablesFile("src/test/resources/test-index-cat.sql");
+               return indexFactory;
+       }
+
+}

Added: oodt/trunk/catalog/src/test/resources/test-index-cat.sql
URL: 
http://svn.apache.org/viewvc/oodt/trunk/catalog/src/test/resources/test-index-cat.sql?rev=1648400&view=auto
==============================================================================
--- oodt/trunk/catalog/src/test/resources/test-index-cat.sql (added)
+++ oodt/trunk/catalog/src/test/resources/test-index-cat.sql Mon Dec 29 
18:14:23 2014
@@ -0,0 +1,32 @@
+ -- 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.
+ 
+DROP TABLE transactions IF EXISTS;
+DROP TABLE transaction_terms IF EXISTS;
+
+CREATE TABLE transactions
+(
+  transaction_id varchar(256) NOT NULL,
+  transaction_date varchar(256) NOT NULL
+);
+
+CREATE TABLE transaction_terms
+(
+  transaction_id varchar(256) NOT NULL,
+  bucket_name varchar(256) NOT NULL,
+  term_name varchar(256) NOT NULL,
+  term_value varchar(1000) NOT NULL
+);
+

Added: oodt/trunk/catalog/src/test/resources/test-mapper-cat.sql
URL: 
http://svn.apache.org/viewvc/oodt/trunk/catalog/src/test/resources/test-mapper-cat.sql?rev=1648400&view=auto
==============================================================================
--- oodt/trunk/catalog/src/test/resources/test-mapper-cat.sql (added)
+++ oodt/trunk/catalog/src/test/resources/test-mapper-cat.sql Mon Dec 29 
18:14:23 2014
@@ -0,0 +1,26 @@
+ -- 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.
+ 
+DROP TABLE CatalogServiceMapper IF EXISTS;
+
+CREATE TABLE CatalogServiceMapper (
+  CAT_SERV_TRANS_ID VARCHAR(255) NOT NULL ,
+  CAT_SERV_TRANS_FACTORY VARCHAR(255) NOT NULL ,
+  CAT_TRANS_ID VARCHAR(255) NOT NULL ,
+  CAT_TRANS_FACTORY VARCHAR(255) NOT NULL ,
+  CAT_TRANS_DATE VARCHAR(255) NOT NULL ,
+  CATALOG_ID VARCHAR(255) NOT NULL
+);
+


Reply via email to