Package hermes.postoffice

Examples of hermes.postoffice.OscMessage


    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);
   
    //make sure the number of arguments is correct
    assertEquals(message.getNumberOfRemainingArguments(), 3);
    //Should be an int
    assertEquals(message.getTypeTagOfNextArgument(), "i");
    //check the value
    int intValue = message.getAndRemoveInt();
    assertEquals((Integer)intValue, (Integer)testObjects[0]);
 
    //make sure the number of arguments is correct
    assertEquals(message.getNumberOfRemainingArguments(), 2);
    //Should be a string
    assertEquals(message.getTypeTagOfNextArgument(), "s");
    //check the value
    String stringValue = message.getAndRemoveString();
    assertEquals((String)stringValue, (String)testObjects[1]);
   
    //make sure the number of arguments is correct
    assertEquals(message.getNumberOfRemainingArguments(), 1);
    //Should be a float
    assertEquals(message.getTypeTagOfNextArgument(), "f");
    //check the value
    Float floatValue= message.getAndRemoveFloat();
    assertEquals((Float)floatValue, (Float)testObjects[2]);

    assertEquals(message.getNumberOfRemainingArguments(), 0);
   
  }
View Full Code Here


    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) {
      }
   
  }
View Full Code Here

TOP

Related Classes of hermes.postoffice.OscMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.