You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by jo...@apache.org on 2004/01/26 22:10:27 UTC
cvs commit: ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit MarshallerTest.java
jochen 2004/01/26 13:10:26
Modified: src/jaxme/org/apache/ws/jaxme/util Duration.java
src/jaxme/org/apache/ws/jaxme/junit MarshallerTest.java
Log:
Fixed the handling of absent values in Duration. (jconlon@verticon.com)
Revision Changes Path
1.3 +8 -1 ws-jaxme/src/jaxme/org/apache/ws/jaxme/util/Duration.java
Index: Duration.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/util/Duration.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Duration.java 24 Jan 2004 22:16:10 -0000 1.2
+++ Duration.java 26 Jan 2004 21:10:26 -0000 1.3
@@ -294,7 +294,14 @@
}
++offset;
}
- return new Duration(isNegative, years, months, daysOfMonth, hours, minutes, seconds, millis);
+ return new Duration(isNegative,
+ years == -1 ? 0 : years,
+ months == -1 ? 0 : months,
+ daysOfMonth == -1 ? 0 :daysOfMonth,
+ hours == -1 ? 0 : hours,
+ minutes == -1 ? 0 : minutes,
+ seconds == -1 ? 0 : seconds,
+ millis == -1 ? 0 : millis);
}
public boolean equals(Object o) {
1.7 +33 -1 ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/MarshallerTest.java
Index: MarshallerTest.java
===================================================================
RCS file: /home/cvs/ws-jaxme/src/jaxme/org/apache/ws/jaxme/junit/MarshallerTest.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- MarshallerTest.java 24 Jan 2004 22:14:39 -0000 1.6
+++ MarshallerTest.java 26 Jan 2004 21:10:26 -0000 1.7
@@ -375,4 +375,36 @@
assertEquals(2, author.getRating());
assertEquals("This is a test.", author.getValue());
}
+
+ /**
+ * Tests that toString returns an appropriate xsd:duration value
+ */
+ public void testExplicitToString() {
+ String dur1 = "P0Y0M0DT0H2M60S";
+ Duration duration1 = Duration.valueOf(dur1);
+ String actualReturn = duration1.toString();
+ assertEquals("return value not as expected", dur1, actualReturn);
+ }
+
+ /**
+ * Tests that toString returns an appropriate xsd:duration value
+ */
+ public void testImplicitToString() {
+ String dur2 = "PT2M60S";
+ Duration duration2 = Duration.valueOf(dur2);
+ String actualReturn = duration2.toString();
+ String expect = "P0Y0M0DT0H2M60S";
+ assertEquals("return value not as expected ", expect, actualReturn);
+ }
+
+ /**
+ * Test that getMillis returns the total time of duration in
+ milliseconds
+ */
+ public void testMillis() {
+ String dur2 = "PT2M60S";
+ Duration duration2 = Duration.valueOf(dur2);
+ assertEquals(2, duration2.getMinutes());
+ assertEquals(60, duration2.getSeconds());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org