OPENJPA-1101 Remove unused/outdated/incomplete OSGi integration tests, as this is being handled by Apache Aries for now

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@920894 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-03-09 14:32:46 +00:00
parent dbe6745966
commit ce0886e110
12 changed files with 0 additions and 1156 deletions

View File

@ -1,318 +0,0 @@
<?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.
-->
<!--
Maven release plugin requires the project tag to be on a single line.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-integration</artifactId>
<version>2.0.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>openjpa-integration-osgi-itests</artifactId>
<version>2.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>OpenJPA Integration Tests - OSGi</name>
<description>OpenJPA Integration Tests - OSGi</description>
<dependencies>
<!--
Note: Scope should be set to test for all depends
-->
<!-- OpenJPA runtime and depends -->
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-osgi</artifactId>
<version>${version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jpa_2.0_spec</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jta_1.1_spec</artifactId>
<scope>provided</scope>
</dependency>
<!-- Not needed yet...
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-validation_1.0_spec</artifactId>
<scope>test</scope>
</dependency>
-->
<!-- Note: Overriding parent versions as these have bundle metadata -->
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
<artifactId>commons-pool</artifactId>
<scope>test</scope>
</dependency>
<!-- Testcase depends -->
<!--
<dependency>
<groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-examples</artifactId>
<version>${version}</version>
<scope>test</scope>
</dependency>
-->
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>test</scope>
</dependency>
<!-- use the bundlized version of commons-dbcp from servicemix -->
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.commons-dbcp</artifactId>
<version>1.2.2_3</version>
<scope>test</scope>
</dependency>
<!-- Test framework depends -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
<version>0.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit</artifactId>
<version>0.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-default</artifactId>
<version>0.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit-extender-impl</artifactId>
<version>0.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId>
<version>1.3.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-mvn</artifactId>
<version>0.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.osgi.core</artifactId>
<version>1.2.0</version>
<scope>provided</scope>
</dependency>
<!-- Apache Felix framework -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.configadmin</artifactId>
<version>1.0.10</version>
<scope>test</scope>
</dependency>
<!-- Note: This depend has to be after all the rest -->
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.main</artifactId>
<version>1.6.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>ops4j.releases</id>
<url>http://repository.ops4j.org/maven2</url>
</repository>
<repository>
<id>ops4j.snapshots</id>
<url>http://repository.ops4j.org/mvn-snapshots</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>ops4j.releases</id>
<url>http://repository.ops4j.org/maven2</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
<build>
<resources>
<!-- for source jar -->
<resource>
<directory>src/main/resources</directory>
</resource>
<!-- for test jar -->
<resource>
<directory>src/test/resources</directory>
</resource>
<!-- also include license and notice files in all the jars -->
<resource>
<directory>${basedir}/../../openjpa-project/</directory>
<includes>
<include>NOTICE.txt</include>
<include>LICENSE.txt</include>
<include>DISCLAIMER.txt</include>
</includes>
<targetPath>META-INF</targetPath>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>process-classes</phase>
<configuration>
<tasks>
<ant antfile="src/main/ant/enhancer.xml" target="enhance" inheritRefs="true">
<property name="maven.test.skip" value="${maven.test.skip}" />
<property name="test" value="${test}" />
<property name="outdir" value="${project.build.outputDirectory}" />
<property name="project.build.outputDirectory" value="${project.build.outputDirectory}" />
<property name="openjpa.loglevel" value="${openjpa.loglevel}" />
<property name="build.enhance" value="${build.enhance}" />
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<id>generate-depends-file</id>
<goals>
<goal>generate-depends-file</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-Name>${artifactId}</Bundle-Name>
<Bundle-SymbolicName>${groupId}.${artifactId};singleton=true</Bundle-SymbolicName>
<Bundle-DocURL>http://openjpa.apache.org/documentation.html</Bundle-DocURL>
<Bundle-Activator>hellojpa.Main</Bundle-Activator>
<!-- <Private-Package>hellojpa*,META-INF*</Private-Package> -->
<Import-Package>org.apache.openjpa.*,*</Import-Package>
<!-- <Export-Package></Export-Package> -->
<Require-Bundle>org.apache.geronimo.specs.geronimo-jpa_2.0_spec;bundle-version="[1.0.0,2.0.0)",org.apache.openjpa.openjpa-osgi;bundle-version="[2.0.0,3.0.0)"</Require-Bundle>
<!-- Eclipse metadata -->
<Eclipse-Autostart>false</Eclipse-Autostart>
</instructions>
<unpackBundle>true</unpackBundle>
</configuration>
<executions>
<execution>
<id>bundle-manifest</id>
<phase>process-classes</phase>
<goals>
<goal>manifest</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<forkMode>pertest</forkMode>
<argLine>${surefire.jvm.args}</argLine>
<excludes>
<!-- exclude everything for now.... -->
<exclude>org/apache/openjpa/**/Test*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,129 +0,0 @@
Setting up Apache Felix Karaf for OpenJPA 2.0.x
Installing and running Apache Felix Karaf
---------------------------------------------------
1) Download and extract Apache Felix Karaf 1.0.0 from:
http://www.apache.org/dist/felix/apache-felix-karaf-1.0.0.zip
http://www.apache.org/dist/felix/apache-felix-karaf-1.0.0.tar.gz
2) Start Karaf under Java SE 5 or 6:
cd apache-felix-karaf-1.0.0/bin
karaf
Installing and running the Felix Web Console and Jetty:
-------------------------------------------------------
1) Install the following bundles:
a) osgi:install http://www.apache.org/dist/felix/org.osgi.compendium-1.4.0.jar
b) osgi:install http://www.apache.org/dist/felix/org.apache.felix.scr-1.0.8.jar
c) osgi:install http://www.apache.org/dist/felix/org.apache.felix.http.jetty-2.0.2.jar
d) osgi:install http://www.apache.org/dist/felix/org.apache.felix.webconsole-2.0.0.jar
2) Start the web console:
a) osgi:start <bundle id for org.apache.felix.http.jetty>
b) osgi:start <bundle id for org.apache.felix.webconsole>
Note: You will have to start the Config, Event and Scr bundles for those
tabs to function in the web console.
3) Access the web console in a browser:
http://localhost:8080/system/console
uid = admin
pwd = admin
Installing OpenJPA 2.0.x
--------------------------------------------
1) Install the following released prereq bundles:
a) osgi:install http://repo1.maven.org/maven2/commons-collections/commons-collections/3.2.1/commons-collections-3.2.1.jar
b) osgi:install http://repo1.maven.org/maven2/commons-lang/commons-lang/2.4/commons-lang-2.4.jar
c) osgi:install http://repo1.maven.org/maven2/commons-pool/commons-pool/1.5/commons-pool-1.5.jar
d) osgi:install http://repo1.maven.org/maven2/org/apache/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar
e) osgi:install http://repo1.maven.org/maven2/org/apache/geronimo/specs/geronimo-jta_1.1_spec/1.1.1/geronimo-jta_1.1_spec-1.1.1.jar
2) Install the following SNAPSHOT prereq bundles:
a) osgi:install http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/geronimo/specs/geronimo-jpa_2.0_spec/1.0-EA9-SNAPSHOT/geronimo-jpa_2.0_spec-1.0-EA9-SNAPSHOT.jar
b) osgi:install http://mirrors.ibiblio.org/pub/mirrors/maven2/org/apache/geronimo/specs/geronimo-validation_1.0_spec/1.0-EA6-SNAPSHOT/geronimo-validation_1.0_spec-1.0-EA6-SNAPSHOT.jar
3) Install the latest OpenJPA 2.0.0-SNAPSHOT build:
For latest published nightly build of OpenJPA 2.0.0-SNAPSHOT:
a) osgi:install http://people.apache.org/repo/m2-snapshot-repository/org/apache/openjpa/openjpa-osgi/2.0.0-SNAPSHOT/openjpa-osgi-2.0.0-SNAPSHOT.jar
For a locally built OpenJPA trunk (2.0.0-SNAPSHOT):
a) osgi:install file:///<m2_repo>/org/apache/openjpa/openjpa-osgi/2.0.0-SNAPSHOT/openjpa-osgi-2.0.0-SNAPSHOT.jar
4) Check the Karaf logfile for any problems:
apache-felix-karaf-1.0.0/data/log/karaf.log
Installing an OSGi and/or Blueprint based sample app:
-----------------------------------------------------
This step is still a work-in-progress and TBD...
1) Build the openjpa-integration/osgi-itests module in trunk (2.0.0-SNAPSHOT)
from source.
2) Install the bundlized HelloJPA example:
a) osgi:install file:///<m2_repo>/org/apache/openjpa/openjpa-integration-osgi-itests/2.0.0-SNAPSHOT/openjpa-integration-osgi-itests-2.0.0-SNAPSHOT.jar
b) osgi:start <bundle id for geronimo-jpa_2.0_spec>
c) osgi:start <bundle id for openjpa-osgi>
d) osgi:start <bundle id for openjpa-integration-osgi-itests>
Note: At this point the start should fail with one of the following messages:
a) If you are not using a level of OpenJPA and the Geronimo Spec that
supports resolving providers in an OSGi environment -
Bundle start
org.osgi.framework.BundleException: Activator start error in bundle
org.apache.openjpa.openjpa-integration-osgi-itests [45].
. . .
Caused by: javax.persistence.PersistenceException: No persistence providers
available for "hellojpa" after trying the following discovered
implementations: NONE
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:189)
at hellojpa.Main.main(Main.java:38)
at hellojpa.Main.start(Main.java:81)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:667)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1699)
... 15 more
b) The latest code, which still has some issues loading in OSGi -
Bundle start
org.osgi.framework.BundleException: Activator start error in bundle
org.apache.openjpa.openjpa-integration-osgi-itests [45].
. . .
Caused by: java.lang.NoSuchMethodError: javax.persistence.spi.PersistenceUnitInfo.getValidationMode()Ljavax/persistence/ValidationMode;
at org.apache.openjpa.persistence.PersistenceUnitInfoImpl.toOpenJPAProperties(PersistenceUnitInfoImpl.java:487)
. . .
at hellojpa.Main.main(Main.java:38)
at hellojpa.Main.start(Main.java:81)
at org.apache.felix.framework.util.SecureAction.startActivator(SecureAction.java:667)
at org.apache.felix.framework.Felix.activateBundle(Felix.java:1699)
... 15 more
2) To reinstall the sample app, you'll need to uninstall it first, even if the initial install failed:
a) osgi:uninstall <bundle id for openjpa-integration-osgi-itests>
Shutting down Karaf:
---------------------
1) From the Karaf cmdline:
osgi:shutdown

View File

@ -1,85 +0,0 @@
<?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.
-->
<project name="enhance" basedir=".">
<!--
This build file executes the PCEnhancer on the test entities. It's in a
separate file instead of nested in pom.xml to make some conditional
processing easier.
Test classes will not be compiled if maven is invoked with
-Dmaven.test.skip=true.
-->
<condition property="maven.test.skip.istrue">
<istrue value="${maven.test.skip}" />
</condition>
<condition property="skip.enhance">
<or>
<equals arg1="${test}" arg2="false" />
<equals arg1="${build.enhance}" arg2="false" />
<istrue value="${maven.test.skip}" />
<istrue value="${skipTests}" />
</or>
</condition>
<!-- =================================
target: enhance
================================= -->
<target name="enhance"
description="--> run the enhancer unless test=false"
unless="skip.enhance">
<antcall target="enhance.all.entities"
inheritall="true"
inheritrefs="true" />
</target>
<!-- =================================
target: enhance.all.entities
================================= -->
<target name="enhance.all.entities"
description="--> enhance the test entities"
unless="skip.enhance">
<echo> running enhancer</echo>
<!--
Inherited references won't be present until the task is called.
Therefore the path definition needs to stay inside the task.
-->
<path id="cp">
<path refid="maven.test.classpath" />
</path>
<taskdef name="openjpac"
classname="org.apache.openjpa.ant.PCEnhancerTask">
<classpath refid="cp" />
</taskdef>
<fileset id="enhance.path.ref"
dir="${project.build.outputDirectory}">
<include name="**/*.class" />
<exclude name="**/Test*.class" />
</fileset>
<openjpac>
<classpath refid="cp" />
<fileset refid="enhance.path.ref" />
<config log="DefaultLevel=${openjpa.loglevel}" />
</openjpac>
</target>
</project>

