Skip to content
This repository has been archived by the owner on Jun 7, 2021. It is now read-only.

Commit

Permalink
Adjust datasource examples and add tests.
Browse files Browse the repository at this point in the history
Remove gratuitous jaxrs-msc example.
  • Loading branch information
bobmcwhirter committed Nov 30, 2015
1 parent 94b73bc commit 69212dd
Show file tree
Hide file tree
Showing 20 changed files with 132 additions and 225 deletions.
Expand Up @@ -10,12 +10,12 @@

<parent>
<groupId>org.wildfly.swarm.examples</groupId>
<artifactId>wildfly-swarm-examples-parent</artifactId>
<artifactId>examples-datasource</artifactId>
<version>1.0.0.Alpha6-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

<artifactId>wildfly-swarm-example-datasource-deployment</artifactId>
<artifactId>example-datasource-deployment</artifactId>

<name>WildFly Swarm Examples: Datasource Deployment</name>
<description>WildFly Swarm Examples: Datasource Deployment</description>
Expand All @@ -30,11 +30,26 @@
<configuration>
<mainClass>org.wildfly.swarm.examples.ds.deployment.Main</mainClass>
</configuration>
<executions>
<execution>
<id>package</id>
</execution>
<execution>
<id>start</id>
</execution>
<execution>
<id>stop</id>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.wildfly.swarm.examples</groupId>
<artifactId>examples-base</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-jaxrs</artifactId>
Expand Down
@@ -0,0 +1,33 @@
package org.wildfly.swarm.examples.ds.deployment;

import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.wildfly.swarm.it.AbstractIntegrationTest;
import org.wildfly.swarm.it.Log;

import static org.fest.assertions.Assertions.assertThat;

/**
* @author Bob McWhirter
*/
@RunWith(Arquillian.class)
public class DatasourceIT extends AbstractIntegrationTest {

@Drone
WebDriver browser;

@Test
public void testIt() throws Exception {
Log log = getStdOutLog();

assertThatLog( log ).hasLineContaining( "WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]" );
assertThatLog( log ).hasLineContaining( "WFLYSRV0010: Deployed \"h2\" (runtime-name : \"h2\")" );


browser.navigate().to("http://localhost:8080/");
assertThat(browser.getPageSource()).contains("Howdy using connection: org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7" );
}
}
Expand Up @@ -18,30 +18,20 @@ public static void main(String[] args) throws Exception {

Container container = new Container();

// Start the container
container.start();

// Create a JDBC driver deployment using maven groupId:artifactId
// The version is resolved from your pom.xml's <dependency>
container.deploy(Swarm.artifact("com.h2database:h2", "h2"));

/*
// Create a DS deployment
DatasourceDeployment dsDeployment = new DatasourceDeployment(container, new Datasource("ExampleDS")
.connectionURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE")
.driver("h2")
.authentication("sa", "sa")
);
*/

JARArchive dsArchive = ShrinkWrap.create(JARArchive.class);
dsArchive.as(DatasourceArchive.class).datasource(
new DataSource("ExampleDS")
.connectionUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE")
.driverName("h2")
.userName("sa")
.password("sa")
);
dsArchive.as(DatasourceArchive.class).dataSource("ExampleDS", (ds) -> {
ds.connectionUrl("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE");
ds.driverName("h2");
ds.userName("sa");
ds.password("sa");
});

// Deploy the datasource
container.deploy(dsArchive);
Expand Down
File renamed without changes.
Expand Up @@ -10,12 +10,12 @@

<parent>
<groupId>org.wildfly.swarm.examples</groupId>
<artifactId>wildfly-swarm-examples-parent</artifactId>
<artifactId>examples-datasource</artifactId>
<version>1.0.0.Alpha6-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

<artifactId>wildfly-swarm-example-datasource-subsystem</artifactId>
<artifactId>example-datasource-subsystem</artifactId>

<name>WildFly Swarm Examples: Datasource Subsystem</name>
<description>WildFly Swarm Examples: Datasource Subsystem</description>
Expand All @@ -42,16 +42,24 @@
</configuration>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
<id>package</id>
</execution>
<execution>
<id>start</id>
</execution>
<execution>
<id>stop</id>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.wildfly.swarm.examples</groupId>
<artifactId>examples-base</artifactId>
</dependency>
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-jaxrs</artifactId>
Expand Down
@@ -0,0 +1,32 @@
package org.wildfly.swarm.examples.ds.deployment;

import org.jboss.arquillian.drone.api.annotation.Drone;
import org.jboss.arquillian.junit.Arquillian;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.openqa.selenium.WebDriver;
import org.wildfly.swarm.it.AbstractIntegrationTest;
import org.wildfly.swarm.it.Log;

import static org.fest.assertions.Assertions.assertThat;

/**
* @author Bob McWhirter
*/
@RunWith(Arquillian.class)
public class DatasourceIT extends AbstractIntegrationTest {

@Drone
WebDriver browser;

@Test
public void testIt() throws Exception {
Log log = getStdOutLog();

assertThatLog( log ).hasLineContaining( "WFLYJCA0001: Bound data source [java:jboss/datasources/ExampleDS]" );


browser.navigate().to("http://localhost:8080/");
assertThat(browser.getPageSource()).contains("Howdy using connection: org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7" );
}
}
30 changes: 30 additions & 0 deletions datasource/pom.xml
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright 2015 Red Hat, Inc. and/or its affiliates.
~
~ Licensed under the Apache License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
-->
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.wildfly.swarm.examples</groupId>
<artifactId>wildfly-swarm-examples-parent</artifactId>
<version>1.0.0.Alpha6-SNAPSHOT</version>
<relativePath>../</relativePath>
</parent>

<artifactId>examples-datasource</artifactId>

<name>WildFly Swarm Examples: Datasource parent</name>
<description>WildFly Swarm Examples: Datasource parent</description>

<packaging>pom</packaging>


<modules>
<module>datasource-deployment</module>
<module>datasource-subsystem</module>
</modules>
</project>
62 changes: 0 additions & 62 deletions jaxrs-msc/pom.xml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 69212dd

Please sign in to comment.