/** * Test deep copy of properties. */ public void testCopy() throws IOException, URISyntaxException, ParseException { Property copy = property.copy(); assertEquals(property, copy); copy.getParameters().add(Value.BOOLEAN); assertFalse(property.equals(copy)); assertFalse(copy.equals(property)); }
/** * Test equality of properties. */ public void testEquals() { assertTrue(property.equals(property)); @SuppressWarnings("serial") Property notEqual = new Property("notEqual", null) { public String getValue() { return ""; } public void setValue(String value) throws IOException, URISyntaxException, ParseException { } public void validate() throws ValidationException { } }; assertFalse("Properties are equal", property.equals(notEqual)); assertFalse("Properties are equal", notEqual.equals(property)); }
/** * */ public final void testValidationException() { try { property.validate(); fail("Should throw ValidationException"); } catch (ValidationException e) { e.printStackTrace(); } }
/** * */ public void testGetValue() { assertEquals(expectedValue, property.getValue()); }
suite.addTest(new PropertyTest("testEquals", property)); suite.addTest(new PropertyTest(property, "value")); suite.addTest(new PropertyTest("testValidation", property)); suite.addTest(new PropertyTest("testValidationException", invalidProperty));
public void testImmutable() throws IOException, URISyntaxException, ParseException { super.testImmutable(); try { version.setMinVersion("3.0"); fail("UnsupportedOperationException should be thrown"); } catch (UnsupportedOperationException uoe) { } try { version.setMaxVersion("5.0"); fail("UnsupportedOperationException should be thrown"); } catch (UnsupportedOperationException uoe) { } }
/** * */ public void testToString() { assertEquals(expectedValue, property.toString()); }
/** * @return */ public static TestSuite suite() { TestSuite suite = new TestSuite(); XProperty p = new XProperty("TEST"); p.setValue("value"); suite.addTest(new XPropertyTest(p, "value")); suite.addTest(new XPropertyTest("testValidationException", p)); suite.addTest(new XPropertyTest("testRelaxedValidation", p)); p = new XProperty("X-TEST"); suite.addTest(new XPropertyTest("testValidation", p)); p = new XProperty("TEST"); p.setValue("geo:37.331684,-122.030758"); suite.addTest(new XPropertyTest(p, "geo:37.331684,-122.030758")); suite.addTest(new PropertyTest("testToString", p, "TEST:geo:37.331684\\,-122.030758\r\n")); XProperty pUrl = new XProperty("TEST"); pUrl.getParameters().add(Value.URI); pUrl.setValue("geo:37.331684,-122.030758"); suite.addTest(new XPropertyTest(pUrl, "geo:37.331684,-122.030758")); suite.addTest(new PropertyTest("testToString", pUrl, "TEST;VALUE=URI:geo:37.331684,-122.030758\r\n")); return suite; } }
/** * @throws IOException * @throws URISyntaxException * @throws ParseException */ @SuppressWarnings("serial") public void testImmutable() throws IOException, URISyntaxException, ParseException { try { property.setValue(""); fail("UnsupportedOperationException should be thrown"); } catch (UnsupportedOperationException uoe) { } try { property.getParameters().add(new Parameter("name", null) { public String getValue() { return null; } }); fail("UnsupportedOperationException should be thrown"); } catch (UnsupportedOperationException uoe) { } }