[jboss-cvs] Picketlink SVN: r473 - in federation/trunk/picketlink-fed-core/src/test: resources/parser and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Oct 14 16:42:05 EDT 2010


Author: anil.saldhana at jboss.com
Date: 2010-10-14 16:42:04 -0400 (Thu, 14 Oct 2010)
New Revision: 473

Added:
   federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java
   federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/
   federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/wst-batch-validate-one.xml
Log:
add simple perf test

Added: federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java	                        (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/java/org/picketlink/test/identity/federation/core/parser/WST_SAML_ParsingPerfTestCase.java	2010-10-14 20:42:04 UTC (rev 473)
@@ -0,0 +1,98 @@
+/*
+ * 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.picketlink.test.identity.federation.core.parser;
+
+import java.io.InputStream;
+
+import javax.xml.transform.Source;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.picketlink.identity.federation.core.parsers.wst.WSTrustParser;
+import org.picketlink.identity.federation.core.saml.v2.util.DocumentUtil;
+import org.picketlink.identity.federation.core.wstrust.WSTrustJAXBFactory;
+import org.w3c.dom.Document;
+
+/**
+ * Some simple perf tests
+ * @author Anil.Saldhana at redhat.com
+ * @since Oct 14, 2010
+ */
+public class WST_SAML_ParsingPerfTestCase
+{
+   private int runs = 1000;
+
+   String fileName = "parser/perf/wst-batch-validate-one.xml";
+   
+   /**
+    * This test just tests some saml/wst payload performance
+    * using JAXB and Stax.
+    * 
+    * <b>NOTE:</b> For the test to work, just comment out @Ignore
+    * @throws Exception
+    */
+   @Test
+   @Ignore
+   public void testParsingPerformance() throws Exception
+   {
+      ClassLoader tcl = Thread.currentThread().getContextClassLoader();
+      InputStream configStream = tcl.getResourceAsStream( fileName );
+      
+      Document doc = DocumentUtil.getDocument( configStream );
+      Source source =  DocumentUtil.getXMLSource(doc);
+      
+     
+      //JAXB way
+      long start = System.currentTimeMillis(); 
+      for( int i = 0 ; i < runs; i++ )
+      {
+         useJAXB( source ); 
+      }
+      long elapsedTimeMillis = System.currentTimeMillis() - start; 
+      System.out.println("JAXB, time spent for " + runs  
+            + " iterations = " + elapsedTimeMillis + " ms or " + elapsedTimeMillis/1000F + " secs");
+
+
+      //Stax Way
+      start = System.currentTimeMillis(); 
+      for( int i = 0 ; i < runs; i++ )
+      {
+         useStax( tcl );
+      }
+      elapsedTimeMillis = System.currentTimeMillis() - start; 
+      System.out.println("STAX, time spent for " + runs  
+            + " iterations = " + elapsedTimeMillis + " ms or " + elapsedTimeMillis/1000F + " secs");
+   }
+   
+   private void useJAXB( Source source ) throws Exception
+   {
+      WSTrustJAXBFactory.getInstance().parseRequestSecurityToken(source); 
+   }
+   
+   private void useStax( ClassLoader tcl ) throws Exception
+   {
+      InputStream configStream = tcl.getResourceAsStream( fileName );
+      
+      WSTrustParser parser = new WSTrustParser();
+      parser.parse( configStream );  
+   }
+}
\ No newline at end of file

Added: federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/wst-batch-validate-one.xml
===================================================================
--- federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/wst-batch-validate-one.xml	                        (rev 0)
+++ federation/trunk/picketlink-fed-core/src/test/resources/parser/perf/wst-batch-validate-one.xml	2010-10-14 20:42:04 UTC (rev 473)
@@ -0,0 +1,50 @@
+<wst:RequestSecurityToken Context="validatecontext2" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
+    <wst:RequestType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/BatchValidate</wst:RequestType>
+    <wst:TokenType>http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Status</wst:TokenType>
+    <wst:ValidateTarget>
+      <saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" ID="ID_cf9efbf0-9d7f-4b4a-b77f-d83ecaafd374" 
+        IssueInstant="2010-09-30T19:13:37.911Z" Version="2.0">
+        <saml2:Issuer>Test STS</saml2:Issuer>
+        <saml2:Subject>
+          <saml2:NameID NameQualifier="urn:picketlink:identity-federation">jduke</saml2:NameID>
+          <saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"/>
+        </saml2:Subject>
+        <saml2:Conditions NotBefore="2010-09-30T19:13:37.911Z" NotOnOrAfter="2010-09-30T21:13:37.911Z">
+          <saml2:AudienceRestriction>
+            <saml2:Audience>http://services.testcorp.org/provider2</saml2:Audience>
+          </saml2:AudienceRestriction>
+        </saml2:Conditions>
+        <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
+          <ds:SignedInfo>
+            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"/>
+            <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmlds#rsa-sha1"/>
+            <ds:Reference URI="#ID_cf9efbf0-9d7f-4b4a-b77f-d83ecaafd374">
+              <ds:Transforms>
+                <ds:Transform Algorithm="http://www.w3.org/2000/09/xmlds#enveloped-signature"/>
+                <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
+              </ds:Transforms>
+              <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmlds#sha1"/>
+              <ds:DigestValue>TMZdBOA0MvR7aNpCAg2CXggkdZc=</ds:DigestValue>
+            </ds:Reference>
+          </ds:SignedInfo>
+          <ds:SignatureValue>
+Q8mEzGWlnWmSmb+KUkP0wju4LOINaUYXBBXNF5vRhYVBixSUe8HSHKzNIdQ+ZGtijaV1vh0LUFbT
+//faZKyHRgPXtskDn8cJTVT6obp7rUIOCKMoCs5p9/bUAbtaQHYjfWpifdT3PaTdlehpS8INK2P0
+JUQYU3q8F3u7je9VHbA=
+          </ds:SignatureValue>
+          <ds:KeyInfo>
+            <ds:KeyValue>
+              <ds:RSAKeyValue>
+                <ds:Modulus>
+suGIyhVTbFvDwZdx8Av62zmP+aGOlsBN8WUE3eEEcDtOIZgO78SImMQGwB2C0eIVMhiLRzVPqoW1
+dCPAveTm653zHOmubaps1fY0lLJDSZbTbhjeYhoQmmaBro/tDpVw5lKJwspqVnMuRK19ju2dxpKw
+lYGGtrP5VQv00dfNPbs=
+                </ds:Modulus>
+                <ds:Exponent>AQAB</ds:Exponent>
+              </ds:RSAKeyValue>
+            </ds:KeyValue>
+          </ds:KeyInfo>
+        </ds:Signature>
+      </saml2:Assertion>
+    </wst:ValidateTarget>
+</wst:RequestSecurityToken>



More information about the jboss-cvs-commits mailing list