incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r1199146 - in /incubator/odf/trunk/odfdom/src: main/java/org/odftoolkit/odfdom/type/Length.java test/java/org/odftoolkit/odfdom/type/DataTypeTest.java
Date Tue, 08 Nov 2011 07:58:10 GMT
Author: devinhan
Date: Tue Nov  8 07:58:09 2011
New Revision: 1199146

URL: http://svn.apache.org/viewvc?rev=1199146&view=rev
Log:
#ODFTOOLKIT-295# Exit condition of Length.parseUnit in ODFDOM is wrong.[Developer:Oliver Rau;Reviewer:Devin]

Modified:
    incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/type/Length.java
    incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/type/DataTypeTest.java

Modified: incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/type/Length.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/type/Length.java?rev=1199146&r1=1199145&r2=1199146&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/type/Length.java (original)
+++ incubator/odf/trunk/odfdom/src/main/java/org/odftoolkit/odfdom/type/Length.java Tue Nov
 8 07:58:09 2011
@@ -117,9 +117,9 @@ public class Length implements OdfDataTy
 					identifiedInput = true;
 					break;
 				}
-				if (!identifiedInput) {
-					throw new NumberFormatException("The input length " + length + " has no valid Unit!");
-				}
+			}
+			if (!identifiedInput) {
+				throw new NumberFormatException("The input length " + length + " has no valid Unit!");
 			}
 		}
 		return lengthUnit;

Modified: incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/type/DataTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/type/DataTypeTest.java?rev=1199146&r1=1199145&r2=1199146&view=diff
==============================================================================
--- incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/type/DataTypeTest.java
(original)
+++ incubator/odf/trunk/odfdom/src/test/java/org/odftoolkit/odfdom/type/DataTypeTest.java
Tue Nov  8 07:58:09 2011
@@ -40,7 +40,7 @@ public class DataTypeTest {
 	private static final Logger LOG = Logger.getLogger(DataTypeTest.class.getName());
 
 	@Test
-	public void testDataType() {
+	public void testAnyURI() {
 		// AnyURI
 		AnyURI anyURI = AnyURI.valueOf("./Object 1");
 		URI uri = anyURI.getURI();
@@ -52,26 +52,35 @@ public class DataTypeTest {
 			LOG.log(Level.SEVERE, e.getMessage(), e);
 			Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
 		}
-
+	}
+	
+	@Test
+	public void testBase64() {
 		// Base64Binary
 		Base64Binary base64Binary = Base64Binary.valueOf("GVCC9H6p8LeqecY96ggY680uoZA=");
 		byte[] bytes = base64Binary.getBytes();
 		LOG.info("bytes:" + bytes.length);
 		Assert.assertTrue(Base64Binary.isValid("KWy1spZbKcHOunnKMB6dVA=="));
-
+	}
+	
+	@Test
+	public void testCellAddress() {		
 		// CellAddress
 		CellAddress cellAddress = new CellAddress("Sheet1.A3");
 		Assert.assertEquals(cellAddress.toString(), "Sheet1.A3");
 		Assert.assertFalse(CellAddress.isValid("33"));
 		Assert.assertTrue(CellAddress.isValid("$.$Z11"));
-
+	}
+	
+	@Test
+	public void testCellRangeAddress() {
 		// CellRangeAddress
 		CellRangeAddress cellRangeAddress1 = CellRangeAddress.valueOf("A.A1:A.F19");
 		CellRangeAddress cellRangeAddress2 = new CellRangeAddress(
 				"$(first).8:$(second).19");
 		CellRangeAddress cellRangeAddress3 = new CellRangeAddress("$.$8:$.19");
 		Assert.assertTrue(CellRangeAddress.isValid("$Sheet1.B12:$Sheet1.E35"));
-
+		
 		// CellRangeAddressList
 		CellRangeAddressList addressList = CellRangeAddressList.valueOf(cellRangeAddress1.toString()
+ " " + cellRangeAddress2.toString());
 		Assert.assertEquals(addressList.getCellRangesAddressList().get(0).toString(), cellRangeAddress1.toString());
@@ -82,7 +91,10 @@ public class DataTypeTest {
 			// CellRangeAddressList is not allowed to have a empty string
 			Assert.assertNull(addressList2);
 		}
-
+	}
+	
+	@Test
+	public void testColor() {
 		// Color
 		try {
 			Color color = new Color("#ff00ff");
@@ -116,6 +128,10 @@ public class DataTypeTest {
 		} catch (Exception e) {
 			LOG.log(Level.SEVERE, e.getMessage(), e);
 		}
+	}
+	
+	@Test
+	public void testDateTime() {
 		// DateOrDateTime
 		DateTime time1 = DateTime.valueOf("2007-09-28T22:01:13");
 		Assert.assertNotNull(time1);
@@ -133,7 +149,10 @@ public class DataTypeTest {
 		LOG.info(aFactory.newXMLGregorianCalendar(calendar).toString());
 		DateOrDateTime time3 = new DateOrDateTime(aFactory.newXMLGregorianCalendar(calendar));
 		Assert.assertNotNull(time3.getXMLGregorianCalendar());
-
+	}
+	
+	@Test
+	public void testStyle() {
 		// StyleName,StyleNameRef,StyleNameList
 		StyleName styleName1 = new StyleName("ta1");
 		StyleName styleName2 = new StyleName("_22");
@@ -154,7 +173,10 @@ public class DataTypeTest {
 		Assert.assertTrue(StyleNameRefs.isValid(""));
 		styleList = StyleNameRefs.valueOf("").getStyleNameRefList();
 		Assert.assertTrue(styleList.size() == 0);
-
+	}
+	
+	@Test
+	public void testItegerPercent() {
 		// Integer,Percent
 		PositiveInteger positiveInt = new PositiveInteger(1);
 		NonNegativeInteger nnInt = new NonNegativeInteger(positiveInt.intValue());
@@ -162,7 +184,10 @@ public class DataTypeTest {
 		Percent percent = new Percent(0.3);
 		Percent percent1 = Percent.valueOf("30.0%");
 		Assert.assertTrue(percent1.doubleValue() == percent.doubleValue());
-
+	}
+	
+	@Test
+	public void testMeasurement() {
 		// Measurement
 		String inchMeasure = "-4.354in";
 		Length length = new Length(inchMeasure);
@@ -172,8 +197,7 @@ public class DataTypeTest {
 		Assert.assertTrue(PositiveLength.isValid("0.01pt"));
 		Assert.assertTrue(NonNegativeLength.isValid("0.00pt"));
 		Assert.assertFalse(NonNegativeLength.isValid("-0.00pt"));
-		@SuppressWarnings("static-access")
-		int mmValue = length.parseInt(length.toString(), Unit.MILLIMETER);
+		int mmValue = Length.parseInt(length.toString(), Unit.MILLIMETER);
 
 		NonNegativePixelLength pixelLength = NonNegativePixelLength.valueOf("1240px");
 		NonNegativePixelLength pixelLength1 = null;
@@ -182,5 +206,9 @@ public class DataTypeTest {
 		} catch (NumberFormatException ex) {
 			Assert.assertNull(pixelLength1);
 		}
+		
+		// make sure Units are resolved correctly
+		Unit unit = Length.parseUnit("cm");
+		Assert.assertEquals(Unit.CENTIMETER, unit);
 	}
 }



Mime
View raw message