DerivedUnionTest.java :  » UML » umlatj » org » umlatj » kernel » Java Open Source

Java Open Source » UML » umlatj 
umlatj » org » umlatj » kernel » DerivedUnionTest.java
package org.umlatj.kernel;

import java.util.ArrayList;
import java.util.Collection;

import org.junit.Assert;
import org.junit.Test;

public class DerivedUnionTest {

  @Classifier
  public static class General {

    @Property(isDerivedUnion = true)
    public Object getScalar() {
      return null;
    }
    
    @Property(isDerivedUnion = true)
    public Collection<Object> getMyCollection() {
      return null;
    }
  }

  @Classifier
  public static class SubScalar extends General {

    @Property(subset = "scalar")
    Object name;
  }
  
  @Classifier
  public static class SubCollection extends General {

    @Property(subset = "myCollection")
    Collection<String> strings = new ArrayList<String>();
  }
  

  @Test
  public void scalar() {
    SubScalar sub = new SubScalar();
    Assert.assertNull(sub.getScalar());

    sub.name = this;
    Assert.assertEquals(sub.getScalar(), this);

  }
  
  @Test
  public void collection() {
    SubCollection sub = new SubCollection();
    sub.strings.add("a");
    
    Assert.assertTrue(sub.getMyCollection().contains("a"));
  }
  
//  @Test
//  public void dump() throws Exception {
//    BeanInfo info = Introspector.getBeanInfo(Sub.class);
//    
//  }

}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.