forked from arquillian/arquillian-container-glassfish
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ARQ-397 Add support for sunResourcesXML deployment during container s…
…tartup * Fix EAR WebModule deployment scanning for Servlet ProtocolMetadata discovery
- Loading branch information
1 parent
81f36d5
commit 2dc49ca
Showing
6 changed files
with
270 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
....1/src/test/java/org/jboss/arquillian/container/glassfish/embedded_3_1/app/MyServlet.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, Red Hat Middleware LLC, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed 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.jboss.arquillian.container.glassfish.embedded_3_1.app; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.annotation.Resource; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
import javax.sql.DataSource; | ||
|
||
/** | ||
* TestServlet | ||
* | ||
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a> | ||
* @version $Revision: $ | ||
*/ | ||
@WebServlet(urlPatterns = MyServlet.URL_PATTERN) | ||
public class MyServlet extends HttpServlet | ||
{ | ||
private static final long serialVersionUID = 1L; | ||
|
||
public static final String URL_PATTERN = "/Test"; | ||
|
||
public static final String MESSAGE = "hello"; | ||
|
||
@Resource(name = "jdbc/arquillian") private DataSource arquillianDS; | ||
|
||
@Override | ||
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException | ||
{ | ||
response.getWriter().append(arquillianDS != null ? MESSAGE : "#fail"); | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
.../org/jboss/arquillian/container/glassfish/embedded_3_1/app/ResourceXmlClientTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, Red Hat Middleware LLC, and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed 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.jboss.arquillian.container.glassfish.embedded_3_1.app; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.InputStream; | ||
import java.net.URL; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* GlassFishEmbeddedContainerTestCase | ||
* | ||
* @author <a href="mailto:aslak@redhat.com">Aslak Knutsen</a> | ||
* @version $Revision: $ | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class ResourceXmlClientTestCase | ||
{ | ||
/** | ||
* Deployment for the test | ||
* @return | ||
*/ | ||
@Deployment(testable = false) | ||
public static WebArchive getDeployment() | ||
{ | ||
return ShrinkWrap.create(WebArchive.class).addClass(MyServlet.class); | ||
} | ||
|
||
@Test | ||
public void shouldBeAbleToDeployWebArchive(@ArquillianResource(MyServlet.class) URL baseURL) throws Exception | ||
{ | ||
String body = readAllAndClose( | ||
new URL(baseURL, "Test").openStream()); | ||
|
||
Assert.assertEquals( | ||
"Verify that the servlet was deployed and returns expected result", | ||
MyServlet.MESSAGE, | ||
body); | ||
} | ||
|
||
private String readAllAndClose(InputStream is) throws Exception | ||
{ | ||
ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
try | ||
{ | ||
int read; | ||
while( (read = is.read()) != -1) | ||
{ | ||
out.write(read); | ||
} | ||
} | ||
finally | ||
{ | ||
try { is.close(); } catch (Exception e) { } | ||
} | ||
return out.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<arquillian xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian-1.0.xsd"> | ||
<arquillian | ||
xmlns="http://jboss.org/schema/arquillian" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://jboss.org/schema/arquillian http://jboss.org/schema/arquillian/arquillian_1_0.xsd"> | ||
|
||
<engine> | ||
<property name="deploymentExportPath">target/</property> | ||
</engine> | ||
<container qualifier="glassfish" default="true"> | ||
<configuration> | ||
<property name="sunResourcesXml">src/test/resources/sun-resources.xml</property> | ||
<property name="bindHttpPort">7070</property> | ||
</configuration> | ||
</container> | ||
</arquillian> |
19 changes: 19 additions & 0 deletions
19
glassfish-embedded-3.1/src/test/resources/sun-resources.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE resources PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Resource Definitions //EN" | ||
"http://www.sun.com/software/appserver/dtds/sun-resources_1_4.dtd"> | ||
<resources> | ||
<jdbc-resource pool-name="ArquillianEmbeddedDerbyPool" | ||
jndi-name="jdbc/arquillian"/> | ||
<jdbc-connection-pool name="ArquillianEmbeddedDerbyPool" | ||
res-type="javax.sql.DataSource" | ||
datasource-classname="org.apache.derby.jdbc.EmbeddedDataSource" | ||
is-isolation-level-guaranteed="false"> | ||
<property name="databaseName" value="target/databases/derby"/> | ||
<property name="createDatabase" value="create"/> | ||
</jdbc-connection-pool> | ||
<!-- | ||
<custom-resource res-type="java.lang.String" jndi-name="message" factory-class="org.glassfish.resources.custom.factory.PrimitivesAndStringFactory" enabled="true"> | ||
<property name="value" value="hello"/> | ||
</custom-resource> | ||
--> | ||
</resources> |