TestDatatypeDefinition.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 » TestDatatypeDefinition.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: TestDatatypeDefinition.java 3531 2006-12-08 09:28:11Z sji $
 */
package com.bostechcorp.cbesb.common.mdl;

import java.io.File;

import junit.framework.TestCase;

import com.bostechcorp.cbesb.common.mdl.IDatatypeDefinition;
import com.bostechcorp.cbesb.common.mdl.IMDLDocument;
import com.bostechcorp.cbesb.common.mdl.MDLParser;
import com.bostechcorp.cbesb.common.mdl.impl.DatatypeDefinitionImpl;
import com.bostechcorp.cbesb.common.mdl.impl.MDLDocumentImpl;
/**
 * test datatypeDefinition
 *
 */
public class TestDatatypeDefinition extends TestCase {
  File mdlFile = new File("target/test-data/in/datatypes.mdl");

  IMDLDocument mdlDoc = new MDLDocumentImpl();

  protected void setUp() throws Exception {
    super.setUp();
    mdlDoc = MDLParser.load(mdlFile);
  }
  protected void tearDown() throws Exception {
    super.tearDown();
  }
  public void testGetDatatype(){
    IDatatypeDefinition datatypeDef=new DatatypeDefinitionImpl();
    datatypeDef=mdlDoc.getAllDatatypeDefinitions()[0];
    assertEquals("AN",datatypeDef.getName());
    
    datatypeDef=mdlDoc.getDatatypeDefinition(mdlDoc.getTargetNamespace(), "AN");
    assertEquals("string",datatypeDef.getBaseType());
    assertEquals("String",datatypeDef.getDescription());
    
  }
  public void testaddDatatype(){
    IDatatypeDefinition datatypeDef=new DatatypeDefinitionImpl();
    datatypeDef.setBaseType("number");
    datatypeDef.setName("add");
    datatypeDef.setDescription("new");
    datatypeDef.setNamespaceURI("com.add");
    
    int count=mdlDoc.getAllDatatypeDefinitions().length;
    mdlDoc.addDatatypeDefinition(datatypeDef);
    
    assertEquals(count+1,mdlDoc.getAllDatatypeDefinitions().length);
    assertEquals("number",datatypeDef.getBaseType());
    assertEquals("add",datatypeDef.getName());
    assertEquals("new",datatypeDef.getDescription());
    assertEquals("com.add",datatypeDef.getNamespaceURI());
    
    
  }
}
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.