Author: anil.saldhana(a)jboss.com
Date: 2008-11-02 01:03:20 -0500 (Sun, 02 Nov 2008)
New Revision: 118
Added:
identity-federation/trunk/identity-bindings/
identity-federation/trunk/identity-bindings/.classpath
identity-federation/trunk/identity-bindings/.project
identity-federation/trunk/identity-bindings/pom.xml
identity-federation/trunk/identity-bindings/src/
identity-federation/trunk/identity-bindings/src/main/
identity-federation/trunk/identity-bindings/src/main/java/
identity-federation/trunk/identity-bindings/src/main/java/org/
identity-federation/trunk/identity-bindings/src/main/java/org/jboss/
identity-federation/trunk/identity-bindings/src/main/java/org/jboss/identity/
identity-federation/trunk/identity-bindings/src/main/java/org/jboss/identity/federation/
identity-federation/trunk/identity-bindings/src/main/java/org/jboss/identity/federation/bindings/
identity-federation/trunk/identity-bindings/src/main/java/org/jboss/identity/federation/bindings/tomcat/
identity-federation/trunk/identity-bindings/src/main/resources/
identity-federation/trunk/identity-bindings/src/test/
identity-federation/trunk/identity-bindings/src/test/java/
identity-federation/trunk/identity-bindings/src/test/java/org/
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/bindings/
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/bindings/Tomcat5TestCase.java
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/helpers/
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/helpers/Tomcat5Embedded.java
identity-federation/trunk/identity-bindings/src/test/resources/
Log:
JBID-32: embedded tomcat
Added: identity-federation/trunk/identity-bindings/.classpath
===================================================================
--- identity-federation/trunk/identity-bindings/.classpath (rev
0)
+++ identity-federation/trunk/identity-bindings/.classpath 2008-11-02 06:03:20 UTC (rev
118)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var"
path="M2_REPO/apache-tomcat/catalina/5.5.12/catalina-5.5.12.jar"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
+ <classpathentry kind="var"
path="M2_REPO/apache-tomcat/tomcat-util/5.5.12/tomcat-util-5.5.12.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/apache-logging/commons-logging-api/1.0.3/commons-logging-api-1.0.3.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/apache-modeler/commons-modeler/1.1patch/commons-modeler-1.1patch.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/apache-tomcat/tomcat-coyote/5.5.12/tomcat-coyote-5.5.12.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/javax/servlet/servlet-api/2.5/servlet-api-2.5.jar"/>
+ <classpathentry kind="var"
path="M2_REPO/apache-tomcat/tomcat-http/5.5.12/tomcat-http-5.5.12.jar"/>
+ <classpathentry kind="output" path="target/eclipse-classes"/>
+</classpath>
Added: identity-federation/trunk/identity-bindings/.project
===================================================================
--- identity-federation/trunk/identity-bindings/.project (rev 0)
+++ identity-federation/trunk/identity-bindings/.project 2008-11-02 06:03:20 UTC (rev
118)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>identity-bindings</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: identity-federation/trunk/identity-bindings/pom.xml
===================================================================
--- identity-federation/trunk/identity-bindings/pom.xml (rev 0)
+++ identity-federation/trunk/identity-bindings/pom.xml 2008-11-02 06:03:20 UTC (rev 118)
@@ -0,0 +1,99 @@
+<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">
+ <parent>
+ <groupId>org.jboss.identity</groupId>
+ <artifactId>jboss-identity-fed-parent</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <relativePath>../parent</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>jboss-identity-bindings</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss Identity Federation Server Bindings</name>
+ <
url>http://labs.jboss.org/portal/jbosssecurity/</url>
+ <description>JBoss Identity OpenSAML contains the foundation for Federated
Identity Needs.</description>
+ <licenses>
+ <license>
+ <name>lgpl</name>
+ <
url>http://repository.jboss.com/licenses/lgpl.txt</url>
+ </license>
+ </licenses>
+ <organization>
+ <name>JBoss Inc.</name>
+ <url>http://www.jboss.org</url>
+ </organization>
+ <scm>
+
<
connection>scm:svn:http://anonsvn.jboss.org/repos/jbossidentity/identi...
+
<
developerConnection>scm:svn:https://svn.jboss.org/jbossidentity/identi...
+
<
url>http://viewvc.jboss.org/cgi-bin/viewvc.cgi/jbossidentity/identity-...
+ </scm>
+ <build>
+ <plugins>
+ <plugin>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.4.3</version>
+ <configuration>
+ <printSummary>true</printSummary>
+ <disableXmlReport>false</disableXmlReport>
+ <testFailureIgnore>false</testFailureIgnore>
+ <includes>
+ <include>**/**TestCase.java</include>
+ </includes>
+ <forkMode>pertest</forkMode>
+
<argLine>-Djava.endorsed.dirs=${basedir}/src/test/resources/endorsed</argLine>
+ <useFile>false</useFile>
+ <trimStackTrace>false</trimStackTrace>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-tomcat</groupId>
+ <artifactId>catalina</artifactId>
+ <version>5.5.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-tomcat</groupId>
+ <artifactId>tomcat-coyote</artifactId>
+ <version>5.5.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-tomcat</groupId>
+ <artifactId>tomcat-util</artifactId>
+ <version>5.5.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-tomcat</groupId>
+ <artifactId>tomcat-http</artifactId>
+ <version>5.5.12</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-logging</groupId>
+ <artifactId>commons-logging-api</artifactId>
+ <version>1.0.3</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>apache-modeler</groupId>
+ <artifactId>commons-modeler</artifactId>
+ <version>1.1patch</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Added:
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/bindings/Tomcat5TestCase.java
===================================================================
---
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/bindings/Tomcat5TestCase.java
(rev 0)
+++
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/bindings/Tomcat5TestCase.java 2008-11-02
06:03:20 UTC (rev 118)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.tomcat.bindings;
+
+import org.jboss.test.tomcat.helpers.Tomcat5Embedded;
+
+import junit.framework.TestCase;
+
+/**
+ * Tomcat5 Embedded
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 1, 2008
+ */
+public class Tomcat5TestCase extends TestCase
+{
+ public void testTomcat5() throws Exception
+ {
+ Tomcat5Embedded emb = new Tomcat5Embedded();
+ emb.setHomePath("target/tomcat");
+ emb.startServer();
+ Thread.sleep(2000);
+ assertTrue("Tomcat5 started", emb.hasStarted());
+ emb.stopServer();
+ Thread.sleep(1000);
+ assertTrue(emb.hasStopped());
+ }
+}
\ No newline at end of file
Added:
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/helpers/Tomcat5Embedded.java
===================================================================
---
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/helpers/Tomcat5Embedded.java
(rev 0)
+++
identity-federation/trunk/identity-bindings/src/test/java/org/jboss/test/tomcat/helpers/Tomcat5Embedded.java 2008-11-02
06:03:20 UTC (rev 118)
@@ -0,0 +1,150 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY 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 along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.test.tomcat.helpers;
+
+import java.net.InetAddress;
+
+import org.apache.catalina.Engine;
+import org.apache.catalina.Host;
+import org.apache.catalina.LifecycleEvent;
+import org.apache.catalina.LifecycleListener;
+import org.apache.catalina.connector.Connector;
+import org.apache.catalina.startup.Embedded;
+import org.apache.tomcat.util.IntrospectionUtils;
+
+/**
+ * Embedded Tomcat Service
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Nov 1, 2008
+ */
+public class Tomcat5Embedded
+{
+ Embedded embedded = null;
+ Host host;
+
+ String homePath = null;
+
+ StartStopLifeCycleListener listener = new StartStopLifeCycleListener();
+
+ public void setHomePath( String path)
+ {
+ this.homePath = path;
+ }
+
+ public void startServer() throws Exception
+ {
+ if(this.homePath == null)
+ throw new IllegalStateException("Catalina path not set");
+
+ //System.setProperty("catalina.home", this.homePath);
+ embedded = new Embedded();
+ embedded.setCatalinaHome(homePath);
+ Engine engine = embedded.createEngine();
+ engine.setDefaultHost("localhost");
+
+ // Create a default virtual host
+ this.host = this.embedded.createHost("localhost", this.homePath
+ + "/webapps");
+ engine.addChild(this.host);
+
+
+ embedded.addEngine(engine);
+
+ /*
+ * embedded.createConnector(...)
+ * seems to be broken.. it always returns a null connector.
+ * see work around below
+ */
+ InetAddress address = null;
+ Connector connector = null;
+ try
+ {
+ connector = new Connector();
+ connector.setScheme("http");
+ connector.setSecure(false);
+ address = InetAddress.getLocalHost();
+ if (address != null)
+ {
+ IntrospectionUtils.setProperty(connector, "address",
""
+ + address);
+ }
+ IntrospectionUtils.setProperty(connector, "port", "" +
8080);
+
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ connector.setEnableLookups(false);
+
+ embedded.addConnector(connector);
+ embedded.addLifecycleListener(listener);
+ // Start the embedded server
+ embedded.start();
+ }
+
+ public boolean hasStarted()
+ {
+ return this.listener.isStarted();
+ }
+
+ public boolean hasStopped()
+ {
+ return this.listener.hasStopped();
+ }
+
+ public void stopServer() throws Exception
+ {
+ embedded.stop();
+ }
+
+ class StartStopLifeCycleListener implements LifecycleListener
+ {
+ private boolean started = false;
+ private boolean stopped = true;
+
+ public void lifecycleEvent(LifecycleEvent lifecycleEvent)
+ {
+ if(lifecycleEvent.getType().equals("start"))
+ {
+ started = true;
+ stopped = false;
+ }
+ else
+ if(lifecycleEvent.getType().equals("stop"))
+ {
+ started = false;
+ stopped = true;
+ }
+ }
+
+ public boolean isStarted()
+ {
+ return started;
+ }
+
+ public boolean hasStopped()
+ {
+ return stopped;
+ }
+ }
+}
\ No newline at end of file