You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2011/02/23 00:05:47 UTC
svn commit: r1073537 - in /geronimo/sandbox/djencks/txmanager:
connector-itests/
connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/
geronimo-connector/src/test/java/org/apache/geronimo/connector/
Author: djencks
Date: Tue Feb 22 23:05:46 2011
New Revision: 1073537
URL: http://svn.apache.org/viewvc?rev=1073537&view=rev
Log:
itest now checks for extender-created services
Modified:
geronimo/sandbox/djencks/txmanager/connector-itests/pom.xml
geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java
geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java
Modified: geronimo/sandbox/djencks/txmanager/connector-itests/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/connector-itests/pom.xml?rev=1073537&r1=1073536&r2=1073537&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/connector-itests/pom.xml (original)
+++ geronimo/sandbox/djencks/txmanager/connector-itests/pom.xml Tue Feb 22 23:05:46 2011
@@ -58,7 +58,6 @@
</dependency>
-
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
@@ -115,6 +114,12 @@
<artifactId>geronimo-mock-ra</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.ops4j.pax.swissbox</groupId>
+ <artifactId>pax-swissbox-tinybundles</artifactId>
+ <version>1.3.1</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
Modified: geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java?rev=1073537&r1=1073536&r2=1073537&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java (original)
+++ geronimo/sandbox/djencks/txmanager/connector-itests/src/test/java/org/apache/geronimo/components/connector/itests/ConnectorTest.java Tue Feb 22 23:05:46 2011
@@ -1,22 +1,50 @@
package org.apache.geronimo.components.connector.itests;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectOutput;
+import java.io.ObjectOutputStream;
+
+import javax.resource.ResourceException;
import javax.resource.spi.BootstrapContext;
+import javax.resource.spi.ResourceAdapter;
+import org.apache.geronimo.connector.assembler.impl.AssemblerImpl;
+import org.apache.geronimo.connector.extender.ConnectorExtender;
+import org.apache.geronimo.connector.mock.MockAdminObject;
+import org.apache.geronimo.connector.mock.MockAdminObjectImpl;
+import org.apache.geronimo.connector.mock.MockManagedConnectionFactory;
+import org.apache.geronimo.connector.mock.MockResourceAdapter;
+import org.apache.geronimo.connector.model.AdminObjectInfo;
+import org.apache.geronimo.connector.model.ManagedConnectionFactoryInfo;
+import org.apache.geronimo.connector.model.ResourceAdapterInfo;
+import org.apache.geronimo.connector.model.ResourceAdapterModuleInfo;
+import org.apache.geronimo.connector.outbound.ConnectionManagerContainer;
import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
import org.apache.geronimo.transaction.manager.RecoverableTransactionManager;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Customizer;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
import org.osgi.framework.BundleContext;
+import org.osgi.framework.Constants;
+import static org.junit.Assert.assertEquals;
import static org.ops4j.pax.exam.CoreOptions.equinox;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.systemProperty;
+import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.*;
+
+
@RunWith(JUnit4TestRunner.class)
public class ConnectorTest {
@@ -26,6 +54,7 @@ public class ConnectorTest {
@org.ops4j.pax.exam.junit.Configuration
public static Option[] configuration() {
Option[] options = options(
+
// mavenBundle("org.osgi", "org.osgi.compendium"),
// Log
mavenBundle("org.ops4j.pax.logging", "pax-logging-api"),
@@ -36,6 +65,7 @@ public class ConnectorTest {
mavenBundle("org.apache.felix", "org.apache.felix.scr"),
// Felix mvn url handler
mavenBundle("org.ops4j.pax.url", "pax-url-mvn"),
+// mavenBundle("org.ops4j.pax.swissbox", "pax-swissbox-tinybundles"),
// this is how you set the default log level when using pax logging (logProfile)
@@ -47,9 +77,17 @@ public class ConnectorTest {
mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec"),
mavenBundle("org.apache.geronimo.specs", "geronimo-j2ee-connector_1.6_spec"),
mavenBundle("org.apache.geronimo.specs", "geronimo-validation_1.0_spec"),
+ mavenBundle("org.apache.geronimo.components", "geronimo-mock-ra"),
//org.ops4j.pax.exam.container.def.PaxRunnerOptions.vmOption("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"),
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe(InputStream testProbe) throws Exception {
+ return modifyBundle( testProbe )
+ .add(ConnectorExtender.PLAN_LOCATION, raInputStream()).build();
+ }
+ },
equinox().version("3.5.0")
);
// options = updateOptions(options);
@@ -63,8 +101,69 @@ public class ConnectorTest {
@Test
public void testServicesStart() throws Exception {
+ //TODO figure out how to wait for services to start
+ Thread.sleep(1000);
Assert.assertNotNull(bundleContext.getServiceReference(RecoverableTransactionManager.class.getName()));
Assert.assertNotNull(bundleContext.getServiceReference(BootstrapContext.class.getName()));
Assert.assertNotNull(bundleContext.getServiceReference(ConnectionTracker.class.getName()));
+
+ //mock connector services
+ Assert.assertNotNull(bundleContext.getServiceReference(ResourceAdapter.class.getName()));
+ Assert.assertNotNull(bundleContext.getServiceReference(MockAdminObject.class.getName()));
+ Assert.assertNotNull(bundleContext.getServiceReference(ConnectionManagerContainer.class.getName()));
}
+
+ private static InputStream raInputStream() throws ResourceException, IOException {
+ ResourceAdapterModuleInfo module = newResourceAdapterModule();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutput out = new ObjectOutputStream(baos);
+ out.writeObject(module);
+ out.flush();
+ return new ByteArrayInputStream(baos.toByteArray());
+ }
+
+ private static ResourceAdapterModuleInfo newResourceAdapterModule() throws ResourceException {
+ ResourceAdapterModuleInfo module = new ResourceAdapterModuleInfo();
+ module.name = "module1";
+
+ ResourceAdapterInfo ra = new ResourceAdapterInfo();
+ ra.name = "ra1";
+ ra.resourceAdapterClass = MockResourceAdapter.class.getName();
+ ra.configProperties.put("RAStringProperty", "value1");
+
+ ra.managedConnectionFactoryInfos.add(newMcf("mcf1"));
+ ra.managedConnectionFactoryInfos.add(newMcf("mcf2"));
+
+
+ ra.adminObjectInfos.add(newAdminObject("ao1"));
+ ra.adminObjectInfos.add(newAdminObject("ao2"));
+
+ module.resourceAdapterInfos.add(ra);
+
+ module.managedConnectionFactoryInfos.add(newMcf("mcf3"));
+ module.adminObjectInfos.add(newAdminObject("ao2"));
+ return module;
+ }
+
+ private static AdminObjectInfo newAdminObject(String name) {
+ AdminObjectInfo ao = new AdminObjectInfo();
+ ao.name = name;
+ ao.adminObjectInterface = MockAdminObject.class.getName();
+ ao.adminObjectClass = MockAdminObjectImpl.class.getName();
+ ao.configProperties.put("Tweedle", "Dum");
+ return ao;
+ }
+
+ private static ManagedConnectionFactoryInfo newMcf(String name) {
+ ManagedConnectionFactoryInfo mcf = new ManagedConnectionFactoryInfo();
+ mcf.name = name;
+ mcf.managedConnectionFactoryClass = MockManagedConnectionFactory.class.getName();
+ mcf.maxPoolSize = 10;
+ mcf.poolCardinality = ManagedConnectionFactoryInfo.PoolCardinality.single;
+ mcf.matchingPolicy = ManagedConnectionFactoryInfo.MatchingPolicy.selectAll;
+ mcf.transactionSupport = ManagedConnectionFactoryInfo.TransactionSupport.xaTxCached;
+ return mcf;
+ }
+
+
}
Modified: geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java?rev=1073537&r1=1073536&r2=1073537&view=diff
==============================================================================
--- geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java (original)
+++ geronimo/sandbox/djencks/txmanager/geronimo-connector/src/test/java/org/apache/geronimo/connector/AssemblerTest.java Tue Feb 22 23:05:46 2011
@@ -61,6 +61,16 @@ public class AssemblerTest {
Listener listener = new Listener();
assembler.addListener(listener);
+ ResourceAdapterModuleInfo module = newResourceAdapterModule();
+
+ assembler.assemble(module, new MockBundle(), getClass().getClassLoader(), null, null, null);
+
+ assertEquals(1, listener.raCount);
+ assertEquals(3, listener.aoCount);
+ assertEquals(3, listener.mcfCount);
+ }
+
+ private ResourceAdapterModuleInfo newResourceAdapterModule() {
ResourceAdapterModuleInfo module = new ResourceAdapterModuleInfo();
module.name = "module1";
@@ -80,12 +90,7 @@ public class AssemblerTest {
module.managedConnectionFactoryInfos.add(newMcf("mcf3"));
module.adminObjectInfos.add(newAdminObject("ao2"));
-
- assembler.assemble(module, new MockBundle(), getClass().getClassLoader(), null, null, null);
-
- assertEquals(1, listener.raCount);
- assertEquals(3, listener.aoCount);
- assertEquals(3, listener.mcfCount);
+ return module;
}
private AdminObjectInfo newAdminObject(String name) {