View File

@ -1,156 +0,0 @@
<?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.
-->
<project default="usagewarning">
<property name="parent" value="${basedir}/.."/>
<property name="root" value="${parent}/.."/>
<!-- database connection properties -->
<property name="dbdriver" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<property name="dburl"
value="jdbc:derby:${basedir}/${example}-database;create=true"/>
<property name="dbuser" value=""/>
<property name="dbpass" value=""/>
<target name="usagewarning">
<fail>
Please traverse to a sub-directory, like hellojpa, and run "ant" from there.
</fail>
</target>
<target name="init" depends="init:discover, init:windows, init:unix">
</target>
<target name="init:discover">
<condition property="isWindows">
<os family="windows"/>
</condition>
</target>
<target name="init:windows" if="isWindows">
<property name="platform.script.ext" value=".bat"/>
</target>
<target name="init:unix" unless="isWindows">
<property name="platform.script.ext" value=""/>
</target>
<target name="all" depends="init">
<exec dir="${basedir}/hellojpa" executable="ant${platform.script.ext}"/>
<exec dir="${basedir}/relations" executable="ant${platform.script.ext}"/>
<exec dir="${basedir}/reversemapping" executable="ant${platform.script.ext}"/>
</target>
<path id="classpath"
description="The classpath to use for compiling and running">
<pathelement path="${parent}"/>
<!-- we could include the individual jars as below, but lets use the
openjpa-all.jar with Derby instead
<fileset dir="${root}">
<include name="**/*.jar"/>
<exclude name="openjpa-all-*.jar"/>
</fileset>
-->
<fileset dir="${root}">
<include name="openjpa-all-*.jar"/>
<include name="lib/derby*.jar"/>
</fileset>
</path>
<path id="javaagent">
<fileset dir="${root}">
<include name="openjpa-*.jar"/>
<exclude name="openjpa-all-*.jar"/>
</fileset>
</path>
<pathconvert property="javaagent" refid="javaagent"/>
<target name="clean" depends="pre-clean"
description="Clean up compiled files and generated database files">
<delete includeemptydirs="yes">
<fileset dir="${basedir}">
<include name="*.class"/>
<include name="*.log"/>
<include name="${example}-database/**/*"/>
<include name="${example}-database"/>
</fileset>
</delete>
</target>
<!-- this target can be overridden by the sub-build -->
<target name="pre-clean" description="Pre-clean phase">
</target>
<target name="compile" depends="pre-compile"
description="Compile the example java files">
<javac srcdir="${parent}" classpathref="classpath"
debug="yes" includes="${example}/**.java"/>
</target>
<!-- this target can be overridden by the sub-build -->
<target name="pre-compile" description="Pre-compilation phase">
</target>
<target name="run" depends="compile"
description="Run the example Main program">
<java classname="${example}.Main" classpathref="classpath" fork="yes"
failonerror="yes">
<!--
Specifying the openjpa jar as the javaagent argument is
necessary in order for automatic class-enhancement to work.
-->
<jvmarg value="-javaagent:${javaagent}"/>
<!--
Specify the system properties to use when configuring
OpenJPA. Note that these will only be used becuase in the
examples, the call to "Persistence.createEntityManagerFactory"
is passed "System.getProperties()".
-->
<!--
By default, use the stand-alone Derby database (provided).
This can easily be changes to use your own database's driver,
provided you ensure it is accessible in the classpath.
-->
<sysproperty key="openjpa.ConnectionDriverName"
value="${dbdriver}"/>
<sysproperty key="openjpa.ConnectionURL" value="${dburl}"/>
<sysproperty key="openjpa.ConnectionUserName" value="${dbuser}"/>
<sysproperty key="openjpa.ConnectionPassword" value="${dbpass}"/>
<!--
Tell OpenJPA to automatically create tables in the database
for entities. Note that this should be disabled when
running against a production database, since you probably
don't want to be altering the schema at runtime.
-->
<sysproperty key="openjpa.jdbc.SynchronizeMappings"
value="buildSchema"/>
<!--
Output all the SQL for educational purposes, but set the
general logging level to only show warnings.
-->
<sysproperty key="openjpa.Log"
value="DefaultLevel=WARN,SQL=TRACE"/>
</java>
</target>
</project>

View File

@ -1,89 +0,0 @@
/*
* 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 hellojpa;
import java.util.*;
import javax.persistence.*;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
* A very simple, stand-alone program that stores a new entity in the
* database and then performs a query to retrieve it.
*/
public class Main implements BundleActivator {
@SuppressWarnings("unchecked")
public static void main(String[] args) {
// Create a new EntityManagerFactory using the System properties.
// The "hellojpa" name will be used to configure based on the
// corresponding name in the META-INF/persistence.xml file
EntityManagerFactory factory = Persistence.
createEntityManagerFactory("hellojpa", System.getProperties());
// Create a new EntityManager from the EntityManagerFactory. The
// EntityManager is the main object in the persistence API, and is
// used to create, delete, and query objects, as well as access
// the current transaction
EntityManager em = factory.createEntityManager();
// Begin a new local transaction so that we can persist a new entity
em.getTransaction().begin();
// Create and persist a new Message entity
em.persist(new Message("Hello Persistence!"));
// Commit the transaction, which will cause the entity to
// be stored in the database
em.getTransaction().commit();
// It is always good practice to close the EntityManager so that
// resources are conserved.
em.close();
// Create a fresh, new EntityManager
EntityManager em2 = factory.createEntityManager();
// Perform a simple query for all the Message entities
Query q = em2.createQuery("select m from Message m");
// Go through each of the entities and print out each of their
// messages, as well as the date on which it was created
for (Message m : (List<Message>) q.getResultList()) {
System.out.println(m.getMessage()
+ " (created on: " + m.getCreated() + ")");
}
// Again, it is always good to clean up after ourselves
em2.close();
factory.close();
}
public void start(BundleContext context) {
System.out.println("Bundle start");
main(null);
}
public void stop(BundleContext context) {
System.out.println("Bundle stop");
}
}

