diff options
Diffstat (limited to 'sandbox/old/contrib/persistence/common/src/test')
8 files changed, 242 insertions, 0 deletions
diff --git a/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/DefaultPersistenceUnitBuilderTestCase.java b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/DefaultPersistenceUnitBuilderTestCase.java new file mode 100644 index 0000000000..cd3a914ab9 --- /dev/null +++ b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/DefaultPersistenceUnitBuilderTestCase.java @@ -0,0 +1,29 @@ +/* + * 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.service.persistence.common; + +import junit.framework.TestCase; + +public class DefaultPersistenceUnitBuilderTestCase extends TestCase { + + public void testNewEntityManagerFactory() { + new DefaultPersistenceUnitBuilder().newEntityManagerFactory("test", getClass().getClassLoader()); + } + +} diff --git a/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/Department.java b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/Department.java new file mode 100644 index 0000000000..bbbd32fa87 --- /dev/null +++ b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/Department.java @@ -0,0 +1,30 @@ +/* + * 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.service.persistence.common; + +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class Department { + + @Id + private Long id; + +} diff --git a/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/Employee.java b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/Employee.java new file mode 100644 index 0000000000..d90e3284eb --- /dev/null +++ b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/Employee.java @@ -0,0 +1,30 @@ +/* + * 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.service.persistence.common; + +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +public class Employee { + + @Id + private Long id; + +} diff --git a/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/PersistenceUnitScannerTestCase.java b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/PersistenceUnitScannerTestCase.java new file mode 100644 index 0000000000..b8d7c53d4d --- /dev/null +++ b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/PersistenceUnitScannerTestCase.java @@ -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. + */ +package org.apache.tuscany.service.persistence.common; + +import junit.framework.TestCase; + +public class PersistenceUnitScannerTestCase extends TestCase { + + public void testGetPersistenceUnitInfo() { + + new PersistenceUnitScanner().getPersistenceUnitInfo("test", getClass().getClassLoader()); + + + } + +} diff --git a/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/PersistenceUnitTestCase.java b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/PersistenceUnitTestCase.java new file mode 100644 index 0000000000..6b6fb7ad43 --- /dev/null +++ b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/PersistenceUnitTestCase.java @@ -0,0 +1,32 @@ +package org.apache.tuscany.service.persistence.common; + +import junit.framework.TestCase; + +public class PersistenceUnitTestCase extends TestCase { + + protected void setUp() throws Exception { +/* + addExtension("tuscany.jpa", getClass().getClassLoader().getResource("META-INF/sca/jpa.scdl")); + addExtension("geronimo.jta", getClass().getClassLoader().getResource("META-INF/sca/geronimo.jta.scdl")); + setApplicationSCDL(getClass().getClassLoader().getResource("META-INF/sca/test1.scdl")); + super.setUp(); + RuntimeComponent runtime = (RuntimeComponent) component.getParent().getParent(); + CompositeComponent systemComposite = runtime.getSystemComponent(); + CompositeComponent topLevelComposite = (CompositeComponent) systemComposite.getSystemChild(TUSCANY_SYSTEM); + + JavaAtomicComponent cmp = (JavaAtomicComponent) component.getChild("TestService1"); + TestService1 testService1 = (TestService1) cmp.getTargetInstance(); + testService1.testMethod(); +*/ + } + + protected void tearDown() throws Exception { +/* + super.tearDown(); +*/ + } + + public void testGetComponent() { + } + +} diff --git a/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/TestService1.java b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/TestService1.java new file mode 100644 index 0000000000..74052984b9 --- /dev/null +++ b/sandbox/old/contrib/persistence/common/src/test/java/org/apache/tuscany/service/persistence/common/TestService1.java @@ -0,0 +1,26 @@ +package org.apache.tuscany.service.persistence.common; + +import javax.persistence.EntityManager; +import javax.persistence.EntityManagerFactory; +import javax.persistence.PersistenceUnit; +import javax.transaction.TransactionManager; + +import org.apache.tuscany.api.annotation.Resource; + +public class TestService1 { + + @Resource + protected TransactionManager tx; + + @PersistenceUnit(unitName = "test") + protected EntityManagerFactory emf; + + public void testMethod() throws Exception { + + tx.begin(); + EntityManager em = emf.createEntityManager(); + tx.commit(); + + } + +} diff --git a/sandbox/old/contrib/persistence/common/src/test/resources/META-INF/persistence.xml b/sandbox/old/contrib/persistence/common/src/test/resources/META-INF/persistence.xml new file mode 100644 index 0000000000..0fc71881db --- /dev/null +++ b/sandbox/old/contrib/persistence/common/src/test/resources/META-INF/persistence.xml @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. + --> +<persistence xmlns="http://java.sun.com/xml/ns/persistence" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" + version="1.0"> + <persistence-unit name="test" transaction-type="RESOURCE_LOCAL"> + <provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider> + <class>org.apache.tuscany.service.persistence.common.Employee</class> + <class>org.apache.tuscany.service.persistence.common.Department</class> + <properties> + <property name="openjpa.ConnectionURL" value="jdbc:hsqldb:tutorial_database"/> + <property name="openjpa.ConnectionDriverName" value="org.hsqldb.jdbcDriver"/> + <property name="openjpa.ConnectionUserName" value="sa"/> + <property name="openjpa.ConnectionPassword" value=""/> + <property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/> + </properties> + </persistence-unit> +</persistence>
\ No newline at end of file diff --git a/sandbox/old/contrib/persistence/common/src/test/resources/META-INF/sca/test1.scdl b/sandbox/old/contrib/persistence/common/src/test/resources/META-INF/sca/test1.scdl new file mode 100644 index 0000000000..4470ca506e --- /dev/null +++ b/sandbox/old/contrib/persistence/common/src/test/resources/META-INF/sca/test1.scdl @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" + name="LocalWireComposite"> + + <component name="TestService1"> + <implementation.java class="org.apache.tuscany.service.persistence.common.TestService1"/> + </component> + +</composite>
\ No newline at end of file |