@Test
public void testSetAsUri(){
MeasurementInfoUri infoUri = new MeasurementInfoUri();
Assert.assertNull(infoUri.getAsURI(), "not initialised");
infoUri.setAsURI(null);
Assert.assertNull(infoUri.getAsURI(), "should be clean");
infoUri.setAsURI("");
Assert.assertNull(infoUri.getAsURI(), "should be reset");
infoUri.setAsURI("blabla://");
Assert.assertEquals("blabla", infoUri.getScheme());
Assert.assertEquals("blabla://", infoUri.getAsURI());
infoUri.setAsURI("action://runtime");
Assert.assertEquals("action", infoUri.getScheme());
Assert.assertEquals("runtime", infoUri.getPath());
Assert.assertEquals("action://runtime", infoUri.getAsURI());
infoUri.setAsURI("outcome://object/image/dimension/width#equal");
Assert.assertEquals("outcome", infoUri.getScheme());
Assert.assertEquals("object/image/dimension/width", infoUri.getPath());
Assert.assertEquals("equal", infoUri.getFragment());
Assert.assertEquals("outcome://object/image/dimension/width#equal", infoUri.getAsURI());
try {
infoUri.setAsURI("action://runtime//performance");
Assert.fail("invalid path - should throw exception");
} catch (IllegalArgumentException e) {
// ok
}
try {
infoUri.setAsURI("action://runtime://performance");
Assert.fail("invalid path - should throw exception");
} catch (IllegalArgumentException e) {
// ok
}
try {
infoUri.setAsURI("outcome://object/image/dimension/width#equal#holla");
Assert.fail("invalid fragment - should throw exception");
} catch (IllegalArgumentException e) {
// ok
}
try {
infoUri.setAsURI("blabla#://");
Assert.fail("invalid scheme - should throw exception");
} catch (IllegalArgumentException e) {
// ok
}
try {
infoUri.setAsURI("blabla/hoho://");
Assert.fail("invalid scheme - should throw exception");
} catch (IllegalArgumentException e) {
// ok
}
try {
infoUri.setAsURI("blabla");
Assert.fail("invalid scheme - should throw exception");
} catch (IllegalArgumentException e) {
// ok
}
}