View File

@ -1,72 +0,0 @@
/*
* 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 hellojpa;
import java.util.*;
import javax.persistence.*;
/**
* A very simple persistent entity that holds a "message", has a
* "created" field that is initialized to the time at which the
* object was created, and an id field that is initialized to the
* current time.
*/
@Entity
public class Message {
@Id
private long id = System.currentTimeMillis();
@Basic
private String message;
@Basic
private Date created = new Date();
public Message() {
}
public Message(String msg) {
message = msg;
}
public void setId(long val) {
id = val;
}
public long getId() {
return id;
}
public void setMessage(String msg) {
message = msg;
}
public String getMessage() {
return message;
}
public void setCreated(Date date) {
created = date;
}
public Date getCreated() {
return created;
}
}

View File

@ -1,23 +0,0 @@
<?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.
-->
<project name="hellojpa" default="run">
<property name="example" value="hellojpa"/>
<import file="../build.xml"/>
</project>

View File

@ -1,34 +0,0 @@
<?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"
version="2.0">
<persistence-unit name="hellojpa">
<description>PU for hellojpa</description>
<class>hellojpa</class>
<properties>
<property name="openjpa.DynamicEnhancementAgent"
value="false"/>
</properties>
</persistence-unit>
</persistence>

View File

@ -1,95 +0,0 @@
/*
* 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.openjpa.integration.osgi.itests;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.osgi.framework.Filter;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.util.tracker.ServiceTracker;
public abstract class AbstractIntegrationTest {
public static final long DEFAULT_TIMEOUT = 30000;
@Inject
protected BundleContext bundleContext;
protected <T> T getOsgiService(Class<T> type, long timeout) {
return getOsgiService(type, null, timeout);
}
protected <T> T getOsgiService(Class<T> type) {
return getOsgiService(type, null, DEFAULT_TIMEOUT);
}
protected <T> T getOsgiService(Class<T> type, String filter, long timeout) {
ServiceTracker tracker = null;
try {
String flt;
if (filter != null) {
if (filter.startsWith("(")) {
flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")" + filter + ")";
} else {
flt = "(&(" + Constants.OBJECTCLASS + "=" + type.getName() + ")(" + filter + "))";
}
} else {
flt = "(" + Constants.OBJECTCLASS + "=" + type.getName() + ")";
}
Filter osgiFilter = FrameworkUtil.createFilter(flt);
tracker = new ServiceTracker(bundleContext, osgiFilter, null);
tracker.open();
// Note that the tracker is not closed to keep the reference
// This is buggy, has the service reference may change i think
Object svc = type.cast(tracker.waitForService(timeout));
if (svc == null) {
throw new RuntimeException("Gave up waiting for service " + flt);
}
return type.cast(svc);
} catch (InvalidSyntaxException e) {
throw new IllegalArgumentException("Invalid filter", e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
protected Bundle installBundle(String groupId, String artifactId) throws Exception {
MavenArtifactProvisionOption mvnUrl = mavenBundle(groupId, artifactId);
return bundleContext.installBundle(mvnUrl.getURL());
}
protected Bundle getInstalledBundle(String symbolicName) {
for (Bundle b : bundleContext.getBundles()) {
if (symbolicName.equals(b.getSymbolicName())) {
return b;
}
}
return null;
}
public static MavenArtifactProvisionOption mavenBundle(String groupId, String artifactId) {
return CoreOptions.mavenBundle().groupId(groupId).artifactId(artifactId).versionAsInProject();
}
}

View File

@ -1,121 +0,0 @@
/*
* 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.openjpa.integration.osgi.itests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.ops4j.pax.exam.CoreOptions.felix;
import static org.ops4j.pax.exam.CoreOptions.mavenConfiguration;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.OptionUtils;
import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.profile;
import static org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.Bundle;
@RunWith(JUnit4TestRunner.class)
public class TestOpenJPA extends AbstractIntegrationTest {
@Test
public void testExamples() throws Exception {
System.out.println("********** testExamples starting");
System.out.println("***** Checking that openjpa-examples is installed");
// check for our openjpa-examples via the SymbolicName
Bundle bundle = getInstalledBundle("org.apache.openjpa.openjpa-examples");
assertNotNull(bundle);
System.out.println("***** Starting openjpa-examples bundle");
bundle.start();
System.out.println("***** Stopping openjpa-examples bundle");
bundle.stop();
System.out.println("********** testExamples returning");
}
@Test
public void testEMF() throws Exception {
System.out.println("********** testEMF starting");
System.out.println("***** Creating a EMF");
EntityManagerFactory emf = Persistence.
createEntityManagerFactory("hellojpa", System.getProperties());
assertNotNull(emf);
System.out.println("***** After createEMF");
//OpenJPAConfiguration conf = emf.getConfiguration();
//System.out.println("***** After Config *****");
//assertNotNull(conf);
System.out.println("********** testEMF returning");
}
@org.ops4j.pax.exam.junit.Configuration
public static Option[] configuration() {
Option[] options = options(
// Log
mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
mavenBundle("org.ops4j.pax.logging", "pax-logging-service"),
// Felix Config Admin
mavenBundle("org.apache.felix", "org.apache.felix.configadmin"),
// Maven url handler
mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
// this is how you set the default log level when using pax logging
systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level")
.value("DEBUG"),
// OpenJPA runtime depends
mavenBundle("org.apache.geronimo.specs", "geronimo-jpa_2.0_spec"),
mavenBundle("org.apache.geronimo.specs",
"geronimo-validation_1.0_spec"),
//mavenBundle("org.apache.geronimo.specs", "geronimo-jms_1.1_spec"),
//mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
mavenBundle("commons-collections", "commons-collections"),
mavenBundle("commons-lang", "commons-lang"),
mavenBundle("commons-pool", "commons-pool"),
mavenBundle("org.apache.openjpa", "openjpa"),
// Testcase depends
mavenBundle("org.apache.derby", "derby"),
mavenBundle("org.apache.servicemix.bundles",
"org.apache.servicemix.bundles.commons-dbcp"),
mavenBundle("org.apache.openjpa", "openjpa-examples"),
//vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,
//server=y,suspend=y,address=5005"),
felix() //, equinox(), knopflerfish()
);
// use config generated by the Maven plugin (until PAXEXAM-62/64 fixed)
if (TestOpenJPA.class.getClassLoader().getResource(
"META-INF/maven/paxexam-config.args") != null) {
options = OptionUtils.combine(options, mavenConfiguration());
}
return options;
}
}

View File

@ -1,33 +0,0 @@
################################################################################
#
# 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.
#
################################################################################
# Root logger
log4j.rootLogger=DEBUG, stdout
# CONSOLE appender not used by default
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
# File appender
log4j.appender.out=org.apache.log4j.FileAppender
log4j.appender.out.layout=org.apache.log4j.PatternLayout
log4j.appender.out.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
log4j.appender.out.file=${karaf.base}/data/log/karaf.log
log4j.appender.out.append=true

View File

@ -35,6 +35,5 @@
<module>examples</module>
<module>tck</module>
<module>validation</module>
<!-- <module>osgi-itests</module> -->
</modules>
</project>