Author: rareddy
Date: 2011-12-09 16:44:19 -0500 (Fri, 09 Dec 2011)
New Revision: 3729
Added:
trunk/settings.xml
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
Removed:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/TestDeployment.java
Modified:
trunk/jboss-integration/pom.xml
trunk/pom.xml
trunk/test-integration/common/pom.xml
trunk/test-integration/common/src/test/resources/arquillian.xml
Log:
TEIID-1809, TEIID-1720: making the arquillian tests execute based on given profile. This
will download AS7 and install and overlay teiid binaries and execute any integration
tests. Also, partially upgraded the build to use jboss-parent pom
Modified: trunk/jboss-integration/pom.xml
===================================================================
--- trunk/jboss-integration/pom.xml 2011-12-08 19:19:34 UTC (rev 3728)
+++ trunk/jboss-integration/pom.xml 2011-12-09 21:44:19 UTC (rev 3729)
@@ -88,15 +88,9 @@
<artifactId>jbosssx-client</artifactId>
<scope>provided</scope>
</dependency>
-
+
<dependency>
<groupId>org.jboss.as</groupId>
- <artifactId>jboss-as-security</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <dependency>
- <groupId>org.jboss.as</groupId>
<artifactId>jboss-as-subsystem-test</artifactId>
<scope>test</scope>
</dependency>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-12-08 19:19:34 UTC (rev 3728)
+++ trunk/pom.xml 2011-12-09 21:44:19 UTC (rev 3729)
@@ -1,6 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
- <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-parent</artifactId>
+ <version>7</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.teiid</groupId>
<artifactId>teiid-parent</artifactId>
<packaging>pom</packaging>
@@ -106,7 +111,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
- <version>2.8</version>
+ <version>${version.javadoc.plugin}</version>
<configuration>
<maxmemory>512m</maxmemory>
<excludePackageNames>*.internal,com.*,net.*,org.teiid.cache,org.teiid.common.*,org.teiid.core,org.teiid.deployers,org.teiid.dqp.*,org.teiid.jboss,org.teiid.netty.*,org.teiid.odbc,org.teiid.query,org.teiid.resource.*,org.teiid.rhq.*,org.teiid.runtime,org.teiid.security,org.teiid.services,org.teiid.templates,org.teiid.test.*,org.teiid.transport,org.teiid.vdb.*</excludePackageNames>
@@ -123,30 +128,14 @@
</build>
</profile>
<profile>
- <!--
+ <!--
This is to enable faster build for development time.
-->
<id>dev</id>
<modules>
<module>build</module>
</modules>
- </profile>
- <profile>
- <id>arquillian-tests</id>
- <dependencies>
- <dependency>
- <groupId>org.jboss.spec</groupId>
- <artifactId>jboss-javaee-6.0</artifactId>
- <version>1.0.0.Final</version>
- <type>pom</type>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.as</groupId>
-
<artifactId>jboss-as-arquillian-container-managed</artifactId>
- </dependency>
- </dependencies>
- </profile>
+ </profile>
</profiles>
<build>
<!-- This section defines the default plugin settings inherited by child projects.
-->
@@ -156,7 +145,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
- <version>2.2</version>
+ <version>${version.jar.plugin}</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
@@ -169,17 +158,17 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
- <version>2.3.2</version>
+ <version>${version.compiler.plugin}</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>${maven.compiler.source}</source>
+ <target>${maven.compiler.target}</target>
<showDeprecation>false</showDeprecation>
<showWarnings>false</showWarnings>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.9</version>
+ <version>${version.surefire.plugin}</version>
<configuration>
<includes>
<include>**/*TestCase.java</include>
@@ -191,16 +180,10 @@
<!-- hack to prevent anonymous inner classes in Tests from being run as tests
-->
<include>**/Test*$*.java</include>
</excludes>
- <systemProperties>
- <property>
- <name>user.dir</name>
- <value>${basedir}/target</value>
- </property>
- <property>
- <name>java.io.tmpdir</name>
- <value>${basedir}/target</value>
- </property>
- </systemProperties>
+ <systemPropertyVariables>
+ <user.dir>${basedir}/target</user.dir>
+ <java.io.tmpdir>${basedir}/target</java.io.tmpdir>
+ </systemPropertyVariables>
</configuration>
</plugin>
<!--
@@ -232,7 +215,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
- <version>2.1.2</version>
+ <version>${version.source.plugin}</version>
<executions>
<execution>
<id>attach-sources</id>
@@ -244,13 +227,6 @@
</plugin>
</plugins>
</build>
- <repositories>
- <repository>
- <id>jboss-public-repository</id>
- <name>JBoss Public Maven Repository Group</name>
- <
url>http://repository.jboss.org/nexus/content/groups/public/</url>
- </repository>
- </repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
@@ -610,17 +586,6 @@
<version>${version.javax.enterprise.cdi-api}</version>
</dependency>
<dependency>
- <groupId>org.jboss.arquillian.junit</groupId>
- <artifactId>arquillian-junit-container</artifactId>
- <version>${version.org.jboss.arquillian.core}</version>
- <exclusions>
- <exclusion>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${version.sun.jaxb}</version>
@@ -657,16 +622,4 @@
<module>client-jdk15</module>
<module>admin</module>
</modules>
- <distributionManagement>
- <repository>
- <id>jboss-releases-repository</id>
- <name>JBoss Releases Repository</name>
-
<
url>https://repository.jboss.org/nexus/service/local/staging/deploy/ma...
- </repository>
- <snapshotRepository>
- <id>jboss-snapshots-repository</id>
- <name>JBoss Snapshots Repository</name>
-
<
url>https://repository.jboss.org/nexus/content/repositories/snapshots/...
- </snapshotRepository>
- </distributionManagement>
</project>
Added: trunk/settings.xml
===================================================================
--- trunk/settings.xml (rev 0)
+++ trunk/settings.xml 2011-12-09 21:44:19 UTC (rev 3729)
@@ -0,0 +1,47 @@
+<settings
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
+http://maven.apache.org/xsd/settings-1.0.0.xsd">
+ <profiles>
+ <profile>
+ <id>jboss-public-repository</id>
+ <repositories>
+ <repository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+
<
url>http://repository.jboss.org/nexus/content/groups/public/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>jboss-public-repository-group</id>
+ <name>JBoss Public Maven Repository Group</name>
+
<
url>http://repository.jboss.org/nexus/content/groups/public/</url>
+ <layout>default</layout>
+ <releases>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>never</updatePolicy>
+ </snapshots>
+ </pluginRepository>
+ </pluginRepositories>
+ </profile>
+ </profiles>
+
+ <activeProfiles>
+ <activeProfile>jboss-public-repository</activeProfile>
+ </activeProfiles>
+
+</settings>
Property changes on: trunk/settings.xml
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: trunk/test-integration/common/pom.xml
===================================================================
--- trunk/test-integration/common/pom.xml 2011-12-08 19:19:34 UTC (rev 3728)
+++ trunk/test-integration/common/pom.xml 2011-12-09 21:44:19 UTC (rev 3729)
@@ -50,4 +50,94 @@
<scope>provided</scope>
</dependency>
</dependencies>
+
+ <profiles>
+ <profile>
+ <id>arquillian-tests</id>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.spec</groupId>
+ <artifactId>jboss-javaee-6.0</artifactId>
+ <version>1.0.0.Final</version>
+ <type>pom</type>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.as</groupId>
+
<artifactId>jboss-as-arquillian-container-managed</artifactId>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>${version.dependency.plugin}</version>
+ <executions>
+ <execution>
+ <id>unpack</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+ <groupId>org.jboss.as</groupId>
+
<artifactId>jboss-as-dist</artifactId>
+
<version>${jbossas-version}</version>
+ <type>zip</type>
+ <overWrite>false</overWrite>
+
<outputDirectory>${project.build.directory}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ <execution>
+ <id>unpack2</id>
+ <phase>process-test-classes</phase>
+ <goals>
+ <goal>unpack</goal>
+ </goals>
+ <configuration>
+ <artifactItems>
+ <artifactItem>
+
<groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid</artifactId>
+
<version>${project.version}</version>
+
<classifier>jboss-dist</classifier>
+ <type>zip</type>
+ <overWrite>false</overWrite>
+
<outputDirectory>${project.build.directory}/jboss-as-${jbossas-version}</outputDirectory>
+ </artifactItem>
+ </artifactItems>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>default-test</id>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <systemPropertyVariables>
+
<jbossHome>${project.build.directory}/jboss-as-${jbossas-version}</jbossHome>
+
<serverConfig>standalone-teiid.xml</serverConfig>
+ </systemPropertyVariables>
+ <includes>
+
<include>**/IntegrationTest*</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
</project>
\ No newline at end of file
Copied:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
(from rev 3725,
trunk/test-integration/common/src/test/java/org/teiid/arquillian/TestDeployment.java)
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
(rev 0)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java 2011-12-09
21:44:19 UTC (rev 3729)
@@ -0,0 +1,452 @@
+package org.teiid.arquillian;
+
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+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 java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.sql.Connection;
+import java.sql.Statement;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jboss.arquillian.junit.Arquillian;
+import org.jboss.shrinkwrap.api.ArchivePaths;
+import org.jboss.shrinkwrap.api.ShrinkWrap;
+import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
+import org.jboss.shrinkwrap.api.exporter.ZipExporter;
+import org.jboss.shrinkwrap.api.spec.JavaArchive;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.teiid.adminapi.Admin;
+import org.teiid.adminapi.AdminException;
+import org.teiid.adminapi.AdminFactory;
+import org.teiid.adminapi.DataPolicy;
+import org.teiid.adminapi.Model;
+import org.teiid.adminapi.PropertyDefinition;
+import org.teiid.adminapi.Request;
+import org.teiid.adminapi.Session;
+import org.teiid.adminapi.Translator;
+import org.teiid.adminapi.VDB;
+import org.teiid.adminapi.VDB.ConnectionType;
+import org.teiid.adminapi.VDB.Status;
+import org.teiid.adminapi.impl.VDBTranslatorMetaData;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.jdbc.TeiidDriver;
+
+(a)RunWith(Arquillian.class)
+@SuppressWarnings("nls")
+public class IntegrationTestDeployment {
+
+ private Admin admin;
+
+ @Before
+ public void setup() throws Exception {
+ admin = AdminFactory.getInstance().createAdmin("localhost",
9999, "admin", "admin".toCharArray());
+ }
+
+ @After
+ public void teardown() {
+ admin.close();
+ }
+
+ @Test
+ public void testVDBDeployment() throws Exception {
+ boolean deployed = false;
+ try {
+ Set<?> vdbs = admin.getVDBs();
+ assertTrue(vdbs.isEmpty());
+
+ Collection<String> dsNames = admin.getDataSourceNames();
+ if (dsNames.contains("Oracle11_PushDS")) {
+ admin.deleteDataSource("Oracle11_PushDS");
+ }
+
+ admin.deploy("bqt.vdb",new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
+ deployed = true;
+
+ vdbs = admin.getVDBs();
+ assertFalse(vdbs.isEmpty());
+
+ VDB vdb = admin.getVDB("bqt", 1);
+ assertFalse(vdb.isValid());
+ assertTrue(vdb.getStatus().equals(Status.INACTIVE));
+
+ Properties props = new Properties();
+ props.setProperty("connection-url","jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
+ props.setProperty("user-name", "sa");
+ props.setProperty("password", "sa");
+
+ admin.createDataSource("Oracle11_PushDS", "h2", props);
+ Thread.sleep(2000);
+ vdb = admin.getVDB("bqt", 1);
+ assertTrue(vdb.isValid());
+ assertTrue(vdb.getStatus().equals(Status.ACTIVE));
+
+ dsNames = admin.getDataSourceNames();
+ assertTrue(dsNames.contains("Oracle11_PushDS"));
+
+ admin.deleteDataSource("Oracle11_PushDS");
+ vdb = admin.getVDB("bqt", 1);
+ assertFalse(vdb.isValid());
+ assertTrue(vdb.getStatus().equals(Status.INACTIVE));
+ } finally {
+ if (deployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void testTraslators() throws Exception {
+ Collection<? extends Translator> translators = admin.getTranslators();
+ System.out.println(translators);
+ assertEquals(29, translators.size());
+
+ JavaArchive jar = getLoopyArchive();
+
+ try {
+ admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream());
+
+ VDBTranslatorMetaData t =
(VDBTranslatorMetaData)admin.getTranslator("loopy");
+ assertNotNull(t);
+ assertEquals("ANY", t.getPropertyValue("SupportedJoinCriteria"));
+ assertEquals("true",
t.getPropertyValue("supportsSelectDistinct"));
+ } finally {
+ admin.undeploy("loopy.jar");
+ }
+
+ VDBTranslatorMetaData t =
(VDBTranslatorMetaData)admin.getTranslator("orcl");
+ assertNull(t);
+ }
+
+ private JavaArchive getLoopyArchive() {
+ JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "loopy.jar")
+ .addClasses(SampleExecutionFactory.class)
+ .addAsManifestResource(new
ByteArrayAsset(SampleExecutionFactory.class.getName().getBytes()),
+
ArchivePaths.create("services/org.teiid.translator.ExecutionFactory"));
+ jar.addAsManifestResource(new ByteArrayAsset("Dependencies:
org.jboss.teiid.translator.loopback\n".getBytes()),
+ ArchivePaths.create("MANIFEST.MF"));
+ return jar;
+ }
+
+ @Test
+ public void testVDBConnectionType() throws Exception {
+ boolean vdbOneDeployed = false;
+ boolean vdbTwoDeployed = false;
+ try {
+
+ admin.deploy("bqt.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
+ vdbOneDeployed = true;
+
+ VDB vdb = admin.getVDB("bqt", 1);
+ Model model = vdb.getModels().get(0);
+ admin.assignToModel("bqt", 1, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
+ assertEquals(ConnectionType.BY_VERSION, vdb.getConnectionType());
+
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ conn.close();
+ } catch (Exception e) {
+ fail("must have succeeded in connection");
+ }
+
+ admin.changeVDBConnectionType("bqt", 1, ConnectionType.NONE);
+
+ try {
+ TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ fail("should have failed to connect as no new connections allowed");
+ } catch (Exception e) {
+ //pass
+ }
+
+ admin.deploy("bqt2.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
+ admin.assignToModel("bqt", 2, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
+
+ vdbTwoDeployed = true;
+
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ conn.close();
+ } catch (Exception e) {
+ fail("should not have failed to connect");
+ }
+
+ admin.changeVDBConnectionType("bqt", 2, ConnectionType.ANY);
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ conn.close();
+ } catch (Exception e) {
+ fail("should have connected to the second vdb");
+ }
+
+ vdb = admin.getVDB("bqt", 2);
+ model = vdb.getModels().get(0);
+ assertEquals(model.getSourceConnectionJndiName("Source"),
"java:jboss/datasources/ExampleDS");
+ assertEquals(model.getSourceTranslatorName("Source"), "h2");
+ assertEquals(ConnectionType.ANY, vdb.getConnectionType());
+
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ if (vdbTwoDeployed) {
+ admin.undeploy("bqt2.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void testCacheTypes() throws Exception {
+ String[] array = {Admin.Cache.PREPARED_PLAN_CACHE.toString(),
Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString()};
+ Collection<String> types = admin.getCacheTypes();
+ System.out.println(types);
+ assertArrayEquals(array, types.toArray());
+ }
+
+ @Test
+ public void testSessions() throws Exception {
+ boolean vdbOneDeployed = false;
+ try {
+ vdbOneDeployed = deployVdb();
+
+ Collection<? extends Session> sessions = admin.getSessions();
+ assertEquals (0, sessions.size());
+
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user;ApplicationName=test",
null);
+ sessions = admin.getSessions();
+ assertEquals (1, sessions.size());
+ Session s = sessions.iterator().next();
+
+ assertEquals("user@teiid-security", s.getUserName());
+ assertEquals("test", s.getApplicationName());
+ assertEquals("bqt", s.getVDBName());
+ assertEquals(1, s.getVDBVersion());
+ assertNotNull(s.getSessionId());
+
+ conn.close();
+ } catch (Exception e) {
+ fail("should have connected to the vdb");
+ }
+
+ try {
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user;ApplicationName=test",
null);
+ sessions = admin.getSessions();
+ assertEquals (1, sessions.size());
+ Session s = sessions.iterator().next();
+
+ admin.terminateSession(s.getSessionId());
+ sessions = admin.getSessions();
+ assertEquals (0, sessions.size());
+ conn.close();
+ } catch (Exception e) {
+ fail("should have connected to the vdb");
+ }
+
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+
+ }
+ }
+
+ private boolean deployVdb() throws AdminException, FileNotFoundException {
+ boolean vdbOneDeployed;
+ admin.deploy("bqt.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
+ vdbOneDeployed = true;
+
+ VDB vdb = admin.getVDB("bqt", 1);
+ Model model = vdb.getModels().get(0);
+ admin.assignToModel("bqt", 1, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
+ return vdbOneDeployed;
+ }
+
+ @Test
+ public void testGetRequests() throws Exception {
+ boolean vdbOneDeployed = false;
+ JavaArchive jar = getLoopyArchive();
+
+ try {
+ admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream());
+ vdbOneDeployed = deployVdb();
+ VDB vdb = admin.getVDB("bqt", 1);
+ Model model = vdb.getModels().get(0);
+ Translator t = admin.getTranslator("loopy");
+ assertNotNull(t);
+
+ admin.assignToModel("bqt", 1, model.getName(), "Source",
"loopy", "java:jboss/datasources/ExampleDS");
+ Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
+ Collection<? extends Session> sessions = admin.getSessions();
+ assertEquals (1, sessions.size());
+ Session s = sessions.iterator().next();
+
+ Statement stmt = conn.createStatement();
+
+ Collection<? extends Request> requests = admin.getRequests();
+
+ assertEquals(0, requests.size());
+
+ stmt.execute("select * from source.smalla");
+
+ requests = admin.getRequests();
+ assertEquals(1, requests.size());
+
+ Request r = requests.iterator().next();
+ assertEquals("select * from source.smalla", r.getCommand());
+ assertNotNull(r.getExecutionId());
+ assertNotNull(r.getSessionId());
+
+ stmt.execute("select * from source.smalla");
+ Collection<? extends Request> requests2 =
admin.getRequestsForSession(s.getSessionId());
+ assertEquals(1, requests2.size());
+
+ Request r2 = requests.iterator().next();
+ assertEquals("select * from source.smalla", r2.getCommand());
+ assertEquals(s.getSessionId(), r2.getSessionId());
+
+ stmt.close();
+ conn.close();
+
+ requests = admin.getRequests();
+ assertEquals(0, requests.size());
+
+ } finally {
+ admin.undeploy("loopy.jar");
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void getDatasourceTemplateNames() throws Exception {
+ String[] array = {"teiid-connector-file.rar",
"teiid-connector-salesforce.rar", "teiid-connector-ldap.rar",
"teiid-connector-ws.rar", "h2"};
+ boolean vdbOneDeployed = false;
+ try {
+ vdbOneDeployed = deployVdb();
+ Set<String> templates = admin.getDataSourceTemplateNames();
+ assertArrayEquals(array, templates.toArray());
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void getTemplatePropertyDefinitions() throws Exception{
+ boolean vdbOneDeployed = false;
+ try {
+ HashSet<String> props = new HashSet<String>();
+ vdbOneDeployed = deployVdb();
+ Collection<? extends PropertyDefinition> pds =
admin.getTemplatePropertyDefinitions("h2");
+ for(PropertyDefinition pd:pds) {
+ props.add(pd.getName());
+ }
+ assertTrue(props.contains("connection-url"));
+ assertTrue(props.contains("user-name"));
+ assertTrue(props.contains("password"));
+ assertTrue(props.contains("check-valid-connection-sql"));
+
+
+ HashSet<String> rar_props = new HashSet<String>();
+ pds = admin.getTemplatePropertyDefinitions("teiid-connector-file.rar");
+ for(PropertyDefinition pd:pds) {
+ rar_props.add(pd.getName());
+ }
+
+ assertTrue(rar_props.contains("ParentDirectory"));
+ assertTrue(rar_props.contains("FileMapping"));
+ assertTrue(rar_props.contains("AllowParentPaths"));
+
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void getWorkerPoolStats() throws Exception{
+ boolean vdbOneDeployed = false;
+ try {
+ vdbOneDeployed = deployVdb();
+ assertNotNull(admin.getWorkerPoolStats());
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt.vdb");
+ }
+ }
+ }
+
+ @Test
+ public void testDataRoleMapping() throws Exception{
+ boolean vdbOneDeployed = false;
+ try {
+ admin.deploy("bqt2.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
+ vdbOneDeployed = true;
+
+ VDB vdb = admin.getVDB("bqt", 2);
+ Model model = vdb.getModels().get(0);
+ admin.assignToModel("bqt", 2, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
+
+ vdb = admin.getVDB("bqt", 2);
+ assertTrue(vdb.isValid());
+ List<DataPolicy> policies = vdb.getDataPolicies();
+ assertEquals(1, policies.size());
+
+ DataPolicy dp = policies.get(0);
+ assertEquals("roleOne", dp.getName());
+ assertEquals(2, dp.getPermissions().size());
+ assertTrue(dp.isAllowCreateTemporaryTables());
+ assertTrue(dp.isAnyAuthenticated());
+
+ List<String> roleNames = dp.getMappedRoleNames();
+ assertArrayEquals(new String[]{"ROLE1", "ROLE2"},
roleNames.toArray());
+
+ admin.removeDataRoleMapping("bqt", 2, "roleOne",
"ROLE1");
+
+ vdb = admin.getVDB("bqt", 2);
+ policies = vdb.getDataPolicies();
+ dp = policies.get(0);
+
+ roleNames = dp.getMappedRoleNames();
+ assertArrayEquals(new String[]{"ROLE2"}, roleNames.toArray());
+
+ admin.addDataRoleMapping("bqt", 2, "roleOne", "ROLE3");
+
+ vdb = admin.getVDB("bqt", 2);
+ policies = vdb.getDataPolicies();
+ dp = policies.get(0);
+
+ roleNames = dp.getMappedRoleNames();
+ assertArrayEquals(new String[]{"ROLE2", "ROLE3"},
roleNames.toArray());
+
+ admin.setAnyAuthenticatedForDataRole("bqt", 2, "roleOne", false);
+
+ vdb = admin.getVDB("bqt", 2);
+ policies = vdb.getDataPolicies();
+ dp = policies.get(0);
+
+ assertFalse(dp.isAnyAuthenticated());
+ } finally {
+ if (vdbOneDeployed) {
+ admin.undeploy("bqt2.vdb");
+ }
+ }
+ }
+
+
+}
Property changes on:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/IntegrationTestDeployment.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Deleted:
trunk/test-integration/common/src/test/java/org/teiid/arquillian/TestDeployment.java
===================================================================
---
trunk/test-integration/common/src/test/java/org/teiid/arquillian/TestDeployment.java 2011-12-08
19:19:34 UTC (rev 3728)
+++
trunk/test-integration/common/src/test/java/org/teiid/arquillian/TestDeployment.java 2011-12-09
21:44:19 UTC (rev 3729)
@@ -1,454 +0,0 @@
-package org.teiid.arquillian;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-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 java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.sql.Connection;
-import java.sql.Statement;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
-import org.jboss.arquillian.junit.Arquillian;
-import org.jboss.shrinkwrap.api.ArchivePaths;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.asset.ByteArrayAsset;
-import org.jboss.shrinkwrap.api.exporter.ZipExporter;
-import org.jboss.shrinkwrap.api.spec.JavaArchive;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.teiid.adminapi.Admin;
-import org.teiid.adminapi.AdminException;
-import org.teiid.adminapi.AdminFactory;
-import org.teiid.adminapi.DataPolicy;
-import org.teiid.adminapi.Model;
-import org.teiid.adminapi.PropertyDefinition;
-import org.teiid.adminapi.Request;
-import org.teiid.adminapi.Session;
-import org.teiid.adminapi.Translator;
-import org.teiid.adminapi.VDB;
-import org.teiid.adminapi.VDB.ConnectionType;
-import org.teiid.adminapi.VDB.Status;
-import org.teiid.adminapi.impl.VDBTranslatorMetaData;
-import org.teiid.core.util.UnitTestUtil;
-import org.teiid.jdbc.TeiidDriver;
-
-(a)RunWith(Arquillian.class)
-@SuppressWarnings("nls")
-@Ignore
-public class TestDeployment {
-
- private Admin admin;
-
- @Before
- public void setup() throws Exception {
- admin = AdminFactory.getInstance().createAdmin("localhost",
9999, "admin", "admin".toCharArray());
- }
-
- @After
- public void teardown() {
- admin.close();
- }
-
- @Test
- public void testVDBDeployment() throws Exception {
- boolean deployed = false;
- try {
- Set<?> vdbs = admin.getVDBs();
- assertTrue(vdbs.isEmpty());
-
- Collection<String> dsNames = admin.getDataSourceNames();
- if (dsNames.contains("Oracle11_PushDS")) {
- admin.deleteDataSource("Oracle11_PushDS");
- }
-
- admin.deploy("bqt.vdb",new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
- deployed = true;
-
- vdbs = admin.getVDBs();
- assertFalse(vdbs.isEmpty());
-
- VDB vdb = admin.getVDB("bqt", 1);
- assertFalse(vdb.isValid());
- assertTrue(vdb.getStatus().equals(Status.INACTIVE));
-
- Properties props = new Properties();
- props.setProperty("connection-url","jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
- props.setProperty("user-name", "sa");
- props.setProperty("password", "sa");
-
- admin.createDataSource("Oracle11_PushDS", "h2", props);
- Thread.sleep(2000);
- vdb = admin.getVDB("bqt", 1);
- assertTrue(vdb.isValid());
- assertTrue(vdb.getStatus().equals(Status.ACTIVE));
-
- dsNames = admin.getDataSourceNames();
- assertTrue(dsNames.contains("Oracle11_PushDS"));
-
- admin.deleteDataSource("Oracle11_PushDS");
- vdb = admin.getVDB("bqt", 1);
- assertFalse(vdb.isValid());
- assertTrue(vdb.getStatus().equals(Status.INACTIVE));
- } finally {
- if (deployed) {
- admin.undeploy("bqt.vdb");
- }
- }
- }
-
- @Test
- public void testTraslators() throws Exception {
- Collection<? extends Translator> translators = admin.getTranslators();
- System.out.println(translators);
- assertEquals(29, translators.size());
-
- JavaArchive jar = getLoopyArchive();
-
- try {
- admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream());
-
- VDBTranslatorMetaData t =
(VDBTranslatorMetaData)admin.getTranslator("loopy");
- assertNotNull(t);
- assertEquals("ANY", t.getPropertyValue("SupportedJoinCriteria"));
- assertEquals("true",
t.getPropertyValue("supportsSelectDistinct"));
- } finally {
- admin.undeploy("loopy.jar");
- }
-
- VDBTranslatorMetaData t =
(VDBTranslatorMetaData)admin.getTranslator("orcl");
- assertNull(t);
- }
-
- private JavaArchive getLoopyArchive() {
- JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "loopy.jar")
- .addClasses(SampleExecutionFactory.class)
- .addAsManifestResource(new
ByteArrayAsset(SampleExecutionFactory.class.getName().getBytes()),
-
ArchivePaths.create("services/org.teiid.translator.ExecutionFactory"));
- jar.addAsManifestResource(new ByteArrayAsset("Dependencies:
org.jboss.teiid.translator.loopback\n".getBytes()),
- ArchivePaths.create("MANIFEST.MF"));
- return jar;
- }
-
- @Test
- public void testVDBConnectionType() throws Exception {
- boolean vdbOneDeployed = false;
- boolean vdbTwoDeployed = false;
- try {
-
- admin.deploy("bqt.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
- vdbOneDeployed = true;
-
- VDB vdb = admin.getVDB("bqt", 1);
- Model model = vdb.getModels().get(0);
- admin.assignToModel("bqt", 1, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
- assertEquals(ConnectionType.BY_VERSION, vdb.getConnectionType());
-
- try {
- Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
- conn.close();
- } catch (Exception e) {
- fail("must have succeeded in connection");
- }
-
- admin.changeVDBConnectionType("bqt", 1, ConnectionType.NONE);
-
- try {
- TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
- fail("should have failed to connect as no new connections allowed");
- } catch (Exception e) {
- //pass
- }
-
- admin.deploy("bqt2.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
- admin.assignToModel("bqt", 2, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
-
- vdbTwoDeployed = true;
-
- try {
- Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
- conn.close();
- } catch (Exception e) {
- fail("should not have failed to connect");
- }
-
- admin.changeVDBConnectionType("bqt", 2, ConnectionType.ANY);
- try {
- Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
- conn.close();
- } catch (Exception e) {
- fail("should have connected to the second vdb");
- }
-
- vdb = admin.getVDB("bqt", 2);
- model = vdb.getModels().get(0);
- assertEquals(model.getSourceConnectionJndiName("Source"),
"java:jboss/datasources/ExampleDS");
- assertEquals(model.getSourceTranslatorName("Source"), "h2");
- assertEquals(ConnectionType.ANY, vdb.getConnectionType());
-
- } finally {
- if (vdbOneDeployed) {
- admin.undeploy("bqt.vdb");
- }
- if (vdbTwoDeployed) {
- admin.undeploy("bqt2.vdb");
- }
- }
- }
-
- @Test
- public void testCacheTypes() throws Exception {
- String[] array = {Admin.Cache.PREPARED_PLAN_CACHE.toString(),
Admin.Cache.QUERY_SERVICE_RESULT_SET_CACHE.toString()};
- Collection<String> types = admin.getCacheTypes();
- System.out.println(types);
- assertArrayEquals(array, types.toArray());
- }
-
- @Test
- public void testSessions() throws Exception {
- boolean vdbOneDeployed = false;
- try {
- vdbOneDeployed = deployVdb();
-
- Collection<? extends Session> sessions = admin.getSessions();
- assertEquals (0, sessions.size());
-
- try {
- Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user;ApplicationName=test",
null);
- sessions = admin.getSessions();
- assertEquals (1, sessions.size());
- Session s = sessions.iterator().next();
-
- assertEquals("user@teiid-security", s.getUserName());
- assertEquals("test", s.getApplicationName());
- assertEquals("bqt", s.getVDBName());
- assertEquals(1, s.getVDBVersion());
- assertNotNull(s.getSessionId());
-
- conn.close();
- } catch (Exception e) {
- fail("should have connected to the vdb");
- }
-
- try {
- Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user;ApplicationName=test",
null);
- sessions = admin.getSessions();
- assertEquals (1, sessions.size());
- Session s = sessions.iterator().next();
-
- admin.terminateSession(s.getSessionId());
- sessions = admin.getSessions();
- assertEquals (0, sessions.size());
- conn.close();
- } catch (Exception e) {
- fail("should have connected to the vdb");
- }
-
- } finally {
- if (vdbOneDeployed) {
- admin.undeploy("bqt.vdb");
- }
-
- }
- }
-
- private boolean deployVdb() throws AdminException, FileNotFoundException {
- boolean vdbOneDeployed;
- admin.deploy("bqt.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt.vdb")));
- vdbOneDeployed = true;
-
- VDB vdb = admin.getVDB("bqt", 1);
- Model model = vdb.getModels().get(0);
- admin.assignToModel("bqt", 1, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
- return vdbOneDeployed;
- }
-
- @Test
- public void testGetRequests() throws Exception {
- boolean vdbOneDeployed = false;
- JavaArchive jar = getLoopyArchive();
-
- try {
- admin.deploy("loopy.jar", jar.as(ZipExporter.class).exportAsInputStream());
- vdbOneDeployed = deployVdb();
- VDB vdb = admin.getVDB("bqt", 1);
- Model model = vdb.getModels().get(0);
- Translator t = admin.getTranslator("loopy");
- assertNotNull(t);
-
- admin.assignToModel("bqt", 1, model.getName(), "Source",
"loopy", "java:jboss/datasources/ExampleDS");
- Connection conn =
TeiidDriver.getInstance().connect("jdbc:teiid:bqt@mm://localhost:31000;user=user;password=user",
null);
- Collection<? extends Session> sessions = admin.getSessions();
- assertEquals (1, sessions.size());
- Session s = sessions.iterator().next();
-
- Statement stmt = conn.createStatement();
-
- Collection<? extends Request> requests = admin.getRequests();
-
- assertEquals(0, requests.size());
-
- stmt.execute("select * from source.smalla");
-
- requests = admin.getRequests();
- assertEquals(1, requests.size());
-
- Request r = requests.iterator().next();
- assertEquals("select * from source.smalla", r.getCommand());
- assertNotNull(r.getExecutionId());
- assertNotNull(r.getSessionId());
-
- stmt.execute("select * from source.smalla");
- Collection<? extends Request> requests2 =
admin.getRequestsForSession(s.getSessionId());
- assertEquals(1, requests2.size());
-
- Request r2 = requests.iterator().next();
- assertEquals("select * from source.smalla", r2.getCommand());
- assertEquals(s.getSessionId(), r2.getSessionId());
-
- stmt.close();
- conn.close();
-
- requests = admin.getRequests();
- assertEquals(0, requests.size());
-
- } finally {
- admin.undeploy("loopy.jar");
- if (vdbOneDeployed) {
- admin.undeploy("bqt.vdb");
- }
- }
- }
-
- @Test
- public void getDatasourceTemplateNames() throws Exception {
- String[] array = {"teiid-connector-file.rar",
"teiid-connector-salesforce.rar", "teiid-connector-ldap.rar",
"teiid-connector-ws.rar", "h2"};
- boolean vdbOneDeployed = false;
- try {
- vdbOneDeployed = deployVdb();
- Set<String> templates = admin.getDataSourceTemplateNames();
- assertArrayEquals(array, templates.toArray());
- } finally {
- if (vdbOneDeployed) {
- admin.undeploy("bqt.vdb");
- }
- }
- }
-
- @Test
- public void getTemplatePropertyDefinitions() throws Exception{
- boolean vdbOneDeployed = false;
- try {
- HashSet<String> props = new HashSet<String>();
- vdbOneDeployed = deployVdb();
- Collection<? extends PropertyDefinition> pds =
admin.getTemplatePropertyDefinitions("h2");
- for(PropertyDefinition pd:pds) {
- props.add(pd.getName());
- }
- assertTrue(props.contains("connection-url"));
- assertTrue(props.contains("user-name"));
- assertTrue(props.contains("password"));
- assertTrue(props.contains("check-valid-connection-sql"));
-
-
- HashSet<String> rar_props = new HashSet<String>();
- pds = admin.getTemplatePropertyDefinitions("teiid-connector-file.rar");
- for(PropertyDefinition pd:pds) {
- rar_props.add(pd.getName());
- }
-
- assertTrue(rar_props.contains("ParentDirectory"));
- assertTrue(rar_props.contains("FileMapping"));
- assertTrue(rar_props.contains("AllowParentPaths"));
-
- } finally {
- if (vdbOneDeployed) {
- admin.undeploy("bqt.vdb");
- }
- }
- }
-
- @Test
- public void getWorkerPoolStats() throws Exception{
- boolean vdbOneDeployed = false;
- try {
- vdbOneDeployed = deployVdb();
- assertNotNull(admin.getWorkerPoolStats());
- } finally {
- if (vdbOneDeployed) {
- admin.undeploy("bqt.vdb");
- }
- }
- }
-
- @Test
- public void testDataRoleMapping() throws Exception{
- boolean vdbOneDeployed = false;
- try {
- admin.deploy("bqt2.vdb", new
FileInputStream(UnitTestUtil.getTestDataFile("bqt2.vdb")));
- vdbOneDeployed = true;
-
- VDB vdb = admin.getVDB("bqt", 2);
- Model model = vdb.getModels().get(0);
- admin.assignToModel("bqt", 2, model.getName(), "Source",
"h2", "java:jboss/datasources/ExampleDS");
-
- vdb = admin.getVDB("bqt", 2);
- assertTrue(vdb.isValid());
- List<DataPolicy> policies = vdb.getDataPolicies();
- assertEquals(1, policies.size());
-
- DataPolicy dp = policies.get(0);
- assertEquals("roleOne", dp.getName());
- assertEquals(2, dp.getPermissions().size());
- assertTrue(dp.isAllowCreateTemporaryTables());
- assertTrue(dp.isAnyAuthenticated());
-
- List<String> roleNames = dp.getMappedRoleNames();
- assertArrayEquals(new String[]{"ROLE1", "ROLE2"},
roleNames.toArray());
-
- admin.removeDataRoleMapping("bqt", 2, "roleOne",
"ROLE1");
-
- vdb = admin.getVDB("bqt", 2);
- policies = vdb.getDataPolicies();
- dp = policies.get(0);
-
- roleNames = dp.getMappedRoleNames();
- assertArrayEquals(new String[]{"ROLE2"}, roleNames.toArray());
-
- admin.addDataRoleMapping("bqt", 2, "roleOne", "ROLE3");
-
- vdb = admin.getVDB("bqt", 2);
- policies = vdb.getDataPolicies();
- dp = policies.get(0);
-
- roleNames = dp.getMappedRoleNames();
- assertArrayEquals(new String[]{"ROLE2", "ROLE3"},
roleNames.toArray());
-
- admin.setAnyAuthenticatedForDataRole("bqt", 2, "roleOne", false);
-
- vdb = admin.getVDB("bqt", 2);
- policies = vdb.getDataPolicies();
- dp = policies.get(0);
-
- assertFalse(dp.isAnyAuthenticated());
- } finally {
- if (vdbOneDeployed) {
- admin.undeploy("bqt2.vdb");
- }
- }
- }
-
-
-}
Modified: trunk/test-integration/common/src/test/resources/arquillian.xml
===================================================================
--- trunk/test-integration/common/src/test/resources/arquillian.xml 2011-12-08 19:19:34
UTC (rev 3728)
+++ trunk/test-integration/common/src/test/resources/arquillian.xml 2011-12-09 21:44:19
UTC (rev 3729)
@@ -8,10 +8,8 @@
<property name="executionType">REMOTE</property>
</protocol>
<configuration>
- <property
name="jbossHome">/home/rareddy/testing/jboss-as-7.1.0.Beta1</property>
- <property
name="serverConfig">standalone-teiid.xml</property>
- <property
name="managementAddress">127.0.0.1</property>
- <property name="managementPort">9999</property>
+ <property name="jbossHome">${jbossHome}</property>
+ <property
name="serverConfig">${serverConfig}</property>
<property name="javaVmArguments">-Xmx512m
-XX:MaxPermSize=128m
-Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n</property>
</configuration>
</container>