1   /*
2    * $Id: OperationClassJdomTest.java 1212 2008-11-03 13:15:59Z andreas.hoheisel@first.fraunhofer.de $
3    *
4    * Copyright (c) 2005, The K-Wf Grid Consortium
5    * Fraunhofer Institute for Computer Architecture and Software Technology
6    * See http://www.kwfgrid.eu and http://www.first.fraunhofer.de for more details.
7    */
8   
9   
10  package net.kwfgrid.gworkflowdl;
11  
12  import junit.framework.Assert;
13  import junit.framework.Test;
14  import junit.framework.TestSuite;
15  import net.kwfgrid.gworkflowdl.structure.*;
16  import org.jdom.Element;
17  
18  import java.io.IOException;
19  
20  
21  public final class OperationClassJdomTest extends AbstractTestCase {
22      /***
23       * Create the test case.
24       *
25       * @param testName name of the test case
26       */
27      public OperationClassJdomTest(String testName) {
28          super(testName);
29      }
30  
31      /***
32       * @return the suite of tests being tested
33       */
34      public static Test suite() {
35          return new TestSuite(OperationClassJdomTest.class);
36      }
37  
38      public void testOperationClassJdom() throws IOException, WorkflowFormatException {
39          OperationClass op1 = OperationClassTest.example("ocanton", 5);
40          Element ope1 = OperationClassJdom.java2element(op1);
41  
42          String opxml;
43          Element ope2 = null;
44          opxml = JdomString.element2string(ope1);
45          ope2 = JdomString.string2element(opxml);
46  
47          OperationClass op2 = OperationClassJdom.element2java(ope2);
48          Assert.assertEquals("operation class name", op1.getName(), op2.getName());
49  
50          OperationCandidate[] os1 = op1.getOperationCandidates();
51          Assert.assertNotNull("os1",os1);
52          OperationCandidate[] os2 = op2.getOperationCandidates();
53          Assert.assertNotNull("os2",os2);
54          Assert.assertEquals("number of candidates", os1.length, os2.length);
55  
56          for (int i = 0; i < os1.length; i++) {
57              Assert.assertEquals("operation name", "ocanton_operationName", os1[i].getOperationName());
58              Assert.assertEquals("operation name", os1[i].getOperationName(), os2[i].getOperationName());
59              Assert.assertEquals("is selected", os1[i].isSelected(), os2[i].isSelected());
60          }
61      }
62  }