HHH-8763 osgi extension point test cases
This commit is contained in:
parent
7ee5fa104d
commit
c2f115e5c9
|
@ -49,6 +49,7 @@ dependencies {
|
|||
osgiRuntime( libraries.commons_annotations ) { transitive = false }
|
||||
osgiRuntime( libraries.classmate ) { transitive = false }
|
||||
osgiRuntime( libraries.logging ) { transitive = false }
|
||||
|
||||
// needed for BND
|
||||
osgiRuntimeBnd( libraries.jandex ) { transitive = false }
|
||||
osgiRuntimeBnd( "javax.enterprise:cdi-api:1.1" ) { transitive = false }
|
||||
|
@ -143,7 +144,18 @@ task testClientBundleJar(type: Jar) {
|
|||
"Bundle-Activator" : "org.hibernate.osgi.test.client.OsgiTestActivator",
|
||||
"Bundle-ManifestVersion" : "2",
|
||||
"Bundle-SymbolicName" : "testClientBundle",
|
||||
"Import-Package" : "javassist.util.proxy,javax.persistence,javax.persistence.spi,org.h2,org.hibernate,org.hibernate.proxy,org.osgi.framework")
|
||||
"Import-Package" : "javassist.util.proxy,javax.persistence,javax.persistence.spi,org.h2,org.osgi.framework,"
|
||||
+ "org.hibernate,"
|
||||
+ "org.hibernate.boot.registry.selector,"
|
||||
+ "org.hibernate.boot.registry.selector.spi,"
|
||||
+ "org.hibernate.cfg,"
|
||||
+ "org.hibernate.engine.spi,"
|
||||
+ "org.hibernate.integrator.spi,"
|
||||
+ "org.hibernate.metamodel.source,"
|
||||
+ "org.hibernate.metamodel.spi,"
|
||||
+ "org.hibernate.proxy,"
|
||||
+ "org.hibernate.service,"
|
||||
+ "org.hibernate.service.spi")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,13 @@ import javax.persistence.spi.PersistenceProvider;
|
|||
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.integrator.spi.Integrator;
|
||||
import org.hibernate.metamodel.spi.TypeContributor;
|
||||
import org.hibernate.osgi.test.result.OsgiTestResults;
|
||||
import org.hibernate.osgi.test.result.OsgiTestResultsImpl;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.osgi.framework.BundleActivator;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceReference;
|
||||
|
@ -44,15 +49,26 @@ import org.osgi.framework.ServiceReference;
|
|||
public class OsgiTestActivator implements BundleActivator {
|
||||
|
||||
private OsgiTestResults testResult = new OsgiTestResultsImpl();
|
||||
|
||||
private TestIntegrator integrator = new TestIntegrator();
|
||||
private TestStrategyRegistrationProvider strategyRegistrationProvider = new TestStrategyRegistrationProvider();
|
||||
private TestTypeContributor typeContributor = new TestTypeContributor();
|
||||
|
||||
@Override
|
||||
public void start(BundleContext context) throws Exception {
|
||||
|
||||
// register the test result service
|
||||
context.registerService( OsgiTestResults.class, testResult, new Hashtable() );
|
||||
|
||||
// register example extension point services
|
||||
context.registerService( Integrator.class, integrator, new Hashtable() );
|
||||
context.registerService( StrategyRegistrationProvider.class, strategyRegistrationProvider, new Hashtable() );
|
||||
context.registerService( TypeContributor.class, typeContributor, new Hashtable() );
|
||||
|
||||
testUnmanagedJpa( context );
|
||||
testUnmanagedNative( context );
|
||||
testLazyLoading( context );
|
||||
testExtensionPoints( context );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -188,5 +204,28 @@ public class OsgiTestActivator implements BundleActivator {
|
|||
testResult.addFailure( "Exception: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private void testExtensionPoints(BundleContext context) {
|
||||
try {
|
||||
final ServiceReference serviceReference = context.getServiceReference( SessionFactory.class.getName() );
|
||||
final SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) context.getService(
|
||||
serviceReference );
|
||||
final ServiceRegistry serviceRegistry = sessionFactory.getServiceRegistry();
|
||||
|
||||
// test extension points in the client bundle
|
||||
if (!integrator.passed) {
|
||||
testResult.addFailure( "Could not discover " + integrator.getClass() );
|
||||
}
|
||||
if (!strategyRegistrationProvider.passed) {
|
||||
testResult.addFailure( "Could not discover " + strategyRegistrationProvider.getClass() );
|
||||
}
|
||||
if (!typeContributor.passed) {
|
||||
testResult.addFailure( "Could not discover " + typeContributor.getClass() );
|
||||
}
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
testResult.addFailure( "Exception: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* JBoss, Home of Professional Open Source
|
||||
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
|
||||
* as indicated by the @authors tag. All rights reserved.
|
||||
* See the copyright.txt in the distribution for a
|
||||
* full listing of individual contributors.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License, v. 2.1.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT A
|
||||
* 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,
|
||||
* v.2.1 along with this distribution; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
package org.hibernate.osgi.test.client;
|
||||
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.integrator.spi.Integrator;
|
||||
import org.hibernate.metamodel.source.MetadataImplementor;
|
||||
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* @author Brett Meyer
|
||||
*/
|
||||
public class TestIntegrator implements Integrator {
|
||||
|
||||
public boolean passed = false;
|
||||
|
||||
public void integrate(Configuration configuration, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
|
||||
passed = true;
|
||||
}
|
||||
|
||||
public void integrate(MetadataImplementor metadata, SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
|
||||
passed = true;
|
||||
}
|
||||
|
||||
public void disintegrate(SessionFactoryImplementor sessionFactory, SessionFactoryServiceRegistry serviceRegistry) {
|
||||
passed = true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* JBoss, Home of Professional Open Source
|
||||
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
|
||||
* as indicated by the @authors tag. All rights reserved.
|
||||
* See the copyright.txt in the distribution for a
|
||||
* full listing of individual contributors.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License, v. 2.1.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT A
|
||||
* 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,
|
||||
* v.2.1 along with this distribution; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
package org.hibernate.osgi.test.client;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
||||
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
||||
|
||||
/**
|
||||
* @author Brett Meyer
|
||||
*/
|
||||
public class TestStrategyRegistrationProvider implements StrategyRegistrationProvider {
|
||||
|
||||
public boolean passed = false;
|
||||
|
||||
public Iterable<StrategyRegistration> getStrategyRegistrations() {
|
||||
passed = true;
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* JBoss, Home of Professional Open Source
|
||||
* Copyright 2013 Red Hat Inc. and/or its affiliates and other contributors
|
||||
* as indicated by the @authors tag. All rights reserved.
|
||||
* See the copyright.txt in the distribution for a
|
||||
* full listing of individual contributors.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License, v. 2.1.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT A
|
||||
* 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,
|
||||
* v.2.1 along with this distribution; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301, USA.
|
||||
*/
|
||||
package org.hibernate.osgi.test.client;
|
||||
|
||||
import org.hibernate.metamodel.spi.TypeContributions;
|
||||
import org.hibernate.metamodel.spi.TypeContributor;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
|
||||
/**
|
||||
* @author Brett Meyer
|
||||
*/
|
||||
public class TestTypeContributor implements TypeContributor {
|
||||
|
||||
public boolean passed = false;
|
||||
|
||||
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
|
||||
passed = true;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue