Author: owulff
Date: Wed Feb  5 21:29:47 2014
New Revision: 1564939

URL: http://svn.apache.org/r1564939
Log:
Initial REST integration test

Added:
    
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/
    
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
    cxf/fediz/trunk/services/idp/src/test/resources/rest-client.xml
Modified:
    cxf/fediz/trunk/services/idp/pom.xml

Modified: cxf/fediz/trunk/services/idp/pom.xml
URL: 
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/pom.xml?rev=1564939&r1=1564938&r2=1564939&view=diff
==============================================================================
--- cxf/fediz/trunk/services/idp/pom.xml (original)
+++ cxf/fediz/trunk/services/idp/pom.xml Wed Feb  5 21:29:47 2014
@@ -115,7 +115,7 @@
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-log4j12</artifactId>
                        <version>${slf4j.version}</version>
-               </dependency>
+               </dependency>           
                <dependency>
                        <groupId>org.apache.cxf</groupId>
                        <artifactId>cxf-rt-ws-security</artifactId>
@@ -179,6 +179,16 @@
                        <artifactId>openjpa-all</artifactId>
                        <version>2.2.2</version>
                </dependency>
+               
+        
+        <dependency>
+                         <groupId>org.apache.cxf</groupId>
+                         <artifactId>cxf-rt-rs-client</artifactId>
+                         <version>${cxf.version}</version>
+                         <scope>test</scope>
+                       </dependency>
+                       
+
        </dependencies>
        <build>
                <resources>
@@ -261,11 +271,30 @@
                                        </webResources>
                                </configuration>
                        </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>build-helper-maven-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>reserve-network-port</id>
+                        <goals>
+                            <goal>reserve-network-port</goal>
+                        </goals>
+                        <phase>initialize</phase>
+                        <configuration>
+                            <portNames>
+                                <portName>idp.https.port</portName>
+                            </portNames>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>                  
                        <plugin>
                                <groupId>org.codehaus.mojo</groupId>
                                <artifactId>properties-maven-plugin</artifactId>
                                <executions>
                                        <execution>
+                                           <id>set-tomcat-properties</id>
                                                <goals>
                                                        
<goal>set-system-properties</goal>
                                                </goals>
@@ -277,7 +306,7 @@
                                                                </property>
                                                        </properties>
                                                </configuration>
-                                       </execution>
+                                       </execution>                            
        
                                </executions>
                        </plugin>
                        <plugin>
@@ -285,6 +314,12 @@
                                <artifactId>jetty-maven-plugin</artifactId>
                                <version>${jetty.version}</version>
                                <configuration>
+                                   <!-- 
+                                   
<webAppSourceDirectory>${basedir}/target/fediz-idp/</webAppSourceDirectory>
+                                   
<classesDirectory>${basedir}/target/fediz-idp/WEB-INF/classes</classesDirectory>
+                                    -->
+                                   <stopPort>8005</stopPort>
+                    <stopKey>STOP</stopKey>
                                        <connectors>
                                                <connector 
implementation="org.eclipse.jetty.server.nio.SelectChannelConnector">
                                                        
<port>${idp.http.port}</port>
@@ -294,23 +329,43 @@
                                                        
implementation="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
                                                        
<port>${idp.https.port}</port>
                                                        
<maxIdleTime>30000</maxIdleTime>
-                                                       
<keystore>../../examples/samplekeys/idp-ssl-server.jks</keystore>
+                                                       
<keystore>${basedir}/../../examples/samplekeys/idp-ssl-server.jks</keystore>
                                                        
<keyPassword>tompass</keyPassword>
                                                        
<password>tompass</password>
                                                </connector>
                                        </connectors>
                                        <contextHandlers>
                                                <contextHandler 
implementation="org.eclipse.jetty.webapp.WebAppContext">
-                                                       
<war>target/fediz-idp.war</war>
+                                                       
<war>${basedir}/target/fediz-idp.war</war>
                                                        
<contextPath>/fediz-idp</contextPath>
                                                </contextHandler>
                         <contextHandler 
implementation="org.eclipse.jetty.webapp.WebAppContext">
-                            <war>target/fediz-idp-sts.war</war>
+                            <war>${basedir}/target/fediz-idp-sts.war</war>
                             <contextPath>/fediz-idp-sts</contextPath>
                             
