[teiid-commits] teiid SVN: r3197 - in trunk/connectors/sandbox/coherence_translator/src: META-INF and 7 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Wed May 25 18:10:37 EDT 2011
Author: vhalbert at redhat.com
Date: 2011-05-25 18:10:37 -0400 (Wed, 25 May 2011)
New Revision: 3197
Added:
trunk/connectors/sandbox/coherence_translator/src/META-INF/
trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml
trunk/connectors/sandbox/coherence_translator/src/test/
trunk/connectors/sandbox/coherence_translator/src/test/java/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/
trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java
trunk/connectors/sandbox/coherence_translator/src/test/resources/
trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.vdb
trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.xmi
Log:
TEIID-1594 added test case and artifacts for testing on server
Added: trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml (rev 0)
+++ trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml 2011-05-25 22:10:37 UTC (rev 3197)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+
+ <!-- Custom COHERENCE translator -->
+ <bean name="translator-customoracle-template" class="org.teiid.templates.TranslatorDeploymentTemplate">
+ <property name="info"><inject bean="translator-coherence" /> </property>
+ <property name="managedObjectFactory"> <inject bean="ManagedObjectFactory" /> </property>
+ </bean>
+
+ <bean name="translator-coherence" class="org.teiid.templates.TranslatorTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="TranslatorDeploymentTemplateInfoFactory" />
+ <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.coherence.CoherenceExecutionFactory</parameter>
+ <parameter class="java.lang.String">translator-coherence</parameter>
+ <parameter class="java.lang.String">coherence</parameter>
+ </constructor>
+ </bean>
+
+</deployment>
\ No newline at end of file
Property changes on: trunk/connectors/sandbox/coherence_translator/src/META-INF/jboss-beans.xml
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ LF
Added: trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java
===================================================================
--- trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java (rev 0)
+++ trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java 2011-05-25 22:10:37 UTC (rev 3197)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.coherence.connector;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.junit.Test;
+import org.teiid.coherence.translator.Leg;
+import org.teiid.coherence.translator.Trade;
+
+import com.tangosol.net.CacheFactory;
+import com.tangosol.net.NamedCache;
+
+public class TestCoherenceConnection {
+
+ static {
+ try {
+ loadCoherence();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * Load the cache with 3 trades and 10 legs for each trade.
+ *
+ * @throws Exception
+ */
+ private static void loadCoherence() throws Exception {
+ NamedCache tradesCache = CacheFactory.getCache("Trades");
+
+ // populate the cache
+ Map legsMap = new HashMap();
+ Trade trade = new Trade();
+
+ for (int i = 1; i <= 3; i++) {
+
+ for (int j = 1; j <= 10; j++) {
+ Leg leg = new Leg();
+ leg.setId(j);
+ leg.setNotional(i + j);
+ legsMap.put(j, leg);
+ }
+ trade.setId(i);
+ trade.setLegs(legsMap);
+ tradesCache.put(i, trade);
+ }
+
+ System.out.println("Loaded Coherence");
+
+ }
+
+ /**
+ * This will instantiate the {@link CoherenceManagedConnectionFactory} and
+ * obtain a connection to
+ *
+ * @throws Exception
+ */
+ @Test
+ public void testGet1Trade() throws Exception {
+
+ CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
+ CoherenceConnection conn = (CoherenceConnection) f.createConnectionFactory().getConnection();
+
+ List<Long> ids = new ArrayList<Long>();
+ ids.add(new Long(1));
+ // List<Trade> trades = conn.getTrades(ids);
+
+ List<?> trades = conn.get("Id = " + 1 + "l");
+ if (trades == null || trades.size() == 0) {
+ throw new Exception("get1Trade: No trade found for 1");
+ } else {
+ System.out
+ .println("get1Trade: # of Trades found: " + trades.size());
+ }
+
+ // grab the first trade to confirm trade 1 was found in the cache.
+ Trade t = (Trade) trades.get(0);
+ Map legs = t.getLegs();
+ System.out.println("Num of legs are: " + legs.size());
+
+ }
+
+ @Test
+ public void testGetAllTrades() throws Exception {
+
+ CoherenceManagedConnectionFactory f = new CoherenceManagedConnectionFactory();
+ CoherenceConnection conn = (CoherenceConnection) f
+ .createConnectionFactory().getConnection();
+
+ List<Object> trades = conn.get(null);
+ if (trades == null || trades.size() == 0) {
+ throw new Exception("getAllTrades: No trades found for 1");
+ } else {
+ System.out.println("getAllTrades: # of Trades found: "
+ + trades.size());
+ }
+
+ Trade t = (Trade) trades.get(0);
+ Map legs = t.getLegs();
+ System.out.println("Num of legs are: " + legs.size());
+
+ }
+}
Property changes on: trunk/connectors/sandbox/coherence_translator/src/test/java/org/teiid/coherence/connector/TestCoherenceConnection.java
___________________________________________________________________
Added: svn:keywords
+ Id Revision
Added: svn:eol-style
+ LF
Added: trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.vdb
===================================================================
(Binary files differ)
Property changes on: trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.vdb
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.xmi
===================================================================
--- trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.xmi (rev 0)
+++ trunk/connectors/sandbox/coherence_translator/src/test/resources/Coherence.xmi 2011-05-25 22:10:37 UTC (rev 3197)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ASCII"?>
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:diagram="http://www.metamatrix.com/metamodels/Diagram" xmlns:mmcore="http://www.metamatrix.com/metamodels/Core" xmlns:relational="http://www.metamatrix.com/metamodels/Relational">
+ <mmcore:ModelAnnotation xmi:uuid="mmuuid:f415b6fc-e09b-466a-b19b-f7bdfea4195f" primaryMetamodelUri="http://www.metamatrix.com/metamodels/Relational" modelType="PHYSICAL" ProducerName="Teiid Designer" ProducerVersion="7.1.0.v20110215-1224-H420-GA">
+ <modelImports xmi:uuid="mmuuid:c704e924-4d3e-46c1-ab88-d9811254770a" name="XMLSchema" modelLocation="http://www.w3.org/2001/XMLSchema" modelType="TYPE" primaryMetamodelUri="http://www.eclipse.org/xsd/2002/XSD"/>
+ </mmcore:ModelAnnotation>
+ <diagram:DiagramContainer xmi:uuid="mmuuid:edd4ddef-d373-4aeb-8cf8-212cdd21c3f2">
+ <diagram xmi:uuid="mmuuid:7f6fce9d-a334-4260-9a3a-33f397b9f188" type="packageDiagramType" target="mmuuid/f415b6fc-e09b-466a-b19b-f7bdfea4195f">
+ <diagramEntity xmi:uuid="mmuuid:56b9d09d-2135-4f2f-b19d-eb2925dc1192" name="Trade" modelObject="mmuuid/be73e0b2-9cf2-4d65-a26a-b8fa0892c191" xPosition="20" yPosition="20"/>
+ </diagram>
+ </diagram:DiagramContainer>
+ <mmcore:AnnotationContainer xmi:uuid="mmuuid:7de5077c-41da-4353-b854-d97d63fb5a2c"/>
+ <relational:BaseTable xmi:uuid="mmuuid:be73e0b2-9cf2-4d65-a26a-b8fa0892c191" name="Trade">
+ <columns xmi:uuid="mmuuid:6daf8dc7-6d1b-4564-98dd-3ab2a7f2c0dd" name="TradeID" nativeType="Long">
+ <type href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:54267915-2eb5-4291-8ca0-0e2f24eb4901" name="LegID" nativeType="Long">
+ <type href="http://www.w3.org/2001/XMLSchema#long"/>
+ </columns>
+ <columns xmi:uuid="mmuuid:e8356ebb-6ee7-49ef-bb21-a713fc692ff5" name="Notational" nativeType="Double">
+ <type href="http://www.w3.org/2001/XMLSchema#double"/>
+ </columns>
+ </relational:BaseTable>
+</xmi:XMI>
More information about the teiid-commits
mailing list