Author: chris.laprun(a)jboss.com
Date: 2010-06-14 14:04:39 -0400 (Mon, 14 Jun 2010)
New Revision: 3328
Added:
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V1ToV2ConverterTestCase.java
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2ToV1ConverterTestCase.java
Removed:
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2V1ConverterTestCase.java
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java
Log:
- Fixed wrong toV1Exception implementation.
- Added test cases.
- Renamed V2V1ConverterTestCase to more appropriate V1ToV2ConverterTestCase.
Modified:
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java
===================================================================
---
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java 2010-06-14
12:43:09 UTC (rev 3327)
+++
components/wsrp/trunk/common/src/main/java/org/gatein/wsrp/spec/v1/V2ToV1Converter.java 2010-06-14
18:04:39 UTC (rev 3328)
@@ -561,13 +561,13 @@
}
Class<? extends Exception> v2ExceptionClass = v2Exception.getClass();
- String v1Name = v2ExceptionClass.getSimpleName();
+ String v2Name = v2ExceptionClass.getSimpleName();
if
(!"org.oasis.wsrp.v2".equals(v2ExceptionClass.getPackage().getName()))
{
throw new IllegalArgumentException("Specified exception is not a WSRP 2
exception: " + v2Exception);
}
- String v2Name = v2ExceptionClass.getSimpleName();
+ String v1Name = v1ExceptionClass.getSimpleName();
// V1 class name should match V2 class name plus "V1"
if (!v2Name.equals(v1Name.substring(2)))
{
Copied:
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V1ToV2ConverterTestCase.java
(from rev 3305,
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2V1ConverterTestCase.java)
===================================================================
---
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V1ToV2ConverterTestCase.java
(rev 0)
+++
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V1ToV2ConverterTestCase.java 2010-06-14
18:04:39 UTC (rev 3328)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt 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.gatein.wsrp.spec.v1;
+
+import junit.framework.TestCase;
+import org.oasis.wsrp.v1.V1OperationFailed;
+import org.oasis.wsrp.v1.V1OperationFailedFault;
+import org.oasis.wsrp.v2.InvalidSession;
+import org.oasis.wsrp.v2.OperationFailed;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class V1ToV2ConverterTestCase extends TestCase
+{
+ public void testToV2Exception() throws Exception
+ {
+ Throwable throwable = new Throwable();
+ V1OperationFailed v1OF = new V1OperationFailed("foo", new
V1OperationFailedFault(), throwable);
+ OperationFailed operationFailed =
V1ToV2Converter.toV2Exception(OperationFailed.class, v1OF);
+ assertNotNull(operationFailed);
+ assertEquals("foo", operationFailed.getMessage());
+ assertEquals(throwable, operationFailed.getCause());
+ }
+
+ public void testToV2ExceptionMismatch()
+ {
+ Throwable throwable = new Throwable();
+ V1OperationFailed v1OF = new V1OperationFailed("foo", new
V1OperationFailedFault(), throwable);
+
+ try
+ {
+ V1ToV2Converter.toV2Exception(InvalidSession.class, v1OF);
+ fail("Should have failed as requested v2 exception doesn't match
specified v1");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+
+ public void testToV2ExceptionWrongRequestedException()
+ {
+ Throwable throwable = new Throwable();
+ V1OperationFailed v1OF = new V1OperationFailed("foo", new
V1OperationFailedFault(), throwable);
+
+ try
+ {
+ V1ToV2Converter.toV2Exception(IllegalArgumentException.class, v1OF);
+ fail("Should have failed as requested exception is not a WSRP 2 exception
class");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+
+ public void testToV2ExceptionWrongV1Exception()
+ {
+ try
+ {
+ V1ToV2Converter.toV2Exception(OperationFailed.class, new
IllegalArgumentException());
+ fail("Should have failed as specified exception is not a WSRP 1
exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+}
Added:
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2ToV1ConverterTestCase.java
===================================================================
---
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2ToV1ConverterTestCase.java
(rev 0)
+++
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2ToV1ConverterTestCase.java 2010-06-14
18:04:39 UTC (rev 3328)
@@ -0,0 +1,93 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt 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.gatein.wsrp.spec.v1;
+
+import junit.framework.TestCase;
+import org.oasis.wsrp.v1.V1InvalidSession;
+import org.oasis.wsrp.v1.V1OperationFailed;
+import org.oasis.wsrp.v2.OperationFailed;
+import org.oasis.wsrp.v2.OperationFailedFault;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class V2ToV1ConverterTestCase extends TestCase
+{
+ public void testException() throws Exception
+ {
+ Throwable throwable = new Throwable();
+ OperationFailed operationFailed = new OperationFailed("foo", new
OperationFailedFault(), throwable);
+ V1OperationFailed v1OperationFailed =
V2ToV1Converter.toV1Exception(V1OperationFailed.class, operationFailed);
+ assertNotNull(v1OperationFailed);
+ assertEquals("foo", v1OperationFailed.getMessage());
+ assertEquals(throwable, v1OperationFailed.getCause());
+ }
+
+ public void testExceptionMismatch()
+ {
+ Throwable throwable = new Throwable();
+ OperationFailed operationFailed = new OperationFailed("foo", new
OperationFailedFault(), throwable);
+
+ try
+ {
+ V2ToV1Converter.toV1Exception(V1InvalidSession.class, operationFailed);
+ fail("Should have failed as requested v1 exception doesn't match
specified v2");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+
+ public void testExceptionWrongRequestedException()
+ {
+ Throwable throwable = new Throwable();
+ OperationFailed operationFailed = new OperationFailed("foo", new
OperationFailedFault(), throwable);
+
+ try
+ {
+ V2ToV1Converter.toV1Exception(IllegalArgumentException.class, operationFailed);
+ fail("Should have failed as requested exception is not a WSRP 1 exception
class");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+
+ public void testExceptionWrongException()
+ {
+ try
+ {
+ V2ToV1Converter.toV1Exception(V1OperationFailed.class, new
IllegalArgumentException());
+ fail("Should have failed as specified exception is not a WSRP 1
exception");
+ }
+ catch (IllegalArgumentException e)
+ {
+ // expected
+ }
+ }
+
+}
Deleted:
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2V1ConverterTestCase.java
===================================================================
---
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2V1ConverterTestCase.java 2010-06-14
12:43:09 UTC (rev 3327)
+++
components/wsrp/trunk/common/src/test/java/org/gatein/wsrp/spec/v1/V2V1ConverterTestCase.java 2010-06-14
18:04:39 UTC (rev 3328)
@@ -1,92 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2010, Red Hat Middleware, LLC, and individual
- * contributors as indicated by the @authors tag. See the
- * copyright.txt 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.gatein.wsrp.spec.v1;
-
-import junit.framework.TestCase;
-import org.oasis.wsrp.v1.V1OperationFailed;
-import org.oasis.wsrp.v1.V1OperationFailedFault;
-import org.oasis.wsrp.v2.InvalidSession;
-import org.oasis.wsrp.v2.OperationFailed;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class V2V1ConverterTestCase extends TestCase
-{
- public void testToV2Exception() throws Exception
- {
- Throwable throwable = new Throwable();
- V1OperationFailed v1OF = new V1OperationFailed("foo", new
V1OperationFailedFault(), throwable);
- OperationFailed operationFailed =
V1ToV2Converter.toV2Exception(OperationFailed.class, v1OF);
- assertNotNull(operationFailed);
- assertEquals("foo", operationFailed.getMessage());
- assertEquals(throwable, operationFailed.getCause());
- }
-
- public void testToV2ExceptionMismatch()
- {
- Throwable throwable = new Throwable();
- V1OperationFailed v1OF = new V1OperationFailed("foo", new
V1OperationFailedFault(), throwable);
-
- try
- {
- V1ToV2Converter.toV2Exception(InvalidSession.class, v1OF);
- fail("Should have failed as requested v2 exception doesn't match
specified v1");
- }
- catch (IllegalArgumentException e)
- {
- // expected
- }
- }
-
- public void testToV2ExceptionWrongRequestedException()
- {
- Throwable throwable = new Throwable();
- V1OperationFailed v1OF = new V1OperationFailed("foo", new
V1OperationFailedFault(), throwable);
-
- try
- {
- V1ToV2Converter.toV2Exception(IllegalArgumentException.class, v1OF);
- fail("Should have failed as requested exception is not a WSRP 2 exception
class");
- }
- catch (IllegalArgumentException e)
- {
- // expected
- }
- }
-
- public void testToV2ExceptionWrongV1Exception()
- {
- try
- {
- V1ToV2Converter.toV2Exception(OperationFailed.class, new
IllegalArgumentException());
- fail("Should have failed as specified exception is not a WSRP 1
exception");
- }
- catch (IllegalArgumentException e)
- {
- // expected
- }
- }
-}