TestContentNode.java :  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » common » mdl » Java Open Source

Java Open Source » ESB » cbesb 1.2 
cbesb 1.2 » com » bostechcorp » cbesb » common » mdl » TestContentNode.java
/*
 * ChainBuilder ESB
 *          Visual Enterprise Integration
 * 
 * Copyright (C) 2006 Bostech Corporation
 * 
 * This program is free software; you can redistribute it and/or modify 
 * it under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; either version 2 of the License, or 
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License 
 * along with this program; if not, write to the Free Software 
 * Foundation, Inc.,59 Temple Place, Suite 330, Boston, MA 02111-1307 
 * USA
 *
 * $ID$
 *
 */
package com.bostechcorp.cbesb.common.mdl;

import java.io.File;

import junit.framework.TestCase;

import com.bostechcorp.cbesb.common.mdl.IContentNode;
import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
import com.bostechcorp.cbesb.common.mdl.IMessageDefinition;
import com.bostechcorp.cbesb.common.mdl.MDLParser;
import com.bostechcorp.cbesb.common.mdl.impl.MDLDocumentImpl;

public class TestContentNode extends TestCase {
  File mdlFile = new File("target/test-data/in/contentNodeAndGroup.mdl");

  IMDLDocument mdlDoc = new MDLDocumentImpl();

  protected void setUp() throws Exception {
    super.setUp();
    mdlDoc = MDLParser.load(mdlFile);
  }
  protected void tearDown() throws Exception {
    super.tearDown();
  }
  /**
   * test contentNode 
   * If a field is optional, minOccurs is set to 0. if it is
   * required, it is set to 1. Default value is 1.
   * If the element has no limit, 
   * then maxOccurs is set to "unbounded".  The default value is 1.
   */
  int max;
  int min;
  public void testContentNode(){
    IMessageDefinition msgDef=mdlDoc.getAllMessageDefinitions()[0];
    IContentNode cNode=msgDef.getChildren()[0];
    max=cNode.getMaxOccurs();
    min=cNode.getMinOccurs();
    //maxOccurs and minOccurs have not been set
    //they are default value
    assertEquals(1,max);
    assertEquals(1,min);
    
    
    IContentNode cNode2=msgDef.getChildren()[1];
    max=cNode2.getMaxOccurs();
    min=cNode2.getMinOccurs();
    //maxOccurs is set to "unbounded" and minOccurs is set to 0
    assertEquals(-1,max);
    assertEquals(0,min);
    
    
    IContentNode cNode3=msgDef.getChildren()[2];
    max=cNode3.getMaxOccurs();
    min=cNode3.getMinOccurs();
    //maxOccurs is set to 5
    //minOccurs is set to 2
    assertEquals(5,max);
    assertEquals(2,min);
  
  }
}
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.