[jboss-identity-commits] JBoss Identity SVN: r229 - xmlkey/trunk/xkms/src/test/java/org/jboss/test/identity/xkms/v2/model.

jboss-identity-commits at lists.jboss.org jboss-identity-commits at lists.jboss.org
Sun Jan 18 23:12:16 EST 2009


Author: anil.saldhana at jboss.com
Date: 2009-01-18 23:12:16 -0500 (Sun, 18 Jan 2009)
New Revision: 229

Added:
   xmlkey/trunk/xkms/src/test/java/org/jboss/test/identity/xkms/v2/model/LocateRequestUnitTestCase.java
Log:
unit test for xkms

Added: xmlkey/trunk/xkms/src/test/java/org/jboss/test/identity/xkms/v2/model/LocateRequestUnitTestCase.java
===================================================================
--- xmlkey/trunk/xkms/src/test/java/org/jboss/test/identity/xkms/v2/model/LocateRequestUnitTestCase.java	                        (rev 0)
+++ xmlkey/trunk/xkms/src/test/java/org/jboss/test/identity/xkms/v2/model/LocateRequestUnitTestCase.java	2009-01-19 04:12:16 UTC (rev 229)
@@ -0,0 +1,91 @@
+/*
+ * 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.xkms.v2.model;
+
+import static org.junit.Assert.*;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Marshaller;
+import javax.xml.bind.Unmarshaller;
+
+import org.jboss.identity.xkms.v2.model.LocateRequestType;
+import org.jboss.identity.xkms.v2.model.ObjectFactory;
+import org.jboss.identity.xmlkey.common.JBossJAXBUtil;
+import org.junit.Test;
+
+/**
+ * Unit Test the LocateRequest construct
+ * @author Anil.Saldhana at redhat.com
+ * @since Jan 7, 2009
+ */ 
+public class LocateRequestUnitTestCase
+{
+   String pkg = "org.jboss.identity.xkms.v2.model";
+   String schema = "schema/v2/xkms.xsd";
+   
+   ObjectFactory objectFactory = new ObjectFactory();
+   
+   /**
+    <?xml version="1.0" encoding="utf-8"?>
+    <LocateRequest Id="Ia1d6ca7a067fdd545f1a1396d2f26779"
+                   Service="http://www.example.org/XKMS"
+                   xmlns="http://www.w3.org/2002/03/xkms#">
+       <ResponseMechanism>http://www.w3.org/2002/03/xkms#Represent</ResponseMechanism>
+       <QueryKeyBinding />
+    </LocateRequest>
+    * @throws Exception 
+    */
+   @SuppressWarnings("unchecked")
+   @Test
+   public void testConstruction() throws Exception
+   {
+      String id = "Ia1d6ca7a067fdd545f1a1396d2f26779";
+      String service = "http://www.example.org/XKMS";
+      String responseMech = "http://www.w3.org/2002/03/xkms#Represent";
+     
+      LocateRequestType lrt = objectFactory.createLocateRequestType();
+      lrt.setId(id);
+      lrt.setService(service);
+      
+      lrt.setQueryKeyBinding(objectFactory.createQueryKeyBindingType());
+      
+      lrt.getResponseMechanism().add(responseMech);
+      
+      JAXBElement<LocateRequestType> jaxbLRT = objectFactory.createLocateRequest(lrt);
+      
+      Marshaller m = JBossJAXBUtil.getValidatingMarshaller(pkg, schema);
+      ByteArrayOutputStream baos = new ByteArrayOutputStream();
+      m.marshal(jaxbLRT, baos);
+      
+      StringReader sr = new StringReader(baos.toString());
+      Unmarshaller um = JBossJAXBUtil.getValidatingUnmarshaller(pkg, schema);
+      JAXBElement<LocateRequestType> jaxbLRTUM = (JAXBElement<LocateRequestType>) um.unmarshal(sr);
+      
+      LocateRequestType lrtum = jaxbLRTUM.getValue();
+      assertEquals(id, lrtum.getId());
+      assertEquals(service, lrtum.getService());
+      assertEquals(responseMech, lrtum.getResponseMechanism().get(0));
+   }
+}
\ No newline at end of file




More information about the jboss-identity-commits mailing list