Author: anil.saldhana(a)jboss.com
Date: 2008-12-12 17:38:14 -0500 (Fri, 12 Dec 2008)
New Revision: 156
Added:
identity-federation/trunk/identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/saml/v2/DeflateEncodingDecodingUnitTestCase.java
Log:
test case for deflate encoding/decoding
Added:
identity-federation/trunk/identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/saml/v2/DeflateEncodingDecodingUnitTestCase.java
===================================================================
---
identity-federation/trunk/identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/saml/v2/DeflateEncodingDecodingUnitTestCase.java
(rev 0)
+++
identity-federation/trunk/identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/saml/v2/DeflateEncodingDecodingUnitTestCase.java 2008-12-12
22:38:14 UTC (rev 156)
@@ -0,0 +1,65 @@
+/*
+ * 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.identity.federation.api.saml.v2;
+
+import java.io.InputStream;
+import java.io.StringWriter;
+
+import org.jboss.identity.federation.api.saml.v2.factories.JBossSAMLAuthnRequestFactory;
+import org.jboss.identity.federation.api.saml.v2.factories.JBossSAMLBaseFactory;
+import org.jboss.identity.federation.api.util.Base64;
+import org.jboss.identity.federation.api.util.DeflateUtil;
+import org.jboss.identity.federation.saml.v2.protocol.AuthnRequestType;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test the DEFLATE compression
+ * encoding/decoding cycles
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Dec 11, 2008
+ */
+public class DeflateEncodingDecodingUnitTestCase extends TestCase
+{
+ public void testDeflateEncoding() throws Exception
+ {
+ AuthnRequestType authnRequest =
JBossSAMLAuthnRequestFactory.createAuthnRequestType(
+ "ID_" + JBossSAMLBaseFactory.createUUID(), "http://sp",
+ "http://localhost:8080/idp","http://sp");
+
+ StringWriter sw = new StringWriter();
+ JBossSAMLAuthnRequestFactory.marshall(authnRequest, sw);
+ byte[] deflatedMsg = DeflateUtil.encode(sw.toString());
+
+ String base64Request = Base64.encodeBytes(deflatedMsg, Base64.DONT_BREAK_LINES);
+
+ System.out.println("Request="+base64Request);
+
+ //Decode
+ byte[] decodedMessage = Base64.decode(base64Request);
+ InputStream is = DeflateUtil.decode(decodedMessage);
+ AuthnRequestType decodedRequestType =
JBossSAMLAuthnRequestFactory.getAuthnRequestType(is);
+
+ assertNotNull(decodedRequestType);
+ }
+
+}
\ No newline at end of file