<throwUnavailableOnStartupException>false</throwUnavailableOnStartupException>
                         </contextHandler>                                      
        
                                        </contextHandlers>
                                </configuration>
+                               <executions>
+                                       <execution>
+                                         <id>start-jetty</id>
+                                         <phase>pre-integration-test</phase>
+                                         <goals>
+                                           <goal>run-war</goal>
+                                         </goals>
+                                         <configuration>
+                                           
<scanIntervalSeconds>0</scanIntervalSeconds>
+                                           <daemon>true</daemon>
+                                         </configuration>
+                                       </execution>
+                                       <execution>
+                                         <id>stop-jetty</id>
+                                         <phase>post-integration-test</phase>
+                                         <goals>
+                                           <goal>stop</goal>
+                                         </goals>
+                                       </execution>
+                       </executions>
                                <dependencies>
                                        <dependency>
                                                <groupId>hsqldb</groupId>
@@ -319,6 +374,46 @@
                                        </dependency>
                                </dependencies>
                        </plugin>
+                       <plugin>
+                <artifactId>maven-failsafe-plugin</artifactId>
+                <inherited>true</inherited>
+                <executions>
+                    <execution>
+                        <id>integration-test</id>
+                        <phase>integration-test</phase>
+                        <goals>
+                            <goal>integration-test</goal>
+                        </goals>
+                        <configuration>
+                            <skip>false</skip>
+                            <systemPropertyVariables>
+                                
<idp.https.port>${idp.https.port}</idp.https.port>
+                            </systemPropertyVariables>
+                            <includes>
+                                <include>**/integrationtests/**</include>
+                            </includes>
+                            <argLine>-XX:MaxPermSize=512M</argLine>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>verify</id>
+                        <phase>verify</phase>
+                        <goals>
+                            <goal>verify</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <inherited>true</inherited>
+                <configuration>
+                    <excludes>
+                        <exclude>**/integrationtests/**</exclude>
+                    </excludes>
+                </configuration>
+            </plugin>            
                </plugins>
                <!-- Name of the generated WAR file -->
                <finalName>fediz-idp</finalName>

Added: 
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
URL: 
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java?rev=1564939&view=auto
==============================================================================
--- 
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
 (added)
+++ 
cxf/fediz/trunk/services/idp/src/test/java/org/apache/cxf/fediz/service/idp/integrationtests/RestITTest.java
 Wed Feb  5 21:29:47 2014
@@ -0,0 +1,116 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.apache.cxf.fediz.service.idp.integrationtests;
+
+import java.net.URL;
+
+import javax.ws.rs.client.Client;
+import javax.ws.rs.client.ClientBuilder;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.fediz.service.idp.domain.Idp;
+import org.apache.cxf.fediz.service.idp.rest.Idps;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class RestITTest {
+        
+    private static String idpHttpsPort;
+    private static Bus bus;
+
+
+    @BeforeClass
+    public static void init() {
+        System.setProperty("org.apache.commons.logging.Log", 
"org.apache.commons.logging.impl.SimpleLog");
+        
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
+        
System.setProperty("org.apache.commons.logging.simplelog.log.httpclient.wire", 
"info");
+        
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.commons.httpclient",
 "info");
+        
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.webflow",
 "info");
+        
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security.web",
 "info");
+        
System.setProperty("org.apache.commons.logging.simplelog.log.org.springframework.security",
 "info");
+        
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf.fediz",
 "info");
+        
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.cxf", 
"info");
+
+        idpHttpsPort = System.getProperty("idp.https.port");
+        Assert.assertNotNull("Property 'idp.https.port' null", idpHttpsPort);
+
+        SpringBusFactory bf = new SpringBusFactory();
+        
+        URL busFile = RestITTest.class.getResource("/rest-client.xml");
+        bus = bf.createBus(busFile.toString());
+        SpringBusFactory.setDefaultBus(bus);
+        SpringBusFactory.setThreadDefaultBus(bus);
+        
+    }
+    
+    @AfterClass
+    public static void cleanup() {
+        if (bus != null) {
+            bus.shutdown(true);
+        }
+    }
+    
+    @Test
+    public void testGetAllIdps() {
+        String address = "https://localhost:"; + idpHttpsPort + 
"/fediz-idp/services/rs";
+        Client client = ClientBuilder.newClient();
+        Idps idps = client.target(address).path("idps")
+            .request("application/xml").get(Idps.class);
+        Assert.assertEquals(1L, idps.getIdps().size());
+        
+        Idp idp = idps.getIdps().iterator().next();
+        Assert.assertEquals("Certificate doesn't match",
+                            "stsKeystoreA.properties", idp.getCertificate());
+        Assert.assertEquals("Certificate password doesn't match",
+                            "realma", idp.getCertificatePassword());
+        Assert.assertEquals("Realm doesn't match",
+                            "urn:org:apache:cxf:fediz:idp:realm-A", 
idp.getRealm());
+        Assert.assertEquals("ServiceDescription doesn't match",
+                            "IDP of Realm A", idp.getServiceDescription());
+        Assert.assertEquals("ServiceDisplayName doesn't match",
+                            "REALM A", idp.getServiceDisplayName());
+        Assert.assertEquals("IdpUrl doesn't match",
+                            "https://localhost:9443/fediz-idp/federation";, 
idp.getIdpUrl());
+        Assert.assertEquals("StsUrl doesn't match",
+                            "https://localhost:9443/fediz-idp-sts/REALMA";, 
idp.getStsUrl());
+        Assert.assertEquals("Uri doesn't match",
+                            "realma", idp.getUri());
+        Assert.assertTrue("ProvideIDPList doesn't match", 
idp.isProvideIDPList());
+        Assert.assertTrue("UseCurrentIDP doesn't match", 
idp.isUseCurrentIDP());
+        Assert.assertEquals("Number of AuthenticationURIs doesn't match",
+                            1, idp.getAuthenticationURIs().size());
+        Assert.assertEquals("Number of SupportedProtocols doesn't match",
+                            2, idp.getSupportedProtocols().size());
+        Assert.assertEquals("Number of TokenTypesOffered doesn't match",
+                            2, idp.getTokenTypesOffered().size());
+        Assert.assertEquals("Number of applications doesn't match",
+                            1, idp.getApplications().size());
+        Assert.assertEquals("Number of trusted IDPs doesn't match",
+                            1, idp.getTrustedIdps().size());
+        Assert.assertEquals("Number of claims doesn't match",
+                            4, idp.getClaimTypesOffered().size());
+        
+    }
+
+    
+    
+}

Added: cxf/fediz/trunk/services/idp/src/test/resources/rest-client.xml
URL: 
http://svn.apache.org/viewvc/cxf/fediz/trunk/services/idp/src/test/resources/rest-client.xml?rev=1564939&view=auto
==============================================================================
--- cxf/fediz/trunk/services/idp/src/test/resources/rest-client.xml (added)
+++ cxf/fediz/trunk/services/idp/src/test/resources/rest-client.xml Wed Feb  5 
21:29:47 2014
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you 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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:http="http://cxf.apache.org/transports/http/configuration"; 
xmlns:httpj="http://cxf.apache.org/transports/http-jetty/configuration"; 
xmlns:sec="http://cxf.apache.org/configuration/security"; xsi:schemaLocation="   
      http://www.springframework.org/schema/beans                 
http://www.springframework.org/schema/beans/spring-beans.xsd         
http://cxf.apache.org/transports/http/configuration         
http://cxf.apache.org/schemas/configuration/http-conf.xsd         
http://cxf.apache.org/transports/http-jetty/configuration   
http://cxf.apache.org/schemas/configuration/http-jetty.xsd         
http://cxf.apache.org/configuration/security                
http://cxf.apache.org/schemas/configuration/security.xsd         ">
+    <!-- -->
+    <!-- HTTP/S configuration for web clients -->
+    <!-- -->
+    <http:conduit name="\{https://localhost\:.*\}WebClient\.http-conduit";>
+        <http:client ConnectionTimeout="3000000" ReceiveTimeout="3000000"/>
+        <http:tlsClientParameters disableCNCheck="true">
+            <sec:trustManagers>
+                <sec:keyStore type="JKS" password="tompass" 
file="../../examples/samplekeys/idp-ssl-server.jks"/>
+            </sec:trustManagers>
+        </http:tlsClientParameters>
+    </http:conduit>
+</beans>


Reply via email to