You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by lr...@apache.org on 2008/01/21 20:34:13 UTC
svn commit: r613980 - in
/incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo:
./ src/main/java/org/apache/tuscany/sca/implementation/openjpa/
src/main/resources/META-INF/services/
src/test/java/org/apache/tuscany/sca/implementation...
Author: lresende
Date: Mon Jan 21 11:33:59 2008
New Revision: 613980
URL: http://svn.apache.org/viewvc?rev=613980&view=rev
Log:
Removing derby db, updating test case and other minor cleanup
Added:
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/company.sql
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/org/apache/tuscany/sca/implementation/openjpa/CompanyTestCase.java (with props)
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/Company.java (with props)
Removed:
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/org/apache/tuscany/sca/implementation/openjpa/ImplJpaTestCase.java
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/Abc.java
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/Message.java
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/MyObject.java
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/resources/openjpa.composite
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/test/
Modified:
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/pom.xml
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/java/org/apache/tuscany/sca/implementation/openjpa/JPAImplementationProcessor.java
incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
Added: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/company.sql
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/company.sql?rev=613980&view=auto
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/company.sql (added)
+++ incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/company.sql Mon Jan 21 11:33:59 2008
@@ -0,0 +1,28 @@
+--
+-- 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 COMPANY;
+
+CREATE TABLE COMPANY (
+ ID INT PRIMARY KEY NOT NULL GENERATED ALWAYS AS IDENTITY,
+ NAME VARCHAR(30));
+
+INSERT INTO COMPANY (NAME) VALUES('ACME Publishing');
+INSERT INTO COMPANY (NAME) VALUES('Do-rite plumbing');
+INSERT INTO COMPANY (NAME) VALUES('MegaCorp');
\ No newline at end of file
Modified: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/pom.xml
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/pom.xml?rev=613980&r1=613979&r2=613980&view=diff
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/pom.xml (original)
+++ incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/pom.xml Mon Jan 21 11:33:59 2008
@@ -22,7 +22,7 @@
<parent>
<groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-modules</artifactId>
- <version>1.1-incubating-SNAPSHOT</version>
+ <version>1.2-incubating-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>tuscany-implementation-data-pojo</artifactId>
@@ -111,12 +111,64 @@
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.1.2.1</version>
- <scope>test</scope>
+ <scope>compile</scope>
</dependency>
</dependencies>
<build>
<finalName>${artifactId}</finalName>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>sql-maven-plugin</artifactId>
+ <!-- 1.1 due to MOJO-619 -->
+ <version>1.1-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.derby</groupId>
+ <artifactId>derby</artifactId>
+ <version>10.1.2.1</version>
+ </dependency>
+ </dependencies>
+
+ <executions>
+ <execution>
+ <id>create-db</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+ <url>jdbc:derby:${pom.basedir}/target/test-classes/company;create=true</url>
+ <autocommit>true</autocommit>
+ <onError>continue</onError>
+ <onConnectionError>skip</onConnectionError>
+ <delimiter>;</delimiter>
+ <srcFiles>
+ <srcFile>${pom.basedir}/company.sql</srcFile>
+ </srcFiles>
+ </configuration>
+ </execution>
+
+ <!-- Shutdown DB in order to be able to run unit tests -->
+ <execution>
+ <id>shutdown-database-sothat-test-can-run</id>
+ <phase>process-test-resources</phase>
+ <goals>
+ <goal>execute</goal>
+ </goals>
+ <configuration>
+ <driver>org.apache.derby.jdbc.EmbeddedDriver</driver>
+ <url>jdbc:derby:${pom.basedir}/target/test-classes/company;shutdown=true</url>
+ <skipOnConnectionError>true</skipOnConnectionError>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
</build>
</project>
Modified: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/java/org/apache/tuscany/sca/implementation/openjpa/JPAImplementationProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/java/org/apache/tuscany/sca/implementation/openjpa/JPAImplementationProcessor.java?rev=613980&r1=613979&r2=613980&view=diff
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/java/org/apache/tuscany/sca/implementation/openjpa/JPAImplementationProcessor.java (original)
+++ incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/java/org/apache/tuscany/sca/implementation/openjpa/JPAImplementationProcessor.java Mon Jan 21 11:33:59 2008
@@ -42,7 +42,7 @@
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
public class JPAImplementationProcessor implements StAXArtifactProcessor<JPAImplementation> {
- private final QName QNAME = new QName(Constants.SCA10_TUSCANY_NS, "implementation.jpa");
+ private final QName QNAME = new QName(Constants.SCA10_TUSCANY_NS, "implementation.data.pojo");
private QName DS = new QName(Constants.SCA10_TUSCANY_NS, "datasource");
private JPAImplementationFactory jpaFactory;
Modified: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor?rev=613980&r1=613979&r2=613980&view=diff
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor (original)
+++ incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor Mon Jan 21 11:33:59 2008
@@ -16,4 +16,4 @@
# under the License.
# Implementation class for the artifact processor extension
-org.apache.tuscany.sca.implementation.openjpa.JPAImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#implementation.jpa,model=org.apache.tuscany.sca.implementation.openjpa.JPAImplementation
\ No newline at end of file
+org.apache.tuscany.sca.implementation.openjpa.JPAImplementationProcessor;qname=http://tuscany.apache.org/xmlns/sca/1.0#implementation.data.pojo,model=org.apache.tuscany.sca.implementation.openjpa.JPAImplementation
\ No newline at end of file
Added: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/org/apache/tuscany/sca/implementation/openjpa/CompanyTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/org/apache/tuscany/sca/implementation/openjpa/CompanyTestCase.java?rev=613980&view=auto
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/org/apache/tuscany/sca/implementation/openjpa/CompanyTestCase.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/org/apache/tuscany/sca/implementation/openjpa/CompanyTestCase.java Mon Jan 21 11:33:59 2008
@@ -0,0 +1,78 @@
+/*
+ * 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.tuscany.sca.implementation.openjpa;
+
+import junit.framework.*;
+import org.apache.tuscany.sca.host.embedded.*;
+import org.apache.commons.logging.*;
+import sample.*;
+import javax.persistence.*;
+import java.util.*;
+
+public class CompanyTestCase extends TestCase {
+ private EntityManager em;
+ private Log log = LogFactory.getLog(this.getClass());
+ private SCADomain domain;
+
+ public void setUp() {
+ domain = SCADomain.newInstance("openjpa.composite");
+ em = domain.getService(EntityManager.class, "CompanyServiceComponent");
+
+ }
+
+ public void testAccess() {
+ Company company = new Company();
+ int id = new Random().nextInt();
+
+ company.setId(id);
+ company.setName("Company " + id);
+
+ em.persist(company);
+ log.info(em.find(Company.class, id));
+
+ Query q = em.createQuery("select company from Company company");
+ q.setMaxResults(5);
+ log.info("There are " + q.getResultList().size() + " Company in the database now");
+ }
+
+ public void testRollback() {
+ try {
+ Company company1 = new Company();
+ Company company2 = new Company();
+
+ int id = new Random().nextInt();
+
+ company1.setId(id);
+ company1.setName("Company " + id);
+ em.persist(company1);
+
+ company2.setId(id);
+ company2.setName("Company " + id);
+ em.persist(company2);
+
+ } catch (RuntimeException ex) {
+ log.info("An expected exception occured, Tuscany is rolling back...");
+ }
+ }
+
+ public void tearDown() {
+ em.close();
+ domain.close();
+ }
+}
Propchange: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/org/apache/tuscany/sca/implementation/openjpa/CompanyTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/org/apache/tuscany/sca/implementation/openjpa/CompanyTestCase.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/Company.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/Company.java?rev=613980&view=auto
==============================================================================
--- incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/Company.java (added)
+++ incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/Company.java Mon Jan 21 11:33:59 2008
@@ -0,0 +1,49 @@
+/*
+ * 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 sample;
+
+import javax.persistence.*;
+
+@Entity
+public class Company {
+ @Id
+ private int id;
+ @Basic
+ private String name;
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int i) {
+ id = i;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ return "Company (" + getId() + ") is is " + getName();
+ }
+}
Propchange: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/Company.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/sandbox/lresende/sca/modules/implementation-data-pojo/src/test/java/sample/Company.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org