Changeset 6170


Ignore:
Timestamp:
04/22/10 10:24:47 (10 years ago)
Author:
melissa
Message:

Added a few Annotation tests.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/ome-xml/test/ome/xml/utests/InOut201004Test.java

    r6168 r6170  
    5656import static org.testng.AssertJUnit.*; 
    5757 
     58import ome.xml.r201004.Annotation; 
     59import ome.xml.r201004.BooleanAnnotation; 
     60import ome.xml.r201004.DoubleAnnotation; 
     61import ome.xml.r201004.FileAnnotation; 
     62import ome.xml.r201004.ListAnnotation; 
     63import ome.xml.r201004.LongAnnotation; 
     64import ome.xml.r201004.StringAnnotation; 
     65import ome.xml.r201004.StructuredAnnotations; 
     66import ome.xml.r201004.TimestampAnnotation; 
     67import ome.xml.r201004.XMLAnnotation; 
    5868import ome.xml.r201004.Channel; 
    5969import ome.xml.r201004.Dichroic; 
     
    100110  private static String IMAGE_ID = "Image:0"; 
    101111 
     112  private static String IMAGE_ANNOTATION_ID = "BooleanAnnotation:0"; 
     113 
    102114  private static String PIXELS_ID = "Pixels:0"; 
    103115 
     116  private static String PIXELS_ANNOTATION_ID = "DoubleAnnotation:0"; 
     117 
     118  private static String CHANNEL_ANNOTATION_ID = "XMLAnnotation:0"; 
     119 
    104120  private static String INSTRUMENT_ID = "Instrument:0"; 
    105121 
     
    137153 
    138154  private static final Integer SIZE_T = 50; 
     155 
     156  private static final String CHANNEL_ANNOTATION_XML = 
     157    "<TestData><key>foo</key><value>bar</value></TestData>"; 
    139158 
    140159  private static final String DETECTOR_MODEL = "ReallySensitive!"; 
     
    235254 
    236255  @Test(dependsOnMethods={"testValidImageNode"}) 
     256  public void testValidImageAnnotation() { 
     257    Annotation n = ome.getImage(0).getLinkedAnnotation(0); 
     258    assertNotNull(n); 
     259    assertTrue(n instanceof BooleanAnnotation); 
     260    BooleanAnnotation b = (BooleanAnnotation) n; 
     261    assertEquals(b.getValue(), "false"); 
     262    assertEquals(b.getID(), IMAGE_ANNOTATION_ID); 
     263  } 
     264 
     265  @Test(dependsOnMethods={"testValidImageNode"}) 
    237266  public void testValidPixelsNode() { 
    238267    Pixels pixels = ome.getImage(0).getPixels(); 
     
    254283      assertNotNull(channel.getID()); 
    255284    } 
     285  } 
     286 
     287  @Test(dependsOnMethods={"testValidChannelNode"}) 
     288  public void testValidChannelAnnotation() { 
     289    Channel c = ome.getImage(0).getPixels().getChannel(0); 
     290    Annotation n = c.getLinkedAnnotation(0); 
     291    assertNotNull(n); 
     292    assertTrue(n instanceof XMLAnnotation); 
     293    assertEquals(CHANNEL_ANNOTATION_ID, n.getID()); 
     294    XMLAnnotation xml = (XMLAnnotation) n; 
     295    assertEquals(xml.getValue(), CHANNEL_ANNOTATION_XML); 
     296  } 
     297 
     298  @Test(dependsOnMethods={"testValidPixelsNode"}) 
     299  public void testValidPixelsAnnotation() { 
     300    Annotation n = ome.getImage(0).getPixels().getLinkedAnnotation(0); 
     301    assertNotNull(n); 
     302    assertTrue(n instanceof DoubleAnnotation); 
     303    DoubleAnnotation b = (DoubleAnnotation) n; 
     304    assertEquals(b.getValue(), "3.14"); 
     305    assertEquals(b.getID(), PIXELS_ANNOTATION_ID); 
    256306  } 
    257307 
     
    416466    Image image = new Image(); 
    417467    image.setID(IMAGE_ID); 
     468    BooleanAnnotation annotation = new BooleanAnnotation(); 
     469    annotation.setID(IMAGE_ANNOTATION_ID); 
     470    annotation.setValue("false"); 
     471    image.linkAnnotation(annotation); 
    418472    // Create <Pixels/> 
    419473    Pixels pixels = new Pixels(); 
     
    431485      Channel channel = new Channel(); 
    432486      channel.setID("Channel:" + i); 
     487      if (i == 0) { 
     488        XMLAnnotation channelAnnotation = new XMLAnnotation(); 
     489        channelAnnotation.setID(CHANNEL_ANNOTATION_ID); 
     490        channelAnnotation.setValue(CHANNEL_ANNOTATION_XML); 
     491        channel.linkAnnotation(channelAnnotation); 
     492      } 
    433493      pixels.addChannel(channel); 
    434494    } 
     495    // create Annotation for Pixels 
     496    DoubleAnnotation pixelsAnnotation = new DoubleAnnotation(); 
     497    pixelsAnnotation.setID(PIXELS_ANNOTATION_ID); 
     498    pixelsAnnotation.setValue("3.14"); 
     499    pixels.linkAnnotation(pixelsAnnotation); 
    435500    // Put <Pixels/> under <Image/> 
    436501    image.setPixels(pixels); 
Note: See TracChangeset for help on using the changeset viewer.