testObjects[0] = new Integer(10);
testObjects[1] = new String("Oh hai");
testObjects[2] = new Float(1.0);
//don't need a valid address.. just testing the argument retrieval functionality
OscMessage message = new OscMessage("/DummyAddress", testObjects);
try {
message.getAndRemoveFloat();
fail( "Should throw AssertionError" );
} catch (AssertionError expectedException) {
}
try {
message.getAndRemoveString();
fail( "Should throw AssertionError" );
} catch (AssertionError expectedException) {
}
//remove the element to check Int
message.getAndRemoveInt();
try {
message.getAndRemoveInt();
fail( "Should throw AssertionError" );
} catch (AssertionError expectedException) {
}
//empty the OSCMessage and then check errors..
message.getAndRemoveString();
message.getAndRemoveFloat();
try {
message.getAndRemoveInt();
fail( "Should throw AssertionError because the OSCMessage is empty" );
} catch (AssertionError expectedException) {
}
try {
message.getAndRemoveFloat();
fail( "Should throw AssertionError because the OSCMessage is empty" );
} catch (AssertionError expectedException) {
}
try {
message.getAndRemoveString();
fail( "Should throw AssertionError because the OSCMessage is empty" );
} catch (AssertionError expectedException) {
}
try {
message.getTypeTagOfNextArgument();
fail( "Should throw AssertionError because the OSCMessage is empty" );
} catch (AssertionError expectedException) {
}
//Lastly, check nonexistent typetag
class Impossible {
}
//make a message that contains an 'Impossible'
testObjects = new Object[1];
testObjects[0] = new Impossible();
message = new OscMessage("/DummyAddress", testObjects);
try {
message.getTypeTagOfNextArgument();
fail( "Should throw AssertionError because the tag does not exist" );
} catch (AssertionError expectedException) {
}
}