Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/08/11 12:22:20 (14 years ago)
Author:
mholper
Message:

added unittest #1218

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OKBJavaConnector/HLOKBWebClient/src/test/java/at/hl/okb/wsclient/OKBClientTest.java

    r5242 r5243  
    11package at.hl.okb.wsclient;
    22
     3import static org.junit.Assert.assertTrue;
    34
    4 import junit.framework.Assert;
     5import org.junit.After;
     6import org.junit.AfterClass;
     7import org.junit.Before;
     8import org.junit.BeforeClass;
     9import org.junit.Test;
    510
    6 import org.junit.Test;
     11import at.hl.okb.wsclient.Exception.OKBWebServiceFailedException;
     12import at.hl.wsclient.okb.AddAlgorithm;
     13import at.hl.wsclient.okb.Algorithm;
     14import at.hl.wsclient.okb.ArrayOfAlgorithm;
     15import at.hl.wsclient.okb.ArrayOfDataType;
     16import at.hl.wsclient.okb.DataType;
     17import at.hl.wsclient.okb.IOKBService;
     18import at.hl.wsclient.okb.OKBService;
     19import at.hl.wsclient.okb.ObjectFactory;
     20import at.hl.wsclient.okb.Platform;
    721
    822/**
    923 * @author HolperM
    10  *
     24 * 
    1125 */
    1226public class OKBClientTest {
    13  
    14    
    15       OKBServiceClient client = new OKBServiceClient();
     27
     28  OKBService srv = null;
     29  IOKBService port = null;
     30
     31  /**
     32   * @throws java.lang.Exception
     33   */
     34  @BeforeClass
     35  public static void setUpBeforeClass() throws Exception {
     36  }
     37
     38  /**
     39   * @throws java.lang.Exception
     40   */
     41  @AfterClass
     42  public static void tearDownAfterClass() throws Exception {
     43  }
     44
     45  /**
     46   * @throws java.lang.Exception
     47   */
     48  @Before
     49  public void setUp() throws Exception {
     50    this.srv = new OKBService();
     51    this.port = srv.getWSHttpBindingIOKBService1();
     52  }
     53
     54  /**
     55   * @throws java.lang.Exception
     56   */
     57  @After
     58  public void tearDown() throws Exception {
     59  }
     60
    1661  @Test
    17       public void testGetPlatform()
    18   {
    19       Assert.assertNotNull(client.getPlatformId("ECJ"));
     62  public void AddAlgorithmTest() throws Exception {
     63
     64    ObjectFactory fac = new ObjectFactory();
     65    AddAlgorithm addA = fac.createAddAlgorithm();
     66    addA.setDto(fac.createAddAlgorithmDto(fac.createAlgorithm()));
     67    Long retval = 0L;
     68   
     69//    if (port.getAlgorithm(2L)!=null)
     70//      port.deleteAlgorithm(2L);
     71   
     72
     73    Algorithm a = fac.createAlgorithm();
     74    a.setAlgorithmClassId(1L);
     75    a.setDescription(fac.createNamedOKBItemDescription("a new Algo"));
     76    a.setId(2L);
     77    a.setName(fac.createNamedOKBItemName("Algorithm Name 6"));
     78    a.setPlatformId(1L);
     79    try {
     80      retval = port.addAlgorithm(a);
     81    } catch (Exception e) {
     82      throw new OKBWebServiceFailedException(e.getMessage());
     83    }
     84    assertTrue("Algortihm wasn't added", retval > 0);
     85  }
     86
     87  @Test
     88  public void GetAlgorithmsTest() {
     89
     90    ArrayOfAlgorithm algos = port.getAlgorithms();
     91
     92    for (Algorithm algo : algos.getAlgorithm()) {
     93      System.out.println("algo ClassId:=" + algo.getAlgorithmClassId());
     94      System.out.println("algo Id:=" + algo.getId());
     95      System.out.println("algo PlattformId:=" + algo.getPlatformId());
     96      System.out.println("algo Class:=" + algo.getClass());
     97      System.out.println("algo Description:="
     98          + algo.getDescription().getValue());
     99      System.out.println("algo Name:=" + algo.getName().getValue());
     100    }
     101    assertTrue("No Algorithms found!", algos.getAlgorithm().size() > 0);
     102  }
     103
     104  @Test
     105  public void GetDataTypesTest() {
     106
     107    ArrayOfDataType dataTypes = port.getDataTypes();
     108
     109    for (DataType dataType : dataTypes.getDataType()) {
     110      System.out.println("algo Id:=" + dataType.getId());
     111      System.out.println("algo platformId:=" + dataType.getPlatformId());
     112      System.out.println("algo Name:=" + dataType.getName());
     113      System.out.println("algo Class:=" + dataType.getClass());
     114      System.out.println("algo SQLName:="
     115          + dataType.getSqlName().getValue());
     116    }
     117    assertTrue("No dataTypes found!", dataTypes.getDataType().size() > 0);
     118  }
     119
     120  @Test
     121  public void GetPlatFormTest() {
     122    Platform f = port.getPlatform(1L);
     123    assertTrue(f.getName().getValue().length() > 0);
     124  }
     125
     126  OKBServiceClient client = new OKBServiceClient();
     127
     128  @Test
     129  public void testGetPlatform() {
     130    client.getPlatformId("ECJ");
    20131  }
    21132 
    22   @Test
    23       public void testGetProblemClass()
    24   {
    25       Assert.assertNotNull(client.getProblemClassId("ECJ"));
    26   }
    27   @Test
    28   public void testGetAlgorithmClass()
    29   {
    30       Assert.assertNotNull(client.getAlgorithmClassId("ECJ"));
    31   }
    32133 
    33134}
Note: See TracChangeset for help on using the changeset viewer.